In academic writing with LaTeX there are a lot of things that can be frustrating to the author. For many of these things there exists many packages that can help alleviate this frustration, but it is hard to find them. In this post I list 10 of my favorite packages to help remove some of this frustation, and make your papers look nicer so that you have a higher probability of getting your paper accepted. Hopefully.
Introduction
At the time of writing, The Comprehensive TEX Archive Network (CTAN) has 5841 packages. Many of these are used very often, such as amsmath
, graphics
and xcolor
(Cormode et al., 2012), and some are not used enough. This post is a list of packages that I find very useful in academic writing, but yet I don’t see them being used enough. And a blog isn’t really a blog without a top ten list, I guess.
Without further ado, in alphabetical order, here are 10 useful LaTeX packages for your writing pleasure.
Packages
adjustbox
The adjustbox
package (Scharrer, 2012) allows scaling of a figure or plot, for example one made in TikZ.
1
\usepackage{adjustbox} % Balances the columns of the last page
Here is an example from a real paper, slightly edited for clarity.
1
2
3
4
5
6
7
8
\begin{figure}[t!]
\centering
\begin{adjustbox}{width=.75\linewidth}%
\input{./figures/my_tikz_figure.tex}%
\end{adjustbox}%
\caption{An overview of our solution.}
\label{fig:overview}
\end{figure}
balance or flushend
The two columns on the last page of a two-column paper should be the same length. This package saves you from having to balance the columns manually (Daly, 1999).
1
\usepackage{balance} % Balances the columns of the last page
Simply add \balance
in the first column of the last page, and you’re done! Some users like the flushend
package better as this doesn’t require adding anything on the last page.
booktabs
Simply put, booktabs
(Fear, 2020) makes your tables look good!
Consider this example, adapted from Animal table with booktabs.png (licensed under the Creative Commons Attribution 4.0 International license).
1
\usepackage{booktabs} % Nicer tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
\documentclass[10pt, a4paper]{article}
\usepackage{booktabs}
\usepackage[tableposition=top]{caption}
\begin{document}
\begin{table}
\centering
\caption{This is my table, there are many like it, but this one is mine.}
\label{tbl:mytable}
\begin{tabular}{llr}
\toprule
\multicolumn{2}{c}{Item} \\
\cmidrule(r){1-2}
Animal & Description & Price (\$) \\
\midrule
Gnat & per gram & 13.65 \\
& each & 0.01 \\
Gnu & stuffed & 92.50 \\
Emu & stuffed & 33.33 \\
Armadillo & frozen & 8.99 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
cleveref
Using the cleveref
package (Cubitt, 2012), we can refer to figure, tables etc without specificing the type. See~\cref{tbl:mytable}
produces “See table 1”.
1
\usepackage[capitalise]{cleveref} % Clever references to stuff.
The result is configurable, and we can for example change the figure type name with \crefname{figure}{Fig.}{Fig.}
, where the first Fig.
is the singular form and the second is the plural form.
glossaries-extra
Using the package glossaries-extra
we can add a list of terms and a list of acronyms to our document (Talbot, 2016; Talbot, 2018). It is also very useful for making sure that acronyms are written out the first time they are used.
1
2
3
4
5
6
7
8
9
10
11
12
13
\usepackage[acronym,toc,symbols]{glossaries-extra}
\usepackage{glossary-longbooktabs}
\setabbreviationstyle[acronym]{long-short}
\makeglossaries
\newacronym{gcd}{GCD}{Greatest Common Divisor}
\newglossaryentry{eta}{name={\ensuremath{\eta}}, sort={eta}, description={Learning rate}, type={symbols}}
\clearpage
\printglossary[type=symbols,style=long-booktabs]
\clearpage
\printglossary[type=acronym,style=long-booktabs]
We can then use \gls{gcd}
whenever we need to use the acronym Greatest Common Divisor (GCD) or \gls{eta}
when we need to use the symbol for the learning rate. See Glossaries on Overleaf for more examples.
microtype
Text typeset in LaTeX already looks great, but can be made even nicer with microtype
(Schlicht, 2019). Looking deeper at the micro-typographics extensions provided by microtype
is a great way to ensure getting trapped in a rabbit hole for a long time. Here are the settings I use, borrowed from the excellent post Tips on Writing a Thesis in LaTeX (Khirevich, n.d.).
1
2
3
4
5
6
7
8
9
\usepackage[
protrusion=true,
activate={true,nocompatibility},
final,
tracking=true,
kerning=true,
spacing=true,
factor=1100]{microtype}
\SetTracking{encoding={*}, shape=sc}{40}
pgfplots
The pgfplots
package (Feuersänger, 2014) can be used for creating 2D and 3D plots. It is built on top of the PGF/TikZ package (Feuersänger et al., 2014) and allows the creation of high-quality, customizable, complex graphs, charts, or diagrams directly within your document.
The package supports a wide variety of plot types, such as line plots, scatter plots, bar plots, histograms, and contour plots. pgfplots
can load data from external files, enabling generation of plots without leaving the LaTeX environment. Used together with tikzplotlib
you can convert plots from matplotlib
.
1
\usepackage{pgfplots}
See Publication ready figures for a longer post on the pgfplots package (Feuersänger, 2014).
siunitx
Typesetting numbers with units is actually not trivial. siunitx
(Wright, 2009) adds, among others, the commands \SI
and \num
so that we can write \SI{1024}{\byte}
or \num{{}e5}
, which makes things look much nicer.
1
2
3
\usepackage{siunitx} % A better way of writing things with units
\sisetup{load-configurations = abbreviations, binary-units = true}
\DeclareSIUnit\px{px}
Another use for this package is for aligning numbers in a table, and we can directly use the table format S
or S[table-format=3.2]
, see also Publication ready tables.
tikz
TikZ and PGF (Feuersänger et al., 2014) are packages for programatically creating figures, and deserve a longer writeup.
1
2
3
4
5
6
7
8
\usepackage{tikz}
\usetikzlibrary{shapes, decorations, calc, arrows}
\usetikzlibrary{3d,fit,backgrounds, decorations.text}
\usetikzlibrary{positioning, shapes.symbols}
\usetikzlibrary{decorations.pathreplacing, calligraphy}
\tikzset{>=latex}
See more examples of TikZ figures on TeXample.net.
savetrees
Here is a controversial package. It really doesn’t belong on the recommended package list, but I will keep it here anyways. savetrees
(Pakin, 2007) is magic. It is highly useful when you are approaching a conference deadline and you have one page over the conference limit. Using the subtle
mode, we can preserve the document layout and try to make LaTeX pack text tighter.
1
\usepackage[subtle]{savetrees}
Conclusion
There are probably more top ten lists of LaTeX packages than there are packages, and here’s another one. Hope you enjoyed it!
What are your favorite packages? Comment below!
References
- Cormode, G., Muthukrishnan, S., & Yan, J. (2012). Scienceography: The study of how science is written. Lecture Notes in Computer Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics), 7288 LNCS, 379–391. https://doi.org/10.1007/978-3-642-30347-0_37
- Scharrer, M. (2012). The adjustbox Package. CTAN, 1–29. https://www.ctan.org/pkg/adjustbox
- Daly, P. W. (1999). Balancing the Two Columns of Text on the Last Page. 3–4. https://www.ctan.org/pkg/balance
- Fear, S. (2020). Publication quality tables in LaTeX. 1–18. https://ctan.org/pkg/booktabs
- Cubitt, T. (2012). The cleveref package. Sort, 1–28. https://www.ctan.org/pkg/cleveref
- Talbot, N. L. C. (2016). User Manual for glossaries. 1–240.
- Talbot, N. L. C. (2018). Glossaries-Extra : an Extension To the Glossaries Package. 1–201.
- Schlicht, R. (2019). Microtype. 1–249. https://ctan.org/pkg/microtype
- Khirevich, S. Tips on Writing a Thesis in LaTeX. Retrieved May 3, 2020, from http://www.khirevich.com/latex/microtype/
- Feuersänger, C. (2014). Manual for Plotting Package pgfplots. 1–500. https://ctan.org/pkg/pgfplots
- Feuersänger, C., Menke, H., & Tantau, T. (2014). TikZ & PGF manual. https://www.ctan.org/pkg/pgf
- Wright, J. (2009). siunitx — A comprehensive ( SI ) units package. System, 1–60. https://www.ctan.org/pkg/siunitx
- Pakin, S. (2007). The savetrees package. 1–25. https://www.ctan.org/pkg/savetrees
Suggested citation
If you would like to cite this work, here is a suggested citation in BibTeX format.