%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% METAFONT TUTORIAL                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{i/a/utils/latex/documentation/metafont-tutorial/mftut_bag}
\usepackage{mflogo}
\usepackage[pdftex]{hyperref}
\usepackage{color,graphicx}
\hypersetup{draft,colorlinks,pdfpagemode=None,plainpages=false,%
           pdfstartview=FitH,%
%           pdfauthor={Christophe Grandsire},%
%           pdftitle={The METAFONTtutorial},%
%           pdfsubject={Learn to make fonts with METAFONT},%
%           pdfkeywords={METAFONT, tutorial, fonts}
           }

\renewcommand{\headrulewidth}{0pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BOXES AND GLUE                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[pdftex]{epsfig}
\usepackage{pslatex}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{verbatim}
\usepackage{makeidx}
\usepackage{mflogo}
\usepackage{scalefnt}
\usepackage{multicol}
\usepackage{natbib}
\usepackage{color}
\usepackage{xcolor}
\usepackage{pdfpages}
\usepackage{listings} 
 \lstset{
 numbers=none,
 basicstyle=\scriptsize\ttfamily,
 numberstyle=\Huge, 
 showspaces=false,
 showstringspaces=false,
% aboveskip=\medskip,
% belowskip=\bigskip,
% keywordstyle=\color{black}\ttfamily,
 stringstyle=\ttfamily,
 commentstyle=\tiny\color{black},
% frame=L,
% %frameround=ffft,
% tabsize=4,
% emptylines=1,
 breaklines=true
 }
\usepackage{i/a/utils/latex/commands/LaTeX}
\usepackage{i/a/utils/latex/commands/copyright}
\usepackage{i/a/utils/latex/commands/letterspacing}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setlength\topmargin{-12mm}
%\setlength\oddsidemargin{15mm}
%\setlength\evensidemargin{10mm}
\setlength\textheight{160mm}
\setlength\textwidth{90mm}

\newcommand{\changetotwocolumn}{
\setlength\textwidth{120mm}
\setlength\oddsidemargin{-6mm}
\setlength\evensidemargin{-8mm}
\twocolumn
\lstset{xleftmargin=10pt}
}

\newcommand{\changetoonecolumn}{
\setlength\oddsidemargin{15mm}
\setlength\evensidemargin{-8mm}
\setlength\textwidth{90mm}
\onecolumn
%\lstset{xleftmargin=-20pt}
}

\newlength{\universalstandard}
\setlength{\universalstandard}{.3\textwidth}
\newlength{\universalgrid}
\setlength{\universalgrid}{\universalstandard}
\setlength{\unitlength}{\universalgrid}

\renewcommand{\ttdefault}{pcr}
 \usepackage{helvet}
 \usefont{T1}{phv}{m}{n}
 \renewcommand{\encodingdefault}{T1}
 \renewcommand{\rmdefault}{phv}

\newcommand{\changefont}[3]{
\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont }

\renewcommand*\thechapter{}
\renewcommand*\thesection{\arabic{section}}
\renewcommand*\thesubsection{\arabic{subsection}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\titlepages}{
\vfill
\thispagestyle{empty}
{\Huge Boxes and Glue}
%\newpage
%\thispagestyle{empty}
%.
\newpage
% \thispagestyle{empty}
% \vfill
% developed in february 2010 at the Piet Zwart Institute, Rotterdam
% \newpage
% %.
% \thispagestyle{empty}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\hardpagebreak}{\twocolumn[]\onecolumn}
\newcommand{\codeline}[2]{
\medskip
\lstinline[language=Bash,basicstyle=\large\ttfamily,#1]|#2|
\smallskip
}
\newcommand{\codeinline}[2]{
\lstinline[basicstyle=\normalsize\ttfamily,#1]|#2|
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\graphic}[7]{
\setlength\fboxsep{0pt}
\setlength\fboxrule{#7}
\fbox{
\includegraphics[viewport=#2 #3 #4 #5,clip,width=#6]{#1}
 }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\doublepage}[3]{
\ifthispageodd{
%\hardpagebreak
% DOPPELSEITE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \includepdf[scale=#2,offset=-260 #3]
 {#1}
 \includepdf[scale=#2,offset=-300 #3]
 {#1}
% DOPPELSEITE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\twocolumn[] % DEATH PROOF PAGEBREAK
}{
% DOPPELSEITE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\includepdf[scale=#2,offset=-260 #3]
{#1}
\includepdf[scale=#2,offset=-300 #3]
{#1}
% DOPPELSEITE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\twocolumn[] % DEATH PROOF PAGEBREAK
\clearpage
}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\fullpage}[5]{
\newpage
{\renewcommand{\footnoterule}{\rule{0pt}{0pt}} % REMOVE FOOTNOTERULE
\includepdf[scale=#2,offset=#4 #3,pagecommand={
\thispagestyle{empty}
#5
\newpage
}]
{#1}
} % REMOVE FOOTNOTERULE
\renewcommand{\footnoterule}{\vspace*{10pt} % REMOVE FOOTNOTERULE
\hrule width 0.4\columnwidth \vspace*{10pt}} % REMOVE FOOTNOTERULE
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\grid}[9]{%

%\ifthispageodd{
\hspace{-.5\universalgrid}
\begin{picture}(0,0)%
\put(0.2,-2.4){#1}% |}
\put(0.2,-1.2){#4}% |}
\put(0.2,-3.6){#7}% |}
\put(1.3,-2.4){#2}% |}
\put(1.3,-1.2){#5}% |}
\put(1.3,-3.6){#8}% |}
\put(2.4,-2.4){#3}% |}
\put(2.4,-1.2){#6}% |}
\put(2.4,-3.6){#9}% |}
\end{picture}%
% }{
% \hspace{-1.9\universalgrid}
% \begin{picture}(0,0)%
% \put(0.2,-2.4){#1}% |}
% \put(0.2,-1.2){#4}% |}
% \put(0.2,-3.6){#7}% |}
% \put(1.3,-2.4){#2}% |}
% \put(1.3,-1.2){#5}% |}
% \put(1.3,-3.6){#8}% |}
% \put(2.4,-2.4){#3}% |}
% \put(2.4,-1.2){#6}% |}
% \put(2.4,-3.6){#9}% |}
% \end{picture}%
\twocolumn[] % DEATH PROOF PAGEBREAK
}%}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \newcommand{\grid}[9]{%
% \begin{multicols}{3}[][30\universalgrid]
% #1 

% \smallskip

% #4

% \smallskip

% #7

% \smallskip

% #2

% \smallskip

% #5

% \smallskip

% #8

% \smallskip

% #3

% \smallskip

% #6

% \smallskip

% #9
% \end{multicols}%
% \twocolumn[] % DEATH PROOF PAGEBREAK
% }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\flexcommentbox[4]
{%
\deffootnote[1.5em]{1.5em}{1em}{\textsuperscript{}}
\footnotetext{
\setlength\fboxsep{10pt}%
         \vspace{#2}
         \makebox[.5\textwidth][l]{
          \hspace{#1}
          \parbox{#3}{
          \vspace{-1\textheight}
\colorbox{black}{%
                {\small
                \parbox{#3}{
                \smallskip
                #4 %
                \smallskip
                }
     }
    }
   }
  }
 }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\setbash}
{
\lstset{language=Bash,
        morekeywords={
        rl,head,tail,ls,grep,
        cut,tr,rev,createGRAFIK,
        hole,match,massage,ooflepif % GOLDBERG COMMANDS
        ,wc,md5sum,elif,
        rm,sort,uniq,cp,mv
        }
}}
\newcommand{\setlatex}
{
\lstset{language=TeX,
        morekeywords={
	drawcanvas,smallinfo,begin,
	biginfo,footer,put,graphic,
	newcommand,strongline,vspace,
	mediumline,hspace,grid,canvasgraphic,
	setlength,fbox,includegraphics
        }
}}
\newcommand{\setprocessing}
{
\lstset{language=Java,
        morekeywords={
	draw
        }
}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CITATION %

\newcommand{\citebox}[1]{
{\fontfamily{bun}
  \selectfont
   \scalefont{1.2}
\hspace{-1em}#1
}}

\newcommand{\citeinfo}[1]{
\hspace{-.8em}{\scalefont{.5}{#1}}
}

% DURING TEXT

% http://merkel.zoneo.net/Latex/natbib.php
\let\oldcite\citealt
\renewcommand\cite[1]{
\citebox{\oldcite{#1}}
}
% http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2008-02/msg00382.html
\usepackage{twoopt,ifmtarg}

\let\oldcitep\citealp
\makeatletter
\renewcommandtwoopt\citep[3][][]{%
\begingroup\protected\def\harvardand{\&}
\@ifmtarg{#1}
{\citebox{\oldcitep{#3}}}%
{\@ifmtarg{#2}
{\citebox{\oldcitep[]{#3}}\citeinfo{#1}}
{\citebox{\oldcitep[][]{#3}}\citeinfo{#2, #3}}}%
\endgroup}
\makeatother
\protected\def\harvardand{and}

% BIBLIOGRAPHY AT THE END

\makeatletter
\def\@biblabel#1{\citebox{#1}}
\makeatother



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\superscript}[1]{\ensuremath{^{\textrm{#1}}}}

\footnotesep 10pt
% \skip\footins 10pt plus 4pt minus 2pt
\setlength{\marginparwidth}{0.3in}
\setlength{\skip\footins}{10mm}

% FOOTNOTES BLACK

\deffootnotemark{%
\small{\superscript{\thefootnotemark}}}

\deffootnote[1.5em]{1.5em}{1em}
{
\thefootnotemark\hspace{.4em}
}

\renewenvironment{quotation}
% START ENVIRONMENT
{
%        % CHANGE FONT HERE .V.  %
\it\begin{quote}\fontfamily{ptm}\selectfont
}
% CLOSE ENVIRONMENT
{
\end{quote}
}

% CHANGE HEADLINES
\usepackage{sectsty}
%         % CHANGE FONT HERE .V.  %
%\allsectionsfont{\fontfamily{bun}\selectfont}

% ZEILENABSTAND BEI ITEMIZE %
\let\origitemize\itemize
\def\itemize{\origitemize\itemsep-2pt}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\hyphenation{
pic-tur-esque-ly
purse/brief-case
Bas-ker-ville
tak-en
pho-to-type-set-ting
de-sign-er
Mon-o-type 
Cor-po-ra-tion 
pur-pose 
ma-chine 
mod-elled 
an-a-logue
work-space
pro-duc-tion
en-vi-ron-ment
bit-map
met-a-phor
Ha-bit-u-al 
phra-se-ol-o-gy 
u-ni-form 
in-to-na-tion
spe-ech
pro-gress
show-ed
met-a-phor
meta-medium
}












% \usepackage{marginnote} 
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % RANDNOTIZEN BEI ZWEISPALTIG       %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % http://www.komascript.de/node/985 %

% \usepackage{marginnote}
% \makeatletter
% \g@addto@macro\@mn@margintest{%
%   \if@twocolumn
%     \ifx\@mn@currxpos\relax% don't know which margin use normal one
%       \normalmarginpar
%     \else\ifx\@mn@currxpos\@empty% don't know which margin use normal one
%         \normalmarginpar
%       \else
%         \if@tempswa% use \oddsidemargin for tests
%           \ifdim\@mn@currxpos &gt;\dimexpr \oddsidemargin+1in+\columnwidth\relax
%             \normalmarginpar% right column --&gt; right margin
%           \else
%             \reversemarginpar% left column --&gt; left margin
%           \fi
%         \else% use \evensidemargin for tests
%           \ifdim\@mn@currxpos &gt;\dimexpr \evensidemargin+1in+\columnwidth\relax
%             \reversemarginpar% right column --&gt; right margin
%           \else
%             \normalmarginpar% left column --&gt; left margin
%           \fi
%         \fi
%       \fi
%     \fi
%   \fi
% }
% \makeatother