I recently joined the tex community and had quite a fun week texing. (I migrated this question to codereview, as it seems to be the better place for code-review samples). The result is some layout/format I would like to use for future theses/small-books. I did host the the whole thing here, and as others might like to contribute/pull I just set up a git rep. The small readme and introductory stuff is put inside the 0_main_layout.tex.
I used the latest TeX 3.14159265 (TeX Live 2015) with texstudio under ubuntu 14.04.
A precompiled .pdf is included to have a quick peek, enter image description here Furthermore it is opensource licensed opensource.org/licenses/BSD-3-Clause. What do think about it so far, what needs to be improved? I appreciate any suggestions. Does it cross compile, also under windows?
As the code should be part all be on the platform itself I will post the main file (which includes all the important preamble statements)

% My book_template1 v0.1 for LaTeX                                                                      %
%                                                                                                       %
%INSTALL                                                                                                %
% TeX-Distribution TeXLive 3.14159265 (TeX Live 2015),  (alternative: MiKTeX)
% Compiler: pdfLaTEX (alt.: XeLaTeX, LuaLaTeX; might need slight adjustments)
% TexLive (rec.: zip)   1.  files   -> tug.org/texlive/acquire-netinstall.html
%                           (During the perl script run: [x] create symlinks to standard directories)
%                       2.  docs    -> tug.org/texlive/doc/texlive-en/texlive-en.html
% TeXstudio/maker (for some GUI)    -> texstudio.org
%                       1. set default compiler: txs:///pdflatex | txs:///biber | txs:///pdflatex (advanced options)
%                       1. make sure TeXstudio finds the commands (latex, pdflatex, biber, etc.)
%                           a) if <unknown>, click the folder after each command and
%                           b) enter the PATH given by the TexLive (e.g. /usr/local/texlive/2015/bin/x86_64-linux);
%                           c) default bibliographic .bib processor either bibtex or biber
% produce pdf: 1.build(compile) 2. run your_bib_processor 3. build(compile) again and view. (F5,F8,F5)  %
%                                                                                                       %
% Licensed under  http://opensource.org/licenses/BSD-3-Clause                                           %
%                                                                                                       %
% Date          Author                  Notes                                                           %
% 09/04/2016    Julian                  Initial release                                                 %
%                                                                                                       %
%TOSET  marked entries are to be changed                                                                %
%NOT    marked entries usually mustn't be altered                                                       %
%NOTE   some information on the statement                                                               %
%TEST   environment could be MWE.tex (minimum working example)                                          %
%                                                                                                       %
%NOTE Good to know:                                                                                     %
% 1. \- or \hyphenation{wo-rd-s} declares allowed hyphenation points to avoid overfull lines (\sloppy is bad practise)
% 2. when you changed to another compiler ->tools->clean auxiliary files...
% 3. latex commands for unicode chars (e.g. textgreek)  -> tug.ctan.org/info/symbols/comprehensive/symbols-letter.pdf
% 4. Unicode character finder -> mclean.net.nz/ucf/
% 5. ...
% 6. ...                                                                                                %
%NOTE PREAMBLE (introductory statements)
%TOSET Set raw document layout and text margins -> en.wikibooks.org/wiki/LaTeX/Document_Structure#Document_classes
    \newcommand{\onetwoside}{oneside}   % According to above twoside/oneside (unsymmetric/symmetric margins)
