Closed niveK77pur closed 1 year ago
Thanks for this.
You can use the replacement switch to assist with this:
modifyLineBreaks:
environments:
BodyStartsOnOwnLine: 1
replacements:
-
when: after
substitution: |-
s/(\\begin\{[^}]+?\})\s*(<[^>]+?>)/$1$2/sg
so you need to run
latexindent.pl -m -r -l myfile.tex
which gives
\documentclass{beamer}
\begin{document}
\begin{frame}{Frame Title}
\begin{onlyenv}<1>
I'm here
\end{onlyenv}
\begin{onlyenv}<2>
Where did I go?
\end{onlyenv}
\begin{uncoverenv}<3,5-6>
Hello
\end{uncoverenv}
\begin{onlyenv}<4->
World
\end{onlyenv}
\begin{center}
This
\begin{altenv}<2-4,6>{(}{)}{[}{]}
word
\end{altenv}
\end{center}
\end{frame}
\end{document}
As detailed in the Table at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#id67, the poly-switch BodyStartsOnOwnLine
corresponds to the line break immediately after the begin statement.
If you'd prefer not to employ the r
switch, then perhaps you can switch off the BodyStartsOnOwnLine
on a per-name basis, for example:
modifyLineBreaks:
environments:
BodyStartsOnOwnLine: 1
onlyenv:
BodyStartsOnOwnLine: 0
I hope this helps!
I see, thank you very much for the detailed explanations!
I do remember glancing at that table before but apparently I had decided to ignore what exactly it was showing. It seems that there is no issue after all and things are working exactly as intended; I must have misunderstood what exactly BodyStartsOnOwnLine
does and is supposed to do.
Following your comments, I will opt to disable the setting, and instead enable it on a per-name basis if I need it.
I will proceed to close this issue as everything has been resolved and clarified! Thanks again!
Wonderful, thanks so much :) happy indenting!
On Tue, Aug 29, 2023 at 6:43 PM Kevin Laurent Biewesch < @.***> wrote:
I see, thank you very much for the detailed explanations!
I do remember glancing at that table before but apparently I had decided to ignore what exactly it was showing. It seems that there is no issue after all and things are working exactly as intended; I must have misunderstood what exactly BodyStartsOnOwnLine does and is supposed to do.
Following your comments, I will opt to disable the setting, and instead enable it on a per-name basis if I need it.
I will proceed to close this issue as everything has been resolved and clarified! Thanks again!
— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/462#issuecomment-1697879336, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYC4MXX6HF5VBHMUIBTXXYS37ANCNFSM6AAAAAA4CSWPH4 . You are receiving this because you commented.Message ID: @.***>
original .tex code
yaml settings
Any value from 1 through 4 causes issues. Note that a value of 2 prevents the issue from breaking the document.
actual/given output
With
BodyStartsOnOwnLine: 1
With
BodyStartsOnOwnLine: 2
Note that the trailing
%
here prevents the document from breaking, and keeps the overlay working as it should.With
BodyStartsOnOwnLine: 3
andBodyStartsOnOwnLine: 4
desired or expected output
Overlay specifications are not considered as body of the environment. Example for a value of
BodyStartsOnOwnLine: 1
.anything else
Not sure if related and maybe warrants its own issue, but I noticed here that
\begin{frame}{Frame title}
also has a%
added for a value of 2. Same happens if I have a\begin{frame}[fragile]
or\begin{frame}[fragile]{Frame title}
. They all have a trailing%
added, even though they were already on their own line; as you can see, it works fine for the\begin{center}
which doesn't have additional arguments. For a value of 3 or 4, these arguments are even completely separated from the environment, which also causes a breaking modification to the document (the arguments become part of the body, not arguments to the environment anymore).