Skip to content

Reference

Sections

Similar to Markdown headers, plus * for unnumbered sections.

# Introduction
## Background
### Aside
#* Acknowledgments
\section{Introduction}
\subsection{Background}
\subsubsection{Aside}
\section*{Acknowledgments}

! goes up a level above section, while . goes down to the paragraph level:

!!# Beginning
!# Introduction
.# Results.
.## Part 1.
\part{Beginning}
\chapter{Introduction}
\paragraph{Results.}
\subparagraph{Part 1.}

Emphasis

Similar to Markdown emphasis.

*italic*
**bold**
***bold italic***
\emph{italic}
\textbf{bold}
\defn{bold italic}

You can also redefine the meaning of these symbols:

::styles
* = \textit
** = \textsf
*** = \texttt
*italic*
**sans-serif**
***teletype***
\textit{italic}
\textsf{sans-serif}
\texttt{teletype}

Equivalent ::config form:

::config
styles:
* = \textit
** = \textsf
*** = \texttt
*italic*
**sans-serif**
***teletype***
\textit{italic}
\textsf{sans-serif}
\texttt{teletype}

To use the LaTeX character *, wrap it in braces (so that pairs of emphasis characters aren’t in the same group):

{*}not italic{*}
{**}not bold{**}
{*}not italic{*}
{**}not bold{**}

Lists

Similar to Markdown lists, but with less strict requirements on indentation.

- This is an item.
- This is a longer item that
continues on the next line.
\begin{itemize}
\item This is an item.
\item This is a longer item that
continues on the next line.
\end{itemize}
* This is an item.
* This is a longer item that
continues on the next line.
\begin{itemize}
\item This is an item.
\item This is a longer item that
continues on the next line.
\end{itemize}
1. This is an item.
2. This is a longer item that
continues on the next line.
\begin{enumerate}
\item This is an item.
\item This is a longer item that
continues on the next line.
\end{enumerate}
The algorithm works as follows:
1. Initialize
2. For each step:
* Do the step
* Continue
The algorithm works as follows:
\begin{enumerate}
\item Initialize
\item For each step:
\begin{itemize}
\item Do the step
\item Continue
\end{itemize}
\end{enumerate}

Label/Ref

@=thm:main
@thm:main
@#thm:main
\label{thm:main}
\ref{thm:main}
\pageref{thm:main}

If your label needs spaces or trailing punctuation, put it in quotes or braces:

@='thm main'
@"thm main"
@{thm main}
@#'thm main'
\label{thm main}
\ref{thm main}
\ref{thm main}
\pageref{thm main}

If you want to use a custom \ref system, such as cleveref, you can override the meaning of these symbols:

::styles
@ = \cref
@# = \cpageref
@thm:main
@#thm:main
@thm:main,thm:other
\cref{thm:main}
\cpageref{thm:main}
\cref{thm:main,thm:other}

To use the LaTeX character @ (that’s not part of an email link), wrap it in braces:

To give feedback, {@}me
To give feedback, {@}me

Cite

[[paper1, paper2]]
\cite{paper1, paper2}

Footnotes

Markdown-style footnotes define their content once with [^id]: and insert the first marker with [^id].

This is a problem[^false], but not too bad[^true].
[^false]:
This is actually not true.
See Figure @fig:example.
[^true]: This is actually true.
This is a problem%
\footnote{\label{footnote:false}%
This is actually not true.
See Figure \ref{fig:example}.}%
, but not too bad%
\footnote{\label{footnote:true}This is actually true.}%
.

The first marker expands to \footnote{\label{footnote:id} ...}. Later markers re-use the same footnote number with \footref{footnote:id}, and @^id references that generated label directly as a number (no superscript).