%NOTE Packages, my Macros und Formatdefinitions
    \usepackage[english,ngerman]{babel} % Multilingual support ctan.org/pkg/babel?lang=en
    \usepackage[T1]{fontenc}            % Allows different font encodings and hyphenation ctan.org/pkg/fontenc?lang=en
    \usepackage[utf8]{inputenc}         % Translates input encodings into LaTeX internal language
    \usepackage{lmodern}                % Output font is Latin Modern to improve readability
    %\usepackage{microtype}             % Microtypography to improve readability
    \usepackage{amsmath}                % Improves mathematical formulas
    \usepackage{amsthm}                 % Improves mathematical theorems
    \usepackage{amssymb}                % Extended symbol collection
    \usepackage{gensymb}                % Generic symbols for both text and math mode ctan.org/pkg/gensymb
    \usepackage{textcomp}               % Text Com­pan­ion fonts, which pro­vide many text sym­bols ctan.org/pkg/textcomp
    \usepackage{array}                  % Extending the array and tabular environments ctan.org/pkg/array?lang=en
    \usepackage{textgreek}              % Upright greek letters in text ctan.org/pkg/textgreek?lang=en
    \usepackage{eso-pic}                % Add picture commands (or backgrounds) to every page ctan.org/pkg/eso-pic?lang=en
    \usepackage{graphicx}               % Op­tional ar­gu­ments to the \in­clude­gra ctan.org/pkg/graphicxph­ics
    \usepackage{epstopdf}               % Convert EPS to 'encapsulated' PDF using Ghostscript ctan.org/pkg/epstopdf
    \usepackage[absolute]{textpos}      % Place boxes at arbitrary absolute positions ctan.org/pkg/textpos
    \usepackage{ifthen}     % Conditional commands ctan.org/pkg/ifthen?lang=en
    \usepackage[format=hang, font=it, singlelinecheck=0]{caption}  % Customising captions in floating environments ctan.org/pkg/caption
    \usepackage{fancyhdr}               % Extensive control of page headers and footers ctan.org/pkg/fancyhdr
    \usepackage{xcolor}                 % Color extensions for LaTeX/pdfLaTeX ctan.org/pkg/xcolor
    \usepackage{calc}                   % Adds infix expression to perform arithmetic on the arguments ctan.org/pkg/calc
    \usepackage{tocstyle}               % Define the style of the table of contents ctan.org/pkg/tocstyle
    \usepackage{tocloft}    % Typography changes for Table of contents, LoFigures, LoTables ctan.org/pkg/tocloft
    \usepackage{titlesec}   % Select alternative section titles ctan.org/pkg/titlesec
    \usepackage{titletoc}   % Han­dling toc/lof/lot en­tries ctan.org/pkg/titletoc
        \cftbeforetoctitleskip-12pt %???
        \renewcommand{\cfttoctitlefont}{\LARGE\bfseries} %???
    \usepackage{makeidx}        % Standard LATEX package for creating indexes ctan.org/pkg/makeidx
