Skip to content
Thomas edited this page Nov 22, 2020 · 12 revisions

Press Ctrl+Alt+L to reformat. 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 for listings environments.

Indents in (math) environments

indent-environment

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).

table-formatter-multiline

Algorithm pseudocode

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

For example,

\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}

will be reformatted to

\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.

This documentation has moved to https://hannah-sten.github.io/TeXiFy-IDEA

Clone this wiki locally