% This file makes some output formatting changes in m files published
% in Octave to pdf.

% To use this file, place it, as "setup.tex", in your MATLAB folder,
% or wherever your homework m files are.

% This file can also be used in m files published in Matlab to LaTeX.
% However, in that case the produced LaTeX file will need further
% processing using subbin.exe and pdflatex to create a final pdf.  See
% the contents of folder "proclatex" for the former.

% create a light grey background for code and results
\definecolor{light}{gray}{0.85}
\lstset
{frame=shadowbox,rulesepcolor=\color{gray},backgroundcolor=\color{light}}

% start and end a modified verbatim environment
\newcommand{\bvt}
{\lstset{backgroundcolor=\color{white},xleftmargin=3ex,frame=none}}
\newcommand{\evt}
{\lstset{backgroundcolor=\color{light},xleftmargin=0ex,frame=shadowbox}}

% to create a blank line at the start of a new paragraph
\def\`{\vspace{0.83\baselineskip}}
% to create a blank line without creating a new paragraph
\newcommand{\down}{\\\strut\\}
\newcommand{\tab}{\hspace*{1.5em}}

% fix whitespace around equations
\setlength\abovedisplayskip{-.5\baselineskip}
\setlength\abovedisplayshortskip{-.5\baselineskip}
\setlength\belowdisplayskip{.5\baselineskip}
\setlength\belowdisplayshortskip{.5\baselineskip}

% since we cannot use _ nor \_ outside math mode (starts italics)
\newcommand{\us}{\_}
% since we cannot use * outside math mode (starts bold)
\newcommand{\st}{$*$}
% since we cannot use ~ outside math mode (does weird)
\newcommand{\tl}{\symbol{126}}
% to simplify and since Matlab does not recognize all inline math
\newcommand{\bs}{\textbackslash}

% bug fix for inline math where some characters are wrongly escaped
\def\^#1{\ifmmode^\else\symbol{94}\fi}
\def\_{\ifmmode_\else\symbol{95}\fi}
\def\&{\ifmmode&\else\symbol{38}\fi}
