Learn LaTeX by writing a document.
Eight short lessons and a quick reference. Each lesson has an example you can paste into Tulip and compile.
1. Your first document
LaTeX turns plain text and a few commands into a typeset document. Create a blank project in Tulip, open main.tex, and replace its contents with this example. Then press the play button to compile.
\documentclass{article}
\title{My first paper}
\author{Your name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Every good project starts with a question.
\end{document}
1Introduction
Every good project starts with a question.
1Everything before \begin{document} is the preamble: the document’s setup. Your writing belongs between \begin{document} and \end{document}.
2. Give your writing structure
Use commands for meaning rather than manually styling every heading. LaTeX handles numbering and spacing. Leave a blank line between paragraphs.
\section{Methods}
This is the first paragraph.
This is a new paragraph with \emph{emphasis}.
\subsection{Measurements}
Explain how the data were collected.
1Methods
This is the first paragraph.
This is a new paragraph with emphasis.
1.1Measurements
Explain how the data were collected.
1A larger project can split chapters across files with \input{chapters/methods}. Compile the root document that contains \documentclass, rather than an individual chapter.
3. Write mathematics
Put short mathematics inside $…$. Use an equation environment for a numbered expression. Labels let you refer to equations without hard-coding a number.
Inline mathematics: $E = mc^2$.
\begin{equation}
\sum_{i=1}^{n} x_i = n\bar{x}
\label{eq:mean}
\end{equation}
See Equation~\ref{eq:mean}.
Inline mathematics: E = mc2.
See Equation 1.
1Packages such as amsmath add more mathematical environments. Add \usepackage{amsmath} in the preamble when you need them.
4. Add a figure
Upload an image into your project first. File paths and capitalization must match. The example below expects a file named result.png inside a figures folder.
% Add this in the preamble, before \begin{document}:
\usepackage{graphicx}
% Upload figures/result.png, then use this in the document:
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\linewidth]{figures/result.png}
\caption{The result of the experiment.}
\label{fig:result}
\end{figure}
See Figure~\ref{fig:result}.
See Figure 1.
1The letters in [htbp] suggest where the figure may be placed: here, top, bottom, or a separate page. LaTeX makes the final placement decision.
5. Make a table
A tabular holds the cells; a table around it adds a caption, a label and placement. Each letter in {lrr} is a column: left, right, right. & separates cells and \\ ends a row.
\begin{table}[htbp]
\centering
\begin{tabular}{lrr}
\hline
Sample & Mass (g) & Volume (mL) \\
\hline
A & 12.4 & 10.0 \\
B & 15.1 & 12.5 \\
\hline
\end{tabular}
\caption{Measurements for each sample.}
\label{tab:samples}
\end{table}
See Table~\ref{tab:samples}.
| Sample | Mass (g) | Volume (mL) |
|---|---|---|
| A | 12.4 | 10.0 |
| B | 15.1 | 12.5 |
Table 1: Measurements for each sample.
See Table 1.
1The booktabs package gives the cleaner rules most journals expect: \toprule, \midrule and \bottomrule, with no vertical lines.
6. Cite your sources
A short bibliography can live directly in the document. Put the bibliography before \end{document}, then cite an entry where you discuss it.
\begin{thebibliography}{9}
\bibitem{einstein1905}
Albert Einstein.
On the electrodynamics of moving bodies.
Annalen der Physik, 1905.
\end{thebibliography}
% Cite this entry elsewhere in the document:
% \cite{einstein1905}
References
[1]Albert Einstein. On the electrodynamics of moving bodies. Annalen der Physik, 1905.
1For more than a handful of entries, use a .bib file instead (next lesson). Cross-references can take more than one compilation pass to resolve.
7. Use a .bib file
For anything longer than a few references, keep entries in a .bib file. Export one from Zotero, Mendeley or your reference manager, upload it, and cite entries by key. The bibliography lists only what you cite.
@article{einstein1905,
author = {Albert Einstein},
title = {On the Electrodynamics of Moving Bodies},
journal = {Annalen der Physik},
year = {1905},
}
% In the preamble:
\usepackage[style=authoryear]{biblatex}
\addbibresource{references.bib}
% In the text:
\textcite{einstein1905} introduced special relativity.
% Where the bibliography should appear:
\printbibliography
Einstein (1905) introduced special relativity.
References
Einstein, Albert (1905). “On the Electrodynamics of Moving Bodies”. In: Annalen der Physik.
1If your journal template uses BibTeX instead of biblatex, keep its \bibliographystyle{…} and replace \printbibliography with \bibliography{references}. Tulip runs Biber or BibTeX for you.
When it doesn’t compile
- Open the compilation output and start with the first error; later errors may be consequences.
- Check matching braces,
\begin/\endpairs, and the exact paths of images. - Use
\%,\&, and\_for these characters in ordinary text. - Check that the main file is the one with
\documentclass. Missing packages download automatically; if one still fails, the compile log names it.
Quick reference
| To get | Write |
|---|---|
| Bold, italic | \textbf{…} \emph{…} |
| A bulleted list | \begin{itemize} \item … \end{itemize} |
| A numbered list | \begin{enumerate} \item … \end{enumerate} |
| A footnote | \footnote{…} |
| A link | \usepackage{hyperref} … \url{…} |
| Fraction, root | \frac{a}{b} \sqrt{x} |
| Sub- and superscript | x_{i} x^{2} |
| Sum, integral | \sum_{i=1}^{n} \int_{0}^{1} |
| Greek letters | \alpha \beta \gamma \Delta |
| Aligned equations | \begin{align} a &= b \\ c &= d \end{align} |
| A cross-reference | \label{sec:intro} … \ref{sec:intro} |
| A page break | \newpage |
| %, &, _, # in text | \% \& \_ \# |
Can’t find a symbol? Draw it in Detexify