summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hepthesis
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/hepthesis
Initial commit
Diffstat (limited to 'macros/latex/contrib/hepthesis')
-rw-r--r--macros/latex/contrib/hepthesis/ChangeLog309
-rw-r--r--macros/latex/contrib/hepthesis/Makefile36
-rw-r--r--macros/latex/contrib/hepthesis/README20
-rw-r--r--macros/latex/contrib/hepthesis/TODO72
-rw-r--r--macros/latex/contrib/hepthesis/example/Makefile17
-rw-r--r--macros/latex/contrib/hepthesis/example/appendices.tex28
-rw-r--r--macros/latex/contrib/hepthesis/example/backmatter.tex19
-rw-r--r--macros/latex/contrib/hepthesis/example/chap1.tex48
-rw-r--r--macros/latex/contrib/hepthesis/example/chap2.tex92
-rw-r--r--macros/latex/contrib/hepthesis/example/chap3.tex38
-rw-r--r--macros/latex/contrib/hepthesis/example/ckmfitter-alpha-combined.pdfbin0 -> 17855 bytes
-rw-r--r--macros/latex/contrib/hepthesis/example/example.pdfbin0 -> 380172 bytes
-rw-r--r--macros/latex/contrib/hepthesis/example/example.tex73
-rw-r--r--macros/latex/contrib/hepthesis/example/frontmatter.tex55
-rwxr-xr-xmacros/latex/contrib/hepthesis/example/getNewBibtex16
-rw-r--r--macros/latex/contrib/hepthesis/example/h-physrev.bst949
-rw-r--r--macros/latex/contrib/hepthesis/example/lhcb-detector-cross-section.pdfbin0 -> 191957 bytes
-rw-r--r--macros/latex/contrib/hepthesis/example/mwe.tex13
-rw-r--r--macros/latex/contrib/hepthesis/example/mythesis.bib51
-rw-r--r--macros/latex/contrib/hepthesis/example/mythesismath.sty69
-rw-r--r--macros/latex/contrib/hepthesis/example/preamble.tex70
-rw-r--r--macros/latex/contrib/hepthesis/hepthesis.cls903
-rw-r--r--macros/latex/contrib/hepthesis/hepthesis.pdfbin0 -> 217653 bytes
-rw-r--r--macros/latex/contrib/hepthesis/hepthesis.tex897
24 files changed, 3775 insertions, 0 deletions
diff --git a/macros/latex/contrib/hepthesis/ChangeLog b/macros/latex/contrib/hepthesis/ChangeLog
new file mode 100644
index 0000000000..49b10cde8b
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/ChangeLog
@@ -0,0 +1,309 @@
+2017-12-11 Andy Buckley <andy.buckley@cern.ch>
+
+ * 1.5.2 release.
+
+ * Fix accidental 12pt override of user-specified font-size options.
+
+2017-09-20 Andy Buckley <andy.buckley@cern.ch>
+
+ * 1.5.1 release.
+
+ * Disable deprecated \thesis... commands -- as promised for 1.5.0!
+
+ * Change hepthesis.tex class to basic article, since fancyvrb
+ still generates \tt macros and scrartcl bans them.
+
+ * Replace \sf -> \sffamily and \bf -> \bfseries for proper
+ NFSS/modern LaTeX compatibility. Thanks to William Fawcett for
+ highlighting the problem.
+
+ * Fix a typo (extra 'g') in the \setfrontmatterextramargins
+ command definition. Thanks to Clement Dallard.
+
+2014-12-02 Andy Buckley <andy.buckley@cern.ch>
+
+ * 1.5.0 release.
+
+ * Minor tweaks to Makefile, adding a \thispagestyle{empty} tweak to the example, bump version date.
+
+2014-08-27 Andy Buckley <andy.buckley@cern.ch>
+
+ * Changing example doc font, and removing mythesis.sty/cls files
+ in favour of a preamble.tex
+
+ * Tweaking use of frontmatter, mainmatter, backmatter
+ etc. environments and using afterpage to ensure that page
+ numbering and header styling works more consistently. Apologies
+ that this took so long,
+ cf. http://tex.stackexchange.com/questions/170231/page-numbering-transition-from-frontmatter-to-mainmatter-going-wrong/
+
+2012-08-02 Andy Buckley <andy.buckley@cern.ch>
+
+ * Make \frontquote/\pagequote set the "empty" page style, and
+ minor updates in the example document, including forcing the first
+ page of the first main chapter to be page 1, via judicious use of
+ \pagenumbering{arabic}.
+
+ * Remove dependence on siunitx in the example -- this needs to be
+ sorted out properly in hepunits.
+
+2011-01-01 Andy Buckley <andy@insectnation.org>
+
+ * Fix too-early page numbering: thanks to Steven te Brinke.
+
+2010-05-27 Andy Buckley <andy@insectnation.org>
+
+ * 1.4.3 release.
+
+ * Upgrading to use changepage in place of deprecated chngpage
+ package, and a few other fixes. Also tidying some of the example
+ document, improving the example makefile, and demonstrating
+ sub-figure references with continued captions. Thanks to Ben Wynne
+ for the heads-up.
+
+2009-02-12 Andy Buckley <andy@insectnation.org>
+
+ * Fixed Makefile to put all the relevant files from example into
+ the tarball.
+
+2008-07-10 Andy Buckley <andy@insectnation.org>
+
+ * Ready for *real* 1.4.2 release (more than a month after the
+ first attempt!)
+
+ * Added lots of TODOs and merges for the next version; removed
+ mention in the manual of "cite" as a mandatory package.
+
+2008-07-03 Andy Buckley <andy@insectnation.org>
+
+ * Recursive make is used (warnings about incomplete DAGs be
+ damned) and SCons has been ditched for now.
+
+ * Bundled style files are now hidden by a zip file rather than the
+ weirdo "*.hidden" renaming thing.
+
+2008-05-23 Andy Buckley <andy@insectnation.org>
+
+ * Hiding style files bundled with the example, since they can get
+ accidentally picked up in recursive kpathsea lookups if *TEXINPUTS
+ is set that way.
+
+ * Fixes to makefile etc. SConstruct now works for building LaTeX
+ documents... use it for building future versions.
+
+2007-12-05 Andy Buckley <andy@insectnation.org>
+
+ * Fixed serif headers --- the sfheaders package is no longer
+ needed, since sfheaders are the default in scrbook.
+
+2007-09-12 Andy Buckley <andy@insectnation.org>
+
+ * Updated documentation about changed mandatory packages, some
+ package clashes, and improved example formatting with framed
+ boxes.
+
+ * Added a couple of required earliest release dates to the
+ \RequirePackage lines.
+
+ * Added subfig/continued caption example chapter to the example
+ thesis.
+
+ * Removed subfig reqirement.
+
+2007-07-03 Andy Buckley <andy@insectnation.org>
+
+ * Added command arguments etc. to the documentation.
+
+ * Improved dedication command alignment as for \pagequote.
+
+2007-07-02 Andy Buckley <andy@insectnation.org>
+
+ * Removed "Appendix" label from the colophon page (copied from the
+ book class thebibliography environment).
+
+2007-06-30 Andy Buckley <andy@insectnation.org>
+
+ * Improved the positioning of the \pagequote using the varwidth
+ package - getting csquotes to work with the likes of fancybox was
+ a nightmare.
+
+ * Sorted out some extra \cleardoublepage effects that resulted
+ from re-using the frontmatter and mainmatter definitions.
+
+2007-06-28 Andy Buckley <andy@insectnation.org>
+
+ * Improved the horizonal and vertical centering of the page quote.
+
+ * Restricted the width of the document in the page and chapter
+ quotes.
+
+ * The front quote is now implemented with the name \pagequote and
+ \frontquote is an alias via \let. This is just to give a better
+ name, should someone decide to use it somewhere other than at the
+ front (not that I'm recommending that!)
+
+ * Added 1.5 cm to each margin in the abstract and declaration
+ pages - I think this looks better since they are likely to be
+ short sections.
+
+ * Added the chngpage mechanism for adding extra margin widths on
+ section by section bases.
+
+2007-06-27 Andy Buckley <andy@insectnation.org>
+
+ * Added the \set...spacing commands and the variables that they influence.
+
+2007-06-25 Andy Buckley <andy@insectnation.org>
+
+ * Added optional language argument to \frontquote and \chapterquote. These
+ use the csquotes commands \enquote and \foreignquote if csquotes is loaded.
+
+2007-06-11 Andy Buckley <andy@insectnation.org>
+
+ * Added definite v1.5 to \thesis... command deprecation notices.
+
+ * Tidied up, and removed a few obsolete references to
+ \thesis... commands in the user guide.
+
+2007-06-10 Andy Buckley <andy@insectnation.org>
+
+ * Added the "plainpages=false" fix to hyperref package loading to
+ stop the pdfTeX "destination with the same identifier" warning.
+
+ * Incorporated a variety of improvements from Albert Neumüller:
+ + Babel integration and \enquote
+ + Using subfig rather than subfigure
+ + Introduced penalties to stop enumeration breaking across pages
+ + Using KOMA-script base classes to fix some errors with onepage mode
+ + Avoiding fancyhdr warnings in onepage mode.
+
+ * Fix to make sfheaders.sty only be loaded if the sftitles option
+ is in force. Thanks to Stuart Cook for the bug report and fix.
+
+2006-09-28 Andy Buckley <andy@insectnation.org>
+
+ * Updated date to today, ready for release 1.3.
+
+2006-09-25 Andy Buckley <andy@insectnation.org>
+
+ * Updated example document to demonstrate the bold math in titles
+ and sans-serif titles.
+
+2006-09-21 Andy Buckley <andy@insectnation.org>
+
+ * Made frontmatter centered titles have \LARGE size rather than
+ \Large.
+
+ * Added \boldmath to the definition of \bfseries so that maths in
+ titles etc. will automatically go bold. Thanks to Donald Arsenau
+ for supplying this neat trick!
+
+2006-09-18 Andy Buckley <andy@insectnation.org>
+
+ * Fixed a bug in the definition of \definethesis (argument #2 was
+ never used).
+
+ * Added sftitles option, using the sfheaders package and some
+ changes to the hepthesis-specific sectioning commands. Updated
+ documentation to reflect this.
+
+2006-06-12 Andy Buckley <andy@insectnation.org>
+
+ * Updated the documentation to reflect the recent changes.
+
+ * Removed some lingering \thesis-prefixed commands from the
+ examples.
+
+ * Aliased \maketitle to \titlepage{} (see below).
+
+ * Changed behaviour of \titlepage slightly: the first argument
+ will no longer be presented prefixed with "of" (so you should
+ include "of\\ " in the argument if you want the original,
+ non-internationalised behaviour). Also, the first argument is now
+ optional, so should be wrapped with square brackets rather than
+ curly braces. \thesistitlepage has been similarly updated.
+
+ * Deprecated \definethesis command: it is now just a thin wrapper
+ for \title and \author.
+
+ * Added titling option to use the titling package if
+ available. Otherwise, redefine \title and \author to save their
+ arguments in \thetitle and \theauthor, as well as in \@title,
+ \@author, so that they are available in the document body, in
+ particular for building the title page.
+
+2006-06-06 Andy Buckley <andy@insectnation.org>
+
+ * Prompted by a request from Claudia Strabel, the table, figure,
+ figure* and sidewaysfigure environments now use standard [!htbp]
+ placement specifiers.
+
+2006-02-23 Andy Buckley <andy@insectnation.org>
+
+ * Ready for version 1.2 release (no changes since 2006-01-26 and
+ no reported bugs from beta testing)
+
+2006-01-26 Andy Buckley <andy@insectnation.org>
+
+ * Added appendices and colophon environments and updated the
+ manual and example accordingly.
+
+ * Changed mainmatter environment to a special comment so that it
+ doesn't remove the section numbering until the backmatter starts:
+ I don't understand what it is about \renewenvironment that was
+ doing this.
+
+ * Fixed typo in backmatter definition which made it treat the
+ backmatter as mainmatter.
+
+2005-12-13 Andy Buckley <andy@insectnation.org>
+
+ * Removed pdfpagemode=FullScreen option from hyperref. Maybe
+ re-introduce this sort of thing via an option.
+
+2005-12-09 Andy Buckley <andy@insectnation.org>
+
+ * Fixed typo ("latex" -> "pdflatex") in the documentation of how
+ to use a Makefile to ease the PS/PDF conditional compilation
+ issues.
+
+ * Moved frontquote text up by 1.5 cm to balance the page a bit
+ better. This is still quite A4-specific: maybe this should be
+ specified in terms of \textheight?
+
+ * Added dedication page command and added some \cleardoublepage
+ and page style commands to the quote page command to ensure that
+ it doesn't overlap with the contents pages.
+
+2005-11-01 Andy Buckley <andy@insectnation.org>
+
+ * Hacked the example files into much better shape and updated the
+ documentation to mention the new features and the pre-defined figure widths.
+
+ * Added the "deprecated" typeout into the thesis-prefixed commands
+ and environments.
+
+ * Added a sidewaysfigure environment, which introduces a
+ dependency on the rotating package. It's very standard, so I'm not
+ bothered. Maybe add an option to disable the rotating dependency later...
+
+ * Added the hide{front,back,frontback} options.
+
+2005-09-26 Andy Buckley <andy@insectnation.org>
+
+ * Finished off the first version of the documentation. Example
+ files could do with some work which I'm too lazy to do right now
+ :-)
+
+ * Added the \Chapter, \ChapterRef etc. commands from a personal
+ style file.
+
+2005-09-02 Andy Buckley <andy@insectnation.org>
+
+ * Changed \oddsidemargin and \evensidemargin settings to use the
+ \@bindextramargin length.
+
+ * Added bindnopdf option.
+
+ * Started ChangeLog entries. Oops, I should have started a bit
+ earlier, eh?
diff --git a/macros/latex/contrib/hepthesis/Makefile b/macros/latex/contrib/hepthesis/Makefile
new file mode 100644
index 0000000000..68039accc1
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/Makefile
@@ -0,0 +1,36 @@
+HT := hepthesis
+.PHONY: all clean check
+
+all: $(HT).zip
+ @true
+
+$(HT).zip: README ChangeLog $(HT).pdf example/example.pdf
+ @rm -rf $(HT)
+ @mkdir $(HT)
+ @cp README TODO ChangeLog Makefile $(HT).pdf $(HT).cls $(HT).tex $(HT)/
+ @mkdir $(HT)/example
+ @cp example/*.pdf example/*.tex example/extrastyles.zip example/Makefile $(HT)/example/
+ @cp example/getNewBibtex example/h-physrev.bst $(HT)/example/
+ @cp example/mythesis.bib example/preamble.tex example/mythesismath.sty $(HT)/example/
+ zip -r $@ $(HT)
+ @rm -rf $(HT)
+
+$(HT).pdf: $(HT).tex example/example.pdf
+ (rm -f $(HT).{aux,toc,lof,lot} && pdflatex $(HT).tex && pdflatex $(HT).tex && rm -f $(HT).{aux,toc,lof,lot})
+
+example/example.pdf: force_look
+ cd example && $(MAKE) $(MFLAGS)
+
+clean:
+ @rm -rf $(HT)
+ @rm -f $(HT).zip
+ @rm -f $(HT).pdf $(HT).log $(HT).aux $(HT).out $(HT).dvi comment.cut
+ cd example && $(MAKE) $(MFLAGS) clean
+
+check: $(HT).zip
+ @rm -rf $(HT)
+ @unzip $(HT).zip
+ (cd $(HT) && make $(HT).pdf && make example/example.pdf)
+
+force_look:
+ @true
diff --git a/macros/latex/contrib/hepthesis/README b/macros/latex/contrib/hepthesis/README
new file mode 100644
index 0000000000..23c56dba62
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/README
@@ -0,0 +1,20 @@
+hepthesis LaTeX class, by Andy Buckley <andy@insectnation.org>
+--------------------------------------------------------------
+
+hepthesis is a LaTeX class for typesetting large academic reports,
+in particular PhD theses. It was originally developed for typesetting
+a high-energy physics PhD thesis and includes some features
+specifically tailored to that application.
+
+The basic usage is to place
+\documentclass{hepthesis}
+in the preamble of your document. If you're feeling sophisticated,
+then you can make your own document class based on hepthesis by placing
+\LoadClass{hepthesis}
+in your own class definition file.
+
+Please see hepthesis.pdf for detailed documentation. And have fun :-)
+
+This material is subject to the LaTeX Project Public License.
+See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for
+the details of that license.
diff --git a/macros/latex/contrib/hepthesis/TODO b/macros/latex/contrib/hepthesis/TODO
new file mode 100644
index 0000000000..66cf31a81a
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/TODO
@@ -0,0 +1,72 @@
+TODO list for hepthesis
+-----------------------
+
+* Provide a theme system, with sfheaders, serif headers, palatino+pazo
+ and "HH" as bundled styles
+* Eliminate extra blank page after appendix / before colophon.
+* Make better use of KOMA-Script functionality
+* Provide control options for caption formatting.
+* Integrated loading of csquotes and babel?
+* Multilingual titles etc.
+* Provide an option for centre/right-justifying section titles?
+* Documentation/install in DTX/INS format
+* Use @ifstar:
+\newcommand{\mycommand}{\@ifstar
+ \mycommandStar%
+ \mycommandNoStar%
+}
+\newcommand{\mycommandStar}[2]{starred version}
+\newcommand{\mycommandNoStar}[1]{normal version}
+
+Use microtype package if in pdflatex
+
+Import elements of Hendrik Hoeth's excellent thesis style.
+
+From Flip Tanedo:
+"""
+Hi Andy -- another question (sorry I have so many). I've been using hepthesis to tex up lecture notes since it provides a really nice framework for this. The one thing I've been having trouble doing, however, is writing notes in the margin. I've been trying to use the \marginpar command to jot down comments, but have had difficulty finding enough margin space.
+
+The hepthesis command \setmainmatterextramargins{1cm} doesn't quite help since (1) it trims off of both left and right margins (not just "opposite page binding") and (2) it doesn't actually increase the amount of space that \marginpar can occupy.
+
+I've had some success by doing the following in the preamble:
+ \addtolength{\evensidemargin}{1in}
+ \addtolength{\textwidth}{-1in}
+
+This seems to increase the margin on the side of the page opposite the binding.
+
+However, this affects the entire document, including the title page, front matter, back matter, etc. Is there a way to apply the above spacing only to the main matter?
+"""
+
+Merge David Cottenden's contributions: hepthesis.cls.cottenden
+
+From Manuel Bahr:
+\@ifpackageloaded{hyperref}{%
+ \usepackage[numbers,sort&compress]{natbib}
+ \usepackage{hypernat}
+}{%
+ \usepackage{cite}
+}
+
+
+From giuseppe.passino@elec.qmul.ac.uk:
+
+I'm actually using kile on linux, and I'm keen on the error window facility of clicking on an error and being redirected to the error line, as well as the backward referencing facility by which you can insert source information in the dvi file and be redirected to the correspondent line in the tex file when clicking in the dvi.
+
+Unfortunately, all this cool stuff with hepthesis does not work, since the comment.sty style is used, that wraps the source into a temporary comment.cut file that spoils everything. This is because you define mainmatter etc. as specialcomment. I changed them into \renewcommand, and this problem disappeared. I was anyway curious to know why you went for the comment style instead of a simpler \renewcommand. Hence this email. Additionally, maybe the problem I described above is a reason good enough for you to change the definition of mainmatter end friends..
+
+Just to give you an example, this is the new mainmatter:
+
+\let\@oldmainmatter\mainmatter
+\def\BeginMainMatter{%
+ %\@oldmainmatter%
+ \@mainmattertrue
+ \pagenumbering{arabic}%
+ \adjustwidth[]{\@mainmatterextramargin}{\@mainmatterextramargin}%
+ \begin{\@mainmatterspacing}%
+}
+\def\EndMainMatter{%
+ \end{\@mainmatterspacing}%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+\renewenvironment{mainmatter}{\BeginMainMatter}{\EndMainMatter}
diff --git a/macros/latex/contrib/hepthesis/example/Makefile b/macros/latex/contrib/hepthesis/example/Makefile
new file mode 100644
index 0000000000..6fd9df294f
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/Makefile
@@ -0,0 +1,17 @@
+.PHONY: clean
+
+EXTRASTYS = abhepexpt.sty abhep.sty abmath.sty lineno.sty siunitx.sty SIunits.sty varwidth.sty
+
+example.pdf: example.tex preamble.tex chap1.tex chap2.tex chap3.tex frontmatter.tex appendices.tex
+ @rm -f $(EXTRASTYS)
+ unzip extrastyles.zip
+ @rm -f example.{aux,toc,lof,lot}
+ (pdflatex example && bibtex example && pdflatex example && pdflatex example) || rm -f $(EXTRASTYS) example.pdf
+ @rm -f example.{aux,toc,lof,lot}
+ @rm -f $(EXTRASTYS)
+
+clean:
+ @rm -f $(EXTRASTYS)
+ @rm -f example.pdf example.log example.aux
+ @rm -f *.bbl *.blg *.lof *.cut
+ @rm -f *.lot *.out *.toc
diff --git a/macros/latex/contrib/hepthesis/example/appendices.tex b/macros/latex/contrib/hepthesis/example/appendices.tex
new file mode 100644
index 0000000000..7eb5a08b93
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/appendices.tex
@@ -0,0 +1,28 @@
+%% The "\appendix" call has already been made in the declaration
+%% of the "appendices" environment (see thesis.tex).
+\chapter{Pointless extras}
+\label{app:Pointless}
+
+\chapterquote{%
+Le savant n'\'etudie pas la nature parce que cela est utile; \\
+\indent il l'\'etudie parce qu'il y prend plaisir, \\
+\indent et il y prend plaisir parce qu'elle est belle.}%
+{Henri Poincar\'e, 1854--1912}
+
+Appendixes (or should that be ``appendices''?) make you look really clever, 'cos
+it's like you had more clever stuff to say than could be fitted into the main
+bit of your thesis. Yeah. So everyone should have at least three of them\dots
+
+\section{Like, duh}
+\label{sec:Duh}
+Padding? What do you mean?
+
+\section{$y = \alpha x^2$}
+\label{sec:EqnTitle}
+See, maths in titles automatically goes bold where it should (and check the
+table of contents: it \emph{isn't} bold there!) Check the source: nothing
+needs to be specified to make this work. Thanks to Donald Arsenau for the
+teeny hack that makes this work.
+
+%% Big appendixes should be split off into separate files, just like chapters
+%\input{app-myreallybigappendix}
diff --git a/macros/latex/contrib/hepthesis/example/backmatter.tex b/macros/latex/contrib/hepthesis/example/backmatter.tex
new file mode 100644
index 0000000000..a695bf3a08
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/backmatter.tex
@@ -0,0 +1,19 @@
+\begin{colophon}
+ This thesis was made in \LaTeXe{} using the ``hepthesis'' class~\cite{hepthesis}.
+\end{colophon}
+
+%% You're recommended to use the eprint-aware biblio styles which
+%% can be obtained from e.g. www.arxiv.org. The file mythesis.bib
+%% is derived from the source using the SPIRES Bibtex service.
+\bibliographystyle{h-physrev}
+\bibliography{mythesis}
+
+%% I prefer to put these tables here rather than making the
+%% front matter seemingly interminable. No-one cares, anyway!
+\listoffigures
+\listoftables
+
+%% If you have time and interest to generate a (decent) index,
+%% then you've clearly spent more time on the write-up than the
+%% research ;-)
+%\printindex
diff --git a/macros/latex/contrib/hepthesis/example/chap1.tex b/macros/latex/contrib/hepthesis/example/chap1.tex
new file mode 100644
index 0000000000..a2b6b2d208
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/chap1.tex
@@ -0,0 +1,48 @@
+\chapter{\CP violation in the \Bmeson system}
+\label{chap:SomeStuff}
+
+%% Restart the numbering to make sure that this is definitely page #1!
+\pagenumbering{arabic}
+
+%% Note that the citations in this chapter use the journal and
+%% arXiv keys: I used the SLAC-SPIRES online BibTeX retriever
+%% to build my bibliography. There are also quite a few non-standard
+%% macros, which come from my personal collection. You can have them
+%% if you want, or I might get round to properly releasing them at
+%% some point myself.
+
+\chapterquote{Laws were made to be broken.}%
+{Christopher North, 1785--1854}%: Blackwood's Magazine May 1830
+
+Symmetries, either intact or broken, have proved to be at the heart
+of how matter interacts. The Standard Model of fundamental interactions
+(SM) is composed of three independent continuous symmetry groups denoted
+$\SUgroup{3} \times \SUgroup{2} \times \Ugroup{1}$, representing the
+strong force, weak isospin and hypercharge
+respectively~\cite{Phys.Rev.Lett.19.1264, Phys.Rev.D2.1285,hep-ph/0410370}.
+
+\section{Neutral meson mixing}
+\label{sec:neutralmixing}
+We can go a long way with an effective Hamiltonian approach in
+canonical single-particle quantum mechanics. To do this we construct
+a wavefunction from a combination of a generic neutral meson state
+$\ket{\Xzero}$ and its anti-state $\ket{\Xzerobar}$:
+%
+\begin{equation}
+ \ket{\psi(t)} = a(t)\ket{\Xzero} + b(t)\ket{\Xzerobar}
+\end{equation}
+%
+which is governed by a time-dependent matrix differential equation,
+%
+\begin{equation}
+ \I \pdByd{}{t} \colvector{a \\ b}
+ =
+ \underbrace{%
+ \twomatrix{ M_{11}-\frac{\I}{2}\Gamma_{11}
+ & M_{12}-\frac{\I}{2}\Gamma_{12} }
+ { M_{12}^\ast-\frac{\I}{2}\Gamma_{12}^\ast
+ & M_{22}-\frac{\I}{2}\Gamma_{22} }
+ }_{\boldmatrix{H}}
+ \colvector{a \\ b}
+ .
+\end{equation}
diff --git a/macros/latex/contrib/hepthesis/example/chap2.tex b/macros/latex/contrib/hepthesis/example/chap2.tex
new file mode 100644
index 0000000000..c365719223
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/chap2.tex
@@ -0,0 +1,92 @@
+\chapter{The \LHCb experiment}
+\label{chap:MoreStuff}
+
+\chapterquote{There, sir! that is the perfection of vessels!}
+{Jules Verne, 1828--1905}
+
+\section{The \LHC}
+The Large Hadron Collider (\LHC) at \CERN is a new hadron collider,
+located in the same tunnel as the Large Electron-Positron collider
+(\LEP)~\cite{Brianti:2004qq}. Where \LEP's chief task was the use
+of \unit{90--207}{\GeV} \epluseminus collisions to establish the
+precision physics of electroweak unification\dots
+
+% \begin{figure}
+% \includegraphics[width=\largefigwidth]{ckmfitter-alpha-combined}
+% \caption[CKM Fitter constraints on \alphaCKM.]%
+% {CKM Fitter constraints on \alphaCKM from combined \BToPiPi,
+% \BToRhoPi and \BToRhoRho decay analyses.}
+% \label{fig:CKMFitter}
+% \end{figure}
+
+\section{The \LHCb experiment}
+\label{sec:LHCbInDetail}
+
+Since both \bhadron{s} are preferentially produced in the same direction
+and are forward-boosted along the beam-pipe, the detector is not required
+to have full $4\pi$ solid-angle coverage. \LHCb takes advantage of this
+by using a wedge-shaped single-arm detector with angular acceptance
+\unit{10-300}{\mrad} in the horizontal (bending) plane~\cite{Amato:1998xt}.
+
+\vspace{1cm}
+
+\begin{center}
+{\hspace{1mm}\Large\vdots\hspace{1cm}}
+\end{center}
+
+\vspace{1cm}
+
+The detector is illustrated in \FigureRef{fig:LHCbCrossSection}, showing
+the overall scale of the experiment and the surrounding cavern structure.
+
+\begin{sidewaysfigure}
+ \begin{center}
+ \includegraphics[width=0.8\textheight]{lhcb-detector-cross-section}
+ \caption[Cross-section view of \LHCb, cut in the non-bending $y$--$z$ plane]%
+ {Cross-section view of \LHCb, cut in the non-bending $y$--$z$ plane.}
+ \label{fig:LHCbCrossSection}
+ \end{center}
+\end{sidewaysfigure}
+
+The single-sided detector design was chosen in preference to a two-armed
+design since the detector dimensions are restricted by the layout of the
+IP8 (ex-Delphi) cavern in which \LHCb is located. Using all the available
+space for a single-arm spectrometer more than compensates in performance
+for the \about{50\percent} drop in luminosity.
+
+\section{The \Cerenkov mechanism}
+A Huygens construction in terms of spherical shells of probability for photon
+emission as the particle progresses along its track shows an effective
+``shock-front'' of \Cerenkov emission. This corresponds to an emission cone of
+opening angle \thetaCerenkov around the momentum vector for each point on the
+track,
+%
+\begin{subequations}
+ \label{eq:cosThetaCk}
+ \begin{equation}
+ \cos\,\thetaCerenkov &= \frac{1}{n \beta} +
+ \frac{\hbar k}{2p}%
+ \parenths{ 1 - \frac{1}{n^2} } \\
+ &\,\sim \frac{1}{n \beta}%
+ \label{eq:cosThetaCkApprox}
+ \end{equation}
+\end{subequations}
+%
+where $\beta \equiv v/c$, the relativistic velocity fraction.
+
+\section{Trigger system}
+\label{sec:triggers}
+An overview of the \LHCb trigger characteristics broken down by level
+is shown in \Table~\ref{tab:TriggerDetails}.
+
+\begin{table}[bp]
+ \begin{tabular}{lllll}
+ & L0 & L1 & HLT \\
+ \midrule\\
+ Input rate & \unit{40}{\MHz} & \unit{1}{\MHz} & \unit{40}{\kHz} \\
+ Output rate & \unit{1}{\MHz} & \unit{40}{\kHz} & \unit{2}{\kHz} \\
+ Location & On detector & Counting room & Counting room \\
+ \end{tabular}
+ \caption{Characteristics of the trigger levels and offline analysis.}
+ \label{tab:TriggerDetails}
+\end{table}
diff --git a/macros/latex/contrib/hepthesis/example/chap3.tex b/macros/latex/contrib/hepthesis/example/chap3.tex
new file mode 100644
index 0000000000..85b5a18a8b
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/chap3.tex
@@ -0,0 +1,38 @@
+\chapter{Continued captions}
+\label{chap:ContCaptions}
+
+Here are some funky floats using ``continued captions'', i.e. for a semantically
+collected group of float contents which are too numerous to fit into a single
+float, such as the pretty circles in the following figure:
+
+\newcommand{\circleimg}[1]{%
+\begin{tikzpicture}
+ \draw[color=black,fill=#1,thick] (1,0) circle (1.5cm);
+\end{tikzpicture}%
+}
+
+\begin{figure}[hb]
+ \subfloat[][Example 1a]{\label{fig:cc1a}\circleimg{red!80}}\quad
+ \subfloat[][Example 1b]{\label{fig:cc1b}\circleimg{green!70!yellow}}\quad
+ \subfloat[][Example 1c]{\label{fig:cc1c}\circleimg{blue!80}}\quad
+ \subfloat[][Example 1d]{\label{fig:cc1d}\circleimg{orange!80!yellow}}
+ \caption{Demonstration of \texttt{subfig} continued captions.}
+ \label{fig:cc1}
+\end{figure}
+
+\begin{figure}[p]
+ \ContinuedFloat
+ \subfloat[][Example 1e]{\label{fig:cc1e}\circleimg{violet}}\quad
+ \subfloat[][Example 1f]{\label{fig:cc1f}\circleimg{cyan}}\quad
+ \subfloat[][Example 1g]{\label{fig:cc1g}\circleimg{magenta}}\quad
+ \subfloat[][Example 1h]{\label{fig:cc1h}\circleimg{yellow}}
+ \caption[]{Demonstration of \texttt{subfig} continued captions (continued).}
+\end{figure}
+
+\noindent
+This mechanism means that the same float label is used for both pages of
+floats. Note that we can refer to \FigureRef{fig:cc1} in general, or to
+\FigureRef{fig:cc1g} on \PageRef{fig:cc1g} in particular!
+
+\noindent
+Just for the hell of it, let's also refer to \SectionRef{sec:neutralmixing}.
diff --git a/macros/latex/contrib/hepthesis/example/ckmfitter-alpha-combined.pdf b/macros/latex/contrib/hepthesis/example/ckmfitter-alpha-combined.pdf
new file mode 100644
index 0000000000..9bc7f7c994
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/ckmfitter-alpha-combined.pdf
Binary files differ
diff --git a/macros/latex/contrib/hepthesis/example/example.pdf b/macros/latex/contrib/hepthesis/example/example.pdf
new file mode 100644
index 0000000000..f097575d28
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/example.pdf
Binary files differ
diff --git a/macros/latex/contrib/hepthesis/example/example.tex b/macros/latex/contrib/hepthesis/example/example.tex
new file mode 100644
index 0000000000..9f9c432ed2
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/example.tex
@@ -0,0 +1,73 @@
+%% For normal draft builds (figs undisplayed hence fast compile)
+%\documentclass[hyperpdf,nobind,draft,oneside]{hepthesis}
+%\documentclass[hyperpdf,nobind,draft,twoside]{hepthesis}
+
+%% For short draft builds (breaks citations by necessity)
+%\documentclass[hyperpdf,nobind,draft,hidefrontback]{hepthesis}
+
+%% For Cambridge soft-bound version
+\documentclass[hyperpdf,bindnopdf]{hepthesis}
+%% For Cambridge hard-bound version (must be one-sided)
+%\documentclass[hyperpdf,oneside]{hepthesis}
+
+%% Load special font packages here if you wish
+%\usepackage{lmodern}
+\usepackage{mathpazo}
+%\usepackage{euler}
+
+%% Put package includes etc. into preamble.tex for convenience
+\input{preamble}
+
+%% You can set the line spacing this way
+%\setallspacing{double}
+%% or a section at a time like this
+%\setfrontmatterspacing{double}
+
+
+%% Define the thesis title and author
+\title{A study of \BToKPi decays with\\ the \LHCb experiment}
+\author{Andrew Gordon Buckley}
+
+%% Doc-specific PDF metadata
+\makeatletter
+\@ifpackageloaded{hyperref}{%
+\hypersetup{%
+ pdftitle = {Studying B to K pi decays with LHCb},
+ pdfsubject = {Andy Buckley's PhD thesis},
+ pdfkeywords = {LHCb, B, physics, LHC, heavy flavour},
+ pdfauthor = {\textcopyright\ Andy Buckley}
+}}{}
+\makeatother
+
+
+%% Start the document
+\begin{document}
+
+%% Define the un-numbered front matter (cover pages, rubrik and table of contents)
+\begin{frontmatter}
+ \input{frontmatter}
+\end{frontmatter}
+
+%% Start the content body of the thesis
+\begin{mainmatter}
+ %% Actually, more semantic chapter filenames are better, like "chap-bgtheory.tex"
+ \input{chap1}
+ \input{chap2}
+ \input{chap3}
+ %% To ignore a specific chapter while working on another, making the build faster, comment it out:
+ %\input{chap4}
+\end{mainmatter}
+
+%% Produce the appendices
+\begin{appendices}
+ \input{appendices}
+\end{appendices}
+
+%% Produce the un-numbered back matter (e.g. colophon,
+%% bibliography, tables of figures etc., index...)
+\begin{backmatter}
+ \input{backmatter}
+\end{backmatter}
+
+%% Close
+\end{document}
diff --git a/macros/latex/contrib/hepthesis/example/frontmatter.tex b/macros/latex/contrib/hepthesis/example/frontmatter.tex
new file mode 100644
index 0000000000..30adb15bf9
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/frontmatter.tex
@@ -0,0 +1,55 @@
+%% Title
+\titlepage[of Churchill College]{%
+ A dissertation submitted to the University of Cambridge\\ for the degree of Doctor of Philosophy}
+
+%% Abstract
+\begin{abstract}%[\smaller \thetitle\\ \vspace*{1cm} \smaller {\theauthor}]
+ %\thispagestyle{empty}
+ \LHCb is a \bphysics detector experiment which will take data at
+ the \unit{14}{\TeV} \LHC accelerator at \CERN from 2007 onward\dots
+\end{abstract}
+
+
+%% Declaration
+\begin{declaration}
+ This dissertation is the result of my own work, except where explicit
+ reference is made to the work of others, and has not been submitted
+ for another qualification to this or any other university. This
+ dissertation does not exceed the word limit for the respective Degree
+ Committee.
+ \vspace*{1cm}
+ \begin{flushright}
+ Andy Buckley
+ \end{flushright}
+\end{declaration}
+
+
+%% Acknowledgements
+\begin{acknowledgements}
+ Of the many people who deserve thanks, some are particularly prominent,
+ such as my supervisor\dots
+\end{acknowledgements}
+
+
+%% Preface
+\begin{preface}
+ This thesis describes my research on various aspects of the \LHCb
+ particle physics program, centred around the \LHCb detector and \LHC
+ accelerator at \CERN in Geneva.
+
+ \noindent
+ For this example, I'll just mention \ChapterRef{chap:SomeStuff}
+ and \ChapterRef{chap:MoreStuff}.
+\end{preface}
+
+%% ToC
+\tableofcontents
+
+
+%% Strictly optional!
+\frontquote{%
+ Writing in English is the most ingenious torture\\
+ ever devised for sins committed in previous lives.}%
+ {James Joyce}
+%% I don't want a page number on the following blank page either.
+\thispagestyle{empty}
diff --git a/macros/latex/contrib/hepthesis/example/getNewBibtex b/macros/latex/contrib/hepthesis/example/getNewBibtex
new file mode 100755
index 0000000000..ae2863bb14
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/getNewBibtex
@@ -0,0 +1,16 @@
+#! /usr/bin/env bash
+
+if [[ -n $( echo $* | egrep -- "-h\>|--help\>" ) ]]; then
+ echo -e "Usage: $0 <myfile.tex>"
+ echo "NB. \\input and \\include operations will only work in"
+ echo "the current directory, rather than via the full TeX path."
+ exit 0
+fi
+
+maintexfile=$1
+tempfile=texmerge.$$
+
+cat $maintexfile | sed -e s/'\\input{\([^}]*\)}'/'#include "\1\.tex"'/g > $tempfile
+#cat $tempfile
+cpp $tempfile 2> /dev/null | mail -s "generate bibtex" slaclib2@slac.stanford.edu
+rm -f $tempfile
diff --git a/macros/latex/contrib/hepthesis/example/h-physrev.bst b/macros/latex/contrib/hepthesis/example/h-physrev.bst
new file mode 100644
index 0000000000..7c3c09f9bd
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/h-physrev.bst
@@ -0,0 +1,949 @@
+ENTRY
+{ address
+eprint
+author
+booktitle
+chapter
+collaboration
+edition
+editor
+howpublished
+institution
+journal
+key
+month
+note
+number
+organization
+pages
+publisher
+school
+series
+title
+type
+volume
+year
+}
+{}
+{ label }
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+#1 'mid.sentence :=
+#2 'after.sentence :=
+#3 'after.block :=
+}
+STRINGS { s t }
+FUNCTION {output.nonnull}
+{ 's :=
+output.state mid.sentence =
+{ ", " * write$ }
+{ output.state after.block =
+{ "," * write$
+newline$
+"\newblock " write$
+}
+{ output.state before.all =
+'write$
+{ add.period$ " " * write$ }
+if$
+}
+if$
+mid.sentence 'output.state :=
+}
+if$
+s
+}
+FUNCTION {output}
+{ duplicate$ empty$
+'pop$
+'output.nonnull
+if$
+}
+FUNCTION {output.check}
+{ 't :=
+duplicate$ empty$
+{ pop$ "empty " t * " in " * cite$ * warning$ }
+'output.nonnull
+if$
+}
+FUNCTION {output.bibitem}
+{ newline$
+"\bibitem{" write$
+cite$ write$
+"}" write$
+newline$
+""
+before.all 'output.state :=
+}
+FUNCTION {fin.entry}
+{ add.period$
+write$
+newline$
+}
+FUNCTION {new.block}
+{ output.state before.all =
+'skip$
+{ after.block 'output.state := }
+if$
+}
+FUNCTION {new.sentence}
+{ skip$
+}
+FUNCTION {not}
+{ { #0 }
+{ #1 }
+if$
+}
+FUNCTION {and}
+{ 'skip$
+{ pop$ #0 }
+if$
+}
+FUNCTION {or}
+{ { pop$ #1 }
+'skip$
+if$
+}
+FUNCTION {new.block.checka}
+{ empty$
+'skip$
+'new.block
+if$
+}
+FUNCTION {new.block.checkb}
+{ empty$
+swap$ empty$
+and
+'skip$
+'new.block
+if$
+}
+FUNCTION {new.sentence.checka}
+{ empty$
+'skip$
+'new.sentence
+if$
+}
+FUNCTION {new.sentence.checkb}
+{ empty$
+swap$ empty$
+and
+'skip$
+'new.sentence
+if$
+}
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+{ pop$ "" }
+'skip$
+if$
+}
+FUNCTION {emphasize}
+{ duplicate$ empty$
+{ pop$ "" }
+{ "{\itshape " swap$ * "}" * }
+if$
+}
+FUNCTION {embolden}
+{ duplicate$ empty$
+{ pop$ "" }
+{ "{\bfseries " swap$ * "}" * }
+if$
+}
+FUNCTION {paren}
+{ duplicate$ empty$
+{ pop$ "" }
+{ "(" swap$ * ")" * }
+if$
+}
+INTEGERS { nameptr namesleft numnames }
+INTEGERS { etal }
+FUNCTION {format.names}
+{ 's :=
+#1 'nameptr :=
+s num.names$ 'numnames :=
+numnames #5 >
+s numnames "{ll}" format.name$ "others" = numnames #1 > and
+or 'etal :=
+etal
+{ #1 #1 + 'namesleft := }
+{ numnames 'namesleft := }
+if$
+{ namesleft #0 > }
+{ s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
+nameptr #1 >
+{ namesleft #1 >
+{ ", " * t * }
+{ nameptr #2 >
+{ "," * }
+'skip$
+if$
+t "others" =
+etal or
+{ " {\em et~al.}" * }
+{ " and " * t * }
+if$
+}
+if$
+}
+'t
+if$
+nameptr #1 + 'nameptr :=
+namesleft #1 - 'namesleft :=
+}
+while$
+}
+FUNCTION {format.authors}
+{ author empty$
+{ "" }
+{ author format.names }
+if$
+}
+FUNCTION {format.editors}
+{ editor empty$
+{ "" }
+{ editor format.names
+editor num.names$ #1 >
+{ ", editors" * }
+{ ", editor" * }
+if$
+}
+if$
+}
+FUNCTION {format.edited}
+{ editor empty$
+{ "" }
+{ "edited by " editor format.names * }
+if$
+}
+FUNCTION {format.title}
+{ title empty$
+{ "" }
+{ title "t" change.case$ }
+if$
+}
+FUNCTION {n.dashify}
+{ 't :=
+""
+{ t empty$ not }
+{ t #1 #1 substring$ "-" =
+{ t #1 #2 substring$ "--" = not
+{ "--" *
+t #2 global.max$ substring$ 't :=
+}
+{ { t #1 #1 substring$ "-" = }
+{ "-" *
+t #2 global.max$ substring$ 't :=
+}
+while$
+}
+if$
+}
+{ t #1 #1 substring$ *
+t #2 global.max$ substring$ 't :=
+}
+if$
+}
+while$
+}
+FUNCTION {first.page}
+{ 't :=
+""
+{ t empty$ not t #1 #1 substring$ "-" = not and }
+{ t #1 #1 substring$ *
+t #2 global.max$ substring$ 't :=
+}
+while$
+}
+FUNCTION {format.date}
+{ year empty$
+{ "" }
+'year
+if$
+}
+FUNCTION {format.btitle}
+{ title emphasize
+}
+FUNCTION {tie.or.space.connect}
+{ duplicate$ text.length$ #3 <
+{ "~" }
+{ " " }
+if$
+swap$ * *
+}
+FUNCTION {either.or.check}
+{ empty$
+'pop$
+{ "can't use both " swap$ * " fields in " * cite$ * warning$ }
+if$
+}
+FUNCTION {format.bvolume}
+{ volume empty$
+{ "" }
+{ series empty$
+'skip$
+{ ", " series * }
+if$
+" Vol." volume tie.or.space.connect *
+"volume and number" number either.or.check
+}
+if$
+}
+FUNCTION {format.number.series}
+{ volume empty$
+{ number empty$
+{ series field.or.null }
+{ series empty$
+{ "there's a number but no series in " cite$ * warning$ }
+{ ", " series * }
+if$
+" No. " number tie.or.space.connect *
+}
+if$
+}
+{ "" }
+if$
+}
+FUNCTION {format.edition}
+{ edition empty$
+{ "" }
+{ output.state mid.sentence =
+{ ", " edition "l" change.case$ * }
+{ ", " edition "t" change.case$ * }
+if$
+" ed." *
+}
+if$
+}
+INTEGERS { multiresult }
+FUNCTION {multi.page.check}
+{ 't :=
+#0 'multiresult :=
+{ multiresult not
+t empty$ not
+and
+}
+{ t #1 #1 substring$
+duplicate$ "-" =
+swap$ duplicate$ "," =
+swap$ "+" =
+or or
+{ #1 'multiresult := }
+{ t #2 global.max$ substring$ 't := }
+if$
+}
+while$
+multiresult
+}
+FUNCTION {format.pages}
+{ pages empty$
+{ "" }
+{ pages multi.page.check
+{ "pp." pages n.dashify tie.or.space.connect }
+{ "p." pages tie.or.space.connect }
+if$
+}
+if$
+}
+FUNCTION {format.pages.a}
+{ pages empty$
+{ "" }
+{ "p." pages first.page tie.or.space.connect }
+if$
+}
+FUNCTION {format.vol.num.pages}
+{ volume field.or.null embolden
+" " swap$ * *
+pages empty$
+'skip$
+{ duplicate$ empty$
+{ pop$ format.pages.a }
+{ ", " * pages first.page * }
+if$
+}
+if$
+}
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+'format.pages
+{ type empty$
+{ "chap." }
+{ type "l" change.case$ }
+if$
+chapter tie.or.space.connect
+pages empty$
+'skip$
+{ ", " * format.pages * }
+if$
+}
+if$
+}
+FUNCTION {format.pub.addr.date}
+{ publisher empty$
+{ "" "empty publisher in " cite$ * warning$ }
+{ publisher
+address empty$
+'skip$
+{ ", " * address * }
+if$
+}
+if$
+year empty$
+{ "empty year in " cite$ * warning$ }
+{ ", " * year * }
+if$
+paren " " swap$ *
+}
+FUNCTION {format.book.entry}
+{ format.btitle
+format.bvolume *
+format.number.series *
+format.edition *
+format.pub.addr.date *
+}
+FUNCTION {format.inbook.entry}
+{ format.book.entry
+", " *
+format.chapter.pages *
+}
+FUNCTION {format.in.ed.booktitle}
+{ booktitle empty$
+{ "" }
+{ editor empty$
+{ "in " booktitle emphasize * }
+{ "in " booktitle emphasize * ", " * format.edited * }
+if$
+}
+if$
+}
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+month empty$ year empty$ note empty$
+and and and and and
+{ "all relevant fields are empty in " cite$ * warning$ }
+'skip$
+if$
+}
+FUNCTION {format.thesis.type}
+{ type empty$
+'skip$
+{ pop$
+type "t" change.case$
+}
+if$
+}
+FUNCTION {format.inst.tr.num.date}
+{ institution empty$
+{ "" "empty institution in " cite$ * warning$ }
+{ institution }
+if$
+" Report No." *
+number empty$
+{ "" }
+{ number tie.or.space.connect }
+if$
+year empty$
+{ "empty year in " cite$ * warning$ }
+{ ", " * year * " (unpublished)" * }
+if$
+}
+FUNCTION {format.article.crossref}
+{ key empty$
+{ journal empty$
+{ "need key or journal for " cite$ * " to crossref " * crossref *
+warning$
+""
+}
+{ "In " journal * }
+if$
+}
+{ "In " key * }
+if$
+" \cite{" * crossref * "}" *
+}
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv~}{ll}" format.name$
+editor num.names$ duplicate$
+#2 >
+{ pop$ " {\em et~al.}" * }
+{ #2 <
+'skip$
+{ editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+{ " {\em et~al.}" * }
+{ " and " * editor #2 "{vv~}{ll}" format.name$ * }
+if$
+}
+if$
+}
+if$
+}
+FUNCTION {format.book.crossref}
+{ volume empty$
+{ "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+"In "
+}
+{ "Volume" volume tie.or.space.connect
+" of " *
+}
+if$
+editor empty$
+editor field.or.null author field.or.null =
+or
+{ key empty$
+{ series empty$
+{ "need editor, key, or series for " cite$ * " to crossref " *
+crossref * warning$
+"" *
+}
+{ "{\em " * series * "\/}" * }
+if$
+}
+{ key * }
+if$
+}
+{ format.crossref.editor * }
+if$
+" \cite{" * crossref * "}" *
+}
+FUNCTION {format.incoll.inproc.crossref}
+{ editor empty$
+editor field.or.null author field.or.null =
+or
+{ key empty$
+{ booktitle empty$
+{ "need editor, key, or booktitle for " cite$ * " to crossref " *
+crossref * warning$
+""
+}
+{ "In {\em " booktitle * "\/}" * }
+if$
+}
+{ "In " key * }
+if$
+}
+{ "In " format.crossref.editor * }
+if$
+" \cite{" * crossref * "}" *
+}
+FUNCTION {article}
+{ output.bibitem
+collaboration output
+format.authors "author" output.check
+new.block
+crossref missing$
+{ journal field.or.null
+format.vol.num.pages
+format.date empty$
+'skip$
+{ duplicate$ empty$
+{ pop$ format.date paren }
+{ " " * format.date paren * }
+if$
+}
+if$
+output
+}
+{ format.article.crossref output.nonnull
+format.pages output
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {book}
+{ output.bibitem
+collaboration output
+author empty$
+{ format.editors "author and editor" output.check }
+{ format.authors output.nonnull
+crossref missing$
+{ "author and editor" editor either.or.check }
+'skip$
+if$
+}
+if$
+new.block
+crossref missing$
+{ format.book.entry output }
+{ new.block
+format.book.crossref output.nonnull
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {booklet}
+{ output.bibitem
+collaboration output
+format.authors output
+new.block
+format.title "title" output.check
+howpublished address new.block.checkb
+howpublished output
+address output
+format.date output
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {inbook}
+{ output.bibitem
+collaboration output
+author empty$
+{ format.editors "author and editor" output.check }
+{ format.authors output.nonnull
+crossref missing$
+{ "author and editor" editor either.or.check }
+'skip$
+if$
+}
+if$
+new.block
+crossref missing$
+{ format.inbook.entry output }
+{ format.chapter.pages "chapter and pages" output.check
+new.block
+format.book.crossref output.nonnull
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {incollection}
+{ output.bibitem
+collaboration output
+format.authors "author" output.check
+new.block
+format.title "title" output.check
+new.block
+crossref missing$
+{ format.in.ed.booktitle "booktitle" output.check
+format.bvolume output
+format.number.series output
+format.chapter.pages output
+new.sentence
+publisher "publisher" output.check
+address output
+format.edition output
+format.date "year" output.check
+}
+{ format.incoll.inproc.crossref output.nonnull
+format.chapter.pages output
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {inproceedings}
+{ output.bibitem
+collaboration output
+format.authors "author" output.check
+new.block
+format.title "title" output.check
+new.block
+crossref missing$
+{ format.in.ed.booktitle "booktitle" output.check
+format.bvolume output
+format.number.series output
+format.pages output
+address empty$
+{ organization publisher new.sentence.checkb
+organization output
+publisher output
+format.date "year" output.check
+}
+{ address output.nonnull
+format.date "year" output.check
+new.sentence
+organization output
+publisher output
+}
+if$
+}
+{ format.incoll.inproc.crossref output.nonnull
+format.pages output
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {conference} { inproceedings }
+FUNCTION {manual}
+{ output.bibitem
+collaboration output
+author empty$
+{ organization empty$
+'skip$
+{ organization output.nonnull
+address output
+}
+if$
+}
+{ format.authors output.nonnull }
+if$
+new.block
+format.btitle "title" output.check
+author empty$
+{ organization empty$
+{ address new.block.checka
+address output
+}
+'skip$
+if$
+}
+{ organization address new.block.checkb
+organization output
+address output
+}
+if$
+format.edition output
+format.date output
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {mastersthesis}
+{ output.bibitem
+format.authors "author" output.check
+new.block
+format.title "title" output.check
+new.block
+"Master's thesis" format.thesis.type output.nonnull
+school "school" output.check
+address output
+format.date "year" output.check
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {misc}
+{ output.bibitem
+collaboration output
+format.authors output
+title howpublished new.block.checkb
+format.title output
+howpublished new.block.checka
+howpublished output
+format.date output
+eprint output
+new.block
+note output
+fin.entry
+empty.misc.check
+}
+FUNCTION {phdthesis}
+{ output.bibitem
+format.authors "author" output.check
+new.block
+format.btitle "title" output.check
+new.block
+"PhD thesis" format.thesis.type output.nonnull
+school "school" output.check
+address output
+format.date "year" output.check
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {proceedings}
+{ output.bibitem
+collaboration output
+editor empty$
+{ organization output }
+{ format.editors output.nonnull }
+if$
+new.block
+format.btitle "title" output.check
+format.bvolume output
+format.number.series output
+address empty$
+{ editor empty$
+{ publisher new.sentence.checka }
+{ organization publisher new.sentence.checkb
+organization output
+}
+if$
+publisher output
+format.date "year" output.check
+}
+{ address output.nonnull
+format.date "year" output.check
+new.sentence
+editor empty$
+'skip$
+{ organization output }
+if$
+publisher output
+}
+if$
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {techreport}
+{ output.bibitem
+collaboration output
+format.authors "author" output.check
+new.block
+format.inst.tr.num.date output.nonnull
+eprint output
+new.block
+note output
+fin.entry
+}
+FUNCTION {unpublished}
+{ output.bibitem
+collaboration output
+format.authors "author" output.check
+new.block
+format.title "title" output.check
+new.block
+note "note" output.check
+format.date output
+fin.entry
+}
+FUNCTION {default.type} { misc }
+MACRO {jan} {"Jan."}
+MACRO {feb} {"Feb."}
+MACRO {mar} {"Mar."}
+MACRO {apr} {"Apr."}
+MACRO {may} {"May"}
+MACRO {jun} {"June"}
+MACRO {jul} {"July"}
+MACRO {aug} {"Aug."}
+MACRO {sep} {"Sept."}
+MACRO {oct} {"Oct."}
+MACRO {nov} {"Nov."}
+MACRO {dec} {"Dec."}
+MACRO {acmcs} {"ACM Comput. Surv."}
+MACRO {acta} {"Acta Inf."}
+MACRO {cacm} {"Commun. ACM"}
+MACRO {ibmjrd} {"IBM J. Res. Dev."}
+MACRO {ibmsj} {"IBM Syst.~J."}
+MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
+MACRO {ieeetc} {"IEEE Trans. Comput."}
+MACRO {ieeetcad}
+{"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
+MACRO {ipl} {"Inf. Process. Lett."}
+MACRO {jacm} {"J.~ACM"}
+MACRO {jcss} {"J.~Comput. Syst. Sci."}
+MACRO {scp} {"Sci. Comput. Programming"}
+MACRO {sicomp} {"SIAM J. Comput."}
+MACRO {tocs} {"ACM Trans. Comput. Syst."}
+MACRO {tods} {"ACM Trans. Database Syst."}
+MACRO {tog} {"ACM Trans. Gr."}
+MACRO {toms} {"ACM Trans. Math. Softw."}
+MACRO {toois} {"ACM Trans. Office Inf. Syst."}
+MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
+MACRO {tcs} {"Theoretical Comput. Sci."}
+MACRO {advp} {"Adv. Phys."}
+MACRO {ajp} {"Am. J. Phys."}
+MACRO {ao} {"Appl. Opt."}
+MACRO {apj} {"Astrophys. J."}
+MACRO {apl} {"Appl. Phys. Lett."}
+MACRO {arnps} {"Ann. Rev. Nucl. Sci."}
+MACRO {arns} {"Ann. Rev. Nucl. Part. Sci."}
+MACRO {baps} {"Bull. Am. Phys. Soc."}
+MACRO {cpc} {"Computer Phys. Comm."}
+MACRO {cppcf} {"Comments Plasma Phys. Controlled Fusion"}
+MACRO {fed} {"Fusion Eng. Design"}
+MACRO {ft} {"Fusion Tech."}
+MACRO {ieeens} {"IEEE Trans. Nucl. Sci."}
+MACRO {ieeeps} {"IEEE Trans. Plasma Sci."}
+MACRO {ijimw} {"Int. J. Infrared Millimeter Waves"}
+MACRO {ip} {"Infrared Phys."}
+MACRO {jap} {"J. Appl. Phys."}
+MACRO {jcp} {"J. Comput. Phys."}
+MACRO {jetp} {"Sov. Phys.-JETP"}
+MACRO {jfe} {"J. Fusion Energy"}
+MACRO {jfm} {"J. Fluid Mech."}
+MACRO {jgr} {"J. Geophys. Res."}
+MACRO {jmp} {"J. Math. Phys."}
+MACRO {jne} {"J. Nucl. Energy"}
+MACRO {jnm} {"J. Nucl. Mater."}
+MACRO {josa} {"J. Opt. Soc. Am."}
+MACRO {jpg} {"J. Phys.~G: Nucl. and Part. Phys."}
+MACRO {jphys} {"J. Phys"}
+MACRO {jpp} {"J. Plasma Phys."}
+MACRO {jpsj} {"J. Phys. Soc. Jpn"}
+MACRO {jvst} {"J. Vac. Sci. Technol."}
+MACRO {modphyslettA} {"Mod. Phys. Lett. A"}
+MACRO {nedf} {"Nucl. Eng. Design/Fusion"}
+MACRO {nf} {"Nucl. Fusion"}
+MACRO {nim} {"Nucl. Instrum. Methods"}
+MACRO {np} {"Nucl. Phys."}
+MACRO {npb} {"Nucl. Phys.~B"}
+MACRO {npbps} {"Nucl. Phys. B (Proc. Suppl.)"}
+MACRO {nt/f} {"Nucl. Tech./Fusion"}
+MACRO {pf} {"Phys. Fluids"}
+MACRO {pl} {"Phys. Lett."}
+MACRO {plb} {"Phys. Lett.~B"}
+MACRO {pnas} {"Proc. Nat. Acad. Sci. USA"}
+MACRO {pp} {"Plasma Phys."}
+MACRO {physrep} {"Phys. Rep."}
+MACRO {physrev} {"Phys. Rev."}
+MACRO {pr} {"Phys. Rev."}
+MACRO {prd} {"Phys. Rev.~D"}
+MACRO {prl} {"Phys. Rev. Lett."}
+MACRO {procroysoc} {"Proc. Roy. Soc"}
+MACRO {ps} {"Physica Scripta"}
+MACRO {rmp} {"Rev. Mod. Phys."}
+MACRO {rsi} {"Rev. Sci. Instrum."}
+MACRO {sjnp} {"Sov. J. Nucl. Phys."}
+MACRO {sjpp} {"Sov. J. Plasma Phys."}
+MACRO {spd} {"Sov. Phys.-Dokl."}
+MACRO {sptp} {"Sov. Phys.-Tech. Phys."}
+MACRO {spu} {"Sov. Phys.-Usp."}
+MACRO {zp} {"Z. Phys."}
+MACRO {zpc} {"Z. Phys.~C"}
+READ
+STRINGS { longest.label }
+INTEGERS { number.label longest.label.width }
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+#1 'number.label :=
+#0 'longest.label.width :=
+}
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+number.label #1 + 'number.label :=
+label width$ longest.label.width >
+{ label 'longest.label :=
+label width$ 'longest.label.width :=
+}
+'skip$
+if$
+}
+EXECUTE {initialize.longest.label}
+ITERATE {longest.label.pass}
+FUNCTION {begin.bib}
+{ preamble$ empty$
+'skip$
+{ preamble$ write$ newline$ }
+if$
+"\begin{thebibliography}{" longest.label * "}" * write$ newline$
+}
+EXECUTE {begin.bib}
+EXECUTE {init.state.consts}
+ITERATE {call.type$}
+FUNCTION {end.bib}
+{ newline$
+"\end{thebibliography}" write$ newline$
+}
+EXECUTE {end.bib}
diff --git a/macros/latex/contrib/hepthesis/example/lhcb-detector-cross-section.pdf b/macros/latex/contrib/hepthesis/example/lhcb-detector-cross-section.pdf
new file mode 100644
index 0000000000..79d7f3ef39
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/lhcb-detector-cross-section.pdf
Binary files differ
diff --git a/macros/latex/contrib/hepthesis/example/mwe.tex b/macros/latex/contrib/hepthesis/example/mwe.tex
new file mode 100644
index 0000000000..253311e998
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/mwe.tex
@@ -0,0 +1,13 @@
+\documentclass[oneside]{hepthesis}
+
+\begin{document}
+ \begin{frontmatter}
+ \tableofcontents
+ \end{frontmatter}
+
+ \begin{mainmatter}
+ \chapter{Introduction}
+ lalala
+ \end{mainmatter}
+
+\end{document}
diff --git a/macros/latex/contrib/hepthesis/example/mythesis.bib b/macros/latex/contrib/hepthesis/example/mythesis.bib
new file mode 100644
index 0000000000..f8dc85a0e3
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/mythesis.bib
@@ -0,0 +1,51 @@
+%% Obtained via the getNewBibTeX script and the SPIRES biblio service
+
+@Article{Phys.Rev.Lett.19.1264,
+ author = "Weinberg, Steven",
+ title = "A MODEL OF LEPTONS",
+ journal = "Phys. Rev. Lett.",
+ volume = "19",
+ year = "1967",
+ pages = "1264-1266",
+ SLACcitation = "%%CITATION = PRLTA,19,1264;%%"
+}
+
+@Article{Phys.Rev.D2.1285,
+ author = "Glashow, S. L. and Iliopoulos, J. and Maiani, L.",
+ title = "WEAK INTERACTIONS WITH LEPTON - HADRON SYMMETRY",
+ journal = "Phys. Rev.",
+ volume = "D2",
+ year = "1970",
+ pages = "1285-1292",
+ SLACcitation = "%%CITATION = PHRVA,D2,1285;%%"
+}
+
+@Article{hep-ph/0410370,
+ author = "Willenbrock, Scott",
+ title = "Symmetries of the standard model",
+ year = "2004",
+ eprint = "hep-ph/0410370",
+ SLACcitation = "%%CITATION = HEP-PH 0410370;%%"
+}
+
+@Article{Brianti:2004qq,
+ author = "Brianti, G.",
+ title = "The Large Hadron Collider project: Historical account",
+ journal = "Phys. Rept.",
+ volume = "403-404",
+ year = "2004",
+ pages = "349-364",
+ SLACcitation = "%%CITATION = PRPLC,403-404,349;%%"
+}
+
+@Article{Amato:1998xt,
+ author = "Amato, S. and others",
+ collaboration = "LHCb",
+ title = "LHCb technical proposal",
+ note = "CERN-LHCC-98-4"
+}
+
+@Misc{hepthesis,
+ author = "Buckley, Andy",
+ title = "The hepthesis {\LaTeX} class"
+}
diff --git a/macros/latex/contrib/hepthesis/example/mythesismath.sty b/macros/latex/contrib/hepthesis/example/mythesismath.sty
new file mode 100644
index 0000000000..95ac64fade
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/mythesismath.sty
@@ -0,0 +1,69 @@
+\ProvidesPackage{thesismath}[2005/11/01]
+
+\DeclareRobustCommand{\thesismath}[1]{\ensuremath{\maybebmsf{#1}}}
+\DeclareRobustCommand{\parenths}[1]{\thesismath{\left({#1}\right)}}
+\DeclareRobustCommand{\braces}[1]{\thesismath{\left\{{#1}\right\}}}
+\DeclareRobustCommand{\angles}[1]{\thesismath{\left\langle{#1}\right\rangle}}
+\DeclareRobustCommand{\sqbracs}[1]{\thesismath{\left[{#1}\right]}}
+\DeclareRobustCommand{\mods}[1]{\thesismath{\left\lvert{#1}\right\rvert}}
+\DeclareRobustCommand{\modsq}[1]{\thesismath{\mods{#1}^2}}
+\DeclareRobustCommand{\dblmods}[1]{\thesismath{\left\lVert{#1}\right\rVert}}
+\DeclareRobustCommand{\expOf}[1]{\thesismath{\exp{\!\parenths{#1}}}}
+\DeclareRobustCommand{\eexp}[1]{\thesismath{e^{#1}}}
+\DeclareRobustCommand{\plusquad}{\thesismath{\oplus}}
+\DeclareRobustCommand{\logOf}[1]{\log\!\parenths{#1}}
+\DeclareRobustCommand{\lnOf}[1]{\ln\!\parenths{#1}}
+\DeclareRobustCommand{\ofOrder}[1]{\thesismath{ \mathcal{O}\parenths{#1} }}
+\DeclareRobustCommand{\about}{\thesismath{\sim\!\,}}
+
+%% Vectors, tuples and sets
+\DeclareRobustCommand{\cross}{\thesismath{\times}\xspace}
+\DeclareRobustCommand{\bvec}[1]{\thesismath{\bm{#1}}\xspace}
+\DeclareRobustCommand{\colset}[1]{\thesismath{\begin{Bmatrix}#1\end{Bmatrix}}\xspace}
+\DeclareRobustCommand{\coltuple}[1]{\thesismath{\begin{pmatrix}#1\end{pmatrix}}\xspace}
+\DeclareRobustCommand{\colvector}[1]{\thesismath{\begin{pmatrix}#1\end{pmatrix}}\xspace}
+\DeclareRobustCommand{\colthreevec}[3]{\thesismath{\begin{pmatrix}#1\\ #2\\ #3\end{pmatrix}}\xspace}
+\DeclareRobustCommand{\rowset}[1]{\braces{#1}\xspace}
+\DeclareRobustCommand{\rowtuple}[1]{\parenths{#1}\xspace}
+\DeclareRobustCommand{\rowvector}[1]{\parenths{#1}\xspace}
+\DeclareRobustCommand{\rowthreevec}[3]{\parenths{{#1}, {#2}, {#3}}\xspace}
+
+%% Ranges
+\DeclareRobustCommand{\rangeSS}[1]{\parenths{#1}\xspace}
+\DeclareRobustCommand{\rangeSH}[1]{\left({#1}\right]\xspace}
+\DeclareRobustCommand{\rangeHS}[1]{\left[{#1}\right)\xspace}
+\DeclareRobustCommand{\rangeHH}[1]{\sqbracs{#1}\xspace}
+\DeclareRobustCommand{\softrange}[1]{\rangeSS{#1}}
+\DeclareRobustCommand{\hardrange}[1]{\rangeHH{#1}}
+
+%% Matrix
+\DeclareRobustCommand{\boldmatrix}[1]{\thesismath{\bm{\mathrm{#1}}}\xspace}
+\DeclareRobustCommand{\transposeT}{\MathUpright{T}\,}
+\DeclareRobustCommand{\hermitianT}{\dagger}
+\DeclareRobustCommand{\twomatrix}[2]{\thesismath{\begin{pmatrix}#1\\ #2\end{pmatrix}}\xspace}
+\DeclareRobustCommand{\threematrix}[3]{\thesismath{\begin{pmatrix}#1\\ #2\\ #3\end{pmatrix}}\xspace}
+
+%% Differentials
+\DeclareRobustCommand{\diff}[1]{\thesismath{\mathrm{d} #1}}
+\DeclareRobustCommand{\pdiff}[1]{\thesismath{\partial #1}}
+\DeclareRobustCommand{\dByd}[2]{\thesismath{ \frac{\diff{#1}}{\diff{#2}} }}
+\DeclareRobustCommand{\pdByd}[2]{\thesismath{ \frac{\pdiff{#1}}{\pdiff{#2}} }}
+\DeclareRobustCommand{\DeltaVec}[1]{\thesismath{\boldsymbol{\Delta}\mathbf{#1}}}
+\DeclareRobustCommand{\DeltaN}[1]{\thesismath{\Delta #1}}
+\DeclareRobustCommand{\deltaVec}[1]{\thesismath{\boldsymbol{\delta}\mathbf{#1}}}
+\DeclareRobustCommand{\deltaN}[1]{\thesismath{\delta #1}}
+\DeclareRobustCommand{\d}[1]{\thesismath{\mathrm{d}#1}}
+
+%% Complex numbers
+\DeclareRobustCommand{\I}{\thesismath{\imath}}
+\let\@oldRe\Re
+\let\@oldIm\Im
+\DeclareRobustCommand{\Im}{\thesismath{ \@oldIm{}\mathfrak{m} }\xspace}
+\DeclareRobustCommand{\Re}{\thesismath{ \@oldRe{}\mathfrak{e}\mspace{3mu} }\xspace}
+\DeclareRobustCommand{\ImaginaryPart}[1]{\thesismath{ \,\Im\!\,\braces{#1} }\xspace}
+\DeclareRobustCommand{\RealPart}[1]{\thesismath{ \,\Re\!\braces{#1} }\xspace}
+
+%% Groups
+\DeclareRobustCommand{\group}[1]{\thesismath{\mayberm{#1}}}
+\DeclareRobustCommand{\Ugroup}[1]{\group{U}\parenths{#1}}
+\DeclareRobustCommand{\SUgroup}[1]{\group{S}\Ugroup{#1}}
diff --git a/macros/latex/contrib/hepthesis/example/preamble.tex b/macros/latex/contrib/hepthesis/example/preamble.tex
new file mode 100644
index 0000000000..6c73e5f5d4
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/example/preamble.tex
@@ -0,0 +1,70 @@
+\usepackage{xspace}
+\usepackage{tikz}
+\usepackage{morefloats,subfig,afterpage}
+\usepackage{mathrsfs} % script font
+\usepackage{verbatim}
+
+%% Using Babel allows other languages to be used and mixed-in easily
+%\usepackage[ngerman,english]{babel}
+\usepackage[english]{babel}
+\selectlanguage{english}
+
+%% Citation system tweaks
+\usepackage{cite}
+% \let\@OldCite\cite
+% \renewcommand{\cite}[1]{\mbox{\!\!\!\@OldCite{#1}}}
+
+%% Maths
+% TODO: rework or eliminate maybemath
+\usepackage{abmath}
+\DeclareRobustCommand{\mymath}[1]{\ensuremath{\maybebmsf{#1}}}
+% \DeclareRobustCommand{\parenths}[1]{\mymath{\left({#1}\right)}\xspace}
+% \DeclareRobustCommand{\braces}[1]{\mymath{\left\{{#1}\right\}}\xspace}
+% \DeclareRobustCommand{\angles}[1]{\mymath{\left\langle{#1}\right\rangle}\xspace}
+% \DeclareRobustCommand{\sqbracs}[1]{\mymath{\left[{#1}\right]}\xspace}
+% \DeclareRobustCommand{\mods}[1]{\mymath{\left\lvert{#1}\right\rvert}\xspace}
+% \DeclareRobustCommand{\modsq}[1]{\mymath{\mods{#1}^2}\xspace}
+% \DeclareRobustCommand{\dblmods}[1]{\mymath{\left\lVert{#1}\right\rVert}\xspace}
+% \DeclareRobustCommand{\expOf}[1]{\mymath{\exp{\!\parenths{#1}}}\xspace}
+% \DeclareRobustCommand{\eexp}[1]{\mymath{e^{#1}}\xspace}
+% \DeclareRobustCommand{\plusquad}{\mymath{\oplus}\xspace}
+% \DeclareRobustCommand{\logOf}[1]{\mymath{\log\!\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\lnOf}[1]{\mymath{\ln\!\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\ofOrder}[1]{\mymath{\mathcal{O}\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\SOgroup}[1]{\mymath{\mathup{SO}\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\SUgroup}[1]{\mymath{\mathup{SU}\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\Ugroup}[1]{\mymath{\mathup{U}\parenths{#1}}\xspace}
+% \DeclareRobustCommand{\I}[1]{\mymath{\mathrm{i}}\xspace}
+% \DeclareRobustCommand{\colvector}[1]{\mymath{\begin{pmatrix}#1\end{pmatrix}}\xspace}
+\DeclareRobustCommand{\Rate}{\mymath{\Gamma}\xspace}
+\DeclareRobustCommand{\RateOf}[1]{\mymath{\Gamma}\parenths{#1}\xspace}
+
+%% High-energy physics stuff
+\usepackage{abhep}
+\usepackage{hepnames}
+\usepackage{hepunits}
+\DeclareRobustCommand{\arXivCode}[1]{arXiv:#1}
+\DeclareRobustCommand{\CP}{\ensuremath{\mathcal{CP}}\xspace}
+\DeclareRobustCommand{\CPviolation}{\CP-violation\xspace}
+\DeclareRobustCommand{\CPv}{\CPviolation}
+\DeclareRobustCommand{\LHCb}{LHCb\xspace}
+\DeclareRobustCommand{\LHC}{LHC\xspace}
+\DeclareRobustCommand{\LEP}{LEP\xspace}
+\DeclareRobustCommand{\CERN}{CERN\xspace}
+\DeclareRobustCommand{\bphysics}{\Pbottom-physics\xspace}
+\DeclareRobustCommand{\bhadron}{\Pbottom-hadron\xspace}
+\DeclareRobustCommand{\Bmeson}{\PB-meson\xspace}
+\DeclareRobustCommand{\bbaryon}{\Pbottom-baryon\xspace}
+\DeclareRobustCommand{\Bdecay}{\PB-decay\xspace}
+\DeclareRobustCommand{\bdecay}{\Pbottom-decay\xspace}
+\DeclareRobustCommand{\BToKPi}{\HepProcess{ \PB \to \PK \Ppi }\xspace}
+\DeclareRobustCommand{\BToPiPi}{\HepProcess{ \PB \to \Ppi \Ppi }\xspace}
+\DeclareRobustCommand{\BToKK}{\HepProcess{ \PB \to \PK \PK }\xspace}
+\DeclareRobustCommand{\BToRhoPi}{\HepProcess{ \PB \to \Prho \Ppi }\xspace}
+\DeclareRobustCommand{\BToRhoRho}{\HepProcess{ \PB \to \Prho \Prho }\xspace}
+\DeclareRobustCommand{\X}{\thesismath{X}\xspace}
+\DeclareRobustCommand{\Xbar}{\thesismath{\overline{X}}\xspace}
+\DeclareRobustCommand{\Xzero}{\HepGenParticle{X}{}{0}\xspace}
+\DeclareRobustCommand{\Xzerobar}{\HepGenAntiParticle{X}{}{0}\xspace}
+\DeclareRobustCommand{\epluseminus}{\Ppositron\!\Pelectron\xspace}
+\DeclareRobustCommand{\protonproton}{\Pproton\APantiproton\xspace}
diff --git a/macros/latex/contrib/hepthesis/hepthesis.cls b/macros/latex/contrib/hepthesis/hepthesis.cls
new file mode 100644
index 0000000000..a430515657
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/hepthesis.cls
@@ -0,0 +1,903 @@
+%% hepthesis
+%% LaTeX class for writing PhD theses, particularly those for
+%% high energy physics (HEP)
+%% Author: Andy Buckley <andy@insectnation.org>
+%%
+%% This material is subject to the LaTeX Project Public License.
+%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
+%% or the details of that license.
+%%
+%% Please let me know if you use hepthesis and what you think of it.
+%% I'll try to implement any suggested options or geometry changes,
+%% provided I think they're a good idea!
+
+
+%% ========================================================================
+%% Admin
+%% ========================================================================
+\def\fileversion{1.5.1}
+\def\filedate{2017/09/20}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{hepthesis}[\filedate\space HEP thesis class by Andy Buckley (v\fileversion)]
+
+%% ========================================================================
+%% Option parsing
+%% ========================================================================
+%% Conditional packages (can be disabled)
+\def\@empty{}
+\def\@yes{yes}
+\def\@requireamsmath{yes}
+\def\@requirebooktabs{yes}
+\def\@requiremakeidx{}
+\def\@requiretitling{}
+\def\@requirehep{}
+\def\@requirehyper{}
+\def\@requiredraft{}
+\def\@useAFour{yes}
+\def\@requireAFourWide{}
+\def\@useTwelvePt{yes}
+\def\@oneside{}
+\def\@sftitles{}
+\def\@bindmargins{yes}
+\def\@hidefrontmatter{}
+\def\@hidebackmatter{}
+
+%% Part-wise spacing commands and definitions
+\def\@frontmatterspacing{onehalfspacing}
+\def\@mainmatterspacing{onehalfspacing}
+\def\@appendixspacing{onehalfspacing}
+\def\@backmatterspacing{onehalfspacing}
+
+%% One-sided or two-sided (bound copies may have to be single-sided)
+\DeclareOption{oneside}{%
+ \def\@oneside{yes}
+ \PassOptionsToClass{oneside}{scrbook}}
+\DeclareOption{twoside}{%
+ \def\@oneside{}
+ \PassOptionsToClass{twoside}{scrbook}}
+
+%% Sans serif titles?
+\DeclareOption{sftitles}{%
+ \def\@sftitles{yes}}
+\DeclareOption{rmtitles}{%
+ \def\@sftitles{}}
+
+%% Pad inner margins for binding
+\DeclareOption{bind}{%
+ \def\@bindmargins{yes}}
+\DeclareOption{nobind}{%
+ \def\@bindmargins{}}
+%% Use binding margins if output is not PDF
+\DeclareOption{bindnopdf}{
+ \ifx\pdfoutput\undefined%
+ \def\@bindmargins{yes}%
+ \else%
+ \def\@bindmargins{}%
+ \fi%
+}
+
+%% Use AMS math packages
+\DeclareOption{noams}{%
+ \def\@requireamsmath{}}
+\DeclareOption{ams}{%
+ \def\@requireamsmath{yes}}
+
+%% Change footnote markers to alphabetic
+\DeclareOption{alphafoot}{%
+ \DeclareRobustCommand{\thefootnote}{\alph{footnote}}%
+}
+
+%% Draft mode with line numbers and draft over-print
+\DeclareOption{draft}{%
+ \def\@requiredraft{yes}
+ \AtEndOfPackage{%
+ \let\@oldermainmatter\mainmatter%
+ \DeclareRobustCommand{\mainmatter}{\@oldermainmatter\linenumbers}%
+ }
+}
+
+%% Disable the frontmatter
+\DeclareOption{hidefront}{%
+ \def\@hidefrontmatter{yes}
+}
+\DeclareOption{hideback}{%
+ \def\@hidebackmatter{yes}
+}
+\DeclareOption{hidefrontback}{%
+ \def\@hidefrontmatter{yes}
+ \def\@hidebackmatter{yes}
+}
+
+% Use hyperref package (with decent options)
+\DeclareOption{hyper}{
+ \def\@requirehyper{yes}}
+
+% Use hyperref package (with decent options) only if output is PDF
+\DeclareOption{hyperpdf}{
+ \ifx\pdfoutput\undefined\else%
+ \def\@requirehyper{yes}%
+ \fi%
+}
+
+%% Don't break enumerations (etc.) across pages in
+%% an ugly manner
+\clubpenalty = 10000
+\widowpenalty = 10000
+
+%% Use nice-looking tables
+\DeclareOption{booktabs}{%
+ \def\@requirebooktabs{yes}}
+\DeclareOption{nobooktabs}{%
+ \def\@requirebooktabs{}}
+
+
+%% Allows us to make an index
+\DeclareOption{index}{%
+ \def\@requiremakeidx{yes}
+}
+
+%% Allows us to make an index
+\DeclareOption{titling}{%
+ \def\@requiretitling{yes}
+}
+
+%% Particle physics options
+\DeclareOption{hep}{%
+ \def\@requirehep{yes}
+}
+
+%% Paper size (wide A4 is default)
+\DeclareOption{a4paper}{%
+ \def\@useAFour{yes}%
+ \def\@requireAFourWide{yes}%
+}
+\DeclareOption{a4narrow}{%
+ \def\@useAFour{yes}%
+ \def\@requireAFourWide{}%
+}
+\DeclareOption{a5paper}{%
+ \def\@useAFour{}%
+ \PassOptionsToClass{a5paper}{scrbook}%
+}
+\DeclareOption{b5paper}{%
+ \def\@useAFour{}%
+ \PassOptionsToClass{b5paper}{scrbook}%
+}
+\DeclareOption{letterpaper}{%
+ \def\@useAFour{}%
+ \PassOptionsToClass{letterpaper}{scrbook}%
+}
+\DeclareOption{legalpaper}{%
+ \def\@useAFour{}%
+ \PassOptionsToClass{legalpaper}{scrbook}%
+}
+\DeclareOption{executivepaper}{%
+ \def\@useAFour{}%
+ \PassOptionsToClass{executivepaper}{scrbook}%
+}
+%% Handle the A4 default paper size
+\ifx\@useAFour\@empty\else%
+ \PassOptionsToClass{a4paper}{scrbook}%
+\fi
+
+
+%% Font size (12pt is default)
+\DeclareOption{10pt}{%
+ \def\@useTwelvePt{}%
+ \PassOptionsToClass{10pt}{scrbook}%
+}
+\DeclareOption{11pt}{%
+ \def\@useTwelvePt{}%
+ \PassOptionsToClass{11pt}{scrbook}%
+}
+\DeclareOption{12pt}{%
+ \def\@useTwelvePt{yes}%
+}
+%% Handle the 12pt default font size
+\ifx\@useTwelvePt\@empty\else%
+ \PassOptionsToClass{12pt}{scrbook}%
+\fi
+
+
+%% Options to be passed to the hep package
+\DeclareOption{hepfd}{\def\@requirehep{yes}\PassOptionsToPackage{fd}{hep}}
+\DeclareOption{heplayout}{\def\@requirehep{yes}\PassOptionsToPackage{layout}{hep}}
+\DeclareOption{hephyper}{\def\@requirehep{yes}\PassOptionsToPackage{hyper}{hep}}
+\DeclareOption{hepfloat}{\def\@requirehep{yes}\PassOptionsToPackage{float}{hep}}
+\DeclareOption{hepall}{\def\@requirehep{yes}\PassOptionsToPackage{all}{hep}}
+
+%% Process the options (no package requirement allowed above here)
+\ProcessOptions
+
+
+%% ========================================================================
+%% Base class and packages
+%% ========================================================================
+
+%% Base class
+\LoadClass[chapterprefix]{scrbook}
+
+%% Use wide format if using A4 paper
+\ifx\@requireAFourWide\@empty\else\RequirePackage{a4wide}\fi
+
+%% Use Type 1 font encoding
+\RequirePackage[T1]{fontenc}
+
+%% Useful tools
+\RequirePackage{etoolbox}
+
+%% If building with PDFLaTeX, use microtype spacing adjustments
+\RequirePackage{microtype}
+
+%% Need to be able to locally change the text width.
+\RequirePackage{changepage}
+
+%% Used to center the variable width page quote (must be version >= 0.9a)
+\RequirePackage{varwidth}[2003/03/10]
+
+
+%% AMS math package (optional)
+\ifx\@requireamsmath\@empty\else%
+ \RequirePackage{amsmath}
+ \AtEndOfPackage{%
+ %% Displayed maths environments re-defined to be the same as AMS' align
+ \renewenvironment{displaymath}{\align}{\endalign\ignorespacesafterend}
+ \newenvironment{displaymath*}%
+ {\expandafter\let\expandafter\@oldoldalignstar \csname align*\endcsname \@oldoldalignstar}%
+ {\expandafter\let\expandafter\@oldoldendalignstar \csname endalign*\endcsname \@oldoldendalignstar \ignorespacesafterend}
+ \renewenvironment{equation}{\align}{\endalign\ignorespacesafterend}
+ \renewenvironment{equation*}%
+ {\expandafter\let\expandafter\@oldoldalignstar \csname align*\endcsname \@oldoldalignstar}%
+ {\expandafter\let\expandafter\@oldoldendalignstar \csname endalign*\endcsname \@oldoldendalignstar \ignorespacesafterend}
+ }%
+\fi
+
+%% Index building (optional)
+\ifx\@requiremakeidx\@empty\else\RequirePackage{makeidx}\fi
+
+%% Use the \title and \author arguments to build the front page etc.
+\ifx\@requiretitling\@empty%
+%% Re-define \title and \author to store their args in \thetitle, \theauthor variables
+ \renewcommand*\title[1]{\gdef\@title{#1}\global\let\thetitle\@title}%
+ \renewcommand*\author[1]{\gdef\@author{#1}\global\let\theauthor\@author}%
+\else%
+ \RequirePackage{titling}%
+\fi
+
+%% Serif titles
+\ifx\@sftitles\@empty
+ \addtokomafont{sectioning}{\rmfamily\bfseries}
+\fi
+
+%% In standard tabular: aligns \hline properly with vertical
+%% lines (check with zoom). But you shouldn't using vertical
+%% lines, should you? See booktabs documentation ;-)
+%\RequirePackage{array}
+
+%% Nice tables (optional)
+\ifx\@requirebooktabs\@empty\else%
+ \RequirePackage{booktabs}
+ \AtEndOfClass{%
+ %% Tabular environment, defined to use the booktabs facilities
+ \let\@oldtabular\tabular
+ \let\@oldendtabular\endtabular
+ \renewenvironment{tabular}[1]{%
+ \@oldtabular{@{}#1@{}}%
+ \toprule%
+ }{%
+ \bottomrule%
+ \@oldendtabular%
+ \ignorespacesafterend%
+ }
+ %%
+ }%
+\fi
+
+%% Convenience-included HEP packages (optional)
+\ifx\@requirehep\@empty\else\RequirePackage{hep}\fi
+
+%% ``DRAFT'' underprint and line numbering in draft mode (optional)
+\ifx\@requiredraft\@empty\else%
+ \RequirePackage[pagewise, mathlines]{lineno}
+ \RequirePackage{draftcopy}
+\fi
+
+%% The right way to do custom spacing
+\RequirePackage{setspace}
+%% \singlespacing, \onehalfspacing, \doublespacing
+%% \begin{spacing}{2.5} ...
+
+%% Funky headers
+\RequirePackage{fancyhdr}
+
+%% Make sure bibliography (but not ToC) appears in the ToC
+\RequirePackage[nottoc]{tocbibind}
+
+%% Special comments for block enabling/disabling
+\RequirePackage{comment}
+
+%% Rotated figures (used to define sidewaysfigure)
+\RequirePackage{rotating}
+
+%% Re-defines captions of figures and tables
+%% TODO: make configurable / optional?
+\RequirePackage[format=hang,labelfont=bf,labelsep=colon,font=small]{caption}[2004/01/23]
+
+%% Ability to specify a hook for after a page is completed
+\RequirePackage{afterpage}
+
+%% Misc tweaks
+\AtEndOfClass{%
+ %% Make maths in titles go automatically bold
+ \g@addto@macro\bfseries{\boldmath}
+ %% Declare a bold version of the typewriter font
+ \DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
+}
+
+
+%% ========================================================================
+%% Length definitions
+%% ========================================================================
+
+\setlength{\parindent}{0.6cm} % tweak the initial indent in paras
+\setlength{\parskip}{0.3cm} % tweak the intra-para gap size
+\setlength{\topmargin}{0in}
+\setlength{\textheight}{9in}
+\setlength{\footskip}{0.5in}
+\setlength{\textwidth}{6.2in}
+%% Increase inner margins for binding
+\newlength{\@bindextramargin}
+\AtEndOfClass{%
+ \ifx\@bindmargins\@empty%
+ \setlength{\@bindextramargin}{0.0in}
+ \else%
+ \setlength{\@bindextramargin}{0.2in}
+ \fi
+ \setlength{\oddsidemargin}{\@bindextramargin}
+ \setlength{\evensidemargin}{-\@bindextramargin}
+}
+
+%% Redefine bits of document shape
+\renewcommand{\topfraction}{0.95}%
+\renewcommand{\bottomfraction}{0.95}%
+\renewcommand{\textfraction}{0.05}%
+\renewcommand{\arraystretch}{1.25}%
+
+%% Reset rule widths and the header width
+\renewcommand{\headwidth}{\textwidth}%
+\renewcommand{\headrulewidth}{0.5pt}%
+\renewcommand{\footrulewidth}{0pt}%
+\addtolength{\headheight}{2.5pt}%
+\addtolength{\headsep}{20pt}%
+
+%% Extra margins for various sections
+\newlength{\@mainmatterextramargin}%
+\setlength{\@mainmatterextramargin}{0cm}%
+\newlength{\@backmatterextramargin}%
+\setlength{\@backmatterextramargin}{0cm}%
+\newlength{\@frontmatterextramargin}%
+\setlength{\@frontmatterextramargin}{0cm}%
+\newlength{\@appendixextramargin}%
+\setlength{\@appendixextramargin}{0cm}%
+\newlength{\@abstractextramargin}%
+\setlength{\@abstractextramargin}{1.5cm}%
+\newlength{\@declarationextramargin}%
+\setlength{\@declarationextramargin}{1cm}%
+\newlength{\@acknowledgementsextramargin}%
+\setlength{\@acknowledgementsextramargin}{0cm}%
+\newlength{\@prefaceextramargin}%
+\setlength{\@prefaceextramargin}{0cm}%
+\newlength{\@pagequoteextramargin}%
+\setlength{\@pagequoteextramargin}{2cm}%
+
+%% Top vertical spacing in the front matter
+\newlength{\@frontmattertopskip}%
+\newlength{\@frontmattertitletopskip}%
+\newlength{\frontmattertitleskip}%
+\addtolength{\frontmattertitleskip}{2cm}%
+\addtolength{\@frontmattertitletopskip}{0cm}%
+\setlength{\@frontmattertopskip}{\frontmattertitleskip}%
+\addtolength{\@frontmattertopskip}{\@frontmattertitletopskip}%
+
+%% Figure widths
+\newlength{\smallfigwidth}
+\newlength{\mediumfigwidth}
+\newlength{\largefigwidth}
+\newlength{\hugefigwidth}
+\setlength{\smallfigwidth}{0.45\textwidth}
+\setlength{\mediumfigwidth}{0.6\textwidth}
+\setlength{\largefigwidth}{0.75\textwidth}
+\setlength{\hugefigwidth}{0.9\textwidth}
+
+%% Figure width aliases
+\newlength{\littlefigwidth}
+\newlength{\bigfigwidth}
+\setlength{\littlefigwidth}{\smallfigwidth}
+\setlength{\bigfigwidth}{\largefigwidth}
+
+
+%% ========================================================================
+%% Headers and footers
+%% ========================================================================
+%% No header or footer on the title page
+\AtBeginDocument{\thispagestyle{plain}}
+%% Use funky headers and footers
+\pagestyle{fancy}
+
+
+%% Normal headers and footers (headers are all like RH pages for oneside)
+\ifx\@oneside\@empty%
+ \fancyhead[RO,LE]{\bfseries\thepage}%
+ \fancyhead[LO,RE]{\bfseries\leftmark}%
+\else%
+ \fancyhead[RO,R]{\bfseries\thepage}%
+ \fancyhead[LO,L]{\bfseries\leftmark}%
+\fi%
+\fancyfoot{}%
+%% Lower case header content
+\renewcommand{\chaptermark}[1]{%
+ \markboth{#1}{}%
+}
+
+
+%% Headers and footers for plain (blank) pages
+\fancypagestyle{plain}{%
+ \fancyhf{}%
+ %\fancyhead[RO,LE]{\bfseries \thepage}%
+ \fancyfoot[C]{\bfseries \thepage}%
+ \renewcommand{\headrulewidth}{0pt}%
+ \renewcommand{\footrulewidth}{0pt}%
+}
+
+
+%% Treat forced blank pages in the same way as chapter title pages
+\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else%
+ \hbox{}%
+ %\thispagestyle{empty}%
+ \thispagestyle{plain}%
+ \newpage%
+ \if@twocolumn\hbox{}\newpage\fi\fi\fi}%
+
+%% Commenting out front and back matter
+\ifx\@hidefrontmatter\@yes\AtBeginDocument{\excludecomment{frontmatter}}\fi
+\ifx\@hidebackmatter\@yes\AtBeginDocument{\excludecomment{backmatter}}\fi
+
+
+%% ========================================================================
+%% Internal environments and commands
+%% ========================================================================
+
+\AtEndPreamble{%
+ \RequirePackage[autostyle]{csquotes}[2007/03/25]
+ %% Provide dumb quoting commands in case the csquotes package hasn't been used.
+ \providecommand{\enquote}[1]{``#1''}%
+ \providecommand{\foreignquote}[1]{``#1''}%
+
+ %% Provide mixed-case versions of the Table of contents,
+ %% List of tables, List of figures, Bibliography etc. header names
+ \@ifpackageloaded{babel}{\addto\captionsenglish{%
+ \renewcommand*{\contentsname}{Contents}
+ \renewcommand*{\bibname}{Bibliography}
+ \renewcommand*{\listfigurename}{List of figures}
+ \renewcommand*{\listtablename}{List of tables}
+ }}{%
+ \renewcommand*{\contentsname}{Contents}
+ \renewcommand*{\bibname}{Bibliography}
+ \renewcommand*{\listfigurename}{List of figures}
+ \renewcommand*{\listtablename}{List of tables}
+ }
+
+ %% Hyperlinks (optional, has to come late in the package list)
+ \ifx\@requirehyper\@empty\else%
+ \RequirePackage[colorlinks=true,bookmarks=true,plainpages=false]{hyperref}%
+ % pdfpagemode=None, FullScreen, UseThumbs, UseOutlines
+ \fi
+}
+
+
+%% ========================================================================
+%% Public environments and commands
+%% ========================================================================
+
+
+%% Change the spacing of lines
+\DeclareRobustCommand{\setspacing}[1]{%
+ \setfrontmatterspacing{#1}%
+ \setmainmatterspacing{#1}%
+ \setappendixspacing{#1}%
+ \setbackmatterspacing{#1}%
+}
+\DeclareRobustCommand{\setfrontmatterspacing}[1]{\def\@frontmatterspacing{#1spacing}}
+\DeclareRobustCommand{\setmainmatterspacing}[1]{\def\@mainmatterspacing{#1spacing}}
+\DeclareRobustCommand{\setappendixspacing}[1]{\def\@appendixspacing{#1spacing}}
+\DeclareRobustCommand{\setbackmatterspacing}[1]{\def\@backmatterspacing{#1spacing}}
+
+
+%% Change the extra margin size
+\DeclareRobustCommand{\setextramargins}[1]{%
+ \setfrontmatterextramargins{#1}%
+ \setmainmatterextramargins{#1}%
+ \setappendixextramargins{#1}%
+ \setbackmatterextramargins{#1}%
+}
+\DeclareRobustCommand{\setfrontmatterextramargins}[1]{\setlength{\@frontmatterextramargin}{#1}}
+\DeclareRobustCommand{\setmainmatterextramargins}[1]{\setlength{\@mainmatterextramargin}{#1}}
+\DeclareRobustCommand{\setappendixextramargins}[1]{\setlength{\@appendixextramargin}{#1}}
+\DeclareRobustCommand{\setbackmatterextramargins}[1]{\setlength{\@backmatterextramargin}{#1}}
+\DeclareRobustCommand{\setabstractextramargins}[1]{\setlength{\@abstractextramargin}{#1}}
+\DeclareRobustCommand{\setdeclarationextramargins}[1]{\setlength{\@declarationextramargin}{#1}}
+\DeclareRobustCommand{\setacknowledgementsextramargins}[1]{\setlength{\@acknowledgementsextramargin}{#1}}
+\DeclareRobustCommand{\setprefaceextramargins}[1]{\setlength{\@prefaceextramargin}{#1}}
+
+
+%% An environment for the rubbish at the front of a typical thesis
+\let\@oldfrontmatter\frontmatter
+\specialcomment{frontmatter}{%
+ \setcounter{tocdepth}{2}% show down to subsections in contents
+ \setcounter{secnumdepth}{2}% number down to subsections
+ \newcounter{iterlist}%
+ \@oldfrontmatter%
+ \adjustwidth{\@frontmatterextramargin}{\@frontmatterextramargin}%
+ \begin{\@frontmatterspacing}%
+}{%
+ \end{\@frontmatterspacing}%
+ \endadjustwidth%
+ \ignorespacesafterend%
+ % \thispagestyle{empty}
+}
+
+
+%% Environment for the thesis main body
+\let\@oldmainmatter\mainmatter
+\specialcomment{mainmatter}{%
+ %\@oldmainmatter%
+ \if@twoside\clearpage\fi%
+ \@mainmattertrue%
+ \afterpage{\pagenumbering{arabic}}%
+ \adjustwidth{\@mainmatterextramargin}{\@mainmatterextramargin}%
+ \begin{\@mainmatterspacing}%
+}{%
+ \end{\@mainmatterspacing}%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Environment for appendices
+\specialcomment{appendices}{%
+ \adjustwidth{\@appendixextramargin}{\@appendixextramargin}%
+ \begin{\@appendixspacing}%
+ \appendix%
+}{%
+ \end{\@appendixspacing}%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Environment for all the junk at the end of the thesis
+\let\@oldbackmatter\backmatter
+\specialcomment{backmatter}{%
+ %\thispagestyle{plain}%
+ %pagestyle{plain}%
+ %\@oldbackmatter%
+ \adjustwidth{\@backmatterextramargin}{\@backmatterextramargin}%
+ \begin{\@backmatterspacing}%
+ \appendix%
+}{%
+ \end{\@backmatterspacing}%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Environment for acknowledgements page in frontmatter
+\newenvironment{acknowledgements}{%
+ \cleardoublepage%
+ \adjustwidth{\@acknowledgementsextramargin}{\@acknowledgementsextramargin}%
+ \vspace*{\@frontmattertopskip}%
+ \begin{center}%
+ \begingroup
+ \ifx\@sftitles\@empty\else\sffamily\fi
+ {\LARGE{\textbf{Acknowledgements}}}%
+ \endgroup
+ \end{center}%
+ \vspace*{1cm}%
+}{%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Environment for preface page in frontmatter
+\newenvironment{preface}{%
+ \cleardoublepage%
+ \adjustwidth{\@prefaceextramargin}{\@prefaceextramargin}%
+ \vspace*{\@frontmattertopskip}%
+ \begin{center}%
+ \begingroup
+ \ifx\@sftitles\@empty\else\sffamily\fi
+ {\LARGE{\textbf{Preface}}}%
+ \endgroup
+ \end{center}%
+ \vspace*{1cm}%
+}{%
+ \endadjustwidth%
+ \ignorespacesafterend %
+}
+
+
+%% Environment for declaration rubrik page in frontmatter
+%% (flushright doesn't work in this macro for some reason,
+%% so you'll have to do that bit yourself like in the
+%% example file)
+\newenvironment{declaration}{%
+ \cleardoublepage%
+ \adjustwidth{\@declarationextramargin}{\@declarationextramargin}%
+ \vspace*{\@frontmattertopskip}%
+ \begin{center}%
+ \begingroup
+ \ifx\@sftitles\@empty\else\sffamily\fi
+ {\LARGE\textbf{Declaration}}%
+ \endgroup
+ \end{center}%
+ \vspace*{1cm}%
+}{%
+ %\newline \newline \newline%
+ %\begin{flushright}
+ % \thesisauthor\newline
+ % \today\newline
+ %\end{flushright}
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Environment for thesis abstract in frontmatter
+%% (argument is the thesis title)
+\newenvironment{abstract}[1][Abstract]{%
+ \adjustwidth{\@abstractextramargin}{\@abstractextramargin}%
+ \cleardoublepage%
+ \vspace*{\@frontmattertopskip}%
+ \begin{center}%
+ \begingroup
+ \ifx\@sftitles\@empty\else\sffamily\fi
+ {\LARGE\textbf{#1}}%
+ \endgroup
+ \end{center}%
+ \vspace*{1cm}%
+}{%
+ \endadjustwidth%
+ \ignorespacesafterend%
+}
+
+
+%% Deprecated: combined command for defining the title and author in the preamble
+%% TODO Remove in 1.5
+\DeclareRobustCommand{\definethesis}[2]{%
+ \typeout{hepthesis: definethesis macro is deprecated. Use author and title macros instead.}
+ \author{#1}%
+ \title{#2}%
+}
+
+
+%% Makes a thesis title page
+\let\@oldtitlepage\titlepage
+\let\@oldendtitlepage\endtitlepage
+\DeclareRobustCommand{\titlepage}[2][]{%
+ %\@oldtitlepage%
+ \thispagestyle{empty}%
+ \begingroup%
+ \ifx\@sftitles\@empty\else\sffamily\fi%
+ \begin{center}%
+ \vspace*{\frontmattertitleskip}%
+ \begin{doublespace}%
+ {\Huge\textbf{\thetitle}}\\%
+ \end{doublespace}%
+ \vspace*{3cm}%
+ {\Large{{\theauthor} \\ {#1}}}\\%
+ \vspace*{8cm}%
+ {#2}%
+ \end{center}%
+ \endgroup%
+ %\@oldendtitlepage%
+ %\cleardoublepage%
+}
+\renewcommand{\maketitle}[1]{\titlepage{}}
+
+
+%% A quote on its own page
+\newlength{\@oldparindent}
+\setlength{\@oldparindent}{\parindent}
+\DeclareRobustCommand{\pagequote}[3][same]{%
+ \cleardoublepage%
+ \vspace*{\stretch{2}}%
+ \thispagestyle{empty}%
+ % \thispagestyle{plain}%
+ % \pagestyle{plain}%
+ \begin{center}%
+ \begin{varwidth}{\textwidth}%
+ \def\@samelang{same}%
+ \def\@reqlang{#1}%
+ \ifx\@samelang\@reqlang%
+ \noindent\textsl{\enquote{\hspace{0.1ex}#2}}%
+ \else%
+ \noindent\textsl{\foreignquote{\@reqlang}{\hspace{0.1ex}#2}}%
+ \fi%
+ \newline%
+ \setlength{\parindent}{\@oldparindent}
+ \indent --- {#3}%
+ \end{varwidth}%
+ \end{center}%
+ \vspace*{\stretch{4}}%
+ \if@twoside\clearpage\fi%
+ \thispagestyle{plain}%
+}
+%% Alias
+\let\frontquote\pagequote
+
+
+%% A quote on its own page
+\DeclareRobustCommand{\dedication}[1]{%
+ \cleardoublepage%
+ \vspace*{\stretch{2}}%
+ \thispagestyle{plain}%
+ \pagestyle{plain}%
+ \begin{center}%
+ \begin{varwidth}{\textwidth}%
+ \noindent\textsl{\enquote{#1}}%
+ \end{varwidth}%
+ \end{center}%
+ \vspace*{\stretch{4}}%
+ %\cleardoublepage%
+ \pagestyle{plain}%
+}
+
+
+%% Environment for colophon in backmatter
+\newenvironment{colophon}{%
+ \chapter*{Colophon}%
+ \@mkboth{\MakeUppercase{Colophon}}{\MakeUppercase{Colophon}}%
+}{%
+ \ignorespacesafterend %
+}
+
+
+%% Typesets a chapter quote
+\DeclareRobustCommand{\chapterquote}[3][same]{%
+ \def\@samelang{same}%
+ \def\@reqlang{#1}%
+ \begin{adjustwidth}{}{3cm}%
+ \ifx\@samelang\@reqlang%
+ \noindent\emph{\enquote{#2}}%
+ \else%
+ \noindent\emph{\foreignquote{\@reqlang}{#2}}%
+ \fi%
+ \newline%
+ \indent --- #3%
+ \end{adjustwidth}%
+ \vspace{1cm}%
+}
+
+%% Typesets the first para of a chapter slightly differently
+%% (I don't use it, so maybe it needs some work)
+\newenvironment{chapterintro}[1][blah]{%
+ %\begingroup
+ \def\thearg{#1}%
+ \def\sans{sf}%
+ \def\italic{it}%
+ \def\sansit{sfit}%
+ \ifx\thearg\sans%
+ \sffamily%
+ \else%
+ \ifx\thearg\italic%
+ \itshape%
+ \else%
+ \ifx\thearg\sansit%
+ \sffamily%
+ \itshape%
+ \fi\fi\fi%
+}{%
+ \ignorespacesafterend%
+ %\endgroup
+}
+
+%% Bold inline section heading with a finishing colon
+\DeclareRobustCommand{\verysubsection}[1]{{\noindent\textbf{#1:}}}
+
+%% Table environment
+\let\@oldtable\table
+\let\@oldendtable\endtable
+\renewenvironment{table}[1][tbp]{%
+ \vspace{0.4cm}%
+ \@oldtable[#1]%
+ \begin{center}%
+}{%
+ \end{center}%
+ \@oldendtable%
+ \ignorespacesafterend%
+}
+
+%% Figure environment
+\let\@oldfigure\figure
+\let\@oldendfigure\endfigure
+\renewenvironment{figure}[1][tbp]{
+ \@oldfigure[#1]%
+ \begin{center}%
+}{%
+ \end{center}%
+ \@oldendfigure%
+ \ignorespacesafterend%
+}
+
+%% Figure* environment (lots of \expandafter and \csname gubbins reqd... *sigh*)
+\expandafter\let\expandafter\@oldfigurestar \csname figure*\endcsname
+\expandafter\let\expandafter\@oldendfigurestar \csname endfigure*\endcsname
+\renewenvironment{figure*}[1][tbp]{
+ \@oldfigurestar[#1]%
+ \begin{center}%
+}{%
+ \end{center}%
+ \@oldendfigurestar%
+ \ignorespacesafterend%
+}
+
+%% Sideways figure environment
+\let\@oldsidewaysfigure\sidewaysfigure
+\let\@oldendsidewaysfigure\endsidewaysfigure
+\renewenvironment{sidewaysfigure}[1][tbp]{
+ \@oldsidewaysfigure[#1]%
+ \begin{center}%
+}{%
+ \end{center}%
+ \@oldendsidewaysfigure%
+ \ignorespacesafterend%
+}
+
+
+% %% ``Thesis''-prefixed duplicate commands and environments (deprecated)
+% \newcommand{\thesistypeout}{\typeout{hepthesis: thesis- prefix commands are deprecated and will be removed from hepthesis v1.5 onwards}}
+% \newenvironment{thesistable}{\thesistypeout\table}{\endtable\ignorespacesafterend}
+% \newenvironment{thesistabular}{\thesistypeout\tabular}{\endtabular\ignorespacesafterend}
+% \newenvironment{thesisfigure}{\thesistypeout\expandafter\let\expandafter\@oldoldfigurestar \csname figure*\endcsname \@oldoldfigurestar}%
+% {\expandafter\let\expandafter\@oldoldendfigurestar \csname endfigure*\endcsname \@oldoldendfigurestar \ignorespacesafterend}
+% \newenvironment{thesissidewaysfigure}{\thesistypeout\sidewaysfigure}{\endsidewaysfigure\ignorespacesafterend}
+% \newenvironment{thesisdisplaymath}{\thesistypeout\displaymath}{\enddisplaymath\ignorespacesafterend}
+% \newenvironment{thesisdisplaymath*}{\thesistypeout\expandafter\let\expandafter\@oldolddisplaymathstar \csname displaymath*\endcsname \@oldolddisplaymathstar}%
+% {\expandafter\let\expandafter\@oldoldenddisplaymathstar \csname enddisplaymath*\endcsname \@oldoldenddisplaymathstar \ignorespacesafterend}
+% \newenvironment{thesisequation}{\thesistypeout\equation}{\endequation\ignorespacesafterend}
+% \newenvironment{thesisequation*}{\thesistypeout\expandafter\let\expandafter\@oldoldequationstar \csname equation*\endcsname \@oldoldequationstar}%
+% {\expandafter\let\expandafter\@oldoldendequationstar \csname endequation*\endcsname \@oldoldendequationstar \ignorespacesafterend}
+% \newenvironment{thesisdeclaration}{\thesistypeout\declaration}{\enddeclaration\ignorespacesafterend}
+% \newenvironment{thesisabstract}[1][Abstract]{\thesistypeout\abstract[#1]}{\endabstract\ignorespacesafterend}
+% \newenvironment{thesischapterintro}[1]{\thesistypeout\chapterintro{#1}}{\endchapterintro\ignorespacesafterend}
+% \newenvironment{thesispreface}{\thesistypeout\preface}{\endpreface\ignorespacesafterend}
+% \newenvironment{thesisacknowledgements}[1]{\thesistypeout\acknowledgements}{\endacknowledgements\ignorespacesafterend}
+% \newenvironment{thesisfrontmatter}{\thesistypeout\frontmatter}{\ignorespacesafterend}
+% \newenvironment{thesismainmatter}{\thesistypeout\mainmatter}{\ignorespacesafterend}
+% \newenvironment{thesisbackmatter}{\thesistypeout\backmatter}{\ignorespacesafterend}
+% \DeclareRobustCommand{\thesistitlepage}[2][]{\thesistypeout\titlepage{#1}{#2}}
+% \DeclareRobustCommand{\thesisfrontquote}[2]{\thesistypeout\frontquote{#1}{#2}}
+% \DeclareRobustCommand{\thesischapterquote}[2]{\thesistypeout\chapterquote{#1}{#2}}
+% \DeclareRobustCommand{\thesisverysubsection}[1]{\thesistypeout\verysubsection{#1}}
+
+%% In-document references
+\DeclareRobustCommand{\Chapter}{Chapter\xspace}
+\DeclareRobustCommand{\Section}{Section\xspace}
+\DeclareRobustCommand{\Appendix}{Appendix\xspace}
+\DeclareRobustCommand{\Figure}{Figure\xspace}
+\DeclareRobustCommand{\Table}{Table\xspace}
+\DeclareRobustCommand{\Equation}{equation\xspace}
+\DeclareRobustCommand{\Reference}{reference\xspace}
+%% Standard way to refer to a page number
+\DeclareRobustCommand{\Page}{page\xspace}
+
+%% Reference terms with built-in reference
+\DeclareRobustCommand{\ChapterRef}[1]{\Chapter~\ref{#1}}
+\DeclareRobustCommand{\SectionRef}[1]{\Section~\ref{#1}}
+\DeclareRobustCommand{\AppendixRef}[1]{\Appendix~\ref{#1}}
+\DeclareRobustCommand{\FigureRef}[1]{\Figure~\ref{#1}}
+\DeclareRobustCommand{\TableRef}[1]{\Table~\ref{#1}}
+\DeclareRobustCommand{\EquationRef}[1]{\Equation~\eqref{#1}}
+\DeclareRobustCommand{\ReferenceRef}[1]{\Reference~\cite{#1}}
+\DeclareRobustCommand{\PageRef}[1]{\Page~\pageref{#1}}
diff --git a/macros/latex/contrib/hepthesis/hepthesis.pdf b/macros/latex/contrib/hepthesis/hepthesis.pdf
new file mode 100644
index 0000000000..c6a6f48b0b
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/hepthesis.pdf
Binary files differ
diff --git a/macros/latex/contrib/hepthesis/hepthesis.tex b/macros/latex/contrib/hepthesis/hepthesis.tex
new file mode 100644
index 0000000000..b4c34eff91
--- /dev/null
+++ b/macros/latex/contrib/hepthesis/hepthesis.tex
@@ -0,0 +1,897 @@
+\documentclass[12pt]{article}
+\usepackage{mathpazo}
+\usepackage{maybemath,xspace,setspace,fancybox,fancyvrb}
+\usepackage{a4wide,url,relsize,underscore}
+\usepackage[colorlinks=true,bookmarks=true]{hyperref}
+\newcommand{\maybemath}{\texttt{maybemath}\xspace}
+\newcommand{\hepthesis}{\texttt{hepthesis}\xspace}
+
+\onehalfspacing
+\DefineShortVerb{\|}
+\setlength{\fboxsep}{10pt}
+\addtolength{\fboxrule}{0.6\fboxrule}
+
+\newcommand{\hepthesisversion}{v1.5.2}
+\author{Andy Buckley, \texttt{andy@insectnation.org}}
+\title{hepthesis \hepthesisversion \\ \smaller A class for typesetting academic theses}
+
+%% Bold tt font
+\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
+
+\newcommand{\Or}{\texorpdfstring{\ensuremath{\vert}\xspace}{or}}
+\newcommand{\manifestsAs}{\texorpdfstring{\ensuremath{\Rightarrow\quad}\xspace}{->}}
+\newcommand{\texcmd}[1]{\texorpdfstring{\texttt{\char`\\#1}}{#1}}
+\newcommand{\texenv}[1]{\texorpdfstring{\texttt{#1}}{#1}}
+\newcommand{\texopt}[1]{\texorpdfstring{\texttt{#1}}{#1}}
+\newcommand{\texarg}[1]{\texorpdfstring{\texttt{\{#1\}}}{\textbraceleft#1\textbraceright}}
+\newcommand{\texargoptgen}[1]{\texorpdfstring{\texttt{[}\gen{#1}\texttt{]}}{\textbraceleft<#1>\textbraceright}}
+\newcommand{\texarggen}[1]{\texorpdfstring{\texttt{\{}\gen{#1}\texttt{\}}}{\textbraceleft<#1>\textbraceright}}
+\newcommand{\gen}[1]{\ensuremath{\langle\text{\mdseries\itshape#1\/}\rangle}}
+\newcommand{\texpkg}[1]{#1}
+\newcommand{\texoption}[1]{\texopt{#1}}
+
+\newenvironment{snippet}{\Verbatim}{\endVerbatim}
+\newenvironment{fsnippet}%
+ {\VerbatimEnvironment
+ \begin{Sbox}\begin{minipage}{0.82\textwidth}\begin{Verbatim}}%
+ {\end{Verbatim}\end{minipage}\end{Sbox}
+ \setlength{\fboxsep}{12pt}\vspace*{4mm}\newline\fbox{\TheSbox}\vspace{4mm}\par\noindent}
+
+% \newenvironment{snippet}%
+% {\begin{minted}{latex}}{\end{minted}}
+% \newenvironment{fsnippet}%
+% {\begin{Sbox}\begin{minipage}{0.82\textwidth}\begin{minted}{latex}}%
+% {\end{minted}\end{minipage}\end{Sbox}
+% \setlength{\fboxsep}{12pt}\vspace*{4mm}\newline\fbox{\TheSbox}\vspace{4mm}}
+
+\begin{document}
+{\larger[3] \sffamily \bfseries \maketitle}
+
+\abstract{%
+ The \hepthesis class provides an attractive framework in which to write a PhD
+ or Masters' degree dissertation. The commands provided by this package permit
+ most structural aspects of the thesis to be defined more or less semantically,
+ rather than in terms of raw text sizings and position shifts.
+}
+
+
+\section{Introduction}
+When I began my PhD in 2001, I was surprised to find that there was no standard
+\LaTeX{} thesis class used by students in my field (\emph{h}igh-\emph{e}nergy
+\emph{p}article physics, hence the ``hep''). In retrospect, this is not so
+surprising --- research groups often have an informal system of handing down
+slightly tailored thesis templates (complete with in line \texcmd{vspace}s,
+\texcmd{Huge}s and all the rest) through generations of students without ever
+formalising the style and attempting to do it ``properly''.
+
+By the time it came to write my own thesis it was obvious that I would only
+retain my sanity through measures of extreme procrastination and so this package
+came to be. It has now been edited and hacked on and off since roughly mid-2004,
+taking stylistic features from other theses that I've thought attractive and
+adding features based on my own pickiness and user requests. The typography
+isn't motivated by any formal understanding of the subject, though, so I'm sure
+there's still plenty of room for improvement.
+
+This document documents the structure of \hepthesis and how to make it work
+with you rather than against you. I may be unable to resist including other
+hints and tips on how to make your thesis-writing go smoothly. Please contact me
+with suggested improvements, either to the package or to this documentation.
+
+
+\section{Features}
+Why would you want to use \hepthesis? Here's a list of features, so you can
+decide for yourself:
+
+\begin{itemize}
+\item Semantic macros for defining the front page, abstract, preface, acknowledgements, etc.
+\item Macros for quotes, including a full-page quote and chapter-wise quotes
+\item Attractive header and footer structures
+\item Pre-set margins suitable for binding or for screen viewing
+\item Nicely (re-)defined figure, table and equation environments
+\item Optional mode for generating hyper-links when building PDF files
+\item Built-in draft copy mode with line numbering
+\item Maths in section titles etc. will automatically be boldened if appropriate
+\end{itemize}
+
+
+\section{Recommended usage}
+The basic usage mode for \hepthesis is to place
+%
+\begin{snippet}
+\documentclass{hepthesis}
+\end{snippet}
+%
+in the preamble of your document. This will then set up the document's appearance and
+provide the \hepthesis macros as do the standard \LaTeX{} classes like |article|
+and |report|. A more sophisticated and flexible approach is described in
+Appendix~\ref{app:DerivedClass}.
+
+Although strictly unrelated to \hepthesis, it is usual to write each thesis
+chapter as a separate |.tex| file and to include it with
+\texcmd{include} or \texcmd{input}. You may find it useful to set your
+|LATEXINPUTS| environment variable to ensure that the \texcmd{input}'d
+files are found by \LaTeX.
+
+\hepthesis takes several optional arguments. Personally, I use
+%
+\begin{snippet}
+\documentclass[hyperpdf,bindnopdf]{hepthesis}
+\end{snippet}
+%
+which produces page-centered, hyper-linked PDF files and PostScript files with
+margins suitable for binding and no hyper-links, depending on whether you build
+the document using |latex| or |pdflatex|. The details of the \hepthesis options
+are described in Section~\ref{sec:Options} of this document.
+
+
+\section{Requirements}
+As \hepthesis aims to allow produce a fairly final version of a thesis without
+much additional tweaking, there are quite a few required packages. Most should
+be natively available in your \TeX{} distribution; the rest from CTAN.
+
+Here's the mandatory packages:
+\begin{itemize}
+\item \textbf{scrbook\,\cite{scrbook}} (from KOMA-scripts)
+\item \textbf{setspace\,\cite{setspace}}
+\item \textbf{fancyhdr\,\cite{fancyhdr}}
+\item \textbf{rotating\,\cite{rotating}}
+\item \textbf{comment\,\cite{comment}}
+\item \textbf{tocbibind\,\cite{tocbibind}}
+\item \textbf{caption\,\cite{caption}}
+\item \textbf{changepage\,\cite{changepage}}
+\item \textbf{varwidth\,\cite{varwidth}}
+\end{itemize}
+
+\vspace{0.4cm}
+\noindent\fbox{\begin{minipage}{0.85\textwidth}\textsl{
+%
+Note that the \texpkg{subfig}\,\cite{subfig} (previously \texpkg{subfigure})
+and \texpkg{ccaption}\,\cite{ccaption} packages, which were required up to
+version 1.3, are no longer needed.
+If you need sub-figures then you should \texcmd{usepackage} the package as
+usual in your document preamble or custom class file, and make use of the
+\texcmd{ContinuedFloat} command for continuation captions, which is
+provided by the mandatory \texpkg{caption} package.
+%
+}\end{minipage}}
+\vspace{0.4cm}
+
+Additionally, there are several packages which are only required depending on
+the class options:
+
+\begin{itemize}
+%\item \textbf{cite\,\cite{cite}}
+\item \textbf{csquotes\,\cite{csquotes}:} very standard. Quotation commands will use this if loaded.
+\item \textbf{babel\,\cite{babel}:} very standard. Quotation commands will use this if loaded.
+\item \textbf{a4wide\,\cite{a4wide}:} very standard. Disabled with any paper size option other than |a4paper|
+\item \textbf{amsmath\,\cite{amsmath}:} very, \emph{very} standard. Disabled with the |noams| option
+\item \textbf{hyperref\,\cite{hyperref}:} very standard. Enabled with the |hyper| option
+\item \textbf{booktabs\,\cite{booktabs}:} very standard. Disable with the |nobooktabs| option
+\item \textbf{draftcopy\,\cite{draftcopy}:} very standard. Enable with the |draft| option
+\item \textbf{lineno\,\cite{lineno}:} non-standard (?). Enable with the |draft| option
+\item \textbf{titling\,\cite{titling}:} non-standard (?). Enable with the |titling| option
+\end{itemize}
+
+Some other handy packages (which aren't required at all for compatibility with
+|hepthesis| but may well help you to write your thesis) are summarised in
+Section~\ref{sec:ExtraPackages}.
+
+\subsection{Troublesome interactions}
+Unfortunately not all \LaTeX{} packages get on well with each other --- if
+you are unlucky then you may get some of \TeX's wondertully cryptic error
+messages on trying to use \texpkg{hepthesis}. Here are the problems that I'm
+aware of\dots
+
+\begin{itemize}
+\item
+If you have problems with \LaTeX{} complaining about bad definitions of
+\texcmd{pdfstringdefPreHook}, you may be using an old version of \texpkg{csquotes},
+which doesn't interface well to \texpkg{hyperref}. I think this is fixed in
+\texpkg{csquotes} version 3.2 and later --- it certainly works for version
+3.7. Try including the \texpkg{csquotes} package with
+%
+\begin{snippet}
+\usepackage{csquotes}[2007/03/25]
+\end{snippet}
+%
+so that sufficiently recent version will be used.
+
+\item
+Similarly, version 0.9 of the \texpkg{varwidth} package has a deformed version
+string which means that the package doesn't load properly. This version seems to
+have made its way into some \LaTeX{} package distributions, so if you see such
+an error then version 0.9a or later can be obtained from CTAN and will work
+properly. \texpkg{hepthesis} will check to make sure that the version is as
+required and issue a warning if the version on your system is earlier than those
+known to be good.
+
+\end{itemize}
+
+
+\section{Class options}
+\label{sec:Options}
+
+\subsection{\texopt{oneside} \Or \texopt{twoside}}
+Typeset the thesis for printing in one- or two-sided format: for example, you
+may wish to present preview and draft copies in two-sided format, but the final
+submission may be required to be single-sided. Changing to single-sided form
+will remove the blank facing pages and only use the margins and header/footer
+format specified for right-hand pages.
+
+\subsection{\texopt{bind} \Or \texopt{nobind} \Or \texopt{bindnopdf}}
+Set the margins to be suitable for printing or screen-viewing. Using the
+\texopt{bind} option produces larger inner margins, so that left- and
+right-facing pages have LR-reflection symmetry. Using the \texopt{nobind}
+option makes the margins equal, so that the pages don't jump around when you
+flick through them in |gv| or Adobe Acrobat. The \texopt{bindnopdf} option
+will use binding margins when making a PostScript document and screen-view
+margins when building a PDF. Note that this option requires some carefulness
+with the |.aux| files: this is described in Appendix \ref{app:AuxFileProblem}.
+
+\subsection{\texopt{ams} \Or \texopt{noams}}
+Make use of the AMS mathematical package. This re-defines several \hepthesis
+mathematical environments using more powerful macros and is enabled by default.
+If you don't plan on having any maths in your thesis, then disabling this option
+may speed up your build-time a little.
+
+\subsection{\texopt{alphafoot}}
+Use alphanumeric footnote markers.
+
+\subsection{\texopt{hidefront} \Or \texopt{hideback} \Or \texopt{hidefrontback}}
+Useful for draft builds, these options respectively hide the front matter, the
+back matter or both from the \LaTeX{} compilation, giving a faster build time
+and meaning you don't have to flick through 20 pages of garbage before
+proof-checking the first real content. Note that hiding the back matter will
+fail to include the bit where you generate your bibliography, so unless you make
+a work-around, all your citations will break.
+
+\subsection{\texopt{draft}}
+Prints ``DRAFT'' diagonally across the pages and numbers the lines, suitable for
+proof-reading. This makes use of the standard |draftcopy| and the less-standard
+|lineno| packages.
+
+\subsection{\texopt{sftitles}}
+Uses a sans-serif font for the title page and all chapter, section and
+subsection headings.
+
+\subsection{\texopt{rmtitles}}
+Uses a serif (roman) font for the title page and all chapter, section and
+subsection headings (this is the default).
+
+\subsection{\texopt{booktabs} \Or \texopt{nobooktabs}}
+Use the |booktabs| package to define the \hepthesis tabular environment.
+|booktabs| produces publication quality tables, as opposed to \TeX's rather
+ropey defaults, and so this option is enabled by default. You can disable it if
+your thesis doesn't have any tables and get a slightly faster build, but it is
+strongly encouraged that any table presentation uses the |booktabs| look and
+feel because it's so much better!
+
+\subsection{\texopt{hyper}}
+The |hyper| option is used to activate the |hyperref| package, with some reasonably
+sensible default options. Essentially, it's equivalent to putting
+%
+\begin{snippet}
+\usepackage[colorlinks=true,pdfpagemode=FullScreen, \
+ bookmarks=true]{hyperref}
+\end{snippet}
+%
+in the preamble of your document.
+
+\subsection{\texopt{hyperpdf}}
+|hyperpdf| has the effect of the |hyper| option when building PDF output, and no
+effect at all if building PostScript. This can be handy if you consider the PDFs
+to be for screen-reading purposes and the PS for printing: you probably don't
+want to print a version where all the references and URLs are coloured! Note
+that this option requires some carefulness with the |.aux| file, since
+alternating between PS and PDF builds involves repeatedly writing and removing
+hyperref tokens. A solution to this is described in Appendix \ref{app:AuxFileProblem}.
+
+\subsection{\texopt{index}}
+Include the |makeidx| package, to allow an index to be built. Note that you have
+to do this by hand and that it's probably best done as a retrospective feature
+after you've written the thesis. Not many people want to spend \emph{more} time
+with their thesis when they've done enough to pass!
+
+\subsection{\texopt{titling}}
+Use the |titling| package to redefine the \texcmd{title} and \texcmd{author}
+commands so that their arguments are available through the document as
+\texcmd{thetitle} and \texcmd{theauthor}. This is used, for example, by the
+\texcmd{titlepage} command. If this option isn't passed, a more basic attempt is
+made to do this definition without needing an external package. It's unclear
+whether titling really helps but there may be complicated cases (such as those
+where the author includes a \texcmd{thanks}) where |titling| may do a better
+job. This is untested, though, and the result of using \texcmd{thanks} in a
+|hepthesis| document is to be considered undefined.
+
+\subsection{\texopt{a4paper} \Or \texopt{a4narrow} \Or \texopt{letterpaper} \Or \dots}
+Choose the paper size. Duh.
+
+
+\section{Environments and commands}
+The \hepthesis environments and commands are a mix of new macros and tweaked
+versions of existing standard ones. The ones that re-define standard macros
+can't be disabled (at least, not in this version), so if you don't like them
+then you can either hack \hepthesis to be the way you'd like (preferably in a
+nice way which I can integrate into a future release) or use something else. The
+choice is yours!
+
+Here are the environments and commands, roughly in the order that you'd use them:
+
+\subsection{\texcmd{set{\dots}spacing}\texarggen{spacing}}
+A selection of spacing commands are available to change the overall line spacing
+of the thesis, or to change the spacing within specific document sections if for
+some reason you want to do that. (Personally, I wouldn't --- inconsistent spacing
+is very disconcerting.) Here are the available commands, explicitly:
+\begin{itemize}
+\item \texcmd{setspacing} --- set the following spacings all at once;
+\item \texcmd{setfrontmatterspacing}
+\item \texcmd{setmainmatterspacing}
+\item \texcmd{setappendixspacing}
+\item \texcmd{setbackmatterspacing}
+\end{itemize}
+%
+Each command takes a single argument, which can take the values |single|,
+|onehalf| and |double|, for single spacing, one-and-a-half spacing
+and double spacing respectively. The default is |onehalf|, since I think
+that looks most elegant. If making a draft version, double spacing might be
+useful since it leaves a bit of room for annotations. I can't recommend single
+spacing --- it just looks cramped.
+%
+\begin{fsnippet}
+\documentclass[...]{hepthesis}
+\setmainmatterspacing{double}
+...
+\begin{document}
+ ...
+\end{fsnippet}
+
+
+\subsection{\texcmd{set{\dots}extramargins}\texarggen{length}}
+A selection of commands are available to change the text width on a per-section
+basis. These shouldn't be tweaked too much, but in case you need it, the ability
+for configuration is available. The text width itself is not explicitly
+specified --- instead the commands take as an argument the width to be added to
+both margins. Unless explicitly specified below, all these lengths are zero by
+default so any use of these commands with a positive argument is likely to
+reduce the text width. Here are the ``large-scale'' extra margins commands:
+%
+\begin{itemize}
+\item \texcmd{setextramargins}\texarggen{len} --- set the following lengths all at once;
+\item \texcmd{setfrontmatterextramargins}\texarggen{len}
+\item \texcmd{setmainmatterextramargins}\texarggen{len}
+\item \texcmd{setappendixextramargins}\texarggen{len}
+\item \texcmd{setbackmatterextramargins}\texarggen{len}
+\end{itemize}
+%
+The following commands all add extra margin widths to subsections within the
+front matter. Note that they apply \emph{in addition} to the front matter length.
+%
+\begin{itemize}
+\item \texcmd{setabstractextramargins}\texarggen{len} --- |1.5cm| by default;
+\item \texcmd{setdeclarationextramargins}\texarggen{len} --- |1.5cm| by default;
+\item \texcmd{setacknowledgementsextramargins}\texarggen{len}
+\item \texcmd{setprefaceextramargins}\texarggen{len}
+\end{itemize}
+%
+Each command takes a single argument, which is just a \TeX{} length. Here's an example:
+\nobreak
+%
+\begin{fsnippet}
+\documentclass[...]{hepthesis}
+\setfrontmatterextramargins{1.5}
+...
+\begin{document}
+ ...
+\end{fsnippet}
+
+
+%% TODO Change in v1.5
+\subsection{\texcmd{title}\texarggen{title} and \texcmd{author}\texarggen{author}}
+The usual commands for setting the author and title. Don't use \texcmd{thanks} in
+the \hepthesis author argument: the results are undefined!
+%
+\begin{fsnippet}
+\title{A study of \BToKPi decays with the \LHCb experiment}
+\author{Andrew Gordon Buckley}
+...
+\begin{document}
+ ...
+\end{fsnippet}
+
+Once these commands have been executed, the title and author strings are available
+via the \texcmd{thetitle} and \texcmd{theauthor} commands. These are used by
+\texcmd{titlepage}.
+
+N.B. Up to version 1.3, a special \texcmd{definethesis} command was used to specify
+the thesis author and title. While this is still retained for backwards compatibility,
+it is deprecated and you should use the standard \texcmd{title} and \texcmd{author}
+macros instead. \textbf{\texcmd{definethesis} will be removed in version 1.5}
+
+
+\subsection{\texenv{frontmatter}, \texenv{mainmatter}, \texenv{appendices} and \texenv{backmatter} environments}
+Use these to delimit the auxiliary parts of your thesis from the main feature
+(being all that clever work you spent years working on). In practice, these
+commands change the page-numbering style and set/reset some section counters
+appropriately: the frontmatter and backmatter environments will not use chapter
+numbering but will insert the un-numbered chapter titles in the table of
+contents. Note that this means appendices should be placed in the appendices
+environment between mainmatter and backmatter, rather than in the back matter
+itself, which is intended for such things as the bibliography, colophon etc.
+
+\subsection{\texcmd{titlepage}}
+The \texcmd{titlepage} macro generates a title page for the thesis and as such
+should probably be the first item in the front matter. It takes two arguments:
+an optional elaboration of the author name and the description of the award for
+which the thesis is being submitted. You may need to use a different macro if
+your institution has a very different prescribed format for the layout of thesis
+title pages: in such a case, the \texcmd{theauthor} and \texcmd{thetitle}
+commands will probably be useful. Here's an example of usage:
+%
+\begin{fsnippet}
+\titlepage[of \\ Churchill College]%
+{A dissertation submitted to the University of Cambridge\\
+for the degree of Doctor of Philosophy}
+\end{fsnippet}
+%
+Additionally, the \texcmd{maketitle} command has been redefined to behave as
+\texcmd{titlepage} with two empty arguments. This is only provided to not
+confuse users who convert to |hepthesis| from a standard \LaTeX{} class and
+expect \texcmd{maketitle} to work: \texcmd{titlepage} is a more powerful
+command and should be used by those who are aware of it. That includes you!
+
+\subsection{\texenv{abstract} environment}
+Where you present the summary of your thesis: this should be within the
+\texenv{frontmatter} environment. The \texenv{abstract} environment takes one
+optional argument, which will be the heading above the abstract. If this isn't
+specified, the heading will simply be ``Abstract''. This may be useful for
+providing a stand-alone summary page, with a snippet like:
+%
+\begin{fsnippet}
+\begin{abstract}%
+ [\smaller\thetitle\\ \vspace*{1cm} \smaller{\theauthor}]
+\thispagestyle{empty}
+This thesis describes all the really cool work I did on...
+\end{abstract}
+\end{fsnippet}
+
+\subsection{\texenv{declaration} environment}
+Where you declare that the thesis was all your own work, lies within word
+limits, etc. Use it in the front matter area, of course, with something like
+%
+\begin{fsnippet}
+\begin{declaration}
+ This dissertation is the result of my own work...
+ \vspace*{1cm}
+ \begin{flushright}
+ Andy Buckley
+ \end{flushright}
+\end{declaration}
+\end{fsnippet}
+
+\subsection{\texenv{acknowledgements} environment}
+A nice little environment for putting all those gushing thank-you's (and the
+obligatory thanks to a supervisor). Use it (in the front matter again) like:
+%
+\begin{fsnippet}
+\begin{acknowledgements}
+ Of the many people who deserve thanks, some are
+ particularly prominent, for example...
+\end{acknowledgements}
+\end{fsnippet}
+
+\subsection{\texenv{preface} environment}
+Here's where you summarise the structure of the thesis to come, just before the
+main matter starts, with something like:
+%
+\begin{fsnippet}
+\begin{preface}
+ This thesis describes my research on various aspects of...
+\end{preface}
+\end{fsnippet}
+
+\subsection{\texcmd{dedication}\texarggen{text}}
+Dedicate your thesis to someone/something:
+%
+\begin{fsnippet}
+\begin{mainmatter}
+ \dedication{For Jo}
+ ...
+ \end{frontmatter}
+\end{fsnippet}
+
+
+\subsection{\texcmd{frontquote}\texargoptgen{lang}\texarggen{quote}\texarggen{who}}
+Use this at the start of the main matter if you want to present the ethos of
+your thesis in a few choice words, for example:
+%
+\begin{fsnippet}
+ \frontquote%
+ {Writing in English is the most ingenious torture\\
+ ever devised for sins committed in previous lives.}%
+ {James Joyce}
+ ...
+ \end{frontmatter}
+\end{fsnippet}
+%
+\texcmd{frontquote} also takes an optional argument indicating which language the
+quote is in. This will change the quotation mark and hyphenation styles, if the
+\texpkg{babel} and \texpkg{csquotes} packages are loaded:
+%
+\begin{fsnippet}
+ \frontquote[french]%
+ {Le savant n'\'etudie pas la nature parce que cela est utile; \\
+ il l'\'etudie parce qu'il y prend plaisir et il y prend plaisir
+ parce qu'elle est belle.}%
+ {Henri Poincar\'e, 1854--1912}
+ ...
+ \end{frontmatter}
+\end{fsnippet}
+
+\subsection{\texcmd{chapterquote}\texargoptgen{lang}\texarggen{quote}\texarggen{who}}
+Something flippant/emotive to put at the start of chapters:
+%
+\begin{fsnippet}
+\chapter{\CP violation in the \Bmeson system}
+\label{chap:basictheory}
+\chapterquote{Laws were made to be broken.}%
+ {Christopher North 1785--1854}
+ ...
+\end{fsnippet}
+%
+As for \texcmd{frontquote}, an optional language argument can be used.
+
+\subsection{\texenv{colophon} environment}
+A colophon is an inscription placed at the end of a book or other work that
+talks about how the work was created and what things were used in its creation.
+This should go in the back matter of your thesis and is completely
+optional. Frankly, I've only ever seen them in O'Reilly tech books (and my own
+thesis, of course). If you use this, please mention \hepthesis' r\^ole in
+making your thesis! Here's an example:
+%
+\begin{fsnippet}
+ \begin{backmatter}
+ \begin{colophon}
+ This thesis was made with ``hepthesis'' and it blew my mind...
+ \end{colophon}
+ ...
+\end{fsnippet}
+
+
+\subsection{\texenv{table} environment}
+Tables --- use like any other table (probably combined with the tabular
+environment). It has been slightly modified to be horizontally centered and have
+an slightly increased vertical spacing at the top. It supports the standard
+\LaTeX{} ``[!htbp]'' float placement specifiers.
+
+\subsection{\texenv{tabular} environment}
+If the |booktabs| package is used (enabled by default), then the tabular
+environment is re-defined to have a horizontal bar at top and bottom, which
+looks much nicer than \TeX's default tables.
+
+\subsection{\texenv{figure} and \texenv{sidewaysfigure} environments}
+The \texenv{figure}, \texenv{figure*} and \texenv{sidewaysfigure} environments
+are re-defined to be automatically centered. They support the standard \LaTeX{}
+``[!htbp]'' float placement specifiers.
+
+\subsection{\texenv{equation} and \texenv{displaymath} environments}
+These environments and their starred versions are re-defined so that
+\texenv{equation} behaves like the normal \texenv{displaymath} environment. If
+the AMS package is used (which it is by default) then both are redefined to use
+the AMS \texenv{align} environment, which is much more powerful: it supports
+more intelligent label-placement, sub-equations and boasts a better alignment
+syntax than the default \LaTeX{} displayed math environments. The AMS re-defined
+\texenv{equation} is suitable for most purposes --- \emph{all} my purposes, in
+fact.
+
+\subsection{\texcmd{verysubsection}\texarggen{title}}
+A little command for in-line mini section headings, consisting of a boldened
+phrase specified by the argument, a bold colon and a space. Just for
+convenience, really, when all you want to do is label a paragraph without
+incurring all the vertical space of \texcmd{subsubsub...subsection}s. Use it
+like:
+%
+\begin{fsnippet}
+\verysubsection{\Tevatron Run II experiments}
+Since 1983 and until the commissioning of the \LHC is complete...
+\end{fsnippet}
+
+\subsection{Semantic figure widths}
+Rather than specifying figure widths in raw terms, like centimetres, or document
+parameters like \texcmd{textwidth}, it's nice to be able to have a more semantic
+reference. Having a few standard width also helps to keep things looking
+consistent through the document. For these reasons, |hepthesis| provides four
+standard figure widths, \texcmd{smallfigwidth}, \texcmd{mediumfigwidth},
+\texcmd{largefigwidth} and \texcmd{hugefigwidth}, which are defined in terms of
+the text width and chosen to avoid overflows. Use them like this:
+%
+\begin{fsnippet}
+\begin{figure}
+ \includegraphics[width=\largefigwidth]{ckmfitter-alpha-combined}
+ \caption{CKM Fitter constraints on \alphaCKM.}
+ \label{fig:CKMFitter}
+\end{figure}
+\end{fsnippet}
+
+Note also that this way of including images will automatically look for an
+|.eps| file when building PostScript and a |.pdf| file when building PDF. You
+may find the |eps2pdf| and |pdf2eps| utilities useful.
+
+\subsection{Standard in-document reference terms}
+It's nice to be able to refer to portions of your document with standard names,
+capitalisation, etc. For this reason, I've defined a bunch of macros which give
+consistent and sensible capitalisations. Using them systematically will ensure
+consistency in your references:
+%
+\begin{itemize}
+\item \texcmd{Chapter} \manifestsAs Chapter
+\item \texcmd{Section} \manifestsAs Section
+\item \texcmd{Appendix} \manifestsAs Appendix
+\item \texcmd{Figure} \manifestsAs Figure
+\item \texcmd{Table} \manifestsAs Table
+\item \texcmd{Equation} \manifestsAs equation
+\item \texcmd{Reference} \manifestsAs reference
+\item \texcmd{Page} \manifestsAs page
+\end{itemize}
+
+Taking this consistency thing a step further, here are versions of the same
+commands which take the reference label as a argument:
+%
+\begin{itemize}
+\item \texcmd{ChapterRef}
+\item \texcmd{SectionRef}
+\item \texcmd{AppendixRef}
+\item \texcmd{FigureRef}
+\item \texcmd{TableRef}
+\item \texcmd{EquationRef}
+\item \texcmd{ReferenceRef}
+\item \texcmd{PageRef}
+\end{itemize}
+%
+Using these forms will ensure that the spacing between e.g. the worked
+``Chapter'' and the chapter number is always the same, and that it won't wrap
+over line breaks. The equation, reference and page forms will call the
+\texcmd{eqref}, \texcmd{cite} and \texcmd{pageref} reference macros rather than
+\texcmd{ref}, which is used for all others.
+
+% \subsection{``thesis---'' prefix versions}
+% Additionally, all \hepthesis environments and commands have an alternative name,
+% which is the version described above, prefixed with ``thesis''\footnote{This
+% is a hang-over from early versions of my thesis, when I didn't know how to
+% robustly extend and re-define environments and commands.}. These forms are
+% frankly a bit of a pain to use, so use the short versions, please. The
+% ``thesis---'' versions should be considered deprecated and \textbf{will be removed
+% in the next release, version 1.5}.
+
+
+\section{Recommended extra packages}
+\label{sec:ExtraPackages}
+Here are some other packages it might be good to know about:
+\begin{itemize}
+\item \textbf{SIunits\,\cite{SIunits}:} \emph{the} way to do units and get it right.
+\item \textbf{hepunits\,\cite{hepunits}:} my extension of |SIunits| to include some common HEP units not used elsewhere.
+\item \textbf{hepnames\,\cite{hepnames} and hepparticles\,\cite{hepparticles}:} my packages for typesetting HEP particle names \emph{properly}, with |hepnames| defining macros for a lot of the standard ones. Requires |maybemath|\,\cite{maybemath}
+\item \textbf{braket\,\cite{braket}:} decent implementation of Dirac bra and ket notation
+\item \textbf{cancel\,\cite{cancel}:} the best way to do Feynman slashes (in my opinion)
+\item \textbf{feynmf/feynmp\,\cite{feynmf} and axodraw\,\cite{axodraw}:} various approaches to doing Feynman diagrams, especially in equations, inline contexts and so-on.
+\end{itemize}
+%
+and some related software:
+%
+\begin{itemize}
+\item \textbf{FeynDiagram\,\cite{feyndiagram} and Jaxodraw\,\cite{jaxodraw}}: for Feynman diagrams outside \TeX. You might also
+ be interested in my |pyfeyn|\,\cite{pyfeyn} program.
+\item \textbf{SLAC SPIRES' biblio tools service:} see \url{www.slac.stanford.edu/spires/}
+\end{itemize}
+
+
+
+\section{An example \texttt{hepthesis} thesis}
+Here are some selected snippets from my thesis, which hopefully demonstrate the
+features described. I split my thesis into |preamble.tex| and
+|thesis.tex| files, with the front matter, back matter and chapters
+\texcmd{input}'d into |thesis.tex|. The output was built by running e.g.
+%
+\begin{snippet}
+pdflatex thesis.tex && bibtex thesis && pdflatex thesis.tex
+\end{snippet}
+%
+(though I used a Makefile rather than do it directly). You should note that you
+might not be able to build this exact thesis due to missing packages: if you're
+writing a HEP thesis then I'd encourage you to use the |hepnames| \LaTeX{}
+package for typesetting particle names --- it depends on the extra
+|hepparticles| and |maybemath| packages. The
+examples used here also rely on the |hepunits| package: you can all these extra
+packages from the CTAN\,\cite{CTAN}. See Appendix~\ref{app:InstallingPackages} for
+a quick guide on how to install personal copies of \LaTeX{} packages.
+
+
+\subsection{\texttt{preamble.tex}}
+{\smaller \VerbatimInput{example/preamble.tex}}
+
+\subsection{\texttt{thesis.tex}}
+{\smaller \VerbatimInput{example/example.tex}}
+
+\subsection{\texttt{frontmatter.tex}}
+{\smaller \VerbatimInput{example/frontmatter.tex}}
+
+\subsection{\texttt{chap1.tex}}
+{\smaller \VerbatimInput{example/chap1.tex}}
+
+\subsection{\texttt{chap2.tex}}
+{\smaller \VerbatimInput{example/chap2.tex}}
+
+\subsection{\texttt{backmatter.tex}}
+{\smaller \VerbatimInput{example/backmatter.tex}}
+
+
+\section{Wishlist / TODO}
+I'm not planning on writing another thesis, but maybe I'll add features if
+there's demand. If you add a nice feature, pass it on to me and I'll think about
+including it in the package (and will give you some credit, of course). But anyway,
+here's the TODO:
+%
+\begin{itemize}
+\item Make the spacing in the \texcmd{SectionRef} etc. commands customisable.
+\item Allow the PDF page style to be specified as a class argument
+\item Allow section titles to be centre / right justified?
+\item User control of frontmatter title sizes and alignments? (Probably not\dots)
+\item Provide different styles for the titlepage etc.
+\item Themes, like for Beamer?
+\item Make the vertical spacings on the quote, dedication and title pages change by paper size
+\end{itemize}
+
+
+\section{Feedback}
+\hepthesis has taken a lot of work\dots I hope you think it was worthwhile and
+that you enjoy using it. Or at least, I hope you enjoy writing your thesis more
+than you would have done without it! If you're feeling appreciative, then a teeny
+credit in your thesis acknowledgements would be hugely appreciated.
+
+Other than that, any feedback on the package is very welcome, especially if it's
+constructive criticism! Email your thoughts to
+\texttt{hepthesis@insectnation.org}, please.
+
+
+\section{Acknowledgements}
+I'd like to thank all the people who have provided bug reports, patches, suggestions
+and who have otherwise helped me to get \hepthesis to the state it's in. See the
+|ChangeLog| file in the distribution for names!
+
+
+\appendix
+
+\section{Using your own derived document class}
+\label{app:DerivedClass}
+If you're feeling sophisticated, then you can make your own document class based on
+\hepthesis by placing
+%
+\begin{snippet}
+\LoadClass{hepthesis}
+\end{snippet}
+%
+in your own class definition file. This is a rather nice way of working, since
+it allows you to tweak the \hepthesis defaults without cluttering your
+|.tex| file with preamble junk.
+
+
+\section{Installing personal copies of \LaTeX{} packages}
+\label{app:InstallingPackages}
+Since |hepthesis| depends on several non-standard \LaTeX{} packages, you may have to
+download and install them yourself. If you don't have |root| access to the computer
+on which you're working then you'll probably have to install them into your own home
+directory or similar. Since I expect quite a few prospective users of |hepthesis| will
+be non-experts in the ways of \TeX{}, this is a quick guide on what to do.
+
+\begin{enumerate}
+\item Make a \TeX{} directory tree in your home directory (or any other area you can write to), e.g.
+\begin{snippet}
+$ mkdir -p $HOME/local/texmf/tex/latex
+$ mkdir -p $HOME/local/texmf/bibtex/bib
+$ mkdir -p $HOME/local/texmf/bibtex/bst
+\end{snippet}
+\item Download the packages from CTAN\,\cite{CTAN} or wherever.
+\item Follow the packages' installation instructions to install them into the \\
+ |$HOME/local/texmf/tex/latex| %$
+ directory you made above (or an appropriately-named sub-directory of it if you
+ want to be neat). For simple |.sty| or |.cls| files, this will just involve
+ copying them into your directory of choice. |.dtx| files will probably require
+ running |latex| to build the files to be installed.
+\item If you use the |bash| shell, add the following to your |~/.bashrc| file:
+\begin{snippet}
+export TEXINPUTS="$HOME/local/texmf/tex//:$TEXINPUTS"
+export LATEXINPUTS="$HOME/local/texmf/tex/latex//:$LATEXINPUTS"
+export BIBINPUTS="$HOME/local/texmf/bibtex//:$BIBINPUTS"
+\end{snippet}
+or, if you use the |(t)csh| shell, add the following to your |~/.cshrc| file:
+\begin{snippet}
+setenv TEXINPUTS "$HOME/local/texmf/tex//:$TEXINPUTS"
+setenv LATEXINPUTS "$HOME/local/texmf/tex/latex//:$LATEXINPUTS"
+setenv BIBINPUTS "$HOME/local/texmf/bibtex//:$BIBINPUTS"
+\end{snippet}
+\item That's all: the lines above mean that \LaTeX{} will look for input files
+such as classes, packages, images, \texcmd{input}'d |.tex| files etc. recursively under \\
+|$HOME/local/texmf/tex/latex| %$
+ and that BibTeX will look for its style and database files recursively under
+|$HOME/local/texmf/bibtex|.%$
+You can probably see how this can be extended to keep your thesis development
+directories neat, too!
+\end{enumerate}
+
+
+\section{Distinguishing PS/PDF output in thesis builds}
+\label{app:AuxFileProblem}
+
+The options \texopt{bindnopdf} and \texopt{hyperpdf} change the behaviour
+depending on whether you're building PDF or PostScript output. This is fine if
+you only ever do one, but if you want to switch rapidly between these output
+formats then you'll have problems. This is because the |.aux| file, which
+records the reference keys and suchlike changes depending on whether you're
+making hyper-refs and if the changes of margins force sections on to different
+pages.
+
+A nice solution to this involves using a Makefile, which you probably want to be
+doing anyway. You'll have to read up on the details of Makefiles (and possibly
+GNU automake) elsewhere, but to save on Make-newbie angst, I'll tell you that
+the indents in the following snippet \emph{must} be tabs, rather than spaces!
+Here goes --- put the following into a file called |Makefile|, change the
+|DOCNAME| variable to something which suits your project and run |make thesis| or |make thesispdf|:
+\begin{fsnippet}
+# For a main thesis LaTeX file called ``thesis.tex''
+DOCNAME = thesis
+
+thesis: $(TEXSOURCES) $(DOCNAME).bbl
+ test -f $(DOCNAME).aux.ps && cp $(DOCNAME).aux.ps \
+ $(DOCNAME).aux || true
+ latex $(DOCNAME)
+ cp $(DOCNAME).aux $(DOCNAME).aux.ps
+ ./thesisstats.sh >> buildlog.dat
+
+thesispdf: $(TEXSOURCES) $(DOCNAME).bbl
+ test -f $(DOCNAME).aux.pdf && cp $(DOCNAME).aux.pdf \
+ $(DOCNAME).aux || true
+ pdflatex $(DOCNAME)
+ cp $(DOCNAME).aux $(DOCNAME).aux.pdf
+ ./thesisstats.sh >> buildlog.dat
+\end{fsnippet}
+
+Otherwise you can just delete the |.aux| file when you change between using
+|latex| and |pdflatex|, but this will require more passes, since the
+|.aux| file has to be replaced each time.
+
+\begin{thebibliography}{99}
+\bibitem{CTAN}{CTAN: \url{http://www.ctan.org}. \url{http://www.tex.ac.uk/tex-archive} is shortened to |ctan:| below.}
+\bibitem{scrbook}{scrbook: \url{ctan:/macros/latex/contrib/komascript/}}
+\bibitem{cite}{cite: \url{ctan:/macros/latex/contrib/cite/}}
+\bibitem{setspace}{setspace: \url{ctan:/macros/latex/setspace/}}
+\bibitem{fancyhdr}{fancyhdr: \url{ctan:/macros/latex/contrib/fancyhdr/}}
+\bibitem{rotating}{rotating: \url{ctan:/macros/latex/contrib/rotating/}}
+\bibitem{tocbibind}{tocbibind: \url{ctan:/macros/latex/contrib/tocbibind/}}
+\bibitem{subfig}{subfig: \url{ctan:/obsolete/macros/latex/contrib/subfig/}}
+\bibitem{caption}{caption: \url{ctan:/macros/latex/contrib/caption/}}
+\bibitem{ccaption}{ccaption: \url{ctan:/macros/latex/contrib/ccaption/}}
+\bibitem{changepage}{changepage: \url{ctan:/macros/latex/contrib/changepage/}}
+\bibitem{varwidth}{varwidth: \url{ctan:/macros/latex/contrib/varwidth/}}
+\bibitem{csquotes}{csquotes: \url{ctan:/macros/latex/contrib/csquotes/}}
+\bibitem{babel}{babel: \url{ctan:/macros/latex/contrib/babel/}}
+\bibitem{a4wide}{a4wide: \url{ctan:/macros/latex/contrib/misc/a4wide.sty}}
+\bibitem{amsmath}{amsmath: \url{ctan:/macros/latex/required/amslatex/math/}}
+\bibitem{hyperref}{hyperref: \url{ctan:/macros/latex/contrib/hyperref/}}
+\bibitem{booktabs}{booktabs: \url{ctan:/macros/latex/contrib/booktabs/}}
+\bibitem{draftcopy}{draftcopy: \url{ctan:/macros/latex/contrib/draftcopy/}}
+\bibitem{lineno}{lineno: \url{ctan:/macros/latex/contrib/lineno/}}
+\bibitem{titling}{titling: \url{ctan:/macros/latex/contrib/titling/}}
+\bibitem{SIunits}{SIunits: \url{ctan:/macros/latex/contrib/SIunits/}}
+\bibitem{hepunits}{hepunits: \url{ctan:/macros/latex/contrib/hepunits/}}
+\bibitem{hepnames}{hepnames: \url{ctan:/macros/latex/contrib/hepnames/}}
+\bibitem{hepparticles}{hepparticles: \url{ctan:/macros/latex/contrib/hepparticles/}}
+\bibitem{maybemath}{maybemath: \url{ctan:/macros/latex/contrib/maybemath/}}
+\bibitem{braket}{braket: \url{ctan:/macros/latex/contrib/misc/braket.sty}}
+\bibitem{cancel}{cancel: \url{ctan:/macros/latex/contrib/misc/cancel.sty}}
+\bibitem{feynmf}{feynmf: \url{ctan:/macros/latex/contrib/feynmf/}}
+\bibitem{axodraw}{axodraw: \url{http://www.nikhef.nl/~form/FORMdistribution/axodraw/}}
+\bibitem{feyndiagram}{FeynDiagram: \url{http://www.feyndiagram.com}}
+\bibitem{jaxodraw}{Jaxodraw: \url{http://http://jaxodraw.sourceforge.net/}}
+\bibitem{pyfeyn}{PyFeyn: \url{http://hepforge.cedar.ac.uk/pyfeyn/}}
+\end{thebibliography}
+
+\end{document}