Transpilation Rules
Transpilation rules control how Texpile converts editor content into LaTeX code. Every element you see in the editor (headings, paragraphs, images, tables, blockquotes, etc.) has a corresponding rule that defines what LaTeX it produces.
How Rules Work
Texpile provides a base preset (@texpile/base/v1) that covers all standard elements with sensible defaults. You can use this as-is or override specific rules to match your template’s requirements.
Rules use #placeholder# syntax to insert dynamic content. For example, a heading rule might look like:
\section{#text#} When Texpile encounters a “Heading 1” in the editor, it replaces #text# with the actual heading text.
Using Presets in Rules
Just like exports and document sections, rules support presets. Most templates start with the base preset and only override what they need:
- Add
@texpile/base/v1as the first rule (provides defaults for all elements) - Add any additional presets (e.g.,
@texpile/tables/academic/v1for booktabs-style tables) - Add inline overrides for anything you want to customize
Inline overrides are written as JSON in the code editor within the template editor.
Rules cascade: later items override earlier ones. So if @texpile/base/v1 defines heading/1 as \section{#text#}, and you add an override after it, your override wins.
Common Overrides
Headings
Override how heading levels map to LaTeX commands:
% Heading 1 -> unnumbered section
\section*{#text#}
% Heading 2 -> numbered subsection
\subsection{#text#} Blockquotes
Override the blockquote environment:
\begin{displayquote}
#content#
\end{displayquote} Images
Image rules have several variants depending on alignment and numbering:
- center: default centered figure
- center_spanning: column-spanning figure (for multi-column templates)
- center_unnumbered: figure with caption but no number
- center_nocaption: figure with no caption
- left/right: wrapped figures using
wrapfigure
Each variant also has a _spanning version for multi-column layouts.
Example for a two-column template like IEEE:
% Regular figure (single column)
\begin{figure}[htbp]
\centering
\includegraphics[width=#scale#\columnwidth]{#src#}
\caption{#caps#}
#label#
\end{figure}
% Spanning figure (both columns)
\begin{figure*}[htbp]
\centering
\includegraphics[width=#scale#\textwidth]{#src#}
\caption{#caps#}
#label#
\end{figure*} Available placeholders for images:
#src#: image filename#scale#: width as a fraction (e.g., 0.8)#caps#: caption text#label#: the\label{...}command
Tables
Table rules control the structure of the generated table:
- table: the inner
tabularenvironment - table_row: how each row is formatted
- table_cell: how each cell is formatted
- table_wrapper: the outer
tablefloat environment (numbered tables) - table_wrapper_spanning: column-spanning version of the wrapper
Table Borders
You can customize table borders:
- top: border before the first row (e.g.,
\toprule,\hline, orfalse) - bottom: border after the last row (e.g.,
\bottomrule,\hline, orfalse) - vertical: vertical separators between columns (e.g.,
|,||, orfalse) - headerRow: border after the header row (e.g.,
\midrule,\hline, orfalse) - rowBorder: border between all rows for a grid style
- partialRule: command for partial rules when rowspans cross borders (
\cmidruleor\cline)
Example for academic-style tables (booktabs):
top: \toprule
bottom: \bottomrule
headerRow: \midrule
vertical: false
partialRule: \cmidrule Example for grid-style tables:
top: \hline
bottom: \hline
vertical: |
rowBorder: \hline Citations
Override how citation commands map to LaTeX. Each command has two forms: a basic form and a form with notes (prenote/postnote).
Available placeholders:
#key#: the citation key#pre#: the prenote (e.g., “see”)#post#: the postnote (e.g., “p. 42”)
Default mappings:
autocite -> \autocite{#key#} (with notes: \autocite[#pre#][#post#]{#key#})
parencite -> \parencite{#key#}
textcite -> \textcite{#key#}
cite -> \cite{#key#} You can remap these for different citation packages. For example, IEEE maps everything to \cite:
autocite -> cite
parencite -> cite
textcite -> cite
cite -> cite Cross-References
Customize how references to figures, tables, equations, and sections are formatted:
- figure: e.g.,
Fig.~\ref{#label#}or\autoref{#label#} - table: e.g.,
Table~\ref{#label#} - equation: e.g.,
\eqref{#label#} - section: e.g.,
\ref{#label#} - default: fallback for unknown reference types
Text Marks
Control how inline formatting is output:
- highlight: what LaTeX to generate for highlighted text. Set to
#text#(plain text) if the template doesn’t support highlight. - textcolor: what LaTeX to generate for colored text. Set to
#text#if the template doesn’t support colors.
JSON Reference
Inline rule overrides are written as JSON. You only need to include the keys you want to override. Below is the full reference for every available key.
heading
Maps heading levels (1–5) to LaTeX commands.
| Key | Placeholder | Default |
|---|---|---|
1 | #text# | \section{#text#} |
2 | #text# | \subsection{#text#} |
3 | #text# | \subsubsection{#text#} |
4 | #text# | \paragraph{#text#} |
5 | #text# | \subparagraph{#text#} |
{ "heading": { "1": "\\section*{#text#}" } } paragraph
Template for paragraph text. Placeholder: #text#.
Default: #text#
code_block
Template for code blocks. Placeholder: #text# (the raw code content).
Default: \begin{verbatim}\n#text#\n\end{verbatim}
blockquote
Template for blockquotes. Placeholder: #content# (the blockquote’s inner content).
Default: \begin{quote}\n#content#\n\end{quote}
list
Templates for ordered and unordered lists. Placeholder: #content# (the list items).
| Key | Default |
|---|---|
ordered | \begin{enumerate}\n#content#\n\end{enumerate} |
bullet | \begin{itemize}\n#content#\n\end{itemize} |
list_item
Template for a list item. Placeholder: #content#.
Default: \item #content#
nolabel_list_item
Template for a list item without a label (used in certain list contexts). Placeholder: #content#.
Default: \item[] #content#
image
Templates for images. Each variant controls a different alignment/caption combination. Placeholders:
#src#: image filename#scale#: width as a fraction of text/column width (e.g.,0.8)#scale2#: adjusted width for wrapfigure (scale minus margin)#caps#: caption text#label#: the\label{...}command
Variants:
| Key | Description |
|---|---|
center | Centered figure with caption and number |
center_spanning | Column-spanning centered figure |
center_unnumbered | Centered figure with caption, no number (\caption*) |
center_unnumbered_spanning | Column-spanning, unnumbered |
center_nocaption | Centered figure with no caption |
center_nocaption_spanning | Column-spanning, no caption |
left | Left-aligned wrapped figure with caption |
left_unnumbered | Left-aligned wrapped figure, no number |
left_nocaption | Left-aligned wrapped figure, no caption |
right | Right-aligned wrapped figure with caption |
right_unnumbered | Right-aligned wrapped figure, no number |
right_nocaption | Right-aligned wrapped figure, no caption |
margin | Number. Margin subtracted from scale for wrapfigure width. Default: 0.02 |
Example (single-column figure for IEEE):
{
"image": {
"center": "\\begin{figure}[htbp]\n\\centering\n\\includegraphics[width=#scale#\\columnwidth]{#src#}\n\\caption{#caps#}\n#label#\\end{figure}"
}
} marks
Templates for inline text formatting. Placeholder: #text# (the marked text).
| Key | Description | Default |
|---|---|---|
strong | Bold text | \textbf{#text#} |
em | Italic text | \textit{#text#} |
u | Underlined text | \underline{#text#} |
code | Inline code | \texttt{#text#} |
link | Hyperlink. Additional placeholder: #href# | \href{#href#}{#text#} |
textcolor | Colored text. Additional placeholder: #color# | \textcolor{#color#}{#text#} |
highlight | Highlighted text. Additional placeholder: #color# | {\sethlcolor{#color#}\hl{#text#}} |
To disable highlight or textcolor output, set them to #text# (outputs plain text with no formatting).
text_transforms
Templates for special text transformations.
| Key | Description | Default |
|---|---|---|
tab | Tab character replacement | \hspace{0.5in} |
straight_quote | Straight quote replacement | \texttt{"} |
citation
Maps citation variant names to LaTeX citation commands. The value is the command name (without backslash). Texpile automatically generates the full command with #key#, #pre#, and #post# placeholders.
| Key | Description | Default |
|---|---|---|
autocite | Automatic citation | autocite → \autocite{#key#} |
parencite | Parenthetical citation | parencite → \parencite{#key#} |
textcite | Narrative/textual citation | textcite → \textcite{#key#} |
cite | Basic cite command | cite → \cite{#key#} |
To map all variants to a single command (e.g., IEEE):
{
"citation": {
"autocite": "cite",
"parencite": "cite",
"textcite": "cite",
"cite": "cite"
}
} ref
Templates for cross-references. Placeholder: #label# (the reference label).
| Key | Description | Default |
|---|---|---|
figure | Figure reference | \autoref{#label#} |
table | Table reference | \autoref{#label#} |
equation | Equation reference | \autoref{#label#} |
section | Section reference | \autoref{#label#} |
default | Fallback for unknown types | \autoref{#label#} |
Example (IEEE-style references):
{
"ref": {
"figure": "Fig.~\\ref{#label#}",
"table": "Table~\\ref{#label#}",
"equation": "\\eqref{#label#}"
}
} table
Templates for table structure. Contains sub-keys for each part of the table.
Structure templates:
| Key | Placeholders | Description |
|---|---|---|
table | #columns#, #content# | The inner tabular environment |
table_row | #content# | A single table row |
table_cell | #content# | A single table cell |
table_wrapper | #caption#, #label#, #content#, #notes# | The outer table float (numbered) |
table_wrapper_spanning | Same as above | Column-spanning version |
table_caption | #text# | Caption formatting |
table_label | #text# | Label formatting |
table_notes | #text# | Footnote/notes formatting |
tableColumnPattern: controls the column specifiers in the tabular environment.
| Key | Sub-keys | Description |
|---|---|---|
default | all | Column specifier applied to all columns (e.g., X, c, l) |
withHeaderColumn | first, rest | When a header column is enabled, first applies to the first column and rest to the remaining columns |
tableBorders: controls border lines.
| Key | Type | Description |
|---|---|---|
top | string or false | Border before first row (e.g., \toprule, \hline) |
bottom | string or false | Border after last row |
headerRow | string or false | Border after header row |
vertical | string or false | Vertical column separator (e.g., \|) |
rowBorder | string or false | Border between every row (grid style) |
partialRule | string | Command for partial rules with rowspans (\cmidrule or \cline) |
Example (booktabs-style table):
{
"table": {
"tableBorders": {
"top": "\\toprule",
"bottom": "\\bottomrule",
"headerRow": "\\midrule",
"vertical": false,
"partialRule": "\\cmidrule"
}
}
}