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

Extra comment? #398

Closed dpo closed 1 year ago

dpo commented 1 year ago

original .tex code

Some text with a command \citep[Theorem~\(10.1\)]{rtrw}
\begin{equation}%
    \label{eq:nlp-stationarity}
    0 \in \nabla f(x) + \partial (h + \chi(\cdot; \R^n_+))(x).
\end{equation}

yaml settings

modifyLineBreaks:
    oneSentencePerLine:
        manipulateSentences: 1
        sentencesBeginWith:
            other: "\$|\\\\\("

actual/given output

Some text with a command \citep[Theorem~\(10.1\)]{rtrw} \begin{equation} \label{eq:nlp-stationarity} 0 \in \nabla f(x) + \partial (h + \chi(\cdot; \R^n_+))(x).
    %
\end{equation}

desired or expected output

Some text with a command \citep[Theorem~\(10.1\)]{rtrw} \begin{equation} \label{eq:nlp-stationarity} 0 \in \nabla f(x) + \partial (h + \chi(\cdot; \R^n_+))(x).
\end{equation}

Where does that final % come from?

cmhughes commented 1 year ago

Many thanks.

Your original code contains a comment symbol, after the \begin{equation}. This is moved to the end of the sentence. See https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#features-of-the-onesentenceperline-routine for details, and https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#lst-multiple-sentences3-mod1 covers this.