LaTeX editor features
LaTeX Multi-File Support
CoCalc’s support for multi-file documents is now available. Here’s a summary of features:
The user interface is initially identical to the current single-file interface.
If you explicitly input other files, then build, there is a new menu on the top of a text editor that lets you select from any of the subfiles.
If you double click on the pdf on some latex generated by a subfile, then that file is automatically opened.
Errors and warnings have links that, when clicked, may open a subfile.
Forward search from subfiles works as it should.
Saving a subfile saves all files and kicks off a build.
See the section LaTeX/Modular Documents in the WikiBooks LaTeX book for a helpful introduction to working with multiple files in LaTeX.
Forward & Inverse Search
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 PDF preview.
(In rare cases where full positional information is not available, this feature may not be active.)
Inverse: Double-click on an area of interest in the PDF Preview area. The cursor in the text editor will jump to the paragraph in the source-code.
Spellcheck
Spell checking during LaTeX editing is available for several languages. You can enable/disable Spellcheck and change the language for a particular file by opening the Settings
frame as shown:
You can use your browser’s spell checking for the document if you prefer. Choose “Browser (your browser’s spell check)”. You can find out more about browser spell checking here. In many browsers, a misspelled word is indicated by a colored underline, and control-clicking the underlined word will bring up a menu of suggested spellings.
Note that the Spellcheck feature is also available in Markdown and HTML editors.
Word count
CoCalc can show you current word count statistics generated by texcount. In order to see them, change one of the frames or created a new one in the Frame editor. Select “Word Count” as shown below:
Build command
In the build panel, you can use the “Engine” dropdown menu to select a supported LaTeX engine. This replaces the current build command with a generic one, that’s know to work well in many situations! These options are available:
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.
Output Directory
By default, an -output-directory=...
is set,
such that your current directory is kept clean of temporary files.
Instead, the actual build process happens in a temporary in-memory directory.
Some packages do not work under these circumstances,
hence there are (no bulid dir)
variants, which do not set a temporary output directory flag.
Bring your own command
More general, you can also specify your own build command.
To avoid any processing of your build command, append a “;” semicolon at the end of your command or
even specify several commands separated by semicolons.
You could also use GNU Makefiles and call make ...;
from here.
Default build command
The selected build command is stored in a companion file in the project. You can also store the default engine or even hardcode the build command in the LaTeX document itself. There are two relevant directives, which are special comment lines at the beginning of your file.
% !TeX program = xelatex
: upon opening the file the first time, theXeLaTeX
engine is selected. This is one of the default engine directives known from other latex editors. Later on, this line has no effect and your engine selection in CoCalc takes precedence. This could also bepdflatex
orluatex
.% !TeX cocalc = ... file.tex
: This takes precedence over any other build command configurations. The command after the equal sign is used to build your document. Without a semicolon, the last token is replaced by the current file name, hence it is ok to just addfile.tex
. If there is a semicolon, no processing takes place. A suitable standard build command could be:% !TeX cocalc = latexmk -pdf -f -g -bibtex -deps -synctex=1 -interaction=nonstopmode file.tex
Encoding
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 definitions are the preferred choices:
PDFLaTeX:
\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern}
XeLaTeX or LuaTeX:
\usepackage{fontspec}
The default template already selects the correct configuration for you.