Each example consists of a complete small LaTeX document shown within the page like this:
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Example text.
\end{document}
Each example is complete. However you may wish to edit it to make small changes, perhaps as part of an Exercise set at the end of the lesson.
The editor being used is ACE.
You may customise the theme used in the editor (for example using a dark theme with light text on a dark background) on the Site Settings page. A convenient way to experiment with different themes is to to use Ctrl+, (⌘+, on Mac) while on any example in the site. This displays a panel which allows you to change all the ACE settings.
The ACE repository has a useful page of editor keyboard shortcuts.
Overleaf is one of the most popular online LaTeX editing services. The button, below the example, will submit the code to Overleaf.
If you do not have an account, or the account details are not already cached in your browser, then you will be redirected to a login page where you may login or register with Overleaf. This is a free service but does require you to give some details and agree to terms and conditions.
If your Overleaf account is already cached in your browser, then Overleaf will be opened in a new tab, with a new project with the code. You may then edit it in Overleaf which will simultaneously run LaTeX on your code showing the resulting output or error log.
Unlike documents processed at TeXLive.net, you may save your project in your Overleaf account and return to it later.
The button, below the example, will submit the code to the TeXLive.net service1.
The TeXLive.net service was developed specifically to support this site, and in particular makes use of PDF.js to enable display of PDF on mobile and other browsers without built in PDF readers.
The resulting PDF document (or section of the error log) will be shown inline immediately below the example. A button will be provided so that you may remove this output (or you may leave it in place and continue the rest of the lesson below).
Note that TeXLive.net requires no login or signup of any sort so it is very convenient for small examples, but this site provides no mechanism to save your document. Any changes that you make to the example are lost if you move off the page.
If you have a TeX system installed locally, then you may copy the example code off the page, either explicitly selecting it, or by using select all keyboard shortcuts in the editor (Ctrl+A Ctrl+C in windows for example). This will place the code in your operating system clipboard so you can start a blank document using your local editor, and paste in the text.
Our examples are based around using an up-to-date LaTeX installation. They all work with both of our online demonstration systems, so if you get errors with the examples we provide, you might want to check if your LaTeX system is up-to-date.
When submitting example documents, by default the pdflatex
engine will be used.
You can force the choice of latex
, pdflatex
, xelatex
, lualatex
, platex
or uplatex
by using a comment of the form:
% !TEX
any text lualatex
where the white space at the start is optional and case is ignored as is any text between the first and last word.
This allows the form % !TEX program=pdflatex
used by some TeX editors but does not require the program=
and is currently restricted to specifying just one of the engines that are supported on the online systems being used.
You can see an example of a comment being used to specify LuaLaTeX in some of the examples on this site.
If platex
or uplatex
is specified; then the dvipdfmx
program is also used to produce the PDF result from the DVI file that these variants generate. Similarly dvips
and ps2pdf
are used if latex
is specified.
If the engine is not specified in a % !TeX
comment, then pdflatex
will be used unless you have specified a default TeX engine on the Site Settings page.
If you use the TeXLive.net system, then the PDF output from running an example is shown using PDF.js by default. This provides consistent behavior over the widest range of browsers.
If you would prefer to use your browser’s default PDF reader (either its built in one, or an external application that you have configured) then add a comment of the form:
% !TEX
any text pdf
The default behavior can be explicitly specified by using pdfjs
as the final token. For debugging you may sometimes want the log file returned, even if the document produces a PDF with no errors. This can be specified by using log
as the final token in the comment.
As an alternative to using a % !TeX
comment, you may specify the site default return parameter on the Site Settings page. The Settings are specific to each browser, so for example you may choose to use the default pdfjs
setting on your mobile device, but use pdf
on your desktop browser to use its default PDF rendering.
If using the TeXLive.net system, then additional return options, make4ht
, LaTeXML
or lwarp
may be specified. These return one or more HTML pages in the frame within the page. It may be specified at the same time as xelatex
or lualatex
as well as the default pdflatex
processing.
To enable this output, add a comment of the form:
% !TeX make4ht
Replacing make4ht
by LaTeXML
or lwarp
to specify those systems.
Alternatively you may specify make4ht
, LaTeXML
or lwarp
as the default return option on the Site Settings page.
If using a locally installed TeX system, the same output as the make4ht
option may be obtained by executing
make4ht document.tex "learnlatex4ht,2,mathml,mathjax,svg"
with the addional option -x
or -l
if XeLaTeX or LuaLaTeX are specified.
When running locally, other configurations would be possible. See the make4ht manual.
For LaTeXML
to run locally, you would need to install LaTeXML (it is not part of TeX Live or MiKTeX) and use
latexml document.tex > document.xml
latexmlpost --format=html5 \
--javascript='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js' \
--destination=document.html" document.tex
Many other LaTeXML configurations are possible, as described in the manual.
The lwarp
configuration is not documented here, it is somewhat experimental and subject to change. The current version can be seen at the source repository.
Note that during development of the site we have also used LaTeX.Online and LaTeX-on-HTTP and we thank the developers of those services for making updates to enable the examples on this site to be available at an early stage. ↩