LaTeX article/essay 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 1/2. This file is for smaller documents (think essays, small articles, letters), which usually do well a small set of packages. For more elaborate setups, see etex.tex. If you need some scientific features in your essay (think units or a proper bibliography), see the section MATH AND SCIENCY STUFF in that same document.
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 some basic latex.
But some general LaTeX notes regardless:
-
Feel guilty when you change LaTeX from its defaults. It's the embodiment of 40+ years of typesetting knowledge and research; there's usually a good reason for why LaTeX has those defaults.
-
Consider using XeTeX/XeLaTeX over "normal" LaTeX/PDFTex. XeTeX has built-in support for utf-8, which is the post-2000 way of encoding text streams (that also means that you don't need
in files you compile with XeLaTeX). This enables you to use multi-byte characters in your text, so German, Arabic, Chinese, etc. should be within reach. Most of this document just uses the ASCII subset (so one byte) of UTF-8, but here some multi-byte characters:- ß <- German Eszett (2 bytes)
- ẞ <- Capital form of the above (3 bytes)
- ë <- Dutch trema (2 bytes)
- 森 <- Japanese kanji for woods/forest (4 bytes)
- ¶ <- Pilcrow, the paragraph marker (2 bytes) (prefer
\Pin latex) - § <- Silcrow/section marker (2 bytes) (prefer
\Sin latex)
Furthermore, XeLaTeX also has great support for fonts! You can basically select any font installed on your system, while with LaTeX this is a bit more problematic/involved at times.
-
Don't end paragraphs with
\\; just use two newlines (so enter/enter) instead. It doesn't actually end the paragraph, and causes a host of other problems which you probably don't want (See: https://tex.stackexchange.com/questions/82664/when-to-use-par-and-when-newline-or-blank-lines) -
Don't force figures, let them flow free! In 99% of cases, it's better to let LaTeX handle the layout; consider using no specifier or
[hbt]over[h]or[H](see 2/2 for the latter) in combination with apair (Thegoes after the caption). -
Use math mode for math; please don't (ab)use them for other thinks (so, for example,
\textsuperscriptfor super script, not. Note that using math mode usually switches to a different font.
Some other good resources besides my rants are:
- CTAN (a link is provided with each package explained, it also has the manuals for most of the packages referenced);
- https://tex.stackexchange.com;
- https://practicaltypography.com. ← especially this one, it's great.
TYPOGRAPHY AND TYPESETTING
Allows you to select fonts. Works without any other packages and with almost all fonts in XeLaTex, but requires inputenc(?) with pdftex. CTAN: https://ctan.org/pkg/fontspec
The actual font selection. You can select fonts per block/thing/whatever, but read fontspec's manual for that
\setmainfont
LaTeX's default is fully justified text. This changes that to left-aligined, leaving a ragged edge on the right while still allowing some hyphenation. (https://www.ctan.org/pkg/ragged2e)
Some argue that left-aligned is more readable, but it's just what you prefer (https://practicaltypography.com/justified-text.html)
Handles language-specific hyphenation and other typographical rules CTAN: https://www.ctan.org/pkg/babel
Context specific quotations. It's really fancy; it automatically adjust the quoting delimiters depending on how you nest the quotes, and on the language of the document. In Dutch, the outer quote is "" and the inner quote ', while in french they use guillemets. Due to the localization features best used with babel. CTAN: https://www.ctan.org/pkg/csquotes
But tbh usually I'm too lazy and just do this: ``some quote''. If you're not using it's features you can leave it out, but unless you're really worried about compilation times I'd just leave it in.
Better list formatting. Allows the configuration of the spacing, numbering, bullets, what have you. Also nice for inline lists.
Removes the "paragraph skip". LaTeX' default is to separate paragraph by indenting their first line, but this irks many engineers.
CTAN: https://www.ctan.org/pkg/parskip See also https://tex.stackexchange.com/questions/40429/how-to-use-the-parskip-package-space-in-between-paragraphs
NICE-TO-HAVES
This uses hyperref to have the footnote link back to where its source CTAN: https://www.ctan.org/pkg/footnotebackref
Allows you to load in images; "enhanced graphics support"
Hyperref handles hyperlinks, (IIRC) both within the document itself (think to footnotes, the table of contents, links to figures, etc.), but also to external resource (think urls and such). I think it might also handle the TOC in the pdf.
Hyperref must be the last package loaded, otherwise LaTeX requires extra compilation runs. But read the manual of course.
Hyperref's defaults are kind of shit (the red boxes around the links), so this setup sets them to the "web defaults" (blue underlined links)
It also sets the page to which the pdf will open by default (so the first page), and the pdf author and title fields. IIRC, you can set more metadata fields but this is what I usually do
\hypersetup
This is the setup for the \maketitle macro. It is really simplistic, so if you want
more you probably have to roll it yourself. But for single-author documents/articles
it's usually fine. For student stuff, the way I put my student number in the document
is: \author
\title
\author
You can use \date for the current date, but consider writing the date yourself
for repeatable compilations and control over the date's format (like \date).
\date
\begin{document}
Prints the title block. Should be used before any text.
\maketitle
\end{document}