GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
1
mark.george
/
templates
Browse code
Various changes.
master
1 parent
4a0e305
commit
e626109098a15474f73390037c2162da2e6a52cd
Mark
authored
on 6 Mar 2017
Patch
Showing
5 changed files
latex/lectures/preamble.tex
latex/lectures/presentation.tex
plantuml/class-diagram-tips.md
r/graph-functions.r
xelatex/preamble.tex
Ignore Space
Show notes
View
latex/lectures/preamble.tex
\usepackage[pdftex]{hyperref} % options added via hypersetup below \RequirePackage[l2tabu, orthodox]{nag} % checks for deprecated/dodgy syntax \usepackage{etex} % increase number of dimension registers, since we now load enough packages to full the default number \usepackage{fixseminar} \usepackage{soul} \usepackage{graphicx} \usepackage{paralist} \usepackage{multicol} \usepackage{tabularx} \usepackage{hhline} \usepackage{bbding} \usepackage{xargs} \usepackage{texpower} % options added via \PassOptionsToPackage in driver files \usepackage[T1]{fontenc} % needed for getting rid of smart quotes in code \usepackage[scaled]{beramono} % code font \usepackage{textcomp} % needed for getting rid of smart quotes in code \usepackage{microtype} \usepackage{listings} \usepackage{todonotes} \usepackage[default]{gillius} \usepackage{enumitem} % used for nest \usepackage{booktabs} % better rules for tables (use alone or with tabularx) \usepackage[sharp]{easylist} % simple nested lists %\usepackage{showframe} % for checking margins \definecolor{SectionColor}{rgb}{0.32,0.32,0.32} \usepackage[skins]{tcolorbox} % inline highlighting of code \newcommand{\hilightchar}[1]{\colorbox{yellow!75}{\makebox[0pt]{\strut{#1}}}} \newcommand{\hilight}[1]{\setlength{\fboxsep}{1pt}\colorbox{yellow!75}{#1}} % uses the same spacing as \hilight, but does no highlighting. Use on the % original code when using incremental highlighting. \newcommand{\nohilight}[1]{\setlength{\fboxsep}{1pt}\fboxrule0pt\fbox{#1}} \newcommand{\error}[1]{\colorbox{red!75}{#1}} \tcbset{enhanced,boxsep=0pt,top=6pt,bottom=6pt,left=8pt,right=0pt,drop fuzzy shadow} % % PDF tex graphics extensions {graphicx} \DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png,.mps} % slidemargins {seminar,powersem} \renewcommand{\slidetopmargin}{15mm} \renewcommand{\slidebottommargin}{28mm} % 'correct' the bottom margin \renewcommand{\slideleftmargin}{15mm} \renewcommand{\sliderightmargin}{15mm} %%% source code highlighting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % first param is font size, second is baselineskip \newcommand\codesize{\fontsize{9}{1.1em}\selectfont} \newcommand\smallcodesize{\fontsize{8}{1.1em}\selectfont} % define the colors for code highlighting (based on Eclipse colors) \definecolor{KeywordColor}{rgb}{0.5,0,0.33} % violet \definecolor{CommentColor}{rgb}{0.25,0.5,0.37} % green \definecolor{StringColor}{rgb}{0.16,0,1} % blue % define the colors for code highlighting (based on NetBeans colors) %\definecolor{KeywordColor}{rgb}{0.0,0,0.9} %\definecolor{CommentColor}{rgb}{0.45,0.45,0.45} % a bit darker than NetBeans %\definecolor{StringColor}{rgb}{0.81,0.48,0.0} % create the fonts for code highlighting \newcommand{\codefont}{\fontfamily{fvm}\selectfont} % beramono \newcommand{\commentfont}{\sffamily\itshape} % 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\codesize, stringstyle=\color{StringColor}\codefont\codesize, aboveskip=0pt, belowskip=0pt, lineskip=-5pt, showstringspaces=false, tabsize=3, showtabs=false, columns=fullflexible, flexiblecolumns=true, xleftmargin=0pt, breaklines=true }\lstset{#1}} {} % create a new environment for source code blocks \lstnewenvironment{smallcodeblock}[1][] {% set up source code highlighting environment {listings} \lstset{ language=Java, upquote=true, basicstyle=\color{black}\codefont\smallcodesize, keywordstyle=\color{KeywordColor}\codefont\smallcodesize, commentstyle=\color{CommentColor}\commentfont\codesize, stringstyle=\color{StringColor}\codefont\smallcodesize, aboveskip=0pt, belowskip=0pt, lineskip=-9pt, showstringspaces=false, tabsize=2, showtabs=false, columns=fullflexible, flexiblecolumns=true, xleftmargin=0pt, breaklines=true }\lstset{#1}} {} \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]" } % command for typesetting inline code \renewcommand{\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!}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % command for figures - first param is scale, second is file \newcommand{\fig}[2] { \begin{figure}[H] \centering{\includegraphics[scale=#1,draft=false]{#2}} \end{figure} \vspace{-0.75\baselineskip} } % command for figures rotated 90 degrees left - first param is scale. \newcommand{\rotatedfig}[2] { \begin{figure}[H] \centering{\includegraphics[scale=#1,draft=false, angle=90]{#2}} \end{figure} } % command for figures - first param is scale, second is file \newcommand{\capfig}[3] { \begin{figure}[H]% \centering{\includegraphics[scale=#1,draft=false]{#2}% \\ % {\footnotesize #3} % } \end{figure} % \vspace{-0.75\baselineskip} } % command for figures that fit the page width \newcommand{\fittedfig}[1] { \begin{figure}[H] \begin{center} \resizebox{\textwidth}{!}{\includegraphics[draft=false]{#1}} \vspace{-25pt} \end{center} \end{figure} } % suppress section numbers \setcounter{secnumdepth}{-2} % scale factors used by seminar/powersem package to make over/under full slides fit a bit better \renewcommand{\slideshrink}{1.0} \renewcommand{\slideskip}{0.25} \renewcommand{\slidestretch}{1.05} % increase paragraph spacing a little bit so slides don't look so crowded \renewcommand{\slideparskip}{1.5ex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% sections %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[sf,bf]{titlesec} \titlespacing{\section}{0pt}{0pt}{0pt} \titlespacing{\subsection}{0pt}{0pt}{0pt} \titlespacing{\subsubsection}{0pt}{0pt}{0pt} \titlespacing{\paragraph}{0pt}{0pt}{-0.5\parskip} \newcommand\mysectionstyle{\huge\sffamily} \newcommand\mysubsectionstyle{\LARGE\sffamily} \newcommand\mysubsubsectionstyle{\Large\sffamily} \newcommand\mysubsubsubsectionstyle{\sffamily\bfseries} \titleformat{\section}{\mysectionstyle\filcenter}{\theparagraph}{1em}{} \titleformat{\subsection}{\mysubsubsubsectionstyle}{\theparagraph}{1em}{} \titleformat{\subsubsection}{\mysubsubsectionstyle}{\theparagraph}{1em}{} \titleformat{\paragraph}{\mysubsubsubsectionstyle}{\theparagraph}{1em}{} % repurpose \paragraph as \subsubsubsection (which it sort of is already) \newcommand{\subsubsubsection}[1]{\paragraph{#1}} %%%% % shrinkable sections - shrink to \textwidth if too long %%%% %section \let\oldsection\section \newsavebox{\secbox} \newlength{\secboxlength} \renewcommand{\section}[1]{% \sbox{\secbox}{\mbox{\mysectionstyle#1}}\settowidth{\secboxlength}{\usebox{\secbox}}% \oldsection{\ifdim\secboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\secbox}}\else{\usebox{\secbox}}\fi}} %subsection \let\oldsubsection\subsection \newsavebox{\subsecbox} \newlength{\subsecboxlength} \renewcommand{\subsection}[1]{% \sbox{\subsecbox}{\mbox{\mysubsectionstyle#1}}\settowidth{\subsecboxlength}{\usebox{\subsecbox}}% \oldsubsection{\ifdim\subsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsecbox}}\else{\usebox{\subsecbox}}\fi}} %subsubsection \let\oldsubsubsection\subsubsection \newsavebox{\subsubsecbox} \newlength{\subsubsecboxlength} \renewcommand{\subsubsection}[1]{% \sbox{\subsubsecbox}{\mbox{\mysubsubsectionstyle#1}}\settowidth{\subsubsecboxlength}{\usebox{\subsubsecbox}}% \oldsubsubsection{\ifdim\subsubsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsubsecbox}}\else{\usebox{\subsubsecbox}}\fi}} %subsubsubsection \let\oldsubsubsubsection\subsubsubsection \newsavebox{\subsubsubsecbox} \newlength{\subsubsubsecboxlength} \renewcommand{\subsubsubsection}[1]{% \sbox{\subsubsubsecbox}{\mbox{\mysubsubsubsectionstyle#1}}\settowidth{\subsubsubsecboxlength}{\usebox{\subsubsubsecbox}}% \oldsubsubsubsection{\ifdim\subsubsubsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsubsubsecbox}}\else{\usebox{\subsubsubsecbox}}\fi}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% miscellaneous stuff %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % suppress built in slide centering (which buggers up incremental uncovering, % and makes things jump around a lot) \centerslidesfalse % options for hyperef \hypersetup{ final={true}, colorlinks={true}, urlcolor={blue}, filecolor={blue}, linkcolor={blue}, bookmarks={true}, bookmarksopen={true}, pdfpagemode={None} } % title/subject/author attributes are set in lecturedetails.tex % command for continuing slides - moves the content down a bit \newcommand{\continued}{\null\smallskip} \newcommand{\ra}[0]{$\rightarrow$~} \slidepagestyle{empty} \slideframe[\setlength{}{}]{none} % environment for generating first page content \newenvironment{lecturecontent}% {% \null\vfill\maketitle\vfill\vfill\null% \newslide \section{Topics covered}% \begin{itemize} }% {% \end{itemize}% } \newcommand{\point}[2]{\textbf{#1}\\#2} \renewcommand{\emph}[1]{\color{emcolor}\textit{#1}} \newcommand{\strong}[1]{\color{emcolor}\textbf{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% lists %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fix the extra spacing that itemize/enumerate has when you put have an blank % line prior to the environment (paralist). \setlength{\pltopsep}{0.2\baselineskip} \setlength{\plpartopsep}{-0.2\baselineskip} \setlength{\plitemsep}{0.2\baselineskip} \setlength{\plparsep}{0.2\baselineskip} % use paralist compact versions by default so that above tweaks are used %\renewenvironment{itemize}% % {\begin{compactitem}}% % {\end{compactitem}} % %\renewenvironment{enumerate}% % {\begin{compactenum}}% % {\end{compactenum}} % rationalise the bullet points \def\labelitemi{\footnotesize\raisebox{0.175em}{$\bullet$}\normalsize} \def\labelitemii{\footnotesize\raisebox{0.175em}{$\circ$}\normalsize} \def\labelitemiii{\footnotesize\raisebox{0.175em}{$\diamond$}\normalsize} \def\labelitemiv{\footnotesize\raisebox{0.175em}{$\triangleright$}\normalsize} \def\labelitemv{\footnotesize\raisebox{0.175em}{$\star$}\normalsize} % easylist configuration \ListProperties(% Hang=true, % hanging indent Space=0pt, % additional space between different nest levels Space*=0pt, % additional space between same levels Hide=1000, % hide all numbering Margin=1em, Align=move, Margin1=1em, Style1*=\labelitemi\hskip.5em, Space1*=0.2em, % level 1 Margin2=2em, Style2*=\labelitemii\hskip .5em, Space2*=0.1em, % level 2 Margin3=3em, Style3*=\labelitemiii\hskip .5em, % level 3 Margin4=4em, Style4*=\labelitemiv\hskip .5em, % level 4 Margin5=5em, Style5*=\labelitemv\hskip .5em % level 5 ) % my attempt at creating a configurable easylist environment for controlling % spacing \usepackage{calc} % allows more complex calculations \newenvironment{nest}[1][0pt]% {% \ListProperties(% Space=#1, % additional space between different nest levels Space*=#1, % additional space between same levels ) \begin{easylist}% }% {% \end{easylist} % reset easylist spacing \ListProperties(% Space=0pt, % additional space between different nest levels Space*=0pt, % additional space between same levels ) }% % my attempt at creating a flat nested list environment %\usepackage{calc} % allows more complex calculations %\newenvironment{nest}[1][1]% %{\setlength{\parskip}{#1\baselineskip*\real{0.4}}}% %{\setlength{\leftskip}{0pt}\vspace{-2pt}\setlength{\parskip}{\slideparskip}} % %\def\liUndent{-10pt} %\def\liVgap{-4pt} %\def\liSkip{20pt} %\def\liiSkip{35pt} %\def\liiiSkip{46pt} %\def\liiiiSkip{57pt} %\def\liiiiiSkip{68pt} % %\newcommand{\li}{\smallskip\hspace{\liUndent}\labelitemi\hspace{5pt}\setlength{\leftskip}{\liSkip}} %\newcommand{\lii}{\hspace{\liUndent}\labelitemii\hspace{5pt}\setlength{\leftskip}{\liiSkip}} %\newcommand{\liii}{\hspace{\liUndent}\labelitemiii\hspace{5pt}\setlength{\leftskip}{\liiiSkip}} %\newcommand{\liiii}{\hspace{\liUndent}\labelitemiv\hspace{5pt}\setlength{\leftskip}{\liiiiSkip}} %\newcommand{\liiiii}{\hspace{\liUndent}\labelitemv\hspace{5pt}\setlength{\leftskip}{\liiiiiSkip}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% to-do notes %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\fix}[1]{\todo[color=red!60,noline,size=\large,inline]{Fix: #1}} %\newcommand{\comment}[1]{\todo[color=yellow!60,inline,size=\large]{#1}} %\newcommand{\incomplete}{\todo[color=red!60,inline,size=\large]{Incomplete}} %\newcommand{\complete}{\todo[color=green!60,inline,size=\large]{Complete}} \newcommand{\complete}{{\color{green}\Checkmark}~} \newcommand{\incomplete}{{\color{red}\XSolidBrush}~} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% slide environment %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % redefine texpower slide % new slide env that centers vertically % this is currently bustificated - haven't had time to look into it %\newenvironment{centredslide}% %{\slide\topskip0pt\minipage[c][\textheight][c]{\textwidth}}% %{\endminipage\endslide}
\usepackage[pdftex]{hyperref} % options added via hypersetup below \RequirePackage[l2tabu, orthodox]{nag} % checks for deprecated/dodgy syntax \usepackage{etex} % increase number of dimension registers, since we now load enough packages to full the default number \usepackage{fixseminar} \usepackage{soul} \usepackage{graphicx} \usepackage{paralist} \usepackage{multicol} \usepackage{tabularx} \usepackage{hhline} \usepackage{bbding} \usepackage{xargs} \usepackage{texpower} % options added via \PassOptionsToPackage in driver files \usepackage[T1]{fontenc} % needed for getting rid of smart quotes in code \usepackage[scaled]{beramono} % code font \usepackage{textcomp} % needed for getting rid of smart quotes in code \usepackage{microtype} \usepackage{listings} \usepackage{todonotes} \usepackage[default]{gillius} \usepackage{enumitem} % used for nest \usepackage{booktabs} % better rules for tables (use alone or with tabularx) \usepackage[sharp]{easylist} % simple nested lists %\usepackage{showframe} % for checking margins \definecolor{SectionColor}{rgb}{0.32,0.32,0.32} \usepackage[skins]{tcolorbox} % inline highlighting of code \newcommand{\hilightchar}[1]{\colorbox{yellow!75}{\makebox[0pt]{\strut{#1}}}} \newcommand{\hilight}[1]{\setlength{\fboxsep}{1pt}\colorbox{yellow!75}{#1}} % uses the same spacing as \hilight, but does no highlighting. Use on the % original code when using incremental highlighting. \newcommand{\nohilight}[1]{\hspace{-0.7\fboxsep}{\fboxrule0pt\fbox{#1}}} \newcommand{\error}[1]{\colorbox{red!75}{#1}} \tcbset{enhanced,boxsep=0pt,top=6pt,bottom=6pt,left=8pt,right=0pt,drop fuzzy shadow} % % PDF tex graphics extensions {graphicx} \DeclareGraphicsExtensions{.jpg,.jpeg,.pdf,.png,.mps} % slidemargins {seminar,powersem} \renewcommand{\slidetopmargin}{15mm} \renewcommand{\slidebottommargin}{28mm} % 'correct' the bottom margin \renewcommand{\slideleftmargin}{15mm} \renewcommand{\sliderightmargin}{15mm} %%% source code highlighting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % first param is font size, second is baselineskip \newcommand\codesize{\fontsize{9}{1.1em}\selectfont} \newcommand\smallcodesize{\fontsize{8}{1.1em}\selectfont} % define the colors for code highlighting (based on Eclipse colors) \definecolor{KeywordColor}{rgb}{0.5,0,0.33} % violet \definecolor{CommentColor}{rgb}{0.25,0.5,0.37} % green \definecolor{StringColor}{rgb}{0.16,0,1} % blue % define the colors for code highlighting (based on NetBeans colors) %\definecolor{KeywordColor}{rgb}{0.0,0,0.9} %\definecolor{CommentColor}{rgb}{0.45,0.45,0.45} % a bit darker than NetBeans %\definecolor{StringColor}{rgb}{0.81,0.48,0.0} % create the fonts for code highlighting \newcommand{\codefont}{\fontfamily{fvm}\selectfont} % beramono \newcommand{\commentfont}{\sffamily\itshape} % 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\codesize, stringstyle=\color{StringColor}\codefont\codesize, aboveskip=0pt, belowskip=0pt, lineskip=-5pt, showstringspaces=false, tabsize=3, showtabs=false, columns=fullflexible, flexiblecolumns=true, xleftmargin=0pt, breaklines=true }\lstset{#1}} {} % create a new environment for source code blocks \lstnewenvironment{smallcodeblock}[1][] {% set up source code highlighting environment {listings} \lstset{ language=Java, upquote=true, basicstyle=\color{black}\codefont\smallcodesize, keywordstyle=\color{KeywordColor}\codefont\smallcodesize, commentstyle=\color{CommentColor}\commentfont\codesize, stringstyle=\color{StringColor}\codefont\smallcodesize, aboveskip=0pt, belowskip=0pt, lineskip=-9pt, showstringspaces=false, tabsize=2, showtabs=false, columns=fullflexible, flexiblecolumns=true, xleftmargin=0pt, breaklines=true }\lstset{#1}} {} \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]" } % command for typesetting inline code \renewcommand{\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!}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % command for figures - first param is scale, second is file \newcommand{\fig}[2] { \begin{figure}[H] \centering{\includegraphics[scale=#1,draft=false]{#2}} \end{figure} \vspace{-0.75\baselineskip} } % command for figures rotated 90 degrees left - first param is scale. \newcommand{\rotatedfig}[2] { \begin{figure}[H] \centering{\includegraphics[scale=#1,draft=false, angle=90]{#2}} \end{figure} } % command for figures - first param is scale, second is file \newcommand{\capfig}[3] { \begin{figure}[H]% \centering{\includegraphics[scale=#1,draft=false]{#2}% \\ % {\footnotesize #3} % } \end{figure} % \vspace{-0.75\baselineskip} } % command for figures that fit the page width \newcommand{\fittedfig}[1] { \begin{figure}[H] \begin{center} \resizebox{\textwidth}{!}{\includegraphics[draft=false]{#1}} \vspace{-25pt} \end{center} \end{figure} } % suppress section numbers \setcounter{secnumdepth}{-2} % scale factors used by seminar/powersem package to make over/under full slides fit a bit better \renewcommand{\slideshrink}{1.0} \renewcommand{\slideskip}{0.25} \renewcommand{\slidestretch}{1.05} % increase paragraph spacing a little bit so slides don't look so crowded \renewcommand{\slideparskip}{1.5ex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% sections %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage[sf,bf]{titlesec} \titlespacing{\section}{0pt}{0pt}{0pt} \titlespacing{\subsection}{0pt}{0pt}{0pt} \titlespacing{\subsubsection}{0pt}{0pt}{0pt} \titlespacing{\paragraph}{0pt}{0pt}{-0.5\parskip} \newcommand\mysectionstyle{\huge\sffamily} \newcommand\mysubsectionstyle{\LARGE\sffamily} \newcommand\mysubsubsectionstyle{\Large\sffamily} \newcommand\mysubsubsubsectionstyle{\sffamily\bfseries} \titleformat{\section}{\mysectionstyle\filcenter}{\theparagraph}{1em}{} \titleformat{\subsection}{\mysubsubsubsectionstyle}{\theparagraph}{1em}{} \titleformat{\subsubsection}{\mysubsubsectionstyle}{\theparagraph}{1em}{} \titleformat{\paragraph}{\mysubsubsubsectionstyle}{\theparagraph}{1em}{} % repurpose \paragraph as \subsubsubsection (which it sort of is already) \newcommand{\subsubsubsection}[1]{\paragraph{#1}} %%%% % shrinkable sections - shrink to \textwidth if too long %%%% %section \let\oldsection\section \newsavebox{\secbox} \newlength{\secboxlength} \renewcommand{\section}[1]{% \sbox{\secbox}{\mbox{\mysectionstyle#1}}\settowidth{\secboxlength}{\usebox{\secbox}}% \oldsection{\ifdim\secboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\secbox}}\else{\usebox{\secbox}}\fi}} %subsection \let\oldsubsection\subsection \newsavebox{\subsecbox} \newlength{\subsecboxlength} \renewcommand{\subsection}[1]{% \sbox{\subsecbox}{\mbox{\mysubsectionstyle#1}}\settowidth{\subsecboxlength}{\usebox{\subsecbox}}% \oldsubsection{\ifdim\subsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsecbox}}\else{\usebox{\subsecbox}}\fi}} %subsubsection \let\oldsubsubsection\subsubsection \newsavebox{\subsubsecbox} \newlength{\subsubsecboxlength} \renewcommand{\subsubsection}[1]{% \sbox{\subsubsecbox}{\mbox{\mysubsubsectionstyle#1}}\settowidth{\subsubsecboxlength}{\usebox{\subsubsecbox}}% \oldsubsubsection{\ifdim\subsubsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsubsecbox}}\else{\usebox{\subsubsecbox}}\fi}} %subsubsubsection \let\oldsubsubsubsection\subsubsubsection \newsavebox{\subsubsubsecbox} \newlength{\subsubsubsecboxlength} \renewcommand{\subsubsubsection}[1]{% \sbox{\subsubsubsecbox}{\mbox{\mysubsubsubsectionstyle#1}}\settowidth{\subsubsubsecboxlength}{\usebox{\subsubsubsecbox}}% \oldsubsubsubsection{\ifdim\subsubsubsecboxlength>\textwidth\protect\resizebox{\textwidth}{!}{\usebox{\subsubsubsecbox}}\else{\usebox{\subsubsubsecbox}}\fi}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% miscellaneous stuff %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % suppress built in slide centering (which buggers up incremental uncovering, % and makes things jump around a lot) \centerslidesfalse % options for hyperef \hypersetup{ final={true}, colorlinks={true}, urlcolor={blue}, filecolor={blue}, linkcolor={blue}, bookmarks={true}, bookmarksopen={true}, pdfpagemode={None} } % title/subject/author attributes are set in lecturedetails.tex % command for continuing slides - moves the content down a bit \newcommand{\continued}{\null\smallskip} \newcommand{\ra}[0]{$\rightarrow$~} \slidepagestyle{empty} \slideframe[\setlength{}{}]{none} % environment for generating first page content \newenvironment{lecturecontent}% {% \null\vfill\maketitle\vfill\vfill\null% \newslide \section{Topics covered}% \begin{itemize} }% {% \end{itemize}% } \newcommand{\point}[2]{\textbf{#1}\\#2} \renewcommand{\emph}[1]{\color{emcolor}\textit{#1}} \newcommand{\strong}[1]{\color{emcolor}\textbf{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% lists %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fix the extra spacing that itemize/enumerate has when you put have an blank % line prior to the environment (paralist). \setlength{\pltopsep}{0.2\baselineskip} \setlength{\plpartopsep}{-0.2\baselineskip} \setlength{\plitemsep}{0.2\baselineskip} \setlength{\plparsep}{0.2\baselineskip} % use paralist compact versions by default so that above tweaks are used %\renewenvironment{itemize}% % {\begin{compactitem}}% % {\end{compactitem}} % %\renewenvironment{enumerate}% % {\begin{compactenum}}% % {\end{compactenum}} % rationalise the bullet points \def\labelitemi{\footnotesize\raisebox{0.175em}{$\bullet$}\normalsize} \def\labelitemii{\footnotesize\raisebox{0.175em}{$\circ$}\normalsize} \def\labelitemiii{\footnotesize\raisebox{0.175em}{$\diamond$}\normalsize} \def\labelitemiv{\footnotesize\raisebox{0.175em}{$\triangleright$}\normalsize} \def\labelitemv{\footnotesize\raisebox{0.175em}{$\star$}\normalsize} % easylist configuration \ListProperties(% Hang=true, % hanging indent Space=0pt, % additional space between different nest levels Space*=0pt, % additional space between same levels Hide=1000, % hide all numbering Margin=1em, Align=move, Margin1=1em, Style1*=\labelitemi\hskip.5em, Space1*=0.2em, % level 1 Margin2=2em, Style2*=\labelitemii\hskip .5em, Space2*=0.1em, % level 2 Margin3=3em, Style3*=\labelitemiii\hskip .5em, % level 3 Margin4=4em, Style4*=\labelitemiv\hskip .5em, % level 4 Margin5=5em, Style5*=\labelitemv\hskip .5em % level 5 ) % my attempt at creating a configurable easylist environment for controlling % spacing \usepackage{calc} % allows more complex calculations \newenvironment{nest}[1][0pt]% {% \ListProperties(% Space=#1, % additional space between different nest levels Space*=#1, % additional space between same levels ) \begin{easylist}% }% {% \end{easylist} % reset easylist spacing \ListProperties(% Space=0pt, % additional space between different nest levels Space*=0pt, % additional space between same levels ) }% % my attempt at creating a flat nested list environment %\usepackage{calc} % allows more complex calculations %\newenvironment{nest}[1][1]% %{\setlength{\parskip}{#1\baselineskip*\real{0.4}}}% %{\setlength{\leftskip}{0pt}\vspace{-2pt}\setlength{\parskip}{\slideparskip}} % %\def\liUndent{-10pt} %\def\liVgap{-4pt} %\def\liSkip{20pt} %\def\liiSkip{35pt} %\def\liiiSkip{46pt} %\def\liiiiSkip{57pt} %\def\liiiiiSkip{68pt} % %\newcommand{\li}{\smallskip\hspace{\liUndent}\labelitemi\hspace{5pt}\setlength{\leftskip}{\liSkip}} %\newcommand{\lii}{\hspace{\liUndent}\labelitemii\hspace{5pt}\setlength{\leftskip}{\liiSkip}} %\newcommand{\liii}{\hspace{\liUndent}\labelitemiii\hspace{5pt}\setlength{\leftskip}{\liiiSkip}} %\newcommand{\liiii}{\hspace{\liUndent}\labelitemiv\hspace{5pt}\setlength{\leftskip}{\liiiiSkip}} %\newcommand{\liiiii}{\hspace{\liUndent}\labelitemv\hspace{5pt}\setlength{\leftskip}{\liiiiiSkip}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% to-do notes %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\fix}[1]{\todo[color=red!60,noline,size=\large,inline]{Fix: #1}} %\newcommand{\comment}[1]{\todo[color=yellow!60,inline,size=\large]{#1}} %\newcommand{\incomplete}{\todo[color=red!60,inline,size=\large]{Incomplete}} %\newcommand{\complete}{\todo[color=green!60,inline,size=\large]{Complete}} \newcommand{\complete}{{\color{green}\Checkmark}~} \newcommand{\incomplete}{{\color{red}\XSolidBrush}~} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% slide environment %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % redefine texpower slide % new slide env that centers vertically % this is currently bustificated - haven't had time to look into it %\newenvironment{centredslide}% %{\slide\topskip0pt\minipage[c][\textheight][c]{\textwidth}}% %{\endminipage\endslide}
Ignore Space
Show notes
View
latex/lectures/presentation.tex
% Driver file for generating a presentation version suitable for displaying via a project. % This uses a coloured background, and enables the incremental uncovering of content. \documentclass[a4,landscape,KOMA,calcdimensions,display]{powersem} \PassOptionsToPackage{coloremph,colorhighlight,whitebackground}{texpower} \include{preamble} \defineTPcolor{inactivecolor}{rgb}{0.1,0.1,0.1} \defineTPcolor{pagecolor}{rgb}{0.87, 0.88, 0.90} \defineTPcolor{textcolor}{rgb}{0.25, 0.25, 0.25} \defineTPcolor{emcolor}{rgb}{0.25, 0.25, 0.25} \include{lecturedetails} \include{content}
% Driver file for generating a presentation version suitable for displaying via a project. % This uses a coloured background, and enables the incremental uncovering of content. \documentclass[a4,landscape,KOMA,calcdimensions,display]{powersem} \PassOptionsToPackage{coloremph,colorhighlight,whitebackground}{texpower} \include{preamble} \defineTPcolor{inactivecolor}{rgb}{0.1,0.1,0.1} \defineTPcolor{pagecolor}{rgb}{0.87, 0.88, 0.90} \defineTPcolor{textcolor}{rgb}{0.32, 0.32, 0.32} \defineTPcolor{emcolor}{rgb}{0.32, 0.32, 0.32} %\backgroundstyle[startcolor=red, midcolor=yellow, endcolor=red, stripes=500]{doublehgradient} \include{lecturedetails} \include{content}
Ignore Space
Show notes
View
plantuml/class-diagram-tips.md
## Controlling Class Layout Layout is determined dymanically, so can be tricky if you are trying to get a specific layout, but you can usually beat it into submission with a combination of the following: ' force class diagram mode class c1 ' horizontal placement c1 -> c2 ' vertical placement c2 --> c3 ' left placement c4 -left-> c4 You can use `left`, `right`, `up`, and `down` to control placement direction. If adding a link screws up the class placement you can use `[norank]` to exclude the link from the layout process: ' link will not affect class placement c4 -[norank]-> c2 You can also use `[hidden]` to create invisible links solely for the purpose of influencing the layout. Repeating them will increase the likelihood that the classes will be placed closer and even be aligned with each other: ' place c2 and c4 closer together c2 -[hidden]-> c4 ' repeated again to place c2 and c4 even closer c2 -[hidden]-> c4 Note that although the links are hidden they still affecting the drawing of links on the same path. If you temporarily remove the `[hidden]` option you can see what is going on. You can fiddle with the ordering and direction to ensure the one that is being drawn is in the place that you want it (usually in the middle). The trick is to use identical links with the same class ordering and direction. If you want the link drawn in the opposite direction you can't flip the order of the classes - you need to swap the placement of the arrow: ' place c2 and c4 closer c2 -[hidden]- c4 ' draw the actual link between the hidden links c2 <-[norank]- c4 ' place c2 and c4 even closer c2 -[hidden]- c4 ### General Layout Tips Understanding how the layout engine works (GraphVis) makes it easier to get what you want. The previous example with the `[hidden]` and `[norank]` links got weird because we were giving the layout engine conflicting information. The layout is determined by the order that classes occur. Classes are drawn at the top of the document have higher ranking than those below. The rank is determined by: * The order in which classes are added to the diagram * The layout hints (horizontal, vertical, left, right, up, down) * The direction in which the links are defined. The class on the left has higher rank than the one on the right: `higher -> lower` Link direction can have a dramatic impact. If we add a `c4 --> c2` link we confuse the engine by having `c4` on the left which gives it a higher ranking than `c2` and causes the diagram to flip upside down: class c1 c1 -> c2 c2 --> c3 c3 -left-> c4 ' whoops, this flips the diagram on its head c4 --> c2 Drawing links from the top down prevents this re-ranking problem, and means you don't have to use `[norank]` as often. Since the arrow direction has no effect on the layout we can just flip the end that the arrow is drawn at to account for the link being in a different order: ' ranking maintained, so layout isn't dramatically affected ' arrow drawn at opposite end to account for reverse order c2 <-- c4 We could have also used the `up` layout hint to prevent the re-ranking: c4 -up-> c2 ## Layout Direction You can change the ranking direction from vertical to horizontal using `left to right direction`: left to right direction class c1 c1 -> c2 c2 --> c3 c3 -left-> c4 c2 <-- c4 This also changes the meaning of the layout hints. Horizontal hints become vertical, etc. ## Spacing You can control the spacing between class using the `NodeSep` and `RankSep` skinparams. SkinParam { NodeSep 45 ' horizontal spacing RankSep 45 ' vertical spacing } ## Grouping You can influence the layout to ensure classes are grouped together: together { class c1 class c2 } c1 -- c2 ## Line style Polylines will occasionally be used. For some line decorations (crows feet for ERD for example) look like crap when wonky angles are used. ' straight lines only skinparam linetype ortho ' allow polylines skinparam linetype polyline ## Sequence diagram coloring You can change the colors of the arrows and messages as followings: a -[#red]> b : <color blue> some message</color>
## Controlling Class Layout Layout is determined dymanically, so can be tricky if you are trying to get a specific layout, but you can usually beat it into submission with a combination of the following: ' force class diagram mode class c1 ' horizontal placement c1 -> c2 ' vertical placement c2 --> c3 ' left placement c4 -left-> c4 You can use `left`, `right`, `up`, and `down` to control placement direction. If adding a link screws up the class placement you can use `[norank]` to exclude the link from the layout process: ' link will not affect class placement c4 -[norank]-> c2 You can also use `[hidden]` to create invisible links solely for the purpose of influencing the layout. Repeating them will increase the likelihood that the classes will be placed closer and even be aligned with each other: ' place c2 and c4 closer together c2 -[hidden]-> c4 ' repeated again to place c2 and c4 even closer c2 -[hidden]-> c4 Note that although the links are hidden they still affecting the drawing of links on the same path. If you temporarily remove the `[hidden]` option you can see what is going on. You can fiddle with the ordering and direction to ensure the one that is being drawn is in the place that you want it (usually in the middle). The trick is to use identical links with the same class ordering and direction. If you want the link drawn in the opposite direction you can't flip the order of the classes - you need to swap the placement of the arrow: ' place c2 and c4 closer c2 -[hidden]- c4 ' draw the actual link between the hidden links c2 <-[norank]- c4 ' place c2 and c4 even closer c2 -[hidden]- c4 ### General Layout Tips Understanding how the layout engine works (GraphVis) makes it easier to get what you want. The previous example with the `[hidden]` and `[norank]` links got weird because we were giving the layout engine conflicting information. The layout is determined by the order that classes occur. Classes are drawn at the top of the document have higher ranking than those below. The rank is determined by: * The order in which classes are added to the diagram * The layout hints (horizontal, vertical, left, right, up, down) * The direction in which the links are defined. The class on the left has higher rank than the one on the right: `higher -> lower` Link direction can have a dramatic impact. If we add a `c4 --> c2` link we confuse the engine by having `c4` on the left which gives it a higher ranking than `c2` and causes the diagram to flip upside down: class c1 c1 -> c2 c2 --> c3 c3 -left-> c4 ' whoops, this flips the diagram on its head c4 --> c2 Drawing links from the top down prevents this re-ranking problem, and means you don't have to use `[norank]` as often. Since the arrow direction has no effect on the layout we can just flip the end that the arrow is drawn at to account for the link being in a different order: ' ranking maintained, so layout isn't dramatically affected ' arrow drawn at opposite end to account for reverse order c2 <-- c4 We could have also used the `up` layout hint to prevent the re-ranking: c4 -up-> c2 ## Layout Direction You can change the ranking direction from vertical to horizontal using `left to right direction`: left to right direction class c1 c1 -> c2 c2 --> c3 c3 -left-> c4 c2 <-- c4 This also changes the meaning of the layout hints. Horizontal hints become vertical, etc. ## Spacing You can control the spacing between class using the `NodeSep` and `RankSep` skinparams. SkinParam { NodeSep 45 ' horizontal spacing RankSep 45 ' vertical spacing }
Ignore Space
Show notes
View
r/graph-functions.r
library(TeachingDemos) # define some colors dCol <- rgb(1.0,0,0,alpha=0.2) dBorder <- rgb(1.0,0,0,alpha=1.0) # function for producing a histogram histogram <- function(data, width=5, step=10, min=0, max=100, xlab=columnName, ylab=NULL, overridelabels=NULL, showcurve=FALSE, stats=TRUE, showbinwidth=FALSE, ylimit=NULL, curveAdjust=0.6, centresRight=TRUE, statsRight=FALSE, values=TRUE, ...) { # get number of results of data in specified column n <- length(data) # create histogram data h <- hist(data, breaks=seq(min, max, by=width), include.lowest=TRUE, right=centresRight, plot=FALSE) if(showcurve) { # calculate density for plotting a fitted curve den <- density(data, curveAdjust, kernel="cosine", na.rm=TRUE) } # calculate range for y-axis unless it is specified as a parameter if(is.null(ylimit)) { ylimit <- max(h$count) ylimit <- ceiling(ylimit / step) * step if(showcurve) { ylimit <- max(c(ylimit,width*n*den$y)) } } subText = "" if(showbinwidth) { subText = paste("(bin width of ", width,")",sep="") } # create initial plot if(is.null(ylab)) { ylab <- "Count" } plot(h,ylim=c(0, ylimit), xlab=xlab, ylab=ylab, sub=subText, axes=FALSE, ...) # plot some hrizontal grid lines abline(h=seq(0, ylimit, by=step), col="grey", lty="solid", lwd=0.5) # plot the histogram lines(h, ylim=c(0, ylimit), border="darkblue", col="light blue") mtext("Histogram", side=3, line=0.25) ## render the axis labels ## # cache the original graphics params and shrink the text a bit op <- par(cex=0.7, font.lab=2) # y-axis LEFT <- 2 axis(LEFT, at=seq(0, ylimit, by=step), las=1) # x-axis # are we overriding x labels? if (!is.null(overridelabels)) { axis(1, at=seq(min+0.5*width, max-0.5*width, by=width), labels=overridelabels) } else { axis(1, at=seq(min, max, by=width), labels=seq(min, max, by=width)) } # restore graphics params par(op) # plot density curve if required if(showcurve) { # scale the height of the curve and render it polygon(x=den$x, y=width*n*den$y, col=dCol, border=dBorder) } # render values over bars if(values) { op <- par(cex=0.7) # cache the graphics params plot(h, labels=TRUE, col="transparent", border="transparent", add=TRUE) par(op) # restore graphics params } if(stats) { op <- par(cex=0.7) avg <- mean(na.omit(data), trim=0) med <- median(na.omit(data)) mi <- min(na.omit(data)) ma <- max(na.omit(data)) maxCount <- length(which(round(data,3) == max)) subsStr <- paste("Submissions: ", length(na.omit(data)), sep="") avgStr <- paste("Mean: ", round(avg,1), " (", round((avg/max)*100,1),"%)", sep="") medStr <- paste("Median: ", round(med,1), " (", round((med/max)*100,1),"%)", sep="") minStr <- paste("Minimum: ", round(mi,1), " (",round((mi/max)*100,1),"%)", sep="") maxStr <- paste("Maximum: ", round(ma,1), " (",round((ma/max)*100,1),"%)", sep="") fullMarksStr <- paste("Full Marks: ", maxCount," (", round(maxCount/length(na.omit(data))*100,1),"%)", sep="") combinedStr <- paste(subsStr, avgStr, medStr, minStr, maxStr, fullMarksStr, sep="\n") strW <- strwidth(combinedStr) strH <- strheight(combinedStr) margin <- 2 xmargin <- margin * max / 100 ymargin <- margin * ylimit / 100 if(!statsRight) { rect(xleft=0, xright=strW+xmargin*2, ytop=ylimit, ybottom=ylimit-strH-ymargin*2, col="white") text(x=xmargin, y=ylimit-(strH / 2) - ymargin, combinedStr, adj=0) } else { rect(xleft=max-strW-(xmargin*2), max, ytop=ylimit, ybottom=ylimit-strH-ymargin*2, col="white") text(x=max-strW-xmargin, y=ylimit-(strH / 2) - ymargin, combinedStr, adj=0) } par(op) } } # function for producing a scatter plot summaryboxplot <- function(data, formula, drawOutlierLabels=F, extras=NULL, labs=NULL, ...) { # add padding if adding extras op <-if(!is.null(extras)) { par(mar=c(4+length(extras), 4, 4, 2) + 0.15) } else { par() } boxplot(formula=formula, data=data, axes=F, ylim=c(0,100), ...) abline(h=seq(0,100, by=5), col="grey", lty="solid", lwd=0.5) axis(2, at=seq(0,100, by=10), las=1) axis(1, labels=levels(labs), at=seq(1, length(levels(labs))), font=2, ...) if(!is.null(extras)) { for(i in 1:length(extras)) { mtext(line=i-1, text=names(extras[i]), side=1, padj=4, adj=1, at=0.55, cex=0.8, font=2); axis(line=i-1, side=1, padj=2, at=seq(1,nrow(extras[i])), labels=t(extras[i]), cex.axis=0.8, tick=F, ...) } } b <- boxplot(formula=formula, data=data, col="light blue", yaxt="n", xaxt="n", add=TRUE) for (g in unique(b$group)) { # for every group that has at least one outlier # get assessment label l <- b$name[g] # get outliers o <- b$out[which(b$group == g)] # get x,y coords of outliers and ID labels x0 <- rep(g, length(o)); x1 <- rep(g+0.1, length(o)) y0 <- o; y1 <- spread.labs(o, 1.25*strheight('A'), maxiter=6000, stepsize = 0.05) # plots IDs if(drawOutlierLabels) { # get IDs of outliers i <- data$ID[data$Assessment == l & data$Mark %in% o] text(x1, y1, i, adj=c(-0.1,0.5), col="black", cex=0.7) # plot lines linking IDs to points (swap y0 with y1 if the lines pointing to outliers are backwards) segments(x0+0.5*strwidth("X")+strwidth(" "), y0, x1-strwidth(""), y1, col="black", lty=1) } # replot outliers with coloured background points(x=x0, y=y0, bg="light blue", pch=21) } par(op) }
library(TeachingDemos) # define some colors dCol <- rgb(1.0,0,0,alpha=0.2) dBorder <- rgb(1.0,0,0,alpha=1.0) # function for producing a histogram histogram <- function(data, width=5, step=10, min=0, max=100, xlab=columnName, ylab=NULL, overridelabels=NULL, showcurve=FALSE, stats=TRUE, showbinwidth=FALSE, ylimit=NULL, curveAdjust=0.6, centresRight=TRUE, statsRight=FALSE, values=TRUE, ...) { # get number of results of data in specified column n <- length(data) # create histogram data h <- hist(data, breaks=seq(min, max, by=width), include.lowest=TRUE, right=centresRight, plot=FALSE) if(showcurve) { # calculate density for plotting a fitted curve den <- density(data, curveAdjust, kernel="cosine", na.rm=TRUE) } # calculate range for y-axis unless it is specified as a parameter if(is.null(ylimit)) { ylimit <- max(h$count) ylimit <- ceiling(ylimit / step) * step if(showcurve) { ylimit <- max(c(ylimit,width*n*den$y)) } } subText = "" if(showbinwidth) { subText = paste("(bin width of ", width,")",sep="") } # create initial plot if(is.null(ylab)) { ylab <- "Number of Students" } plot(h,ylim=c(0, ylimit), xlab=xlab, ylab=ylab, sub=subText, axes=FALSE, ...) # plot some hrizontal grid lines abline(h=seq(0, ylimit, by=step), col="grey", lty="solid", lwd=0.5) # plot the histogram lines(h, ylim=c(0, ylimit), border="darkblue", col="light blue") mtext("Histogram", side=3, line=0.25) ## render the axis labels ## # cache the original graphics params and shrink the text a bit op <- par(cex=0.7, font.lab=2) # y-axis LEFT <- 2 axis(LEFT, at=seq(0, ylimit, by=step), las=1) # x-axis # are we overriding x labels? if (!is.null(overridelabels)) { axis(1, at=seq(min+0.5*width, max-0.5*width, by=width), labels=overridelabels) } else { axis(1, at=seq(min, max, by=width), labels=seq(min, max, by=width)) } # restore graphics params par(op) # plot density curve if required if(showcurve) { # scale the height of the curve and render it polygon(x=den$x, y=width*n*den$y, col=dCol, border=dBorder) } # render values over bars if(values) { op <- par(cex=0.7) # cache the graphics params plot(h, labels=TRUE, col="transparent", border="transparent", add=TRUE) par(op) # restore graphics params } if(stats) { op <- par(cex=0.7) avg <- mean(na.omit(data), trim=0) med <- median(na.omit(data)) mi <- min(na.omit(data)) ma <- max(na.omit(data)) maxCount <- length(which(round(data,3) == max)) subsStr <- paste("Submissions: ", length(na.omit(data)), sep="") avgStr <- paste("Mean: ", round(avg,1), " (", round((avg/max)*100,1),"%)", sep="") medStr <- paste("Median: ", round(med,1), " (", round((med/max)*100,1),"%)", sep="") minStr <- paste("Minimum: ", round(mi,1), " (",round((mi/max)*100,1),"%)", sep="") maxStr <- paste("Maximum: ", round(ma,1), " (",round((ma/max)*100,1),"%)", sep="") fullMarksStr <- paste("Full Marks: ", maxCount," (", round(maxCount/length(na.omit(data))*100,1),"%)", sep="") combinedStr <- paste(subsStr, avgStr, medStr, minStr, maxStr, fullMarksStr, sep="\n") strW <- strwidth(combinedStr) strH <- strheight(combinedStr) margin <- 2 xmargin <- margin * max / 100 ymargin <- margin * ylimit / 100 if(!statsRight) { rect(xleft=0, xright=strW+xmargin*2, ytop=ylimit, ybottom=ylimit-strH-ymargin*2, col="white") text(x=xmargin, y=ylimit-(strH / 2) - ymargin, combinedStr, adj=0) } else { rect(xleft=max-strW-(xmargin*2), max, ytop=ylimit, ybottom=ylimit-strH-ymargin*2, col="white") text(x=max-strW-xmargin, y=ylimit-(strH / 2) - ymargin, combinedStr, adj=0) } par(op) } } # function for producing a scatter plot #pointlabels are labels to be rendered beside each point on the plot scatter <- function(pointlabels=NULL, x, y, xlab, ylab, maxx=100, maxy=100, fit=FALSE, ...) { # plot x vs y as solid points (thats what the pch=19 means) points plot(x, y, xlim=c(0,maxx), ylim=c(0,maxy), col="light blue", pch=19, xlab=xlab, ylab=ylab, xaxt='n',yaxt='n', ...) # plot some grid lines abline(h=seq(0, maxy, 10), col="light grey", lty="solid", lwd=0.5) abline(v=seq(0, maxx, 10), col="light grey", lty="solid", lwd=0.5) # abline(a=0, b=1, col="light grey", lwd=0.5) # plot the graph points(x, y, xlim=c(0,maxx), ylim=c(0,maxy), col="light blue", pch=19, xlab=xlab, ylab=ylab, ...) # cache the original graphics params and shrink the text a bit op <- par(cex=0.7) # y-axis LEFT <- 2 axis(LEFT, at=seq(0, maxy, by=10), las=1) axis(1, at=seq(0, maxx, by=10)) par(op) mtext("Scatter Plot", side=3, line=0.25) # replot the points with darker outline to create a border around the points points(x,y, col="dark blue") # display point labels next to points if they were provided if(!is.null(pointlabels)) { # calculate a normalised offset for the x position of the labels xlabelpos <- x-3.8*(maxx/100) # render the labels text(xlabelpos,y,pointlabels, cex=0.5) } # change plot color op <- par(col="red") co <- list() co$x <- x co$y <- y valid <- is.na(co$x) | is.na(co$y) valid <- !valid co$x <- co$x[valid] co$y <- co$y[valid] if(fit) { # render a lowess regression lines(lowess(co)) #abline(reggie) } # restore original plot params par(op) } # Sums two vectors in a coalescing fashion. # If either value in x1 or x2 is NA that the result is the non-NA value. # If both values in x1 or x2 are NA then the result is NA. # If neither x1 or x2 is NA then the result is x1 + x2. # coalescing_sum <- function (x1, x2) { # # # Iterative version. Keeping around as an example. # # results <- 1:length(x1) # # for(i in 1:length(x1)) { # # if(xor(is.na(x1[i]),is.na(x2[i]))) { # results[i] <- ifelse(is.na(x1[i]), 0, x1[i]) + ifelse(is.na(x2[i]), 0, x2[i]) # } else { # results[i] <- x1[i] + x2[i] # } # # } # # return(results) # } # Sums two vectors in a coalescing fashion. # If either value in x1 or x2 is NA that the result is the non-NA value. # If both values in x1 or x2 are NA then the result is NA. # If neither x1 or x2 is NA then the result is x1 + x2. coalescing_sum <- function (x, y) { # keep track of which positions have both values as na both.na <- is.na(x) & is.na(y) # zero nas x[is.na(x)] <- 0 y[is.na(y)] <- 0 # do the sum z <- x + y; # replace positions with both na as na z[both.na] <- NA return(z) } summaryboxplot <- function(data, formula, drawOutlierLabels=F, extras=NULL, labs=NULL, ...) { # add padding if adding extras op <-if(!is.null(extras)) { par(mar=c(4+length(extras), 4, 4, 2) + 0.15) } else { par() } boxplot(formula=formula, data=data, axes=F, ylim=c(0,100), ...) abline(h=seq(0,100, by=5), col="grey", lty="solid", lwd=0.5) axis(2, at=seq(0,100, by=10), las=1) axis(1, labels=levels(labs), at=seq(1, length(levels(labs))), font=2, ...) if(!is.null(extras)) { for(i in 1:length(extras)) { mtext(line=i-1, text=names(extras[i]), side=1, padj=4, adj=1, at=0.55, cex=0.8, font=2); axis(line=i-1, side=1, padj=2, at=seq(1,nrow(extras[i])), labels=t(extras[i]), cex.axis=0.8, tick=F, ...) } } b <- boxplot(formula=formula, data=data, col="light blue", yaxt="n", xaxt="n", add=TRUE) for (g in unique(b$group)) { # for every group that has at least one outlier # get assessment label l <- b$name[g] # get outliers o <- b$out[which(b$group == g)] # get x,y coords of outliers and ID labels x0 <- rep(g, length(o)); x1 <- rep(g+0.1, length(o)) y0 <- o; y1 <- spread.labs(o, 1.25*strheight('A'), maxiter=6000, stepsize = 0.05) # plots IDs if(drawOutlierLabels) { # get IDs of outliers i <- data$ID[data$Assessment == l & data$Mark %in% o] text(x1, y1, i, adj=c(-0.1,0.5), col="black", cex=0.7) # plot lines linking IDs to points (swap y0 with y1 if the lines pointing to outliers are backwards) segments(x0+0.5*strwidth("X")+strwidth(" "), y0, x1-strwidth(""), y1, col="black", lty=1) } # replot outliers with coloured background points(x=x0, y=y0, bg="light blue", pch=21) } par(op) }
Ignore Space
Show notes
View
xelatex/preamble.tex
\documentclass[a4paper, 11pt]{article} \RequirePackage[l2tabu, orthodox]{nag} \usepackage[a4paper, portrait, hmargin=20mm, vmargin=25mm]{geometry} \usepackage[bookmarks, colorlinks]{hyperref} \usepackage{paralist, float, tabularx, hhline, graphicx, xcolor, todonotes, bbding, hyperref, needspace, booktabs, changepage} \hypersetup{ citecolor=black, linkcolor=black, % don't need colored links urlcolor=blue!55!black % blue enough to see, but dark enough to print } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% fonts %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{fontspec} \setmainfont{Lora} \setsansfont{Roboto Condensed} \setmonofont[Scale=MatchLowercase]{Inconsolata} \usepackage{microtype} % general improvements to typography % make \emph do italics (just in case other environments change it) \renewcommand{\emph}[1]{\textit{#1}} % add a \strong command \newcommand{\strong}[1]{\textbf{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 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 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\textsf{\PaperCode~--~\PaperTitle}} \fancyhead[C]{} \fancyhead[R]{\footnotesize\textsf{\LabNum\LabTitle}} \fancyfoot[L]{} \fancyfoot[C]{\footnotesize\textsf{\thepage}} \fancyfoot[R]{} \setlength{\headheight}{14pt} \renewcommand{\footrulewidth}{0pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% general layout %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % relax the justification/hyphenation wrapping settings \pretolerance=200 \tolerance=500 \setlength{\emergencystretch}{1.5em} % try harder to avoid widows and orphans \clubpenalty=300 \widowpenalty=300 % kill the paragraph indenting \setlength{\parindent}{0 mm} \setlength{\parskip}{0.7\baselineskip} % create an indent command that does not rely on \parindent \renewcommand{\indent}{\hspace*{1em}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% syntax highlighting %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{listings} % syntax highlighting \usepackage{lstautogobble} % add-on for listings that auto-gobbles leading spaces in code % create the fonts for code highlighting \newcommand\codesize{\fontsize{11}{10}\selectfont} \newcommand{\codefont}{\ttfamily} % 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, although darker so that they are readable when printed on a black and white printer) \definecolor{KeywordColor}{rgb}{0.0,0,0.6} \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}, sensitive=false, comment=[l]{//}, morecomment=[s]{/*}{*/}, morestring=[b]', morestring=[b]" } \lstdefinelanguage{xml} { morestring=[b][\color{black}]", moredelim=[s][\color{KeywordColor}]{<}{>}, morecomment=[s]{<?}{?>}, morecomment=[s]{<!--}{-->}, commentstyle=\color{CommentColor}, stringstyle=\color{StringColor}, identifierstyle=\color{black}, alsoletter=-: } % create a new environment for source code blocks \lstnewenvironment{codeblock}[1][] { \lstset{ language=Java, upquote=true, autogobble=true, xleftmargin=1em, basicstyle=\color{black}\codefont\codesize, keywordstyle=\color{KeywordColor}\codefont\codesize, commentstyle=\color{CommentColor}\codefont\codesize, 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}[1]{% \lstset{% language={}, upquote=true, basicstyle=\color{black}\codefont\bfseries\codesize, keywordstyle=\color{black}\codefont\bfseries\codesize, stringstyle=\color{black}\codefont\bfseries\codesize, showstringspaces=false, showtabs=false }% \mbox{\lstinline!#1!}} % 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] \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] \makebox[\textwidth][c]{\includegraphics[scale=#1,draft=false]{#2}}% \vspace{-5pt} \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} } % command for figures that fit the page width \newcommand{\fittedfig}[1] { \begin{figure}[H] \begin{center} \resizebox{\textwidth}{!}{\includegraphics[draft=false]{#1}} \vspace{-25pt} \end{center} \end{figure} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% lists %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fix the extra spacing that itemize/enumerate has when you put have an blank % 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}} \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}[1]{\todo[color=red!60,inline,size=\large]{Incomplete: #1}} %\newcommand{\complete}{\todo[color=green!60,inline,size=\large]{Complete}} \newcommand{\complete}{{\color{green}\Checkmark}~} \newcommand{\incomplete}{{\color{red}\XSolidBrush}~} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% misc %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % a simpler way of getting a right arrow \newcommand{\ra}[0]{$\rightarrow$~} % a section header and counter for exercises \newcounter{ExerciseCounter} \newcommand{\exercise}[1]{% \stepcounter{ExerciseCounter}% \section{Exercise \arabic{ExerciseCounter}~--~#1} } % menus, key strokes, paths \usepackage[os=win]{menukeys} \renewmenumacro{\menu}[>]{roundedmenus} \renewmenumacro{\keys}[>]{roundedkeys} \renewmenumacro{\path}[>]{pathswithfolder} \changemenucolortheme{roundedmenus}{blacknwhite} \changemenucolortheme{pathswithfolder}{blacknwhite} \changemenucolortheme{roundedkeys}{blacknwhite}
\documentclass[a4paper, 11pt]{article} \RequirePackage[l2tabu, orthodox]{nag} \usepackage[a4paper, portrait, hmargin=20mm, vmargin=25mm]{geometry} \usepackage[bookmarks, colorlinks]{hyperref} \usepackage{paralist, float, tabularx, hhline, graphicx, xcolor, todonotes, bbding, hyperref, needspace, booktabs, changepage} \hypersetup{ citecolor=black, linkcolor=black, % don't need colored links urlcolor=blue!55!black % blue enough to see, but dark enough to print } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% fonts %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{fontspec} \setmainfont{Lora} \setsansfont{Roboto Condensed} \setmonofont[Scale=MatchLowercase]{Inconsolata} \usepackage{microtype} % general improvements to typography \usepackage{listings} % syntax highlighting \usepackage{lstautogobble} % add-on for listings that auto-gobbles leading spaces in code % make \emph do italics (just in case other environments change it) \renewcommand{\emph}[1]{\textit{#1}} % add a \strong command \newcommand{\strong}[1]{\textbf{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 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 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\textsf{\PaperCode~--~\PaperTitle}} \fancyhead[C]{} \fancyhead[R]{\footnotesize\textsf{\LabNum\LabTitle}} \fancyfoot[L]{} \fancyfoot[C]{\footnotesize\textsf{\thepage}} \fancyfoot[R]{} \setlength{\headheight}{14pt} \renewcommand{\footrulewidth}{0pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% general layout %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % relax the justification/hyphenation wrapping settings \pretolerance=200 \tolerance=500 \setlength{\emergencystretch}{1.5em} % try harder to avoid widows and orphans \clubpenalty=300 \widowpenalty=300 % kill the paragraph indenting \setlength{\parindent}{0 mm} \setlength{\parskip}{0.7\baselineskip} % create an indent command that does not rely on \parindent \renewcommand{\indent}{\hspace*{1em}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% syntax highlighting %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % create the fonts for code highlighting \newcommand\codesize{\fontsize{11}{10}\selectfont} \newcommand{\codefont}{\ttfamily} % 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, although darker so that they are readable when printed on a black and white printer) \definecolor{KeywordColor}{rgb}{0.0,0,0.6} \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}, sensitive=false, comment=[l]{//}, morecomment=[s]{/*}{*/}, morestring=[b]', morestring=[b]" } \lstdefinelanguage{xml} { morestring=[b][\color{black}]", moredelim=[s][\color{KeywordColor}]{<}{>}, morecomment=[s]{<?}{?>}, morecomment=[s]{<!--}{-->}, commentstyle=\color{CommentColor}, stringstyle=\color{StringColor}, identifierstyle=\color{black}, alsoletter=-: } % create a new environment for source code blocks \lstnewenvironment{codeblock}[1][] { \lstset{ language=Java, upquote=true, autogobble=true, xleftmargin=1em, basicstyle=\color{black}\codefont\codesize, keywordstyle=\color{KeywordColor}\codefont\codesize, commentstyle=\color{CommentColor}\codefont\codesize, 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}[1]{% \lstset{% language={}, upquote=true, basicstyle=\color{black}\codefont\bfseries\codesize, keywordstyle=\color{black}\codefont\bfseries\codesize, stringstyle=\color{black}\codefont\bfseries\codesize, showstringspaces=false, showtabs=false }% \mbox{\lstinline!#1!}} % 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] \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] \makebox[\textwidth][c]{\includegraphics[scale=#1,draft=false]{#2}}% \vspace{-5pt} \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} } % command for figures that fit the page width \newcommand{\fittedfig}[1] { \begin{figure}[H] \begin{center} \resizebox{\textwidth}{!}{\includegraphics[draft=false]{#1}} \vspace{-25pt} \end{center} \end{figure} } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% lists %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % fix the extra spacing that itemize/enumerate has when you put have an blank % 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}} \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}[1]{\todo[color=red!60,inline,size=\large]{Incomplete: #1}} %\newcommand{\complete}{\todo[color=green!60,inline,size=\large]{Complete}} \newcommand{\complete}{{\color{green}\Checkmark}~} \newcommand{\incomplete}{{\color{red}\XSolidBrush}~} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% misc %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % a simpler way of getting a right arrow \newcommand{\ra}[0]{$\rightarrow$~} % a section header and counter for exercises \newcounter{ExerciseCounter} \newcommand{\exercise}[1]{% \stepcounter{ExerciseCounter}% \section{Exercise \arabic{ExerciseCounter}~--~#1} } % menus, key strokes, paths \usepackage[os=win]{menukeys} \renewmenumacro{\menu}[>]{roundedmenus} \renewmenumacro{\keys}[>]{roundedkeys} \renewmenumacro{\path}[>]{pathswithfolder} \changemenucolortheme{roundedmenus}{blacknwhite} \changemenucolortheme{pathswithfolder}{blacknwhite} \changemenucolortheme{roundedkeys}{blacknwhite}
Show line notes below