%NOTE Switching the .bib-file processors bibtex/biber also requires changing the default bibliography tool in TeXstudio
\newcommand{\usebibproc}{biber} %TOSET  and changing this variable to one of these: bibtex/biber
    \ifthenelse{\equal{\usebibproc}{bibtex} }{}{
        \usepackage[                % stuff in case of biber: .bib file, style etc.
        \defbibfilter{papers}{  type=article or type=book } }   % Can seperate books/eBooks and links
    \usepackage{subcaption} % Customising captions in floating environments ctan.org/pkg/caption
    %\usepackage{multirow}  % Create tabular cells spanning multiple rows ctan.org/pkg/multirow
    \usepackage{colortbl}   % Add colour to LATEX tables
    \usepackage{url}        % Verbatim with URL-sensitive line breaks  ctan.org/pkg/url
    \urlstyle{same}         % Set appearance of url font
    \usepackage{blindtext}  % Com­mands \blind­text and \Blind­text for creating random docs  ctan.org/pkg/hyperref
    \usepackage{hyperref}   % Extensive Cross-ref­er­enc­ing com­mands ctan.org/pkg/hyperr
    %\usepackage{nomencl}   % To create a Nomenclature ctan.org/pkg/nomenclef (got replaced by glossaries)
    \usepackage[acronyms,nopostdot]{glossaries} % Make custom, multiple, sorted lists (abbreviation, glossary(explaining terms), symbols)
    \usepackage{setspace}   % Set space between lines ctan.org/pkg/setspace
    \usepackage[bottom]{footmisc}   % Change the type­set­ting of foot­notes  ctan.org/pkg/footmisc
    \usepackage{chngcntr}   % Change the resetting of counters ctan.org/pkg/chngcntr
    \usepackage{courier}    % Adobe Type 1 "free" copies of Courier ctan.org/pkg/courier
    \usepackage{listings}   % Typeset source code listings using LATEX ctan.org/pkg/listings
    \renewcommand{\familydefault}{\sfdefault} %???  % Standard font family without (sans) serifs typeface
    \usepackage{helvet}     % Load Helvetica (Arial like), scaled ctan.org/pkg/helvet
    \usepackage{etoolbox}   %   ctan.org/pkg/etoolbox ???
    \makeatletter           % Changes the category code(catcode) of "@" to 11, to have access to package-internal macros
        \patchcmd{\@makechapterhead}{50\p@}{0pt}{}{}    % Removes space above \chapter head
        \patchcmd{\@makeschapterhead}{50\p@}{0pt}{}{}   % Removes space above \chapter* head
    \makeatother            % Resets the category code(catcode) of "@" to 11,
    \usepackage{afterpage}  % Execute command after the next page break ctan.org/pkg/afterpage?lang=en
    \newcommand\blankpage{\newpage\null\thispagestyle{empty}\addtocounter{page}{-1}\newpage }   
    %NOTE Name and further variables/custom_commands (do not use umlaute here)  
    \newcommand{\NAME}{Peter Lustig}    
    \newcommand{\DURATION}{00}% in months   
    \newcommand{\CUSTODIAN}{Dipl.-Ing. Ein Meister} 
    \newcommand\EQUALGG{\mathrel{\overset{\makebox[0pt]{\mbox{\normalfont\tiny\sffamily GG}}}{=}}} %custom "GG" over "="
    \hypersetup{                % Settings for hyperlinks
        hidelinks, pdfdisplaydoctitle=true, pdfstartview={Fit},
        pdfinfo={ %TOSET pdf internal settings
            Title={Dies ist ein Title wie er im Buche steht.},
            Author={\NAME}, Subject={\MYTHESIS} }}
    \lstset{                            % Settings for listings     
        morekeywords={loadrt, setp, addf, net} } 
    %NOTE custom environments
    \definecolor{dunkelgrau}{rgb}{0.8,0.8,0.8}   % custom colors of department
    \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}    % Fixed width columns right justified
    %NOTE page format ()-> sharelatex.com/learn/Page_size_and_margins
    \setlength{\hoffset}{-25.40013mm}   % Delete 1inch = 25.40013mm default offset
        \setlength{\oddsidemargin}{210mm - \textwidth - \evensidemargin}
    \setlength{\topmargin}{20mm}        % Distance from offset edge to header top edge
    \setlength{\headheight}{0.7mm}      % Header height
    \setlength{\headsep}{12.4mm}            % Distance header bottom edge to text box upper edge
    \setlength{\topskip}{12pt}          % Distance to from text box upper edge to 1st baseline
    \setlength{\textheight}{228mm}      % Text box height
    \setlength{\footskip}{12mm}         % Distance to from text box lower edge to lower footbox edge
    \renewcommand{\baselinestretch}{1.25}   % Scale vertical distance between lines in a paragraph
    \setlength{\unitlength}{10mm}       %Define unit used inside \begin{figure} environment
    \setlength{\mathindent}{10mm}   %NOTE only use with fleqn (left equations)
    \newlength{\matfigwidth}        % s.o.
    \setlength{\abovecaptionskip}{10pt} % Space between figure and caption
    \captionsetup{width=.95\textwidth}  % Slightly indent figure captions
    \setlength{\parskip}{1ex plus .2ex minus .2ex}  % Paragraph line-break settings (1ex = 1.51323)
    \setlength{\parindent}{0em}                     % Indent setting (1em = 3.51462)
    \frenchspacing                                  % No spacing difference between words and sentences
    \setcounter{secnumdepth}{3}                     % Up to what level sectioning titles are numbered
    %TOSET your customized glossaries etc. 
        \setacronymstyle{long-short}                % behaviour: first time use long term, then use abbreviation
        \newglossary*{mysyms}{Symbolverzeichnis}    % custom glossary, type=mysmys
        \makenoidxglossaries                        % initialize, the main(def.) glossary gets dedicated to definitions
        %\glstoctrue    % add them to TOC
    %DEF \newglossaryentry{<label>}{<name>,<description>,<type(to put it into the right glossary) } 
        % Reference it within text with the label \gls{<label>}, in headings \glsentrytext{<label>}
        \newglossaryentry{potato}{name={potato},plural={potatoes}, description={starchy tuber}} 
        \newglossaryentry{cabbage}{name={cabbage},description={vegetable with thick green or purple leaves}}
        \newglossaryentry{ROS_def}{name={ROS},description={Operating system connecting various C++ nodes}}
        %... glossary
        \newacronym{ac:ros}{ROS}{Roboter Operating System}
        \newacronym{ac:svm}{SVM}{support vector machine}
        %... acronyms
        \newglossaryentry{R}{type=mysyms,name={R},description={rational number amount}} 
    %NOTE Define custom footer/header layouts ->fancyhdr
        \fancyhf{} % clear all header and footer fields
        \ifthenelse{\equal{\onetwoside}{twoside} }{ % twoside layout                
            \fancyhead[LE,RO]{\thepage}                 % Page numbering Left/Even, Right/Odd
            \fancyhead[LO]{\scriptsize \rightmark}
            \fancyhead[RE]{\scriptsize \leftmark}
            \fancyhead[L]{\scriptsize \nouppercase{\leftmark}}  % oneside layout
            \renewcommand{\footrulewidth}{0pt} } }
    \patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{mystyle}}{}{}  % Put header above chapters
    \tocloftpagestyle{mystyle}          % Assign the your style also to TOC, LOF, LOT 
