Skip to content

Instantly share code, notes, and snippets.

@enricobacis
Last active November 24, 2021 21:51
Show Gist options
  • Save enricobacis/af2031ef6d3e9958b9e8eae5aa86f6c8 to your computer and use it in GitHub Desktop.
Save enricobacis/af2031ef6d3e9958b9e8eae5aa86f6c8 to your computer and use it in GitHub Desktop.
UniBG PhD Thesis Template (for enhanced version)
% This should produce something similar to what is shown in the DocX file at:
% https://aisberg.unibg.it/sr/docs/CollanaSAFD/CollanaDottorato_presentazione.html
\documentclass[12pt,a4paper,twoside,openright,oldfontcommands]{memoir}
% Set page dimension and line spacing.
\usepackage[top=2.5cm, bottom=2.0cm, left=2.0cm, right=2.0cm, a4paper]{geometry}
\linespread{1.5}
% Do not reset figures/tables counter per chapter
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
% Fix font sizes / spaces of titles and other elements.
\renewcommand*{\chapnumfont}{\Large\bfseries}
\renewcommand*{\chaptitlefont}{\Large\bfseries}
\setsecheadstyle{\large\bfseries}
\setsubsecheadstyle{\normalsize\bfseries}
\renewcommand{\chaptername}{{\Large\bfseries Chapter}}
\renewcommand{\afterchapternum}{.\space\space}
\setlength{\beforechapskip}{-2em}
\addtolength{\afterchapskip}{-1.5em}
\setlength{\parindent}{0pt}
\setaftersecskip{0.5em}
\setaftersubsecskip{0.5em}
% Fix footnotes
\setlength{\footmarkwidth}{0em}
\setlength{\footmarksep}{0em}
\setlength{\footnotesep}{1em}
\setlength{\footparindent}{0em}
% Punish offending text
\clubpenalty=10000
\widowpenalty=10000
\tolerance=999
% Hide warning for conflicting package
\usepackage{silence}
\WarningsOff[fmtcount]
% Import all packages
\usepackage{array}
\usepackage{caption}
\usepackage{cite}
\usepackage{color}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{makecell}
\usepackage[hyphens]{url}
\usepackage{xcolor}
\usepackage{xspace}
\usepackage[export]{adjustbox}
%packages to insert pseudocode
\usepackage[caption=false,font=small]{subfig}
\usepackage[normalem]{ulem}
\usepackage[breaklinks=true,colorlinks=true,linkcolor=black,urlcolor=black,citecolor=black,bookmarks=true,bookmarksopenlevel=2]{hyperref}
% Fix table of contents / list of figures / list of tables.
\addtodef*{\cftsectionfont}{}{\bfseries}
\addtodef*{\cftsubsectionfont}{}{\bfseries}
\addtodef*{\cftparagraphfont}{}{\bfseries}
\addtodef*{\cftsubparagraphfont}{}{\bfseries}
\addtodef*{\cftsectionpagefont}{}{\bfseries}
\addtodef*{\cftsubsectionpagefont}{}{\bfseries}
\addtodef*{\cftparagraphpagefont}{}{\bfseries}
\addtodef*{\cftsubparagraphpagefont}{}{\bfseries}
\renewcommand*{\cftchapterleader}{\normalfont\cftdotfill{\cftsectiondotsep}}
\maxsecnumdepth{subsection}
\maxtocdepth{subsection}
\renewcommand{\cftchapteraftersnum}{.}
\renewcommand{\cftfigureaftersnum}{:}
\renewcommand{\cfttableaftersnum}{:}
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
\renewcommand*{\cftchaptername}{Chapter\space}
\renewcommand*{\cftappendixname}{\hspace{1.5em}Appendix\space}
\renewcommand*\contentsname{{\Large \textit{Table of Contents}}}
\renewcommand*{\cftfigurename}{Figure \space}
\renewcommand{\listfigurename}{List of Figures}
\renewcommand*{\cfttablename}{Table \space}
\renewcommand{\listtablename}{List of Tables}
% Fix captions.
\captionsetup{font={bf,small}}
\captionsetup{labelfont={bf,small}}
% Fix footers / headers.
\nouppercaseheads
\createmark{chapter}{left}{nonumber}{}{}
\definecolor{light-gray}{gray}{0.5}
\makepagestyle{preintro}
\makeevenfoot{preintro}{}{}{}
\makeoddfoot{preintro}{}{}{}
\makeevenhead{preintro}{}{{\color{light-gray} Name Surname}}{}
%
\copypagestyle{intro}{preintro}
\makeoddhead{intro}{}{{\color{light-gray} Introduction}}{}
\makeevenfoot{intro}{}{{\color{light-gray} \thepage}}{}
\makeoddfoot{intro}{}{{\color{light-gray} \thepage}}{}
%
\copypagestyle{afterintro}{intro}
\makeoddhead{afterintro}{}{{\color{light-gray} \leftmark}}{}
%
\copypagestyle{appendices}{intro}
\makeoddhead{appendices}{}{{\color{light-gray} Appendices}}{}
%
\copypagestyle{conclusions}{intro}
\makeoddhead{conclusions}{}{{\color{light-gray} Conclusions}}{}
%
\renewcommand{\bibname}{References}
\createplainmark{bib}{left}{References}
\createplainmark{lof}{left}{List of Figures}
\createplainmark{lot}{left}{List of Tables}
% Use Times New Roman.
\usepackage{newtxtext,newtxmath}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% Fix page styles and numbering.
\makeevenfoot{plain}{}{{\color{light-gray} \thepage}}{}
\makeoddfoot{plain}{}{{\color{light-gray} \thepage}}{}
\makeevenfoot{empty}{}{}{}
\makeoddfoot{empty}{}{}{}
\aliaspagestyle{cleared}{empty}
\pagenumbering{gobble}
% ------------------ ACKNOWLEDGMENTS ---------------- %
\pagestyle{empty}
% Acknowledgements has to be in a different style.
\section*{{\normalsize \textit{Acknowledgments}}}
\label{chap:acknowledgments}
\input{chapters/acknowledgments}
\cleardoublepage
% -------------------- DEDICATION ------------------- %
\pagestyle{empty}
\input{dedication}
\cleardoublepage
% --------------- TABLE OF CONTENTS --------------- %
\pagestyle{preintro}
% The asterisk prevents these from showing up in the ToC
\tableofcontents*
\cleardoublepage
% -------------------- CONTENTS ------------------- %
\pagenumbering{arabic}
\setcounter{page}{1}
\pagestyle{intro}
\chapter*{Introduction}
\label{chap:intro}
\addcontentsline{toc}{chapter}{Introduction}
\input{chapters/intro}
\chapter[shortname for ToC]{Long Name Chapter 1}
\label{chap:chapter1}
\pagestyle{afterintro}
\input{chapters/chapter1}
%% ... and so on ... %%
\chapter*{Conclusions}
\pagestyle{conclusions}
\label{chap:conclusions}
\addcontentsline{toc}{chapter}{Conclusions}
\input{chapters/conclusions}
\cleardoublepage
% -------------------- APPENDIX ------------------- %
% Fix style in appendices.
\thispagestyle{empty}
\addcontentsline{toc}{chapter}{Appendices}
\renewcommand*{\thechapter}{\arabic{chapter}}
\renewcommand{\appendixname}{{\Large\bfseries Appendix}}
\renewcommand*{\chapnumfont}{\Large\bfseries}
\renewcommand*{\chaptitlefont}{\large\bfseries}
\renewcommand{\afterchapternum}{\\\medskip}
% Add Appendices page.
\vspace*{\stretch{1}}
\begin{center}
\bfseries
\Large
Appendices
\end{center}
\vspace{\stretch{2}}
\cleardoublepage
\appendix
\pagestyle{appendices}
\addtocontents{toc}{\protect\vskip -1em}
\input{chapters/appendix1}
% ... and so on ... %
\cleardoublepage
% --------------------- LISTS -------------------- %
\pagestyle{afterintro}
\listoffigures*
\addcontentsline{toc}{chapter}{List of Figures}
\cleardoublepage
\listoftables*
\addcontentsline{toc}{chapter}{List of Tables}
\cleardoublepage
% ------------------ BIBLIOGRAPHY ----------------- %
\pagestyle{afterintro}
\bibliography{chapters/chapter1/biblio, chapters/chapter2/biblio}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment