LaTeX writing tips

When writing a research paper, thesis, report, or just any type of document, there are many different systems for preparing your document – WYSIWYG systems, such as Word and Pages, and typesetting systems, such as LaTeX to mention a few. When writing reports and research papers, especially within disciplines that requires equations and calculations, LaTeX is popular.

The principles of writing documents in LaTeX is very similar to writing in HTML and styling using CSS. Simplified, the files used in LaTeX are template files for formatting and styling, source code files for your content, and output files. The output files are the formatted pdf-files. Another feature of LaTeX is the handling of the references using e.g., BibTeX.

You can either download and install LaTeX on your local computer or use an online editor, e.g., Overleaf when writing and compiling your document. Even though these things are general, I strongly recommend using BibTeX with Overleaf when writing.

Below are som Tips & Trix on using LaTeX that I have collected over the years, most often as frequent errors in students’ papers.

Tips on how to organize the LaTeX project during writing

Include the right packages.

Nice packages for writing and styling:

  • Include the hyperref package to use hyperlinks in your text.
  • Include the graphicx package for enhanced graphics support.
  • Include the xcolor package for color support.
Break up large TeX-files

If you are writing a longer document, e.g., a thesis or report, it might be of value to split the document into smaller parts, e.g., the different chapters of your writing. It becomes easier to find and edit text. The different files are included into the main document using the command \include{ }.



Labels and cross-references

Put labels on figures, images, and anything that is included in your writing that you want to cross-reference. Making a cross reference to a label makes e.g., figure number or page number to be updates automatically.

LaTeX code:
%labeling figures, tables, etc.

%Writing cross-reference in LaTeX code:
The results from the survey are presented in figure \ref{fig:survey-results} on page \pageref{fig:survey-results}.

The results from the survey are presented in figure 4 on page 36.

Here are some small tips & trix on using LaTeX
(a.k.a. Frequent errors in student papers)

Swedish (or other special) characters

Check for the ability to write Swedish (or other non-English) characters (most often noticed when writing Umeå University).

If you are using Swedish (or other non-English) characters regularly through a paper, e.g., when writing in another language than English, add the UTF-8 package (see below). If you are writing in e.g., English and using just a few non-English (or other special) characters, you can type special characters directly into your code (see example below).

% Adding the UTF-8 package

% Swedish special characters in any LaTeX code
\AA    % Å
\aa    % å
\"{A}  % Ä
\"{a}  % ä
\"{O}  % Ö
\"{o}  % ö

% Other useful special characters
-       % Hyphens (-)
--      % en-dash (–) (sv: tankstreck) (Used to mark ranges, e.g., pages in reference lists)
---     % em-dash (—) (Used to separates extra information in text)
\ldots  % Ellipsis (…) (Used when omitting information, e.g., in a quote)

\&      % Ampersand, and-sign (system characters need to be escaped using \ ) 
~       % Non-breaking space
Space before (any) reference

Put a space between the last word before the reference and the reference: “… as been shown [7].” or “…as been shown (Mejtoft, 2011).” Use “ “ or “~” (non-breaking space) in source code. Most often a non-breaking space might be your best option.

LaTeX code (using natbib):
… as been shown~\cite{Mejtoft:2011}

… as been shown [7].


… as been shown (Mejtoft, 2011).
Quotation marks

Single quotation marks are produced using ` at the start and ‘ at the end. Double quotation marks (for citation) are produced by typing ` ` and ‘ ‘ (two directed single quote characters at the beginning and two undirected single quotation characters at the end of the quote. Then you will get distinctly left-handed and right-handed typographic quotation marks.


LaTeX code:
Previous research has defined this as a ` `total waste of time' ' regarding tracing.

Previous research has defined this as “a total waste of time” regarding tracing.
LaTeX code (using natbib):
\citet{Mejtoft:2000} states that ` `previous research has defined this as `a total waste of time' regarding tracing' '.

Mejtoft (2000) states that “previous research has defined this as ‘a total waste of time’ regarding tracing”.

If the single and double quotation follow each other, the control sequence \, should be used to ensure the right spacing in-between the different quotation marks.


LaTeX code (using natbib):
Tracing --- according to \citet{Mejtoft:2000}, ` `previous research has defined this as `a total waste of time'\,' '.

Tracing – according to Mejtoft (2000), “previous research has defined this as ‘a total waste of time’ ”.
Width of figures

It is possible to specify the width of figures, to set the appropriate size of the figure compared to the rest of the document. It might be necessary to work with textwidth, columnwidth, and linewidth, depending on the situation. Read more.

% Sets the width to the full width of the text
% Sets the width to 80% of the width of the text

% Sets the width to the full width of the column (valuable when having two or more columns)
% Sets the width to 60% of the full width of the column

% Sets the width to 50% of the length of the line in the current environment

Force line break on long weblinks

From time to time, long URLs do not break in the reference list (and sometimes in other parts of the paper). To solve this problem, use the package url and define characters that is used for line break (if necessary).


\def\UrlBreaks{\do\-\do\.}   % Defines "-" and "." as characters for line break 

For most references you can export references as BibTeX from the publishers’ websites and the databases, e.g. ACM Digital Library, IEEE Xplore, ScienceDirect etc.

Use the right type in the BibTex entries – @article, @inproceedings, @book, @inbook, @online, @techreport being some of the most common.

More on writing references using BibTeX here.

Licensed under a Attribution-ShareAlike 4.0 Creative Commons license.

(First published by Thomas Mejtoft: 2020-02-20; Revised: 2022-04-05; Last updated: 2023-02-21)