Text and Fonts

Faces, sizes, colour, spacing, symbols and code, and the fonts mLaTeX carries.

Faces and sizes

Every font command comes in two forms: a command that takes its text as an argument, such as \textbf{bold}, and a declaration that changes everything after it to the end of the group, such as {\bfseries bold}.

Families

CommandDeclarationResult
\textrm{}\rmfamilyRoman, the body's family.
\textsf{}\sffamilySans serif.
\texttt{}\ttfamilyTypewriter.

Series

CommandDeclarationResult
\textbf{}\bfseriesBold.
\textmd{}\mdseriesMedium, again.

Shapes

CommandDeclarationResult
\textit{}\itshapeItalic.
\textsl{}\slshapeSlanted.
\textsc{}\scshapeSmall capitals.
\textup{}\upshapeUpright, again.
\emph{}Emphasis, set in italic.

Sizes

From smallest to largest, each a declaration:

{\tiny tiny} {\scriptsize scriptsize} {\footnotesize footnotesize} {\small small}
{\normalsize normalsize} {\large large} {\Large Large} {\LARGE LARGE}
{\huge huge} {\Huge Huge}

The sizes follow the class's body size, so \large in a 12pt document is larger than in a 10pt one.

Formulas in text

Formulas take the size and colour of the text around them, so {\small $x$} is small and a heading's formula is a heading's size.

The body's family

To set the whole body in sans serif, as some classes and templates do:

\renewcommand{\familydefault}{\sfdefault}

Fonts

The fonts mLaTeX carries

mLaTeX ships its fonts with it, so a document looks the same on every machine.

UseFonts
Body textLatin Modern: roman, sans, typewriter, small capitals, and their cuts
Other scriptsNew Computer Modern, the same design with Greek, Cyrillic, Hebrew, Armenian, Georgian and Devanagari; STIX Two Text
Arabic, Persian, UrduNoto Naskh Arabic
MathematicsNew Computer Modern Math (regular, book, bold, sans), STIX Two Math, Fira Math, Asana Math, and the TeX Gyre Bonum, DejaVu, Pagella, Schola and Termes maths

Characters a font cannot draw

A character the body's font cannot draw is taken from New Computer Modern, then from the mathematics font for a symbol, and finally from your system's fonts for a script mLaTeX carries nothing for, such as Chinese, Japanese or Korean.

Text is shaped with HarfBuzz, so ligatures, kerning and joining scripts come out as the font intends.

fontspec and unicode-math

fontspec's \setmainfont and unicode-math's \setmathfont choose the nearest face mLaTeX carries rather than one from your system by name:

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}    % set in STIX Two, the nearest Times-like face
\setmathfont{STIX Two Math}

A name with nothing near it leaves the text in the current face, with a warning.

Font packages

Font packages such as times, palatino, helvet, mathptmx or newtxtext are accepted, and the document is set in Latin Modern.


Colour

\textcolor, \color, \colorbox, \fcolorbox, \definecolor and \colorlet are part of mLaTeX, so they work without loading xcolor.

Coloured text

\textcolor{colour}{text} colours its text. \color{colour} colours everything after it to the end of the group:

\textcolor{red}{Stop.} {\color{blue} Everything here is blue.}

Coloured boxes

\colorbox{colour}{text} sets its text on a coloured background; \fcolorbox{frame}{background}{text} adds a frame. A colour chosen inside a box stays in that box.

\colorbox{yellow}{highlighted} and \fcolorbox{red}{white}{framed}

Defining colours

\definecolor{name}{model}{values} names a colour. \colorlet{name}{colour} names a colour you already have, or a mixture.

ModelValuesExample
RGBThree numbers from 0 to 255\definecolor{accent}{RGB}{47,111,189}
rgbThree numbers from 0 to 1\definecolor{accent}{rgb}{0.18,0.44,0.74}
HTMLSix hexadecimal digits\definecolor{accent}{HTML}{2F6FBD}
cmykFour numbers from 0 to 1\definecolor{ink}{cmyk}{0,0.6,1,0}
cmyThree numbers from 0 to 1\definecolor{ink}{cmy}{0,0.6,1}
grayOne number from 0 to 1\definecolor{shade}{gray}{0.85}