%%%   END OF PREAMBLE -> START OF DOCUMENT ENVIRONMENT                                                %%
        \pagenumbering{gobble}          % Remove page numbers (and reset to 1) until \pagenumbering{numstyle}
        \graphicspath{{./bilder/}}      %TOSET Picture path
        %NOTE Title page layout 
            \setlength{ \arrayrulewidth }{0.5pt}                % Change weight of tabular lines
            \renewcommand{\baselinestretch}{1.5}\normalsize     % s.o. (see above)
            \begin{textblock*}{0mm}[0,0](24.6mm + 10mm, 23.2mm + 27mm + 5mm)
            \begin{textblock*}{130mm}[0,0](24.6mm + 27mm, 23.7mm + 20mm + 5mm)
                \Large \bfseries You must be the change you want to see in the world.

            \begin{textblock*}{0mm}[0,0](24.6mm + \paperwidth + 0.8mm - 30mm - 15mm , 23.2mm + 12mm + 5mm)
            \begin{textblock*}{130mm}[0,0](24.6mm + 27mm, 23.2mm + 47mm + 15mm)
				\small\bfseries \MYTHESIS \; im Studiengang \MYCOURSE
            \begin{textblock*}{160mm}[0,0](24.6mm + 27mm, 23.2mm + 77mm)
				Lehrstuhl fuer Hier und Da\\
				Prof. Dr.-Ing. J. Alleswisser
            \begin{textblock*}{130mm}[0,0](24.6mm + 27mm, 23.2mm + 111mm)
				\includegraphics[width=168.8mm,height=94.9mm]{void.png} %TOSET your picture for the title page
            \begin{textblock*}{130mm}[0,0](24.6mm + 27mm - 2.3mm , 23.2mm + 222mm)
						Bearbeiter: 	&	\NAME 				& Matrikelnr.: \MATRNR\\
						& & \\
						Betreuer:		&	Prof. Dr.-Ing. J. Schlaumeier	& \\ 
						&	\CUSTODIAN	& \\
						& & \\
						Abgabetermin: 	&	\MYTHESISENDED 				& \\
						Bearbeitungszeit:	&	\DURATION\; Monate &
            \renewcommand{\baselinestretch}{1.25}\normalsize    % (s.o.)
        %NOTE Introductory statement        
            \\Ich versichere, dass ich die vorliegende Arbeit ohne fremde Hilfe und ohne Benutzung anderer als  
            der angegebenen Quellen angefertigt habe und dass die Arbeit in gleicher oder ähnlicher Form noch       
            keiner anderen Pruefungsbehörde vorgelegen hat und von dieser als Teil einer Prüfungsleistung       
            angenommen wurde. Alle Ausführungen, die wörtlich oder sinngemäß übernommen wurden, sind als 
            solche gekennzeichnet.\\
            \vspace{20mm}   \\
            Erlangen, den \today\\[-5mm]
        %NOTE Autoassign defined hdr-style depending on twoside/oneside page
            %\fancyhead{} \fancyfoot{}                  % (same as \fancyhf{})  
            \pagestyle{mystyle}         % Clearing/Using your own format 
            \renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{} }  % Influence the chapter/section format
            \renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1} }           
        %\renewcommand{\figurename}{Abbildung}          % Default name for figures
        %\renewcommand{\chaptername}{Abschnitt}         % "          " for chapters
        %\captionsetup[subfigure]{labelformat=simple}   % Define empty/simple/parens for nolabel/number_latters/n_l+parens
        %\renewcommand\thesubfigure{(\alph{subfigure})} % Prevent double parentheses in the subfigures
        %\counterwithout{footnote}{chapter}             % Reset footnote with every new chapter     
        %NOTE Table of contents
        %\frontmatter               % Turns off chapter numbering and uses latin literals
        \pagenumbering{Roman}       % Use Large Latin page-numbers
        \setcounter{tocdepth}{3}    % Down to which level sectioning commands are printed to ToC
        \renewcommand{\baselinestretch}{1.46}\normalsize    % s.o. (see above)
        \setlength{\cftaftertoctitleskip}{1.8em}    % Distance from chapter to first entry of toc, lof, lot 
        \currentpdfbookmark{Inhaltsverzeichnis}{Inhaltsverzeichnis}         %NOTE table of contents TOC
        \cleardoublepage            % ends current page and all figures, tables so far appeared to be printed
        \currentpdfbookmark{Abbildungsverzeichnis}{Abbildungsverzeichnis}   %NOTE list of figures LOF
        \currentpdfbookmark{Tabellenverzeichnis}{Tabellenverzeichnis}       %NOTE list of tables LOT
        \addtocontents{lot}{ \protect\markboth{Tabellenverzeichnis}{Tabellenverzeichnis} }
        \renewcommand{\baselinestretch}{1.5}\normalsize     % s.a. (see above)
    %NOTE further Lists of abbreviations and(/only latter) List of symbols
        \currentpdfbookmark{Glossar}{Glossar}   %TOSET only if %\glstoctrue (false)
        \setglossarysection{section}            % get them on one page
        \printnoidxglossaries   % Shortcut to display all glossaries at once 
        \glsglossarymark{Glossar}               % change header if wanted
    \mainmatter          %NOTE  Turns on chapter numbering, resets page numbering and uses arabic numerals
    \input{1_fulltext}   %NOTE file containing the chapters, sections and subsections
    \phantomsection     % Might adjust bookmark reference
    \ifthenelse{\equal{\usebibproc}{bibtex} }{  %NOTE backend=bibtex (no utf8)      
            \bibliography{LiteraturWestern15}{} % specify .bib file name, cant be utf8      
            \bibliographystyle{is-abbrv}        % bibliography style
        }{          %NOTE backend=biber (BibTEX replacement) the BibLATEX package
            %\pdfbookmark[0]{Literatur gedruckt}{Literatur gedruckt}        % Bookmark for printed literature
            \printbibliography[filter=papers,title={Literaturverzeichnis }]
            \pdfbookmark[0]{Literatur online}{Literatur online}             % Bookmark for digital literature
            \printbibliography[type=misc,title={Literaturverzeichnis (Links) }] }
    \setcounter{tocdepth}{3}            % to which level the sectioning commands are printed in the ToC      
    \appendix   %NOTE start appendix: Resets chapter numbering, uses letters for chapter numbers
    %\renewcommand{\@chapapp}{Anhang}   % rename headertitle
    %TOSET choose the appendix formats you use
        \setlength{\cftaftertoctitleskip}{1.8em}    % Distance from chapter heading to first entry of toc/lof/lot 
        \input{Anhang_A_Bilder}                 % appendix for pictures
        \input{Anhang_B_Listings_Tabellen}      % appendix for Listings (code)
        \input{Anhang_C_Listen}                 % appendix for Lists (a)..b)..c)..etc)
        \input{Anhang_D_Weiterfuerend}          % Additional text taken out of the fulltext file (better flow)
        \input{Anhang_E_Datentraeger}           % reference to CD/DVD   
    %NOTE choose to have CV added (uncomment then)  
            \input{my_cv}   %NOTE file to your CV
