After four years of experimental design, data acquisition and analysis I just finished putting together everything into my PhD thesis. I did not find any templates that really worked for me (although classicthesis looks quite nice), so I put together my own set of random LaTex commands. I’m not a graphics designer but I’m quite happy with the end results – so here are the choices I made and the corresponding LaTex code.
Let’s go!
General setup
I used the memoir class, which gives easier control over page styles, and easily toggles between one- and two-sided print (which I needed for specific graduate school requirements).
\documentclass[10pt,oneside]{memoir} % give the inner margin a bit more space for binding into a book % \usepackage[top=2.4cm, bottom=2.4cm, left=2.9cm, right=1.9cm,marginparwidth=0cm]{geometry} % for an on-screen pdf, set all to 2.4 \usepackage[margin=2.4cm,marginparwidth=0cm]{geometry} \usepackage{titlesec} \pagenumbering{gobble} % dont start page numbering until I say so \usepackage{multicol} % for bibliography \counterwithout{figure}{chapter} % dont number figures across chapters \counterwithin*{equation}{section} % dont number across chapters \usepackage{textcomp} \raggedbottom % dont force the same page length by increasing space between paragraphs % items table of contents not bold \renewcommand*{\cftchapterfont}{\normalfont} % titles not bold % caption will take over, even in memoir class \usepackage[font=small,labelsep=period,labelfont=bf]{caption} % Figure 1. instead of Fig 1. \makeatletter \renewcommand{\fnum@figure}{Figure \thefigure} \makeatother % make sure each chapter is on the right hand side, and has an empty page before - only matters in twosided print \renewcommand{\clearforchapter}{\clearpage~\thispagestyle{cleared}\cleartorecto}
Footnotes without numbering
I wanted to indicate contributions as a footnote, but without referring to this in the text. If you put this in your preamle,
% footnotes https://tex.stackexchange.com/questions/30720/footnote-without-a-marker \newcommand\blfootnote[1]{% \begingroup \renewcommand\thefootnote{}\footnote{#1}% \addtocounter{footnote}{-1}% \endgroup }
then
\blfootnote{This chapter was reprinted under a CC-BY 4.0 license. doi: 10.1038/ncomms14637. \fauxsc{Author contributions:} Conceptualization, A.E.U. and T.H.D.; Investigation, A.E.U.; Formal Analysis, A.E.U. and A.B.; Software, data curation and visualization, A.E.U.; Writing, A.E.U. and T.H.D.; Supervision, T.H.D.}
will result in
Epigraphs
At the start of some chapters, I included quotes which are called epigraphs. This preamble
\usepackage{epigraph} \setlength\epigraphwidth{1\textwidth} \setlength\epigraphrule{0pt} % no line between \setlength\beforeepigraphskip{1\baselineskip} % space before and after epigraph \setlength\afterepigraphskip{2\baselineskip} \renewcommand*{\textflush}{flushright} \renewcommand*{\epigraphsize}{\normalsize\itshape}
with this code
\epigraph{Was there ever in anyone's life span a point free in time, devoid of memory, a night when choice \\was any more than the sum of all the choices gone before? \\ --- \fauxsc{Joan Didion}\small\textup{, Run, River}}
will result in
Graphics and equations
For math I used the Euler math font, which looks like this.
I chose the Avenir font for the rest of the thesis.
\usepackage{graphicx} \usepackage{amsmath} \usepackage{euler} % beautiful math font % Avenir looks great, have to compile using LuaLatex or XeLaTex \usepackage{fontspec} \setmainfont{Avenir} % Also nice: Minion Pro, Open Sans \linespread{1.5} \usepackage{polyglossia} % to create german environments within LuaLaTex (umlauts etc) \setdefaultlanguage{english} \setotherlanguage{german}
Small caps
I am a great fan of the Avenir font, which did not produce small caps using the normal \textsc command. This bit of code fakes small caps (see the epigraph example for an idea of how this looks).
% https://tex.stackexchange.com/questions/55664/fake-small-caps-with-xetex-fontspec \makeatletter \newlength\fake@f \newlength\fake@c \def\fakesc#1{% \begingroup% \xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}% \fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont% \uppercase{#1}% \endgroup% } \makeatother \newcommand\fauxsc[1]{\fauxschelper#1 \relax\relax} \def\fauxschelper#1 #2\relax{% \fauxschelphelp#1\relax\relax% \if\relax#2\relax\else\ \fauxschelper#2\relax\fi% } \def\Hscale{.83}\def\Vscale{.72}\def\Cscale{1.00} \def\fauxschelphelp#1#2\relax{% \ifnum`#1>``\ifnum`#1<`\{\scalebox{\Hscale}[\Vscale]{\uppercase{#1}}\else% \scalebox{\Cscale}[1]{#1}\fi\else\scalebox{\Cscale}[1]{#1}\fi% \ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}
Table environment
I define a column type environment for my CV, with a separator line between dates on the left and items on the right.
\usepackage{array, xcolor} \definecolor{lightgray}{gray}{0.8} \newcolumntype{L}{>{\raggedleft}p{0.16\textwidth}} \newcolumntype{R}{p{0.8\textwidth}} \newcommand\VRule{\color{gray}\vrule width 0.5pt}
Then e.g. this
\begin{tabular}{L!{\VRule}R} 2013 - 2018&\textbf{PhD}\\ &{Department of Neurophysiology and Pathophysiology, UKE}\\ \end{tabular}
produces the layout you can see here.
Citations and bibliography using BibLaTex
The settings below mimic the style used by The Journal of Neuroscience. See also below for specific commands that apply only to the bibliography section.
% https://tex.stackexchange.com/questions/12806/guidelines-for-customizing-biblatex-styles \PassOptionsToPackage{% backend=biber, %instead of bibtex, for own publications list style=authoryear-comp, % Author 1999, 2010 maxcitenames=2,maxbibnames=4, % when does the citation change to et al? uniquelist=false,uniquename=false, firstinits=true, % author initials in list doi=false,isbn=false,url=false,dashed=false, terseinits=true, % no points between initials sortcites=true, sorting=ynt,language=english, }{biblatex} \usepackage{biblatex} \renewbibmacro{in:}{} % no more "In:" for articles \DeclareNameAlias{sortname}{last-first} \DeclareNameAlias{default}{last-first} \AtEveryBibitem{% \clearlist{language} % don't show "en." \clearlist{extra} % clears extra fields such as ISBN nrs } % no comma between last name and initials \renewcommand*{\revsdnamepunct}{} \renewcommand*{\bibfont}{\small} % bibliography in smaller font %-- no "quotes" around titles of chapters/article titles \DeclareFieldFormat[article, inbook, incollection, inproceedings, misc, thesis, unpublished]{title}{#1} %-- no punctuation after volume \DeclareFieldFormat[article]{volume}{{#1}} %-- puts number/issue between brackets \DeclareFieldFormat[article, inbook, incollection, inproceedings, misc, thesis, unpublished]{number}{\mkbibparens{#1}} %-- and then for articles directly the pages w/o any "pages" or "pp." \DeclareFieldFormat[article]{pages}{#1} %-- format 16(4):224--225 for articles \renewbibmacro*{volume+number+eid}{\printfield{volume}\printfield{number}\printunit{\addcolon} } % link to the bib file, which I exported from Zotero usign the BetterBibtex package \addbibresource{/Users/anne/Dropbox/MyLibrary.bib}
When reading from screen, turn references (both to citations and labeled figures) grey to indicate that they work as hyperlinks within the document.
% make citations hyperlinks, grey \usepackage{hyperref} \hypersetup{colorlinks,breaklinks, citecolor=[rgb]{0.3,0.3,0.3}, linkcolor=[rgb]{0.3,0.3,0.3}, filecolor=[rgb]{0.3,0.3,0.3}, urlcolor=[rgb]{0.3,0.3,0.3}} % hyperlink for \citeauthor as well \DeclareCiteCommand{\citeauthor} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\ifciteindex {\indexnames{labelname}} {}% \printtext[bibhyperref]{\printnames{labelname}}} {\multicitedelim} {\usebibmacro{postnote}} % https://tex.stackexchange.com/questions/27607/biblatex-authoryear-comp-and-hyperlinks % make full author-year into hyperlinks, will be colored grey \makeatletter \let\abx@macro@citeOrig\abx@macro@cite \renewbibmacro{cite}{% \bibhyperref{% \let\bibhyperref\relax\relax% \abx@macro@citeOrig% }% } \let\abx@macro@textciteOrig\abx@macro@textcite \renewbibmacro{textcite}{% \bibhyperref{% \let\bibhyperref\relax\relax% \abx@macro@textciteOrig% }% }% \makeatother
This makes citations look like:
See further below for separate commands to format the bibliography section.
This was the preamble, now begin the document itself.
Title page and Table of Contents
\begin{document} % title page \include{chapters/TitlePage} \cleardoublepage % TOC IN BLACK RATHER THAN GRAY % https://tex.stackexchange.com/questions/306613/how-to-change-the-color-of-only-table-of-contents-from-red-to-black { \hypersetup{linkcolor=black} \tableofcontents* }
Once the document has started, define the page style using memoir (not sure if this works equally well in the preabmle). See this documentation by Lars Madsen for the ins and outs of page styles in memoir.
% define my own header style - not bold, small caps % for oneside https://groups.google.com/forum/#!topic/comp.text.tex/RSRcSgnqQWk \aliaspagestyle{chapter}{empty} % no page numbers on the chapter title page \pagestyle{companion} \setlength{\headwidth}{\textwidth} % make sure the companion header extends as far as the text, looks weird otherwise % only print chapter name on the right side of the document! \makeevenhead{companion}{\small\thepage}{}{} \makeoddhead{companion}{\bfseries\rightmark}{}{\small\thepage} \pagenumbering{arabic} % start page numbers here
This creates headers as follows:
Where instead of letting LaTex handle the chapter numbering, I hardcode this manually. \chapter* generates an unnumbered chapter, which by default does not show up in the chaptermark (in the header at the top of the page) or in the TOC, so I do this manually. I liked the vertical line as a separator, which just touches the horizontal line underneath the header.
\chapter*{2.1 $\bigm|$ Pupil-linked arousal is driven by decision uncertainty and alters serial choice bias} \chaptermark{2.1 $\bigm|$ Pupil-linked arousal is driven by decision uncertainty and alters serial choice bias} \addcontentsline{toc}{chapter}{2.1 $\bigm|$ Pupil-linked arousal is driven by decision uncertainty and alters serial choice bias} <span style="font-family: Consolas, Monaco, monospace;">
Chapter specifics
Each chapter went into its own .tex file in the chapters folder, which helped a lot in keeping the overview. In my case:
\include{chapters/Introduction} \include{chapters/2017_NatComm} .... \include{chapters/Discussion}
For each chapter, I made sure I included this to ensure that numbering of figures and equations did not continue (probably possible to do in the preamble but didn’t get that to work).
\setcounter{equation}{0} \setcounter{figure}{0}
Moreover, for including supplementary figures at the end of each chapter file I did
\clearpage \section*{Supplementary Figures} \renewcommand{\thefigure}{S\arabic{figure}} \setcounter{figure}{0} % add all the supplementary figures % Set back to normal figure numbering for the next chapter \renewcommand{\thefigure}{\arabic{figure}}
which will look like this (with both the main and supplementary figure as clickable hyperlinks in grey):
After all chapters, I inserted the bibliography with slightly different formatting rules than the in-text citations, and changed the size and spacing.
% https://tex.stackexchange.com/questions/244971/biblatex-order-of-entries-in-a-multi-citation \chapter*{5 $\bigm|$ Bibliography} \addcontentsline{toc}{chapter}{5 $\bigm|$ Bibliography} \chaptermark{5 $\bigm|$ Bibliography} \begin{multicols}{2}% two columns \begin{refcontext}[sorting=nyt] % make sure that bibliography is sorted by last name, year, title \renewcommand*{\bibfont}{\small\raggedright} % remove 'and' between 2nd to last and last author in bibliography \renewcommand*{\finalnamedelim}{\addcomma\addspace}% \linespread{1.3}\selectfont \printbibliography[heading=none] \end{refcontext} \end{multicols}
which looked like
Add some final pages at the end. That’s it!
% backmatter \include{chapters/Acknowledgements} \include{chapters/CV} \include{chapters/Declaration} \end{document}
That’s it!
You can download the full master tex document, and the first chapter (which is a reprint of this article). Because WordPress does not allow uploading of .tex files, I changed the extension to .odt – make sure to change back to .tex before opening. Note that I converted the chapter file from Word using Pandoc, so the equation syntax is a bit messier than necessary.
Also, here is a pdf of one thesis chapter to see what the total looks like. I’ll post the whole document after I’ve defended it!
Please note:
- I use TexShop 3.88 on Mac OS X.
- Compile using LuaLaTex or XeLaTex (both work afaik), then using BibTex, and again using LuaLaTex/XeLaTex. Some changes (e.g. to hyperlinks and page headers) may only show up after several consecutive compilations.
- I tried to copy the links to source code into comments. If I forgot somewhere, and you’d like me to add, please let me know in a comment.
- I’m not a LaTex expert – if you’re stuck, please try these tried-and-tested methods:
Wow super nice! I might need this in a few months. Thanks for sharing and good luck with your defense!
I need your code, please
You can download the style file and an example chapter, see the links in the final paragraph before ‘please note’. Good luck!
Liebe Dr. Urai, I used this code as a starting point to format my thesis (submitted ~a month ago). This was super helpful-so thank you!
Hi Anne – Excellent post! Thank you for your detailed explanation of the various lines.
Did you have a terms glossary or acronym in your thesis? If so what is the code you used for that? I’m using glossaries with the glossaries-extra package and have a very large (~2.5″) gap between the top of the page and the glossary title.
Thanks again!