Key Points
Introduction to the LaTeX Workflow
- We can use the TeXworks editor to write and compile LaTeX documents.
- The TeXworks interface is divided into three main sections: the editor, the preview pane, and the menu bar.
- We can compile a LaTeX document by clicking the “Typeset” button in the TeXworks editor.
- We can also compile a LaTeX document from the command line using the
pdflatexorlualatexcommand.
Basic LaTeX Document Components
- The
%character is used to add comments to a LaTeX document. - LaTeX documents are a mixture of text and commands.
- Commands start with a backslash
\and sometimes have arguments in curly braces{}. - We can view errors by either clicking on the “Logs and output files” or hovering over the red circle in the text editor.
Error Handling
- Errors are common! Don’t be discouraged by them.
- The first error message is usually the most important one to fix.
- Read the error messages carefully, they often tell you exactly what the problem is.
The Structure of a Document
- LaTeX documents are structured using section commands.
- There are many different section commands in LaTeX, including
\subsubsection{...},\paragraph{...},\chapter{...}, and more. - Lists in LaTeX are created using the
enumerateanditemizeenvironments.
Using Document Classes
- LaTeX document classes set the general layout of the document
- The base document classes are
article,report,book,letter, andslides - Third-party classes can provide additional features
Extending LaTeX
- We can extend LaTeX’s functionality by adding packages to our document.
- We can define custom commands in LaTeX using the
\newcommandcommand.
Using Graphics
- The
graphicxpackage allows us to include images in our LaTeX document. - We can adjust the appearance of images using options in the
\includegraphicscommand. - We can position images manually or automatically using environments
like
centerandfigure. - Floating images can move around the page as text is added or removed.
- We can control the position of floating images using parameters in
the
figureenvironment. - We can add captions to floating images using the
\captioncommand.
Tables
- Tables in LaTeX are created using the
tabularenvironment. - The
arraypackage provides additional functionality for creating tables. - The
booktabspackage provides commands for creating horizontal lines in tables. - The
\multicolumncommand can be used to merge cells in a table. - The
\multirowcommand in themultirowpackage can be used to merge rows in a table.
Adding Cross References
- The
\label{}command marks a spot in the document. - The
\ref{}command refers to a marked spot in the document.
Mathematics
- Inline math mode is marked with
$ ... $or\(...\) - Display math mode is marked with
\[ ... \] - Use
\qty{}{}or\unit{}for properly writing numbers with their scientific unit.
Fonts, Formatting and Spacing
- Use the
parskippackage to add space between paragraphs - Force a new line with
\\ - Add explicit space with
\hspaceand\vspace - Format text explicitly with
\textbf,\textit, etc. - Align text with
\centering,\raggedright, and\raggedleft
Documentation and Finding Help
- CTAN is a large archive of LaTeX packages and documentation
- Texdoc is a website & command line tool for searching LaTeX documentation