% % % EOF % % %

A few technical questions I have:

  1. Do you see any incompatibilities / mistakes when introducing the packages.
  2. Is the import order ok (like glossaries after hyperref etc)
  3. What can I do to make it compile under Windows. (or does it as is)
  4. (your general thoughts on this. )
  • \$\begingroup\$ Why do you start with a standard class by Lamport and customize that instead of using scrbook or memoir? And please use the geometry package. \$\endgroup\$ Apr 10, 2016 at 22:08
  • \$\begingroup\$ Further pkgs = more commands beside the plenty of standard ones. After having read comparison of koma and memoir I will propably switch over to koma. Using Koma, they suggest using typearea instead of geometry, see Chapter 2. \$\endgroup\$
    – droid192
    Apr 11, 2016 at 9:24
  • \$\begingroup\$ edit: geometry seems to be ok, seen on komascript.de \$\endgroup\$
    – droid192
    Apr 12, 2016 at 12:49

1 Answer 1


To answer your questions in turn:

Any package incompatibilities? Import ordering?

Not that I can see, but you’re importing a lot of packages – 44 at a rough count. In general, I prefer to keep a small number of packages in my base file, and include them as-required. This reduces the likelihood of a package clash in a document (hyperref is one common culprit, etoolbox is another).

Only taking dependencies (packages) you need is generally good programming practice:

  • Less work when you’re setting up a fresh build environment.
  • Less chance of packages changing under you and breaking, and/or going away.
  • Faster compilations – in this case, that’ll be the time it takes for LaTeX to produce the final PDF.
  • Reduced risk of unaffected side effects or clashes between packages.

