TeXiFy-IDEA documentation Help

Code formatting

Press Ctrl+Alt+L to reformat.

Fill paragraph

Edit | Fill Paragraph

Fill the paragraph that is currently under the cursor such that each line is filled until the right margin, but does not exceed it.

Disabling the formatter

To disable formatting on a portion of your tex file, wrap the code with

% @formatter:off ... % @formatter:on

and enable these comments in the settings by going to Settings | Editor | Code Style | Formatter Control and checking Enable formatter markers in comments. This can be particularly useful if you have to adhere to formatting conventions different from TeXiFy standards.

Indents in (math) environments

By default all environments are indented, and manual indents will be removed by the formatter.

indent-environment

This can be disabled in the code style settings, where indenting the document environment can have a different setting than other environments.

Indents in groups

Since b0.6.8

When writing inside a group ({...} or [...]) the formatter will indent all content that is on a new line.

indent-group

Blank lines before sectioning commands

Since b0.6.8

Edit this behaviour in the code style settings.

blank-lines-section

Hard wrap

Since b0.6.8

Enable or disable this setting in the code style settings.

hard-wrap

Table formatting

Since b0.6.10

Inside a table environment, like tabular, the &s and \s are aligned, so it is clear which cells belong to the same column.

table-formatter-simple

When formatting the contents of a table, it ignores all table lines that

  • are split over multiple lines, or

  • contain less & than required (for example when using the \multicolumn command).

If you have 'Wrap on typing' set to 'yes', then long lines may be split.

table-formatter-multiline

Algorithm pseudocode

When writing pseudocode using the algorithmicx environment and the algpseudocode set of commands, they will be formatted properly.

\begin{algorithm} \begin{algorithmic} \State begin \If {$i\geq maxval$} \State $i\gets 0$ \Else \If {$i+k\leq maxval$} \State $i\gets i+k$ \EndIf \EndIf \end{algorithmic} \caption{Insertion sort} \label{alg:insertion-sort} \end{algorithm}
\begin{algorithm} \begin{algorithmic} \State begin \If {$i\geq maxval$} \State $i\gets 0$ \Else \If {$i+k\leq maxval$} \State $i\gets i+k$ \EndIf \EndIf \end{algorithmic} \caption{Insertion sort} \label{alg:insertion-sort} \end{algorithm}

The following commands are supported.

  • \If{<condition>} <text> (\ElsIf{<condition>} <text>)* (\Else <text>)? \EndIf

  • \For{<condition>} <text> \EndFor

  • \ForAll{<condition>} <text> \EndFor

  • \While{<condition>} <text> \EndWhile

  • \Repeat <text> \Until{<condition>}

  • \Loop <text> \EndLoop

  • \Function{<name>}{<params>} <body> \EndFunction

  • \Procedure{<name>}{<params>} <body> \EndProcedure

Commands defined using \algblock or \algloop are currently not recognized by the formatter.

Formatting for algorithms written with algorithm2e instead of algorithmicx is also supported.

External formatters

In some cases, you might have external requirements on your formatting which are incompatible with the default TeXiFy formatter. For these cases, there are some built-in actions that run external formatters. Most probably you want to bind a shortcut to this action in File | Settings | Keymap.

Latexindent

Since b0.7.7

If your caret is in a LaTeX file, you can use Code | Reformat with Latexindent. This will run latexindent.pl on the current file, and it will be updated on disk.

bibtex-tidy

Since b0.7.11

At the moment of writing, version 1.7.2 is not yet published to npm, but this version adds a feature which allows TeXiFy to get the output from stdout, which allows for better user feedback because IntelliJ will not have to ask you whether you want to load file changes from disk. You can install the new version locally by cloning the repo, optionally change the version number, run the npm build task and then run npm link.

See https://github.com/FlamingTempura/bibtex-tidy for more information.

Last modified: 01 May 2024