The named colours are xcolor's: black, white, red, green, blue, cyan, magenta, yellow, gray, darkgray, lightgray, brown, lime, olive, orange, pink, purple, teal and violet.

Mixing colours

xcolor's mixtures work wherever a colour does. red!30 is 30% red and the rest white; blue!60!black is 60% blue and the rest black:

\definecolor{accent}{RGB}{47,111,189}
\textcolor{accent}{Important} and \textcolor{blue!60!black}{a darker blue}.

Spacing

Line breaks

\\ and \newline end a line where they stand. \\[6pt] adds space below the break. \linebreak ends the line and stretches it to the full width.

Page breaks

\newpage and \pagebreak start a new page. \clearpage also sets every waiting figure and table first.

Space

  • \hspace{1em} and \vspace{12pt} add horizontal and vertical space.
  • \hfill and \vfill fill all the space there is, pushing what follows to the end of the line or page.
  • \vspace* keeps its space at the top of a page, where \vspace disappears.

Paragraphs

Paragraphs are indented by \parindent and separated by \parskip. For spaced rather than indented paragraphs:

\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt}

The parskip package does the same in one line.

Line spacing

setspace's \onehalfspacing and \doublespacing widen the space between lines, as theses often ask.

Sentence spacing

Sentence spacing follows TeX: a full stop, question mark or exclamation mark is followed by a wider space, unless \frenchspacing is on. Write \@ after a capital that ends a sentence, as in NASA\@.

Breaking paragraphs

Paragraphs are broken the way TeX breaks them, with its penalties, tolerances and hyphenation patterns, so microtype is accepted and needs to do nothing.


Special characters and symbols

Characters TeX reserves

%, $, &, #, _, { and } mean something to TeX. Write them as \%, \$, \&, \#, \_, \{ and \}, and a backslash as \textbackslash.

Accents and input

Accents can be typed directly (é, ñ, ø) or as commands (\'e, \~n, \o). Input is always UTF-8; inputenc and fontenc are accepted and need no options.

Logos

\TeX, \LaTeX and \LaTeXe set the logos.

Symbol packages

pifont's \ding, gensymb's \degree and \celsius, eurosym's \euro, and tipa's phonetic symbols all work.

Icons and emoji

fontawesome5 icons are drawn as the nearest Unicode symbol from your system's fonts; a brand logo, which Unicode does not have, is a dot. emoji's \emoji{rocket} takes the character from your system's fonts.


Quotations, units and emphasis

Quotation marks

csquotes' \enquote{...} curls quotation marks the right way, with single marks for a quotation inside another. \textquote[source]{text} adds the source in parentheses after the quotation, and \blockquote[source]{text} sets a long one apart:

\usepackage{csquotes}
\enquote{She said \enquote{no}.} \textquote[Knuth]{Beware of bugs.}

Numbers and units

siunitx sets numbers and units as it does in LaTeX:

\usepackage{siunitx}
\num{123456.789}, \qty{9.81}{\metre\per\second\squared}, \ang{45}

Underlining and striking out

soul and ulem underline, strike out and space letters; \emph stays italic.


Code

Verbatim

The verbatim block and \verb|...| set text exactly as typed, in the typewriter face. \verb takes any character as its delimiter.

listings

listings sets source code with line numbers and frames:

\usepackage{listings}
\lstset{basicstyle=\small\ttfamily, numbers=left, frame=single}

\begin{lstlisting}
int main() { return 0; }
\end{lstlisting}

fancyvrb and minted

fancyvrb's Verbatim and minted's minted block and \mintinline are read too. Code is set in the typewriter face without syntax colouring, since mLaTeX never runs Pygments.


Hyphenation

Languages

English hyphenation is built into the program. Choosing another language with babel or polyglossia loads that language's patterns; see Languages.

Marking breaks

\- marks where a word may break, and \hyphenation{...} is accepted.


  • Text and Colour: every package, with its commands and an example.
  • Fonts: every package, with its commands and an example.
  • Code and Verbatim: every package, with its commands and an example.