Does it work on Windows?

No idea, sorry. I don’t have a Windows installation of TeX to hand.

Any other comments?

  • There are lots of comments, but they only describe what the package or command is doing. They don’t explain why they’re in this document/template. This makes it very hard to break out into smaller chunks, delete code later, and so on. Tell me how this relates to your document style – what effect is it achieving? Why are you going for that effect?

  • Your document is littered with % TOSET comments. It would be nicer if they were pulled into one section, right at the top of the file, so they can all be edited at once. It reduces the chance that somebody will miss one while going through the document.

  • I’d be tempted to break up this preamble into lots of smaller chunks, which can be enabled or disabled on a per-document basis. Two ways you could do this:

    1. Put it in a style .sty file, with appropriate flags for the different options
    2. Put the chunks in small .tex files, and \input them on-demand.

    That helps cut down the unnecessary dependencies (see above), makes it easier to refactor just a small part of the style file without affecting the rest, and makes it easier to reuse this in non-book documents. For example, your chapter code will just error in the article class.

    Plus, it means you can change the style for every document at once, rather than having to edit lots of documents individually.

  • It’s not clear why you’re defining the \onetwoside macro immediately before passing it to the book class. Why not just pass oneside correctly? It’s less confusing, and doesn’t create the odd sight of a macro being in class options.

  • All the packages you have, and you don’t include booktabs. Loathe as I am to recommend more packages, this makes really nice-looking tables, and your example document does include so. Use it.

  • \$\begingroup\$ I pushed another version to git which considered the good hints you gave above including breakdown into seperate files, especially the frontmatter differs in design, replacing the odd \onetwoside command for ifx option and further restructuring. Thank you \$\endgroup\$
    – droid192
    Apr 10, 2016 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.