Newer
Older
templates / labs / preamble.tex
Mark on 22 Jul 2014 4 KB Existing templates.
\documentclass[a4paper, 12pt]{article}

\usepackage{cmap} % attempt to fix search with ligatures problem.

\usepackage{graphicx}
\usepackage[a4paper, portrait, left=20mm, right=20mm, top=30mm, bottom=30mm]{geometry}
\usepackage[bookmarks, colorlinks=false]{hyperref}

\usepackage{paralist}
\usepackage{pslatex}
\usepackage{float}
\usepackage{tabularx}
\usepackage{hhline}
\usepackage[usenames]{xcolor}
\usepackage{pdfpages}
\usepackage[T1]{fontenc}  % might fix copy-pasting issues
\usepackage{textcomp}
\usepackage{listings}


% PDF tex graphics extensions
\DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png,.mps}

% font size for code
\def\thesize{11truept}

% relax the justification/hyphenation wrapping settings
\tolerance=800
\emergencystretch=15mm

% kill the paragraph indenting
\setlength{\parindent}{0 mm}

\setlength{\parskip}{0.7\baselineskip}

% create the fonts for code highlighting
\newfont{\codefont}{pcrr at \thesize}
\newfont{\keywordfont}{pcrr at \thesize}
\newcommand{\commentfont}{\slshape}
\newcommand{\commentsize}{\small}

% define the colors for code highlighting (based on Eclipse colors)
%\definecolor{KeywordColor}{rgb}{0.5,0,0.33}
%\definecolor{CommentColor}{rgb}{0.25,0.5,0.37}
%\definecolor{StringColor}{rgb}{0.16,0,1}

% define the colors for code highlighting (based on NetBeans colors)
\definecolor{KeywordColor}{rgb}{0.0,0,0.9}
\definecolor{CommentColor}{rgb}{0.39,0.39,0.39}
\definecolor{StringColor}{rgb}{0.41,0.24.0}

% set up pretty printing environment to use above fonts and colours, and set some other things
\lstset{
	language=Java,
	basicstyle=\codefont,
	keywordstyle=\color{KeywordColor}\keywordfont,
	commentstyle=\color{CommentColor}\commentfont,
	stringstyle=\color{StringColor}\tt,
	showstringspaces=false,
	tabsize=3,
	showtabs=false,
	columns=fullflexible,
	flexiblecolumns=true,
	fontadjust=true,
	aboveskip=5pt, belowskip=5pt
}

\lstdefinelanguage{JavaScript}{
  keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break, this},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  morestring=[b]',
  morestring=[b]"
}

% centre command that won't add any vertical space before or after
\newcommand{\centre}[1]{\hfill#1\hfill}

% command for figures with captions - first param is scale.
\newcommand{\captionedfig}[3] {
  \begin{figure}[H]
    \begin{center}
      \includegraphics[scale=#1,draft=false]{#2}
		\\
		#3
		\vspace{-25pt}
    \end{center}
  \end{figure}
}

% command for figures - first param is scale.
\newcommand{\fig}[2] {
  \begin{figure}[H]
    \begin{center}
      \includegraphics[scale=#1,draft=false]{#2}
    \end{center}
  \end{figure}
}

% command for figures rotated 90 degrees right - first param is scale.
\newcommand{\rotatedfig}[2] {
  \begin{figure}[H]
    \begin{center}
      \includegraphics[scale=#1,draft=false, angle=270]{#2}
    \end{center}
  \end{figure}
}

% new indent command that doesn't rely on \parindent
\renewcommand{\indent}{\hspace*{5 mm}}

% command for typesetting inline code
\newcommand{\code}[2][language=java]{\mbox{\lstinline[#1]!#2!}}

% make \emph do italics (just in case other environments make it do something else)
\renewcommand{\emph}[1]{\textit{#1}}

% a simpler way of getting a right arrow
\newcommand{\ra}[0]{$\rightarrow$~}

% a command for padding out a page
\newcommand{\pad}[0]{\vspace{\stretch{1}}}

% environment for typesetting code blocks
\lstnewenvironment{codeblock}[1][]
{\small \lstset{#1}}
{\normalsize}

% command for adding a placeholder for information to be entered at a later date
\newcommand{\fixme}[1]{\textcolor{red}{\textbf{TO DO:~ }#1}}
\newcommand{\todo}[1]{\fixme{#1}}

% fix the extra spacing that itemize/enumerate has when you put have an blank
% line prior to the environment.
\setlength{\pltopsep}{0.2\baselineskip}
\setlength{\plpartopsep}{-0.2\baselineskip}
\setlength{\plitemsep}{0.2\baselineskip}
\setlength{\plparsep}{0.4\baselineskip}


\renewenvironment{itemize}%
  {\begin{compactitem}}%
  {\end{compactitem}}

\renewenvironment{enumerate}%
  {\begin{compactenum}}%
  {\end{compactenum}}