Repository navigation
Formatting Examples
Use tift --print input.tex to inspect formatted source. Place the accompanying settings in tift.toml; unspecified settings use the built-in defaults. Bibliography examples use input.bib.
The README introduces the common formats. This gallery adds custom rules and less frequently used options. See configuration setup for file locations and inheritance, and the configuration reference for every field.
| Example | What it demonstrates |
|---|---|
| Nested indentation and list rules | Nested blocks, list items and continuations, named indentation rules |
| Tables, floats, and Unicode alignment | Column alignment, Unicode width, row breaks, table rules, captions |
| Left, center, and right columns | Per-column l/c/r source justification |
| Aligned equations and matrices | Equation columns and nested matrix alignment |
| TikZ paths and nested loops | Path boundaries, continuation indentation, nested foreach scopes and data lists |
| Forest and qtree trees | Bracket subtrees, labels, and tree width settings |
| Text wrapping, comments, and sentences | Prose and comment wrapping, sentence lines, text arguments, atomic math |
| Nested key/value and image options | Recursive argument layout, comma boundaries, image options and filenames |
| Source protection, macros, and conditionals | Safe macro indentation, verbatim data, off/on/skip controls, inactive branches |
| Custom headers, alignment, and branch blocks | Source declaration inference, ordered signatures, custom table and branch rules |
| BibTeX fields and values | Field indentation and spacing, stable order, literal values |
| Literal and regex replacements | Ordered replacements, captures, protection scopes |
| Formatting selected lines | Full-document context with exact unselected lines |
| Whitespace and line endings | Trailing spaces, blank-line limits, LF/CRLF, final newline |
See supported syntax for additional package forms and protection limits.
The global indentation unit is four spaces. A named quote rule uses two spaces for that wrapper, while nested lists and item continuations keep their own structural levels.
tift.toml
[indent.rules.quote]
width = 2Input
\begin{document}
\begin{quote}
\begin{itemize}
\item First observation.
Its explanation continues here.
\item Second observation.
\end{itemize}
\end{quote}
\end{document}Output
\begin{document}
\begin{quote}
\begin{itemize}
\item First observation.
Its explanation continues here.
\item Second observation.
\end{itemize}
\end{quote}
\end{document}Display-width alignment accounts for wide Unicode text. Float indentation, complete booktabs rules, row boundaries, and the following caption share the same table structure. Built-in package signatures also cover tables such as tabularray and NiceTabular.
tift.toml
[alignment]
width = "display"Input
\begin{table}
\begin{tabular}{ll}\toprule 中文&Value\\\midrule Longer name&42\\\bottomrule\end{tabular}\caption{Measurements}
\end{table}Output
\begin{table}
\begin{tabular}{ll}
\toprule
中文 & Value \\
\midrule
Longer name & 42 \\
\bottomrule
\end{tabular}
\caption{Measurements}
\end{table}Each source column follows its own specification. The Item column uses l, the Label column uses c, and the Count column uses r. Cell widths determine the spaces before and after each cell.
Input
\begin{tabular}{lcr}
Item&Label&Count\\
Long item&B&1234\\
A&Wide label&7\\
\end{tabular}Output
\begin{tabular}{lcr}
Item & Label & Count \\
Long item & B & 1234 \\
A & Wide label & 7 \\
\end{tabular}Math alignment applies to complete outer cells; nested matrix content uses its own alignment rules.
Input
\begin{align}
x&=1\\longer&=a+b\\
\end{align}
\begin{pmatrix}
1&22\\333&4
\end{pmatrix}Output
\begin{align}
x & = 1 \\
longer & = a + b \\
\end{align}
\begin{pmatrix}
1 & 22 \\
333 & 4
\end{pmatrix}Complete outer semicolons separate paths and nodes, and multiline paths receive continuation indentation. Each literal foreach loop adds a level; the following path returns to the picture level. Options, coordinates, and node text retain their ownership.
Input
\begin{tikzpicture}
\draw[thick] (0,0)
-- (1,1);\node at (1,1) {Result};
\foreach \x in {0,1}
\foreach \y in {0,1}
{
\draw (\x,\y) circle (2pt);
}
\draw (0,0) circle (1pt);
\end{tikzpicture}Output
\begin{tikzpicture}
\draw[thick] (0,0)
-- (1,1);%
\node at (1,1) {Result};
\foreach \x in {0,1}
\foreach \y in {0,1}
{
\draw (\x,\y) circle (2pt);
}
\draw (0,0) circle (1pt);
\end{tikzpicture}Set arguments.foreach-lists to "expand" to put each literal record on its own line. The default "preserve" keeps the list's authored layout. "auto" expands lists exceeding arguments.columns, falling back to wrap.columns.
tift.toml
[arguments]
foreach-lists = "expand"Input
\begin{tikzpicture}
\foreach \point in {(0,1),(2,3),(4,5)} {\draw \point circle (1pt);}
\end{tikzpicture}Output
\begin{tikzpicture}
\foreach \point in {%
(0,1),%
(2,3),%
(4,5)%
} {%
\draw \point circle (1pt);%
}
\end{tikzpicture}Coordinates, slash-separated records, and braced values remain together. Compact ranges such as {1,...,100} and macro-supplied lists retain their layout. Inserted percent comments preserve TeX spacing at new line boundaries.
Set trees.mode to "expand" to indent literal child subtrees in forest environments and qtree's \Tree. The default "preserve" keeps the authored tree layout.
tift.toml
[trees]
mode = "expand"Input
\begin{forest}
[root [left [leaf]] [right]]
\end{forest}Output
\begin{forest}
[root
[left
[leaf]%
]
[right]%
]
\end{forest}mode = "auto" expands trees exceeding trees.columns, or wrap.columns when the tree width is omitted. forest = false or qtree = false disables the corresponding dialect. Labels, options, braced contents, and leaves retain their contents. Ambiguous syntax and deferred \node or \edge declarations retain their source layout.
One width budget covers prose, comments, and known ordinary-text arguments. wrap.mode = "wrap" retains existing source boundaries, while "rewrap" joins old lines and wraps the paragraph. Sentence splitting starts new sentences on source lines, and inline math stays atomic. Use "unwrap" to join eligible prose without applying a width limit.
tift.toml
[wrap]
mode = "wrap"
columns = 48
comments = true
[sentences]
enabled = true
preserve-line-breaks = trueInput
\begin{quote}
This sentence describes a long observation while keeping $x+y=z$ together in the source. A second sentence starts here.
% This long comment explains the measurements and the assumptions used by the model.
An existing short line stays here.
\end{quote}
\caption{A long caption describes the measurements and explains the relationship between the variables.}Output
\begin{quote}
This sentence describes a long observation
while keeping $x + y = z$ together in the
source.
A second sentence starts here.
% This long comment explains the
% measurements and the assumptions used by
% the model.
An existing short line stays here.
\end{quote}
\caption{A long caption describes the
measurements and explains the relationship
between the variables.}Nested key-setting commands expand from the inside out. Active wrapping supplies a width for image options, while filenames and grouped values retain their data. Empty percent comments preserve tight TeX spacing at inserted boundaries.
tift.toml
[wrap]
mode = "wrap"
columns = 55
[arguments]
mode = "expand"Input
\pgfkeys{outer={\tikzset{alpha={one}, beta={two}, gamma={three}}}, next={value}}
\includegraphics[width=0.8\linewidth,height=4cm,keepaspectratio,angle=0]{figures/measurement-plot.pdf}Output
\pgfkeys{%
outer={\tikzset{%
alpha={one},
beta={two},
gamma={three}%
}},
next={value}%
}
\includegraphics[%
width=0.8\linewidth,%
height=4cm,%
keepaspectratio,%
angle=0%
]{figures/measurement-plot.pdf}Enable arguments.align-equals to align assignment operators in selected multiline option lists. The default is false.
tift.toml
[arguments]
align-equals = trueInput
\tikzset{
a=1,
long key={x=y,z}
}Output
\tikzset{
a = 1,
long key = {x=y,z}
}Nested braced values retain their contents. Single-line lists stay compact unless active argument expansion rules require a break. Named arguments.rules.<command>.align-equals settings override the global switch. See argument settings for command selection and width rules.
Safe macro definitions receive indentation with body text and line layout protected. Verbatim data, off/on regions, skipped physical lines, and known inactive conditional source retain their bytes. Ordinary active source remains available for formatting.
Input
\newcommand{\message}[1]{
\begin{quote}
Hello, #1.
\end{quote}
}
\begin{quote}
\begin{verbatim}
literal { braces } & data
\end{verbatim}
% tift: off
unaligned source
% tift: on
keep this line % tift: skip
\iffalse
Unbalanced { and $ data stays here.
\fi
Ordinary text with \verb|x & { literal }|.
\end{quote}Output
\newcommand{\message}[1]{
\begin{quote}
Hello, #1.
\end{quote}
}
\begin{quote}
\begin{verbatim}
literal { braces } & data
\end{verbatim}
% tift: off
unaligned source
% tift: on
keep this line % tift: skip
\iffalse
Unbalanced { and $ data stays here.
\fi
Ordinary text with \verb|x & { literal }|.
\end{quote}The source-defined note environment supplies its own header. An explicit mom signature describes the custom table's mandatory/optional/mandatory arguments, and a named alignment rule selects its rows. Special block markers supply branch indentation inside the same document.
tift.toml
[syntax.environment-arguments.mytable]
signature = "mom"
[alignment.rules.mytable]
enabled = true
[[syntax.special]]
name = "algorithmIf"
begin = '\If'
end = '\EndIf'
middle = ['\ElsIf', '\Else']
nested = trueInput
\NewDocumentEnvironment{note}{m O{Info}}{}{}
\begin{note}{Report}[Details]
\If{ready}
\begin{mytable}{Measurements}[t]{ll}
A&B\\Longer&42\\
\end{mytable}
\Else
\State Wait.
\EndIf
\end{note}Output
\NewDocumentEnvironment{note}{m O{Info}}{}{}
\begin{note}{Report}[Details]
\If{ready}
\begin{mytable}{Measurements}[t]{ll}
A & B \\%
Longer & 42 \\
\end{mytable}
\Else
\State Wait.
\EndIf
\end{note}Default bibliography formatting preserves entry-type and field-name case and aligns assignments while preserving entry/field order and literal value contents. [bibtex] name-case = "lower" or "upper" selects uniform name case. Set [bibtex] normalize = false to use uniform assignment spacing.
Input
@article{sample,title={A {Nested} Title},author="Doe, Jane",year=2026}Output
@article{sample,
title = {A {Nested} Title},
author = "Doe, Jane",
year = 2026,
}Replacement rules run in declaration order and support bounded regex capture interpolation. Unprotected scope keeps literal regions outside replacement edits.
tift.toml
[[replacements]]
find = "colour"
replace = "color"
scope = "unprotected"
[[replacements]]
find = 'v([0-9]+)'
replace = 'version $1'
regex = true
scope = "unprotected"Input
The colour is red. Release v1.
\verb|colour v1|Output
The color is red. Release version 1.
\verb|colour v1|The CLI can format one-based selections using full-document structure. Unselected physical lines retain their source bytes.
Command
tift --print input.tex --lines 2,4Input
\begin{quote}
First line.
Second line.
Third line.
\end{quote}Output
\begin{quote}
First line.
Second line.
Third line.
\end{quote}Escaped strings make trailing spaces, CRLF endings, blank lines, and the final newline visible. This configuration removes trailing whitespace, limits blank runs, and selects LF with a final newline.
tift.toml
[whitespace]
max-blank-lines = 1
line-ending = "lf"
final-newline = "always"Input
"Alpha. \r\n\n\n\nBeta.\t"Output
"Alpha.\n\nBeta.\n"tift
- Home
- Getting started
- Command line
- Configuration setup
- Configuration reference
- Formatting
- Formatting examples
- BibTeX and BibLaTeX
- Formula formatting
- Table column alignment
- Code and docstrip formatting
- Project context
- Source analysis
- Supported syntax
- Editor integration
- VS Code / LaTeX Workshop
- Library API
- Cache and tracing
- Performance
- Building from source
- Troubleshooting