Skip to content

Reference

Similar to Markdown headers / CommonMark ATX headings, 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.}

Markdown-style sections can be disabled with ::config -markdownHeadings or ::config -markdownCompat.

Similar to Markdown emphasis / CommonMark emphasis and strong emphasis (but only with *s, no _ syntax).

*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{**}

Markdown-style emphasis can be disabled with ::config -markdownEmphasis or ::config -markdownCompat.

Wrap text in ~~...~~ to strike it out:

The conjecture is ~~false~~ true!
The conjecture is \sout{false} true!

The default output is \sout{...}. Texlish automatically adds \usepackage[normalem]{ulem} to define \sout if needed.

You can customize the generated command with ::styles:

::use soul
::styles ~~ = \st
Keep ~~remove~~.
\usepackage{soul}
Keep \st{remove}.

To minimize conflicts with LaTeX’s nonbreaking space ~, strikethrough requires exactly two tildes on each side. If you need exactly two nonbreaking spaces, wrap the tildes in braces like {~~}.

Strikethrough can be disabled with ::config -markdownStrikethrough or ::config -markdownCompat or ::config latexCompat.

ASCII single and double quote characters '/" become TeX opening/closing quote ligatures, while apostrophes in words stay apostrophes:

"Double quotes"
'Single quotes'
"Outer 'inner'"
Don't change apostrophes' directions.
``Double quotes''
`Single quotes'
``Outer `inner'{}''
Don't change apostrophes' directions.

If you need a lone opening or closing quote, use an empty group to simulate the surrounding context:

before "{} after
before {}" after
before ``{} after
before {}'' after

In more complex settings, you can use explicit \lq (), \rq (), \ldq (), and \rdq () commands to choose your quote.

You can customize the output for opening and closing quote characters using ::config quotes. For example, to use French guillemets like « Bonjour »:

::config
quotes:
":
open = \guillemotleft~
close = ~\guillemotright
"Bonjour"
\guillemotleft~Bonjour~\guillemotright{}

Or to get German low/high quotes like „Er sagte ‚Hallo‘.“:

::config
quotes:
":
open = \quotedblbase
close = \textquotedblleft
':
open = \quotesinglbase
close = \textquoteleft
"Er sagte 'Hallo'"
\quotedblbase{}Er sagte \quotesinglbase{}Hallo\textquoteleft{}\textquotedblleft{}

Quote output ending in a LaTeX control word automatically gets {} appended. The same settings can be written with dotted keys like quotes.".open.

Smart quotes can be fully disabled with ::config -smartQuotes, ::config -markdownCompat, or ::config latexCompat. When disabling, you probably also want to disable or customize Markdown-style code to restrict to three or more backticks, so that one or two backticks can be used for opening quotes.

Similar to Markdown lists / CommonMark list items, 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}

Markdown-style lists can be disabled with ::config -markdownLists or ::config -markdownCompat.

Similar to Markdown blockquotes / CommonMark block quotes, but following Texlish indentation rules instead of lazy paragraph continuation:

We prove NP-hardness of the following problem:
> Given a graph, is it Hamiltonian?
We prove NP-hardness of the following problem:
\begin{quote}
Given a graph, is it Hamiltonian?
\end{quote}

Same-indented quote markers continue the same quote environment:

> First line
> second line
\begin{quote}
First line
second line
\end{quote}

Strictly indented lines belong to the quote, while same-indent lines do not:

> First line
still quoted
no longer quoted
\begin{quote}
First line
still quoted
\end{quote}
no longer quoted

Use a blank quote marker for a paragraph break inside the quote:

> First paragraph
>
> Second paragraph
\begin{quote}
First paragraph
Second paragraph
\end{quote}

You can customize the environment with ::styles:

::styles > = quotation
> A longer quoted passage.
\begin{quotation}
A longer quoted passage.
\end{quotation}

Markdown-style block quotes can be disabled with ::config -markdownBlockquotes or ::config -markdownCompat.

@=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

Label/ref shorthand can be disabled with ::config -refShorthand.

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

Citation shorthand can be disabled with ::config -citeShorthand.

Similar to GitHub Markdown-style footnotes, you can define footnote content once with [^id]: and insert markers 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{\protect\label{footnote:false}%
This is actually not true.
See Figure \ref{fig:example}.}%
, but not too bad%
\footnote{\protect\label{footnote:true}This is actually true.}%
.

The first marker expands to \footnote{\protect\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{\protect\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{\protect\label{footnote:1}First note.}%
, again\footref{footnote:1}.
Second paragraph%
\footnote{\protect\label{footnote:2}Second note.}%
.

You can also use Texlish footnote notation to specify authors and affiliations (in default LaTeX document classes where \footnote works like \thanks).

\author: Alice[^MIT] \and Bob[^MIT]
[^MIT]: MassachuTeX Institute of Texlish
\author{Alice%
\footnote{\protect\label{footnote:MIT}MassachuTeX Institute of Texlish}%
\and Bob\footref{footnote:MIT}}%

Markdown-style footnotes can be disabled with ::config -markdownFootnotes or ::config -markdownCompat.

Similar to Markdown automatic links / CommonMark 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 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}}

To customize the visible text of a link, use Markdown inline links / CommonMark links:

[Texlish](https://texlish.org)
\protect\href{https://texlish.org}{Texlish}

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

Markdown (auto)links can be disabled with ::config -markdownLinks or ::config -markdownCompat.

Markdown images compile to LaTeX \includegraphics.

![](example.png)
\includegraphics{example.png}

Text between the brackets becomes the alt option for accessible PDFs in LaTeX setups that support graphics tagging:

![Example image](example.png)
\includegraphics[alt={Example image}]{example.png}

You can customize the generated command with ::styles:

::styles
! = \includesvg
![](example.svg)
\includesvg{example.svg}

Markdown images can be disabled with ::config -markdownImages or ::config -markdownCompat.

LaTeX normally uses ` for opening quotes. In Texlish, smart quotes let you use straight ASCII quotes '/" instead, freeing up backticks ` for Markdown-style code. Similar to Markdown inline code / CommonMark code spans, matching backtick runs compile to LaTeX \verb:

Write `$x^2$` to produce $x^2$.
Use `` `literal backticks` `` to write code.
Write \verb`$x^2$` to produce $x^2$.
Use \verb|`literal backticks`| to write code.

Code-span line endings and following indentation become a single space. If the code starts and ends with a space, exactly one space gets stripped from each end (like CommonMark), making it easier to write literal backticks.

Fenced code blocks use three or more backticks and compile to a verbatim environment by default:

```
x < y
```
\begin{verbatim}
x < y
\end{verbatim}

If the opening fence is indented, up to that much indentation is removed from each content line, following CommonMark:

Example:
```
if x:
y()
```
Example:
\begin{verbatim}
if x:
y()
\end{verbatim}

You can customize both using ::styles. For inline code commands, the ::styles key is the backtick run. For fenced blocks, add a *.

::styles
`` = \Verb
````* = lstlisting
``inline``
````
block
````
\Verb`inline`
\begin{lstlisting}
block
\end{lstlisting}

Fenced code blocks can specify an info string, such as a language name. Then you can customize the environment for that info string with ::styles. Style values can be a plain environment, a Texlish-style : environment, or a LaTeX-style \begin{environment}:

::styles
```py = : lstlisting[language=Python]
```py
print("hello")
```
\begin{lstlisting}[language=Python]
print("hello")
\end{lstlisting}

If a fenced code block starts with an optional argument, Texlish passes it to the selected environment:

::styles
```* = lstlisting
```[numbers=left]
x
```
\begin{lstlisting}[numbers=left]
x
\end{lstlisting}

Backticks can be disabled with ::config -markdownBackticks or ::config -markdownCompat. Set markdownBackticks to an integer n to enable only runs of n or more backticks: For example, if you prefer traditional TeX backtick quotes instead of smart quotes, you can keep one or two backticks for opening quotes and use three or more for code:

::config markdownBackticks=3
`single quotes'
``double quotes''
```code```
`single quotes'
``double quotes''
\verb`code`

Similar to Markdown horizontal rules / CommonMark thematic breaks, a line of three or more hyphens (with possible spaces in between) draws a horizontal separator:

Before
---
After
Before
\medskip\hrule\medskip
After

The default expansion is \medskip\hrule\medskip. You can customize with ::styles.

::use dashrule
::styles
--- = \bigskip\hrule\bigskip
---- = \bigskip\hrule\medskip\hrule\bigskip
- - - = \medskip\noindent\hdashrule{\linewidth}{0.4pt}{2pt 2pt}\medskip
--- % single
---- % double
- - - % dashed
\usepackage{dashrule}
\bigskip\hrule\bigskip% single
\bigskip\hrule\medskip\hrule\bigskip% double
\medskip\noindent\hdashrule{\linewidth}{0.4pt}{2pt 2pt}\medskip% dashed

Horizontal rules can be disabled with ::config -markdownHorizontalRules or ::config -markdownCompat.

Texlish starts in text mode. All of the features described above are text-mode syntax: Markdown-style section headings, emphasis, strikethrough, smart quotes, lists, footnotes, label/ref shorthand, citations, links, code backticks, and horizontal rules.

Texlish enters math mode inside $...$, $$...$$, \(...\), \[...\], and standard display-math environments including align, alignat, equation, eqnarray, flalign, gather, and multline, plus their starred forms. The same environment names work in Texlish shorthand such as : align. Within math mode, the text-mode features above are disabled, except where \text{...} and related font commands like \textrm re-enter text mode for their braced argument.

$x_12 + *literal*$
\[x^12 + "literal"\]
: align
x_(ij) + \text{*text*}
$x_{12} + *literal*$
\[x^{12} + "literal"\]
\begin{align}
x_{ij} + \text{\emph{text}}
\end{align}

Inside math mode, Texlish auto-groups multi-digit sub/superscripts.

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

Texlish also groups parenthesized sub/superscripts in math mode:

$x_(ij) + x^(i+j)$
$x_{ij} + x^{i+j}$

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

::config scriptGrouping = alphanumeric
$x_12 + x_ij + x^12 + x^ij$
::config -scriptParens
$x_(ij) + x^(i+j)$
$x_{12} + x_{ij} + x^{12} + x^{ij}$
$x_(ij) + x^(i+j)$

Allowed values for scriptGrouping are:

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

Outside math mode, sub/superscripts are not processed.

In LaTeX-compat mode, scriptGrouping gets set to none and scriptParens gets set to false:

::config latexCompat
$x_12 + x_ij + x_(ij) + x^12 + x^ij + x^(ij)$
$x_12 + x_ij + x_(ij) + x^12 + x^ij + x^(ij)$

\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}}%

