cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
866 stars 84 forks source link

Subscript bracket combined with superscript broke latexindent #387

Closed vepain closed 1 year ago

vepain commented 1 year ago

Original .tex code

% subfile.tex

\acommand{
L^+_{v}
}

\acommand{
L_v^{+}
}

YAML settings

Default

Actual/given output

% subfile/tex
\acommand{
L^+_{v}
}

\acommand{
L_v^{+}
}

Desired or expected output

\acommand{
    L^+_{v}
}

\acommand{
     L_v^{+}
}
cmhughes commented 1 year ago

Thanks for this :)

We can use the fineTuning to help us with this

fineTuning:
    namedGroupingBracesBrackets:
      name: '[0-9\.a-zA-Z@\*><_+^]+?'

which gives

% subfile.tex

\acommand{
    L^+_{v}
}

\acommand{
    L_v^{+}
}

See also https://latexindentpl.readthedocs.io/en/latest/sec-fine-tuning.html#lst-fine-tuning2

vepain commented 1 year ago

You are amazing, thank you!

(it allows me to indent algorithm2e commands combined with strange bracket combination from \gls glossaries' commands!) I close this issue and the other linked one :)

Have a nice day

cmhughes commented 1 year ago

Great, glad it worked :)