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

Why am I unable to retain line breaks for \begin{equation*} and \end{equation*}? #461

Closed RobinTruax closed 1 year ago

RobinTruax commented 1 year ago

Original tex code

A
\begin{equation*}
    B
\end{equation*}
C.

yaml settings

modifyLineBreaks: 
  oneSentencePerLine: 
    manipulateSentences: 1
    removalSentenceLineBreaks: 1
    textWrapSentences: 0
  environments: 
    BeginStartsOnOwnLine: 1
    BodyStartsOnOwnLine: 1
    EndStartsOnOwnLine: 1
    DBSFinishesWithLineBreak: 1

Actual/given output tex

A \begin{equation*} B \end{equation*} C.

Desired or expected output tex

A
\begin{equation*}
    B
\end{equation*}
C.

I would not like latexindent to collapse these environments. My other environments (.e.g theorem, definition, lemma, etc.) are not collapsed.

cmhughes commented 1 year ago

Thanks for this.

equation* is specified in the defaultSettings.yaml, the intention is for it to be a helpful demonstration, but maybe it causes confusion...?

So, you need

environments:                           
        equation*:                          
            BeginStartsOnOwnLine: 1
            BodyStartsOnOwnLine: 1
            EndStartsOnOwnLine: 1
            EndFinishesWithLineBreak: 1
cmhughes commented 1 year ago

I've updated defaultSettings.yaml as of https://github.com/cmhughes/latexindent.pl/commit/9039b1d930a53c2fc1cc34b224302944bf636bcb, it'll be part of the next release.

cmhughes commented 1 year ago

Implemented at https://github.com/cmhughes/latexindent.pl/releases/tag/V3.23