The final required argument can omit the bullet, reducing indentation:

\resizebox:
- \linewidth
- !
Body
\resizebox
{\linewidth}%
{!}%
{%
Body}%

~ items get treated as optional arguments:

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

Colon command shorthand can be disabled with ::config -colonCommands.

: 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}

Colon environment shorthand can be disabled with ::config -colonEnvironments.

::tex passes TeX through unchanged. Content can be on the same line and/or on strictly indented lines.

::tex *literal* [bracket](paren)
::tex
\expandafter\ifx\csname @captype\endcsname\relax
\marginpar{xxx}
\else
xxx % in figure/caption
\fi
*literal* [bracket](paren)
\expandafter\ifx\csname @captype\endcsname\relax
\marginpar{xxx}
\else
xxx % in figure/caption
\fi

::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 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}

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 and raw ::tex 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 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$
"straight quotes"
$x_{ij}$
$x_12$
"straight quotes"

Boolean options can be enabled with optionName and disabled with -optionName:

::config -markdownCompat
[Texlish](https://texlish.org)
[Texlish](https://texlish.org)

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:

  • colonCommands: whether \command: compiles to a braced command argument; enabled by default
  • colonEnvironments: whether : environment compiles to \begin{environment}...\end{environment}; enabled by default
  • citeShorthand: whether [[citation]] compiles to \cite{citation}; enabled by default
  • latexCompat: flag setting equivalent to scriptGrouping = none, -scriptParens, -smartQuotes, and -markdownStrikethrough
  • markdownCompat: flag setting equivalent to maximize Markdown compatibility, currently markdownBackticks, markdownBlockquotes, markdownEmphasis, markdownFootnotes, markdownHeadings, markdownHorizontalRules, markdownImages, markdownLinks, markdownLists, markdownStrikethrough, and smartQuotes
  • markdownBackticks: minimum number of backticks that enables code spans and fenced code blocks, or 0 to disable them; enabled by default as 1
  • markdownBlockquotes: whether Markdown-style block quotes like > quote compile to LaTeX quote environments; enabled by default
  • markdownEmphasis: whether *emphasis* and related * runs compile to configured styles; enabled by default
  • markdownFootnotes: whether [^id] markers and [^id]: definitions compile to LaTeX footnotes; enabled by default
  • markdownHeadings: whether Markdown-style headings like # Section compile to LaTeX section commands; enabled by default
  • markdownHorizontalRules: whether horizontal rule lines like --- compile to \medskip\hrule\medskip; enabled by default
  • markdownImages: whether Markdown-style images like ![alt](url) compile to \includegraphics; enabled by default
  • markdownLinks: whether [text](url), <url>, and <email> compile to LaTeX links; enabled by default
  • markdownLists: whether top-level Markdown-style bullets and numbered lists compile to LaTeX lists; enabled by default
  • markdownStrikethrough: whether ~~text~~ compiles to \sout{text} in text mode; enabled by default
  • refShorthand: whether @ref, @=label, @#ref, and @^ref compile to configured cross-reference commands; enabled by default
  • smartQuotes: whether straight ' and " characters compile to TeX opening/closing quote ligatures; enabled by default
  • quotes: output strings for opening/closing straight quote characters, used by smart quotes
  • scriptParens: whether _(...) and ^(...) group sub/superscripts; enabled by default
  • scriptGrouping: script grouping mode, one of numeric (default), alphanumeric, alpha, or none
  • styles: styles for emphasis, strikethrough, block quotes, images, code, horizontal rules, label/ref, or citations; equivalent to ::styles

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

If you’re using a more recent or removed Texlish feature (see the changelog), you want to make sure that your collaborators have a matching version. Use ::version to check that the current Texlish version satisfies a version range:

::version >=0.2.0 <99999.0.0

Without comparison operators, you can specify a version prefix and/or use x, X, or * wildcards. For example, the following are equivalent:

::version 0.2
::version 0.2.x
::version 0.2.*
::version >=0.2.0-0 <0.3.0-0

Use || to accept multiple alternatives:

::version 0.1 || 0.2

Comparisons should specify full major.minor.patch version numbers (optionally with - prerelease), and can be prefixed by <, <=, >, >=, or = (the default meaning of a bare full version). Multiple comparisons and ranges separated by whitespace are combined with AND. Then alternatives separated by || are combined with OR. Comparisons follow SemVer 2.0.0 rules. Prerelease versions are included according to SemVer precedence (like npm SemVer’s includePrerelease option).