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
884 stars 84 forks source link

Indent incorrectly removed #330

Closed tdegeus closed 2 years ago

tdegeus commented 2 years ago

Please provide the following when posting an issue:

original .tex code

and $z = \zeta$ (\cref{eq:z}) \footnote{
    We remark that:
    I)
    The fit of the prefactors.
    II)
    We have checked that
    III)
    $C_f = A / t = c_1^{-1} A^{1 - \zeta} \sim A^{0.37}$.
}.

yaml settings

onlyOneBackUp: 1
defaultIndent: "    "
removeTrailingWhitespace: 1
lookForAlignDelims:
   align: 0
modifyLineBreaks:
  textWrapOptions:
    columns: 100
  oneSentencePerLine:
    manipulateSentences: 1
    removeSentenceLineBreaks: 0

actual/given output

and $z = \zeta$ (\cref{eq:z}) \footnote{
We remark that:
I)
The fit of the prefactors.
II)
We have checked that
III)
$C_f = A / t = c_1^{-1} A^{1 - \zeta} \sim A^{0.37}$.
}.

desired or expected output

and $z = \zeta$ (\cref{eq:z}) \footnote{
    We remark that:
    I)
    The fit of the prefactors.
    II)
    We have checked that
    III)
    $C_f = A / t = c_1^{-1} A^{1 - \zeta} \sim A^{0.37}$.
}.
cmhughes commented 2 years ago

Thanks for this.

This needs fineTuning for the c_1^{-1}, because we have a namedGroupingBracesBrackets that contains an underscore.

So, using

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

gives the output

and $z = \zeta$ (\cref{eq:z}) \footnote{
    We remark that:
    I)
    The fit of the prefactors.
    II)
    We have checked that
    III)
    $C_f = A / t = c_1^{-1} A^{1 - \zeta} \sim A^{0.37}$.
}.
cmhughes commented 2 years ago

Any luck with this?

tdegeus commented 2 years ago

I can confirm your work-around. Thanks!