-
Notifications
You must be signed in to change notification settings - Fork 217
LaTeX Editor
LaTeX is a sophisticated markup language and processor for typesetting documents.
For a general introduction, read this LaTeX wiki book or any other resource.
To use the LaTeX editor, open or create a file whose name ends in .tex
. In general, you edit source code and compile it to a PDF document. CoCalc manages compilation for you, by regularly saving and running the LaTeX processor for you. In the initial screen layout, source is on the left and a preview of the compiled pdf is on the right.
At the top of the preview pane there are several tabs:
-
Preview quickly renders a few pages to see how the current part of the document looks.
- You can easily position the preview by hold-clicking and moving the mouse inside the shown preview.
- The first four buttons at the top are for zooming (our or in, zoom out to full width, and centered to the content of the page).
- The next button is for the resolution of the preview: smaller numbers load more quickly, while you see less detail.
- The last button is for downloading the PDF.
- Issues lists all compilation warnings and errors. Click on the buttons to jump to the corresponding line in the input code on the left. LaTeX may fail to compile (or only partially or in a wrong way) if there are errors.
- PDF shows you an embedded view of the compiled PDF file. This might be broken if your browser has problems rendering the file inline – use the "Preview" tab instead.
-
Build gives you advanced control over how the compilation process works:
- Recompile: erases all temporary documents and starts the compilation from scratch
- Latex: triggers a normal Latex build, which is much faster since temporary files are retained
- Bibtex: explicitly runs Bibtex, usually managed by the build process
- Sage: runs SageMath for SageTeX, usually managed by the build process
- Clean: deletes temporary files
- Command: One row down from the above buttons, the drop-down Command list on the right hand side lets you specify the compilation program. On the left, you can edit the command even further. It is saved as part of the document, at the bottom. By default, it runs LatexMK which manages temporary files and bibtex, and automatically runs SageTeX if necessary.
Forward and inverse search are extremely helpful for navigating in a larger document.
Forward: place your cursor at a specific location in the editor on the left-hand side.
Click the "Forward" button or the [ALT]
+[Return]
keyboard shortcut to jump to the corresponding
location in the preview on the right-hand side.
(In rare cases where full positional information is not available, this feature may not be active.)
Inverse: Double-click on an area of interest on the right hand side in the Preview area. The cursor on the left-hand side will jump to the paragraph in the source-code.
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), there should be a small spinner next to Build
and once done,
the preview renders. You should then see your text rendered in LaTeX.
- 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.
- latexmk + PDFlatex: the default configuration, works in most cases
- latexmk + XeLaTeX: this is useful for foreign languages with many special characters.
- latexmk + LuaTex: uses the LuaLaTeX engine.
UTF8: the build process runs in a Linux environment. All edited documents are assumed to be encoded as UTF-8. Therefore, depending if you compile via PDFLaTeX or XeLaTeX, the following encoding defintions are the preferred choices:
- PDFLaTeX:
\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern}
- XeLaTeX:
\usepackage{fontspec}
The default template already selects the correct configuration for you.
- Upload a PNG or PDF file via CoCalc's "Files" interface.
The uploaded image should be in the same directory as the
.tex
file Otherwise, use relative paths like./images/filename.png
if it is in a subdirectoryimages
. - Follow these instructions
about how to insert a graphic in a figure environment.
Do not forget
\usepackage{graphicx}
in the preamble declaration.
The \
character has a special meaning.
It signals a LaTeX command or is used as an escape character.
To enter a backslash, escape its meaning by entering it twice: \\
.
A dollar sign is entered as \$
, which escapes the meaning of "formula-start".
Possible reasons:
- Are there any errors in the "Issues" tab? LaTeX only compiles well if there are zero reported errors.
- Long documents could take an extended period of time to complete. In the "Preview" tab, disable the preview and only enable it once to avoid piling up too much work on the back-end.
- Similarly, computational-heavy "SageTeX" computations could lead to excessive compilation times. You can pre-compute results or split the document into smaller parts.
The best way is to use the subfiles package as described here.
There is an extended example demonstrating how this works in the CoCalc Library. Click (+)New and look for Library in the middle of the page, then under LaTeX templates
select Multiple source files in CoCalc
. The same example is also available at cloud-examples/latex/multiple-files.
This Wiki is for CoCalc.com.
A more structured documentation is the CoCalc User Manual.
For further questions, please contact us.