diff --git a/labs/preamble.tex b/labs/preamble.tex index 8d2292e..4bcdae9 100644 --- a/labs/preamble.tex +++ b/labs/preamble.tex @@ -1,10 +1,10 @@ -\documentclass[a4paper, 12pt]{article} +\documentclass[a4paper, 12pt, pdftex]{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[pdftex]{graphicx} +\usepackage[pdftex, a4paper, portrait, left=20mm, right=20mm, top=30mm, bottom=25mm]{geometry} +\usepackage[pdftex, bookmarks, colorlinks=false]{hyperref} \usepackage{paralist} \usepackage{pslatex} @@ -13,10 +13,41 @@ \usepackage{hhline} \usepackage[usenames]{xcolor} \usepackage{pdfpages} + +% font stuff +\usepackage[scaled]{beramono} % code font \usepackage[T1]{fontenc} % might fix copy-pasting issues +\usepackage[protrusion=true,expansion=true]{microtype} \usepackage{textcomp} + \usepackage{listings} +\usepackage{sectsty} % easily change section style +\allsectionsfont{\raggedright\sffamily\bfseries} + +\usepackage{titlesec} % allows adjustment of section spacing +\titlespacing{\section}{0pt}{0.75\parskip}{-0.25\parskip} +\titlespacing{\subsection}{0pt}{0.75\parskip}{-0.25\parskip} +\titlespacing{\subsubsection}{0pt}{0.75\parskip}{-0.25\parskip} +\titlespacing{\paragraph}{0pt}{0.75\parskip}{-0.25\parskip} + +% repurpose \paragraph as \subsubsubsection (which is sort of is already) +\titleformat{\paragraph}{\normalfont\normalsize\sffamily\bfseries}{\theparagraph}{1em}{} +\titlespacing{\paragraph}{0pt}{0.75\parskip}{-0.25\parskip} +\newcommand{\subsubsubsection}[1]{\paragraph{#1}} + + +\usepackage{fancyhdr} +\pagestyle{fancyplain} +\fancyhead[L]{\footnotesize\PaperCode~--~\PaperTitle} +\fancyhead[C]{} +\fancyhead[R]{\footnotesize\LabNum\LabTitle} +\fancyfoot[L]{} +\fancyfoot[C]{\thepage} +\fancyfoot[R]{} +\setlength{\headheight}{14pt} +\renewcommand{\footrulewidth}{0pt} + % PDF tex graphics extensions \DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png,.mps} @@ -30,14 +61,12 @@ % 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} +\newcommand\codesize{\fontsize{11}{8}\selectfont} +\newcommand{\codefont}{\fontfamily{fvm}\selectfont} +\newcommand{\commentfont}{\rmfamily\itshape} % define the colors for code highlighting (based on Eclipse colors) %\definecolor{KeywordColor}{rgb}{0.5,0,0.33} @@ -49,22 +78,6 @@ \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, @@ -74,6 +87,41 @@ morestring=[b]" } +% create a new environment for source code blocks +\lstnewenvironment{codeblock}[1][] +{ +\lstset{ + language=Java, + upquote=true, + basicstyle=\color{black}\codefont\codesize, + keywordstyle=\color{KeywordColor}\codefont\codesize, + commentstyle=\color{CommentColor}\commentfont\normalsize, + stringstyle=\color{StringColor}\codefont\codesize, + aboveskip=10pt, + belowskip=0pt, + showstringspaces=false, + tabsize=3, + showtabs=false, + columns=fullflexible, + flexiblecolumns=true, + breaklines=true +}\lstset{#1}} +{} + +% command for typesetting inline code +\newcommand{\code}[2][language=java]{% +\lstset{% + language=Java, + upquote=true, + basicstyle=\color{black}\codefont\normalsize, + keywordstyle=\color{KeywordColor}\codefont\normalsize, + commentstyle=\color{CommentColor}\commentfont\normalsize, + stringstyle=\color{StringColor}\codefont\normalsize, + showstringspaces=false, + showtabs=false +}% +\mbox{\lstinline[#1]!#2!}} + % centre command that won't add any vertical space before or after \newcommand{\centre}[1]{\hfill#1\hfill} @@ -94,6 +142,7 @@ \begin{figure}[H] \begin{center} \includegraphics[scale=#1,draft=false]{#2} + \vspace{-25pt} \end{center} \end{figure} } @@ -110,8 +159,6 @@ % 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}} @@ -122,11 +169,6 @@ % 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}}