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

Indentation inside a command #391

Closed dpo closed 1 year ago

dpo commented 1 year ago

original .tex code

\documentclass{article}

\title{
My title
}

\begin{document}
BLA.

\begin{equation}
e = mc^2.
\end{equation}
\end{document}

yaml settings

defaultIndent: "  "

noAdditionalIndentGlobal:
    commands: 0

actual/given output

\documentclass{article}

\title{
My title
}

\begin{document}
BLA.

\begin{equation}
  e = mc^2.
\end{equation}
\end{document}

desired or expected output

\documentclass{article}

\title{
  My title
}

\begin{document}
  BLA.

  \begin{equation}
    e = mc^2.
  \end{equation}
\end{document}

With the commands option, I was hoping to indent the contents of \title{...}. Also, I'm not sure if it's reasonable to expect that everything between \begin{document} and \end{document} be indented, but could you please point me to the option that would enable/disable it?

I use latexindent 3.19.1 on macOS installed via Homebrew.

Thank you in advance.

cmhughes commented 1 year ago

Thanks for this :)

Perhaps the following might help

indentPreamble: 1
noAdditionalIndent:
    document: 0

Let me know!

cmhughes commented 1 year ago

For reference https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#filecontents-and-preamble and https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#noadditionalindent-and-indentrules :)

dpo commented 1 year ago

Thank you! Sorry if those were basic questions!

cmhughes commented 1 year ago

No worries at all, happy to help :)