\documentclass[11pt, a4paper]{report}

LaTeX report setup mini tutorial for BSc-ME students at the University of Twente.

© Niels ter Meer n.termeer@student.utwente.nl CC-BY-SA 4.0 January 2022 v1.1

File 2/2. This file covers elaborate multi-file feature-rich documents (think project reports). For packages in this file which don't have an explanation with them, look in tex.tex (the first file).

Based on my personal latex templates. This of course doesn't include everything you can do with latex, but this should cover ~90% of most use cases. Note that these files assume you know basic LaTeX.

If this is the first of the two files you run into; do read the general LaTeX notes in the first file.

TYPOGRAPHY AND TYPESETTING

see tex.tex for these

\usepackage{fontspec}
\usepackage{parskip}
\usepackage[document]{ragged2e}
\usepackage[inline]{enumitem}
\usepackage[english]{babel}
\usepackage{csquotes}

Handles "numbering" the appendices. See the example in the document's body below.

CTAN: https://www.ctan.org/pkg/appendix

\usepackage[toc,page]{appendix}

If you want to hate reading more than you probably already do (you're an engineer) use this. These specific options slim down the margins, thereby allowing more text on one line. But doing that hurts my eyes. The LaTeX defaults are there for a reason—leave them. Lines of approximately 80–90 characters long are easier to read. Typography is important. (https://practicaltypography.com/line-length.html)

But the geometry package can do more; it allows good control over the document's dimensions. So when you do actually need this, you'll know it exists.

CTAN: https://www.ctan.org/pkg/geometry

\usepackage[a4paper,left=2.5cm,right=2.5cm,bottom=3cm]{geometry}

PROJECT SETUP

In my opinion the best way to handle multiple file latex projects. This doesn't have any of the weird constraints the other options have, and it changes graphix's import path so you can load images relative to the file you're writing in.

See the document body for some concrete examples.

CTAN: https://www.ctan.org/pkg/import

\usepackage{import}

MATH AND SCIENCY STUFF

Nice package for typesetting units. A better option than abusing math mode. Also includes macros for nicely typesetting numbers, like with spaces between the thousand-places, or for number ranges (also see below). Read the manual for all the cool options!

CTAN: https://ctan.org/pkg/siunitx

\usepackage{siunitx}
\sisetup{
    range-units = single,
    range-phrase = ---,
    exponent-product = \cdot
}

You can then use them like so:

But read the manual, there are abbreviations for common prefix/unit pairs (like \kg) and there are many more options.

I usually define these in projects if I want to have the text flow nicely but still have a range. The default is an em-dash (see above), but sometimes and/to is nicer.

\newcommand{\SIand}[3]{\SIrange[range-phrase =\ and\  ]{#1}{#2}{#3}}
\newcommand{\SIto}[3]{\SIrange[range-phrase =\ to\  ]{#1}{#2}{#3}}

American Mathematical Society's math packages. Yes, you can load multiple packages at once.

Amsmath handles the equation environments and such; basically improving on the basis LaTeX provides. Amssymb adds extra math symbols, and most importantly \mathbb for sets and such (it loads amsfonts internally). (See also https://tex.stackexchange.com/questions/32100/what-does-each-ams-package-do) CTAN: https://www.ctan.org/pkg/latex-amsmath

Note that there are more math fonts available through other packages, such as mathrsfs. See (http://www.peteryu.ca/tutorials/publishing/latex_math_script_styles) I personally only use \mathbb and \mathcal (and \mathfrak if I really have to), so just loading amssymb/amsfonts is usually enough.

\usepackage{amsmath, amssymb}

As an example of amsmath powers, I defined these for my module 7 project. Useful for fluid mechanics and such.

\DeclareMathOperator{\dvg}{\nabla \cdot}
\DeclareMathOperator{\grad}{\nabla}
\DeclareMathOperator{\curl}{\nabla \times}

Furthermore, by default the Re() and Im() use the aforementioned Fraktur font. It looks pretty but it hurts my eyes, so I redefined it like this

\renewcommand{\Re}[1]{\mathbb{R}\text{e}\left(#1\right)}
\renewcommand{\Im}[1]{\mathbb{I}\text{m}\left(#1\right)}

Also, the built in floor is kinda hard to use and the spacing is apparently slightly off, so you can define a command with mathtools to make a macro for it like so: CTAN: https://www.ctan.org/pkg/mathtools

\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

Then use as \floor*{x} and \ceil*{x} See: https://tex.stackexchange.com/questions/118173/how-to-write-ceil-and-floor-in-latex

The "modern" way to do citations. Advantages include:

  1. UTF-8 support (also see the XeTeX note in tex.tex)
  2. Babel support
  3. And much more (mostly to do with programmability and extensibility)

For Mechanical Engineering, I have yet to run into problems with this setup, but YMMV

See also: https://tex.stackexchange.com/questions/25701/bibtex-vs-biber-and-biblatex-vs-natbib CTAN: https://www.ctan.org/pkg/biblatex

\usepackage[backend=biber, style=ieee]{biblatex}

The usual way to use biblatex to point it to .bib files, like so:

\addbibresource{refs/niels.bib}

But it also supports remote data sources, and probably other things too!

CHEATSHEET FOR MANUALLY WRITING .BIB ENTRIES: http://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf

NICE TO HAVES

See <tex.tex> for what these do.

\usepackage{footnotebackref}
\usepackage{graphicx}

You can use this for subfigures in one floating figure element

CTAN: https://www.ctan.org/pkg/subcaption

\usepackage{subcaption}

Sometimes floats don't really cooperate, and don't exactly go where you want them to go (that's expected behaviour; in 99% of cases it's better to let LaTeX handle the layout, flow, and typography).

In those 1% of cases where you do actually need it, float provides an interface to modify the behaviour of floats and define new ones.

Probably the most important thing to most engineers is the [H] placement specifier, also known as the stricter version of [h]: your figure will go exactly there and will probably nuke the rest of your layout. Caveat Emptor.

Again, consider letting LaTeX handle the layout by using even less strict placement specifiers like [hbt] (here(-ish), bottom, top (of the page))

CTAN https://www.ctan.org/pkg/float

\usepackage{float}

Sometimes floats (think figures, tables) still don't cooperate and flow into the next section. You can use this to prevent them from doing that.

Again, LaTeX probably has good reasons for them to flow that way (it is the embodiment of 40+ years of typesetting knowledge). But large numbers of figures may cause issues anyway, so that's a good excuse to feel less guilty about using it.

CTAN: https://www.ctan.org/pkg/placeins

\usepackage{placeins}

Then use \FloatBarrier for points where floats shouldn't fload past. But read the manual (it's just two pages) for more information.

Allows for the import, typesetting, etc. of code snippets. For syntax highlighting it requires some extra software, but on Overleaf that should already be installed.

CTAN: https://www.ctan.org/pkg/minted

\usepackage{minted}

You can also do coloured text in latex! See: https://www.overleaf.com/learn/latex/Using_colours_in_LaTeX

CTAN: https://www.ctan.org/pkg/xcolor

\usepackage{xcolor}

By default, LaTeX' report class has a big swath of white space before the chapter beginning. Personally this doesn't bother me too much but it irks other engineers, so now you know how to fix this too.

CTAN: https://www.ctan.org/pkg/titlesec

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}
	{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{40pt}

\usepackage{hyperref}
\hypersetup{
	colorlinks=true,
	urlcolor=blue,
	citecolor=blue,
	linkcolor=blue,
	pdfstartview={XYZ null null 1.00},
	pdftitle={},
	pdfauthor={}
}

DOCUMENT BODY

\begin{document}

This is, as you probably know, the place where the actual text of your document goes. Since the above uses some packages which may need some more explanation, this bit includes an example of how to lay out the main file of a multi-file latex project, and some extra tricks.

Don't print page numbers, useful for the first (couple of) pages

\pagenumbering{gobble}

THE SLASH AFTER GLUE IS IMPORTANT!!! If you omit the trailing slash in the path you'll get weird errors

\import{glue/}{titlepage.tex}

consider using the abstract environment in this file

\import{glue/}{abstract.tex}

like so \begin{abstract} the abstract \end{abstract}

Use roman page numbers

\pagenumbering{roman}

Print the toc

\tableofcontents

\clearpage % <-- without this it switches over to arabic a page to early

Use arabic (so 1 2 3 etc) page numbers

\pagenumbering{arabic}

This is how to add a starred chapter/section/whatever to the table of contents

\chapter*{Introduction}\addcontentsline{toc}{chapter}{Introduction}\label{intref:intro}

The first argument is the directory, and then the second argument is the file to include. Use \subimport{}{} down further (But RTM).

\import{glue/}{introduction.tex}

\chapter{A}\label{intref:a}
\import{A/}{a.tex}
\import{A/}{b.tex}
\import{A/}{c.tex}

\chapter{B}\label{intref:b}
\import{B/}{a.tex}
\import{B/}{b.tex}
\import{B/}{c.tex}

\chapter{C}\label{intref:b}
\import{C/}{a.tex}
\import{C/}{b.tex}
\import{C/}{c.tex}

\chapter{D}\label{intref:b}
\import{D/}{a.tex}
\import{D/}{b.tex}
\import{D/}{c.tex}

\chapter{E}\label{intref:e}
\import{D/}{ethics.tex}

Appendices are numbered like A B C

\begin{appendix}
\import{appxs/}{one.tex}
\import{appxs/}{two.tex}
\end{appendix}

print the bibliography (see biblatex), and put the heading in the table of contents

\printbibliography[heading=bibintoc]

\end{document}
  1. TYPOGRAPHY AND TYPESETTING
  2. PROJECT SETUP
  3. MATH AND SCIENCY STUFF
  4. NICE TO HAVES
  5. DOCUMENT BODY