Tips for LaTeX

Tips for LaTeX

References

image-20250918-173413.png
Potential issues if the references are not well managed: missing types or inconsistent formatting.

To ensure a good uniformity in the way you reference elements (figures, sections, etc…) in your document, you can use the library cleveref.

The cleveref package allows you to define the format for the different types of cross-references once-and-for-all in the preamble of your document.

In the document’s preamble (e.g. root.tex), after all other packages modifying the referencing system:

\usepackage{cleveref} %% If you want to personalize the references, redefine the formatting like that: \crefname{figure}{Figure}{Figures} \crefname{table}{Table}{Tables} \crefname{section}{Section}{Sections}

In the content files:

Replace all instances of \ref by \cref.

\cref{<label>}

Note: at the beginning of a sentence, use \Cref instead of \cref.

Glossary

For field-specifics terms and acronyms, it is convenient to make use of a glossary. In a paper, even if you do not print the glossary, it ensures that the long version of the acronym will be printed the first time it is used only. The package glossaries is used for that. Glossaries

Import the glossaries package in the preamble, with the acronym parameter:

\usepackage[acronym]{glossaries} \makeglossaries

Define the entries in the preamble:

\newglossaryentry{latex} { name=latex, description={Is a markup language specially suited for scientific documents} } \newacronym{dof}{DOF}{Degrees of Freedom} %\newacronym[description={<description>}, shortplural={<short plural>},longplural={<long plural>}] %{<label>}{<abbrv>}{<full>}

Use it in the text with the following command:

\gls{DOF} % for singular \glspl{DOF} % for plural \Gls{DOF} % for singular, uppercase for the first letter \Glspl{DOF} % for plural, uppercase for the first letter \gls*{DOF} % Add a star if you do not want the symbol to appear as a link to the glossary in the text (useful if you do not print the glossary in a paper)

In a paper, the acronyms should be repeated in the abstract and in the rest of the paper. In a book or thesis, they should be repeated in each chapter. Reset them using the following command:

\glsresetall % Reset the status of all acronyms (first use or not)

General tips

  • To facilitate the tracking of changes and also the navigation in Overleaf from PDF to code editor, it can be useful to use a newline for each sentence. (This will not be visible in the pdf, as only double line break in the editor creates a line break in the output.)

Institut für Mechatronik im Maschinenbau (iMEK), Eißendorfer Straße 38, 21073 Hamburg