Guides for Texlet
How to write LaTeX on iPad and iPhone
LaTeX is plain text. That is good news for anyone who wants to work on an iPad or iPhone: you don't need a desktop computer to write it, only an editor and something that turns your source into typeset output. A full TeX distribution is too big for a phone, but for formulas, lecture notes and short documents, a good editor with a live preview gets you most of the way.
This guide covers the basic structure of a LaTeX document, the difference between inline and display math, a workflow that works well on a touch screen, and how to get your work out of the device again.
The basic structure of a LaTeX document
Every LaTeX document has two parts. The preamble comes first: it declares the document class and loads packages. Everything between \begin{document} and \end{document} is the actual content. A minimal article looks like this:
\documentclass{article}
\usepackage{amsmath}
\title{Lab Report}
\author{Alex Doe}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
The kinetic energy is $E = \frac{1}{2} m v^2$.
\subsection{Method}
\begin{itemize}
\item Measure the mass.
\item Measure the speed.
\end{itemize}
\end{document}Sections, lists and comments
Structure comes from commands, not from formatting. \section{…}, \subsection{…} and \subsubsection{…} create numbered headings; the starred versions such as \section*{…} leave out the number. Bulleted lists use the itemize environment, numbered lists use enumerate, and each entry starts with \item.
A percent sign starts a comment that runs to the end of the line. That also means some characters have a special meaning and must be escaped when you want them as text:
- \% for a percent sign
- \$ for a dollar sign
- \& for an ampersand
- \# for a hash sign
- \_ for an underscore
- \{ and \} for braces
- \textbackslash for a backslash in text
Inline math vs. display math
Inline math sits inside a sentence and is written between dollar signs: $a^2 + b^2 = c^2$. The equivalent \( … \) works as well. Inline math is set compactly so it does not disturb the line spacing, which is why fractions and sums look smaller there.
Display math gets its own centered line. Use \[ … \] for an unnumbered formula and the equation environment for a numbered one. The double-dollar syntax $$ … $$ comes from plain TeX; it usually works, but in LaTeX documents \[ … \] is the recommended form.
Inline: the roots are $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.
Display, unnumbered:
\[
\int_0^1 x^2 \, dx = \frac{1}{3}
\]
Display, numbered:
\begin{equation}
e^{i\pi} + 1 = 0
\end{equation}A workflow that works on a touch screen
The classic LaTeX loop is write, compile, look at the PDF, fix, compile again. On a small screen that loop gets tedious. A live preview shortens it: you see the typeset result while you type and catch a missing brace right away instead of after the next compile.
Texlet is built around that idea. The preview sits below your formula on iPhone and next to it on iPad, and you can switch it to full screen. It works without an account and without an internet connection. Above the keyboard there are building blocks for fractions, roots, superscripts and subscripts, Greek letters, sums, integrals, arrows, brackets, matrices and environments, so you type fewer backslashes on the software keyboard. Brackets close themselves, and pressing Return after \begin{…} adds the matching \end{…}.
A few habits help on any device:
- Write one formula or one section at a time and check the preview before you move on.
- Keep long formulas readable with line breaks and spaces in the source; LaTeX ignores them in math mode.
- Define repeated notation once with \newcommand, for example \newcommand{\R}{\mathbb{R}}.
- Use an external keyboard for longer documents; the iPad is far more pleasant for LaTeX with one.
Files, copying and exporting
Because LaTeX is plain text, the most portable thing you can keep is the .tex file itself. Texlet stores your formulas as ordinary .tex files in the Files app under “On My iPhone › Texlet”, and it can open .tex files from iCloud Drive or other apps and edit them in place. Copying the LaTeX code takes one tap, and printing is built in.
If you need the typeset result elsewhere, Texlet Pro adds export as PDF (as vector graphics) and PNG, and lets you copy a formula as an image that stays sharp in Keynote, Pages or Notes. Pro also syncs your files between iPhone and iPad via iCloud.
When you need a full TeX distribution
A thesis with a bibliography, many packages or a strict university template is best compiled with a full TeX distribution on a computer or an online service. Since your source stays in plain .tex files, nothing you write on the iPad is locked in: you can draft formulas and sections on the go and carry the text over to the final build.
Frequently asked questions
Can I write LaTeX offline on an iPad?
Yes. You need an editor that renders LaTeX on the device. Texlet's live preview works without an internet connection, so you can write and check formulas on a train or in a lecture hall without Wi-Fi.
What is the difference between $…$ and \[…\]?
$…$ places math inline within a sentence and sets it compactly. \[…\] puts the formula on its own centered line in display style. Use the equation environment if the formula should be numbered.
Do I need \documentclass for a single formula?
No. A single formula can be written on its own, for example \frac{a}{b} or $E = mc^2$. The preamble and \begin{document} matter once you write a full document with sections, a title and running text.