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}

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 punctation, 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}

Similar to Markdown autolinks.

<https://texlish.org>
<edemaine@mit.edu>
\url{https://texlish.org}
\href{mailto:edemaine@mit.edu}{edemaine@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}. 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).