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

Issue with align wraping and `\partial` #471

Closed ayghri closed 1 year ago

ayghri commented 1 year ago

There is some weird behavior when using \partial (I lost some brain cells trying to figure out the issue).

\begin{align*}
\frac{\partial f(x)}{\partial x_m} 
& = \sum_{i,j}^{n} w_ij {\frac{\partial{}\Ea{(f_i-f_j)^2}}{\partial{} x_m}} \\
& = \alpha
\end{align*}
noAdditionalIndent:
  aligned: 1
lookForAlignDelims:
  aligned: 1
  alignFinalDoubleBackSlash: 1
modifyLineBreaks:
  preserveBlankLines: 1 # 0/1
  condenseMultipleBlankLinesInto: 1 # 0/1
  textWrapOptions:
    multipleSpacesToSingle: 1
    removeBlockLineBreaks: 1
    columns: 84
    when: after # before/after
    comments:
      wrap: 0 # 0/1
      inheritLeadingSpace: 0 # 0/1
    blocksFollow:
      headings: 1 # 0/1
      commentOnPreviousLine: 1 # 0/1
      par: 1 # 0/1
      blankLine: 1 # 0/1
      verbatim: 1 # 0/1
      filecontents: 1 # 0/1
      # other: 1
      other: \\\]|\\item(?:\h|\[) # regex
    blocksBeginWith:
      A-Z: 1 # 0/1
      a-z: 1 # 0/1
      0-9: 1 # 0/1
      other: 0 # regex
    blocksEndBefore:
      commentOnOwnLine: 1 # 0/1
      verbatim: 1 # 0/1
      filecontents: 1 # 0/1
      # other: 0
      # other: \\begin\{|\\\[|\\end\{    # regex
    huge: overflow # forbid mid-word line breaks
    separator: ""

Output

\begin{align*} 
\frac{\partial f(x)}{\partial x_m} & = \sum_{i,j}^{n} w_ij {\frac{\partial{}\Ea{(f_i-f_j)^2}{\partial{} x_m}} \\ & = \alpha
\end{align*}

When I change partial to delta

\begin{align*}
    \frac{\delta f(x)}{\delta x_m}
     & = \sum_{i,j}^{n} w_ij {\frac{\delta{}\Ea{(f_i-f_j)^2}}{\delta{} x_m}} \\
     & = \alpha
\end{align*}
latexindent --version
> 3.22.2, 2023-07-14
cmhughes commented 1 year ago

Thanks for this, and apologies, this is a bug. I've fixed it as of https://github.com/cmhughes/latexindent.pl/commit/e235ad8b4e4d220f18ca95de55dc738fe8da3d4e and will get it released soon.

ayghri commented 1 year ago

I appreciate it. Glad I could help.

cmhughes commented 1 year ago

Released at https://github.com/cmhughes/latexindent.pl/releases/tag/V3.23.1 thanks again