Your First LaTeX Document
LaTeX is a markup language: you write plain text with commands such as \section{...}, and a compiler turns it into a typeset PDF. In Coauthor the compiler runs in the cloud, so the whole loop is type, click Compile, read the PDF. This page walks through a minimal document from an empty file to a compiled PDF.
- In the workspace panel on the left, click Create new folder and give your project a name, for example
My Paper. LaTeX projects must live in a folder. - Click Create new document. In the Create New Document dialog choose LaTeX Document as the type and Empty Document, enter a filename such as
main.tex, pick your folder, and click Create Document. - Hover over the new file in the folder, click More options, and choose Set as main. A main badge appears next to it. See LaTeX Main Files.
If you would rather start from a working paper, pick From Template instead; see Using Templates.
Type or paste this into main.tex:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\title{A Short Study of Something}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
One paragraph summarizing the work.
\end{abstract}
\section{Introduction}
This is the first paragraph. Blank lines separate paragraphs;
single line breaks do not.
\section{Method}
Text can be \textbf{bold}, \textit{italic}, or \emph{emphasized}.
\end{document}
Tip: in the editor, type \documentclass{ and pick article from the autocomplete popup. On an empty line this inserts a complete skeleton very similar to the one above. See Autocomplete, Snippets, and Find & Replace.
| Part | Purpose |
|---|
\documentclass[12pt]{article} | Chooses the overall layout. article is right for papers; report and book add chapters. Options in [...] set things like font size or two-column layout |
Preamble (everything before \begin{document}) | Loads packages with \usepackage and sets metadata. Nothing here appears in the PDF directly |
\title, \author, \date | Store the title block; \maketitle prints it |
\begin{document} ... \end{document} | The body. Everything you want printed goes here |
\section{...} | A numbered heading. Numbering, spacing, and fonts are handled for you |
% | Starts a comment; the rest of the line is ignored by the compiler |
Every \begin{x} needs a matching \end{x}. The editor inserts the \end line automatically when you close the brace of a \begin{...}.
- Click Compile in the toolbar (or press Ctrl+S).
- Watch the button: Compiling..., then Success!.
- The tab switches to the PDF view. Use LaTeX+PDF in the tab bar to see source and PDF side by side.
Auto compile is on by default, so from now on the PDF refreshes a few seconds after each change. See Compiling and PDF Preview.
If the button turns into a red error count, click it to open the Compilation Results panel and jump to the offending line. The most common first-timer mistakes are a missing \end{document}, a stray %-less & or _ in text, and an unmatched {. See Fixing Common LaTeX Errors.
These characters have meaning in LaTeX and must be escaped to print them literally:
| Character | Type |
|---|
% | \% |
& | \& |
$ | \$ |
# | \# |
_ | \_ |
{ } | \{ \} |
~ | \textasciitilde |
\ | \textbackslash |
Quotation marks are typed as `` and '' (two backticks, two apostrophes); dashes are -, -- (ranges), and --- (punctuation).