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

• 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{ }.
\include{introduction.tex}
\include{background.tex}

...

• Labels and cross-references. Put labels on figures, images, and anything that is included in your writing. Making a cross reference to a label makes e.g., figure number or page number to be updates automatically
...
\label{fig:survey-results}
...

Cross-reference:
The results from the survey are presented in figure \ref{fig:survey-results} on page \pageref{}.

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

Here are some small tips & trix on LaTex (a.k.a. Frequent errors on 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, add the UTF-8 package (see below). If you are using just a few Swedish (or other special) characters, you can type special characters directly into your code (see example below).
% Adding the UTF-8 package
\usepackage[utf8]{inputenc}

% 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)
---    % em-dash (—) (Used to separates extra information)
• Space before (any) reference. Put a space between the word and the reference: “… as been shown [7].” Most often a non-breaking space might be your best option.
Use “ “ or “~” (non-breaking space) in source code.
• Include the right packages. Nice packages for writing and styling.
Include the graphicx package for enhanced graphics support.
Include the xcolor package for color support.
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{xcolor}
• Quotation marks. Single quotation marks are produced using  and ‘. 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.

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

Output:
Previous research has defined this as “a total waste of time” regarding tracing.
LaTeX code:
Mejtoft (2000) states that  previous research has defined this as a total waste of time' regarding tracing' '.

Output:
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.

Example:

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

Output:
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
\includegraphics[width=\textwidth]{results.png}
% Sets the width to 80% of the width of the text
\includegraphics[width=.75\textwidth]{results.png}

% Sets the width to the full width of the column (valuable when having two or more columns)
\includegraphics[width=\columnwidth]{results.png}
% Sets the width to 60% of the full width of the column
\includegraphics[width=.6\columnwidth]{results.png}

% Sets the width to 50% of the length of the line in the current environment
\includegraphics[width=.5\linewidth]{results.png}


• 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).
\usepackage{url}

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

BibTeX. 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.