Getting started with LaTeX

To use the LaTeX editor, open or create a file whose name ends in .tex. By default, you should see an editor similar to the one in the screenshot below:

default CoCalc .tex file editing tab showing 4 panes

Building In general, you edit source code and compile it to a PDF document. Click the “Build” button (or hit shift+enter or alt+t) to build the tex file and produce a PDF. You can also check “Build on save: build LaTex file whenever it is saved to disk” in account preferences, and a build will be triggered whenever your file is saved to disk.

Interface In the initial screen layout, the source is on the left and a preview of the compiled PDF is on the right. Also, there are frames showing issues, warnings, errors, and the build log. You can close any of these panels by clicking the x in the upper right of the panel. You can also split them as much as you want, and change what is displayed in any panel. If you close all the panels, the default layout is restored.

  • The PDF Preview shows the PDF document.

    • You can easily position the preview by using the mouse to drag the preview around.

    • There are buttons for zooming, and expanding to the vertical and horizontal height.

    • There are also buttons for printing and downloading the PDF.

  • Errors and Warnings

    • The Errors and Warnings frame lists all compilation errors and warnings, and other issues. Click on the line number link to jump to the corresponding line in the input code on the left and the preview on the right. LaTeX may fail to compile (or only partially or in a wrong way) if there are many errors.

  • The PDF - Native view (not shown by default) shows you an embedded view of the compiled PDF file, using your browsers native PDF view. This might be broken if your browser has problems rendering the file inline – use the “PDF Preview” view instead. Also, you can’t double click on the Native view to move back to jump to the corresponding tex.

  • The Build Control view gives you more control over how the compilation process works:

    • You can click in the build command line and edit it however you want, or select a different engine from the dropdown menu. By default, we compile using LatexMK, which manages temporary files and BibTeX.

    • Click Clean to delete autogenerated temporary files.

LaTeX 101

It is very easy to start with LaTeX. CoCalc guides your first document with a small default template. You start working between the \begin{document} ... \end{document} instructions.

Everything before \begin{document} is called the preamble and contains the configuration for the document.

For example, remove the \maketitle instruction and replace it by

> Hello \textbf{CoCalc}! This is a formula: $\frac{1}{1+x^2}$.

After saving ([CTRL] + [s] or click the green Save button at upper left), the file will build, and you should see an updated PDF preview.

  • New paragraphs: Single returns for new lines do not have any effect. Use them to keep new sentences in paragraphs at the beginning of a line for better overview. Two or more returns introduce a new paragraph.

  • Formulas: They’re either between $ or $$, or in \begin{equation}...\end{equation} environments.

You can also import your existing documents by uploading in “Files” or importing from ShareLatex/Overleaf.