This is first[^count].
[^count]: But who's counting?
See footnote @^count for details.[^count]
This is first%
\footnote{\label{footnote:count}But who's counting?}%
.
See footnote \ref{footnote:count} for details.\footref{footnote:count}

Numeric IDs are disposable: all matching markers since the previous definition bind to the next matching definition in document order. This lets each paragraph re-use simple IDs like [^1], without having to think up a name.

First paragraph[^1], again[^1].
[^1]: First note.
Second paragraph[^1].
[^1]: Second note.
First paragraph%
\footnote{\label{footnote:1}First note.}%
, again\footref{footnote:1}.
Second paragraph%
\footnote{\label{footnote:2}Second note.}%
.

Similar to Markdown autolinks, you can write URLs and email addresses in angle brackets.

<https://texlish.org>
<edemaine@mit.edu>
\protect\url{https://texlish.org}
\protect\href{mailto:edemaine@mit.edu}{\protect\nolinkurl{edemaine@mit.edu}}

Texlish uses \protect in case these appear in a moving argument.

Texlish even produces a correct mailto: link in the common brace format for writing multiple email addresses at the same domain:

<{edemaine,mdemaine}@mit.edu>
\protect\href{mailto:edemaine@mit.edu,mdemaine@mit.edu}{\protect\nolinkurl{{edemaine,mdemaine}@mit.edu}}

Commands

\command: makes it easier to specify commands with arguments. The argument can be on the same line and/or on indented lines.

\title: The Paper \\
Subtitle
\title{The Paper \\
Subtitle}%
\footnote:
This is a footnote.
\footnote{%
This is a footnote.}%

If the command is in the middle of a line, the argument needs to be either on the same line or indented:

$$
\text: Quadratic formula:
\quad
-b \pm \sqrt:
b^2 - 4 a c
$$
$$
\text{Quadratic formula:}%
\quad
-b \pm \sqrt{%
b^2 - 4 a c}%
$$

Multiple arguments can be specified like a list:

\subcaptionbox:
- This is a caption.
@=fig:example
- \centering
\includegraphics: example
\subcaptionbox
{This is a caption.
\label{fig:example}}%
{\centering
\includegraphics{example}}%

~ items get treated as optional arguments:

\includegraphics:
~ width: 0.5\textwidth
- example
\includegraphics
[width: 0.5\textwidth]%
{example}%

Environments

: env is shorthand for \begin{env} ... \end{env}. You must have a space after the colon, similar to list bullets. Indent the contents.

: theorem
$p$ is prime.
\begin{theorem}
$p$ is prime.
\end{theorem}

Required arguments can be specified with a colon:

: tabular: ccc
1 & 2 & 3
\begin{tabular}{ccc}%
1 & 2 & 3
\end{tabular}

If indented, they must use a bullet (to separate the environment from the content):

: tabular:
- ccc
1 & 2 & 3
\begin{tabular}
{ccc}%
1 & 2 & 3
\end{tabular}
: theorem:
~ Main Result
$p$ is prime.
\begin{theorem}
[Main Result]%
$p$ is prime.
\end{theorem}

Use Packages

::use is shorthand for putting \usepackage{...} in the preamble.

::use amsmath
::use geometry: margin=1in, letterpaper
::use hyperref:
pdftitle = Hello World
pdfauthor = Me
\usepackage{amsmath}
\usepackage[margin=1in, letterpaper]{geometry}
\usepackage[
pdftitle = Hello World
pdfauthor = Me]{hyperref}

You can use many packages at once as an indented block:

::use
amsmath
geometry: margin = 1in
hyperref:
- pdftitle = Hello World
- pdfauthor = Me
\usepackage{amsmath}
\usepackage[margin = 1in]{geometry}
\usepackage[
pdftitle = Hello World
, pdfauthor = Me]{hyperref}

If you put ::use after \begin{document}, it gets hoisted up to the preamble.

\documentclass{article}
\begin{document}
Here is the proof:
::use amsthm
: proof
\end{document}
\documentclass{article}
\usepackage{amsthm}
\begin{document}
Here is the proof:
\begin{proof}
\end{proof}
\end{document}

Preamble

::preamble puts LaTeX code in the preamble. If it appears after \begin{document}, it gets hoisted up.

\documentclass{article}
\begin{document}
Here is the theorem:
::preamble \newtheorem{theorem}{Theorem}
: theorem
\end{document}
\documentclass{article}
\newtheorem{theorem}{Theorem}
\begin{document}
Here is the theorem:
\begin{theorem}
\end{theorem}
\end{document}

Automatic Document Boilerplate

Texlish automatically adds the following LaTeX boilerplate if needed:

  • \documentclass[11pt]{article} as the first line. To use a different document class or option, specify it manually.
  • \begin{document} before the first top-level line starting with apparent text content. Commands and braced text are considered valid preamble, while environments (in particular abstract) are considered text content.
  • \maketitle after an added \begin{document}, if the document uses \title. Won’t be added if you manually specify \begin{document}, so you can use this to override the automatic insertion of \maketitle.
  • \end{document} as the last line. If you want uncompiled notes at the end of the file, feel free to specify \end{document} yourself to delimit them.

If Texlish gets the placement wrong, add the boilerplate manually, and/or report a bug.

\title: Texlish Demo
\documentclass[11pt]{article}
\title{Texlish Demo}%
\begin{document}
\maketitle
\end{document}
% Comment
::use amsthm
\newtheorem{theorem}{Theorem}
: theorem
\documentclass[11pt]{article}
% Comment
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
\end{theorem}
\end{document}
\newtheorem:
- theorem
- Theorem
- content
\documentclass[11pt]{article}
\newtheorem
{theorem}%
{Theorem}%
\begin{document}
\begin{itemize}
\item content
\end{itemize}
\end{document}
Inside document
\end: document % manual separator
Outside document
\documentclass[11pt]{article}
\begin{document}
Inside document
\end{document}% manual separator
Outside document

For clarity, most examples in this documentation disable this feature (via the fragment: true compiler option).

Config

::config changes compiler options for the rest of the file:

$x_ij$
::config
scriptGrouping = alphanumeric
$x_ij$
$x_ij$
$x_{ij}$

For a single option, ::config can also be written on one line:

::config scriptGrouping=alphanumeric
$x_ij$
::config latexCompat
$x_12$
$x_{ij}$
$x_12$

Style config keys can be written in nested form:

*foo*
::config
styles:
* = \textit
*foo*
\emph{foo}
\textit{foo}

or inline form with dots:

*foo*
::config styles.*=\textit
*foo*
\emph{foo}
\textit{foo}

Supported config options are:

  • latexCompat: flag setting equivalent to scriptGrouping = none
  • scriptGrouping: script grouping mode, one of numeric (default), alphanumeric, alpha, or none
  • styles: styles for emphasis or label/ref; equivalent to ::styles

You can also set config options globally in a project config file.

Script Grouping

By default, Texlish auto-groups multi-digit sub/superscripts:

$x^12y^42$
$x^{12}y^{42}$

To change this behavior for the rest of the file, use ::config:

::config scriptGrouping = alphanumeric
$x_12 + x_ij + x^12 + x^ij$
$x_{12} + x_{ij} + x^{12} + x^{ij}$

Allowed values for scriptGrouping are:

  • numeric (default)
  • alphanumeric (letters and digits group together)
  • alpha (letters group together)
  • none (no grouping, like LaTeX)

In LaTeX-compat mode, scriptGrouping is effectively set to none:

::config latexCompat
$x_12 + x_ij + x^12 + x^ij$
$x_12 + x_ij + x^12 + x^ij$