diff --git a/labs/preamble.tex b/labs/preamble.tex index 4bcdae9..8bdbd3e 100644 --- a/labs/preamble.tex +++ b/labs/preamble.tex @@ -1,42 +1,53 @@ -\documentclass[a4paper, 12pt, pdftex]{article} +\documentclass[a4paper, 12pt]{article} -\usepackage{cmap} % attempt to fix search with ligatures problem. +\usepackage[a4paper, portrait, hmargin=20mm, vmargin=25mm]{geometry} +\usepackage[bookmarks, colorlinks]{hyperref} +\usepackage{paralist, float, tabularx, hhline, graphicx, xcolor, todonotes, hyperref} -\usepackage[pdftex]{graphicx} -\usepackage[pdftex, a4paper, portrait, left=20mm, right=20mm, top=30mm, bottom=25mm]{geometry} -\usepackage[pdftex, bookmarks, colorlinks=false]{hyperref} +\hypersetup{ + bookmarks, colorlinks, + citecolor=black, linkcolor=black, % don't need colored links + urlcolor=blue!55!black % blue enough to see, but dark enough to print +} -\usepackage{paralist} -\usepackage{pslatex} -\usepackage{float} -\usepackage{tabularx} -\usepackage{hhline} -\usepackage[usenames]{xcolor} -\usepackage{pdfpages} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% fonts %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% font stuff +\usepackage{cmap} % fix PDF searching (ligatures cause problems) +\usepackage{libertine} % default font set (looks good on both screen and paper) \usepackage[scaled]{beramono} % code font -\usepackage[T1]{fontenc} % might fix copy-pasting issues -\usepackage[protrusion=true,expansion=true]{microtype} -\usepackage{textcomp} +\usepackage[T1]{fontenc} % force type 1 fonts +\usepackage{microtype} % general improvements to typography +\usepackage{textcomp} % additional symbols (like the degrees symbol} +\usepackage{listings} % syntax highlighting -\usepackage{listings} +% make \emph do italics (just in case other environments change it) +\renewcommand{\emph}[1]{\textit{#1}} -\usepackage{sectsty} % easily change section style -\allsectionsfont{\raggedright\sffamily\bfseries} +% add a \strong command +\newcommand{\strong}[1]{\textbf{#1}} -\usepackage{titlesec} % allows adjustment of section spacing +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% sections %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\usepackage[sf,bf]{titlesec} \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) +% repurpose \paragraph as \subsubsubsection (which it 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}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% headers/footers %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \usepackage{fancyhdr} \pagestyle{fancyplain} \fancyhead[L]{\footnotesize\PaperCode~--~\PaperTitle} @@ -49,34 +60,41 @@ \renewcommand{\footrulewidth}{0pt} -% PDF tex graphics extensions -\DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png,.mps} - -% font size for code -\def\thesize{11truept} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% general layout %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % relax the justification/hyphenation wrapping settings \tolerance=800 -\emergencystretch=15mm +\emergencystretch=5mm + +% try to avoid widows and orphans +\clubpenalty = 10000 +\widowpenalty = 10000 % kill the paragraph indenting \setlength{\parindent}{0 mm} \setlength{\parskip}{0.7\baselineskip} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% syntax highlighting %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % create the fonts for code highlighting \newcommand\codesize{\fontsize{11}{8}\selectfont} -\newcommand{\codefont}{\fontfamily{fvm}\selectfont} -\newcommand{\commentfont}{\rmfamily\itshape} +\newcommand{\codefont}{\fontfamily{fvm}\selectfont} % beramono +\newcommand{\commentfont}{\rmfamily\itshape} % standard roman % 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} +% define the colors for code highlighting (based on NetBeans colors, although darker) +\definecolor{KeywordColor}{rgb}{0.0,0,0.7} +\definecolor{CommentColor}{rgb}{0.3,0.3,0.3} +\definecolor{StringColor}{rgb}{0.4,0.22.0} \lstdefinelanguage{JavaScript}{ keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break, this}, @@ -113,10 +131,10 @@ \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, + basicstyle=\color{black}\codefont\codesize, + keywordstyle=\color{black}\codefont\codesize, + commentstyle=\color{black}\commentfont\normalsize, + stringstyle=\color{black}\codefont\codesize, showstringspaces=false, showtabs=false }% @@ -125,6 +143,14 @@ % centre command that won't add any vertical space before or after \newcommand{\centre}[1]{\hfill#1\hfill} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% figures %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% PDF tex graphics extensions +\DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png} + % command for figures with captions - first param is scale. \newcommand{\captionedfig}[3] { \begin{figure}[H] @@ -156,31 +182,19 @@ \end{figure} } -% new indent command that doesn't rely on \parindent -\renewcommand{\indent}{\hspace*{5 mm}} - -% 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}}} - -% 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}} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% lists %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fix the extra spacing that itemize/enumerate has when you put have an blank -% line prior to the environment. +% line prior to the environment (paralist). \setlength{\pltopsep}{0.2\baselineskip} \setlength{\plpartopsep}{-0.2\baselineskip} \setlength{\plitemsep}{0.2\baselineskip} \setlength{\plparsep}{0.4\baselineskip} - +% use paralist compact versions by default so that above tweaks are used \renewenvironment{itemize}% {\begin{compactitem}}% {\end{compactitem}} @@ -188,3 +202,28 @@ \renewenvironment{enumerate}% {\begin{compactenum}}% {\end{compactenum}} + +% rationalise the bullet points +\def\labelitemi{\footnotesize$\bullet$} +\def\labelitemii{\footnotesize$\circ$} +\def\labelitemiii{\footnotesize$\diamond$} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% to-do notes %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% fix todonotes 'wrong margin' issue +\reversemarginpar +\newcommand{\fix}{\todo[color=red!60,noline,size=\large]{Fix}} +\newcommand{\comment}[1]{\todo[color=yellow!60,inline,size=\large]{#1}} +\newcommand{\incomplete}{\todo[color=red!60,inline,size=\large]{Incomplete}} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% misc %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% a simpler way of getting a right arrow +\newcommand{\ra}[0]{$\rightarrow$~} +