Closed arkandias closed 11 months ago
Does the following help
modifyLineBreaks:
commands:
CommandStartsOnOwnLine:
label: -1
The following latexindent.yaml
works:
modifyLineBreaks:
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
replacements:
- substitution: s/(\\begin\{[^}]+?\})\s*(\\label\{)/$1$2/
when: after
and called with
latexindent.pl -l -m -r myfile.tex
\begin{myenv}\label{mylabel}
The body of my environment...
\end{myenv}
Thank you for your solution! It works indeed, but this seems a bit like a hack (and it uses the replacement function which makes the process heavier).
I really think this should be the default behavior (or at least an option), just as in the case of headings. Most people I know place their labels on the same line as the \begin command. It is also what you can find, e.g., here:
You've specified BodyStartsOnOwnLine: 1
which means that the body will start on its own line.
The body of the environment starts after the begin statement as detailed in https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#poly-switches-for-other-code-blocks
Yes, I do want the body to start on its own line, but I would like the body to begin after \label{my label}
.
as of https://github.com/cmhughes/latexindent.pl/commit/cc849d764c2babdc2b68660d61780966aae7fcd2 if you start with
\begin{myenv}\label{mylabel}The body of my environment...\end{myenv}
and use the settings
modifyLineBreaks:
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
fineTuning:
environments:
begin: \\begin\{([a-zA-Z@\*0-9_\\]+)\}\s*\\label\{[^}]+?\}
end: \\end\{\2\}
then you receive the output
\begin{myenv}\label{mylabel}
The body of my environment...
\end{myenv}
and there's no need to use the replacement switch. I'll get this released soon.
Great! Thank you very much, this is a very nice solution!
Hi there,
I hope this question was not already asked (could not fin anything in the Issues...).
I like the following format for (most of) my environments:
So I configured latexindent with the following poly-switches:
However, when I label my environments, I like the label to be placed on the same line as the \begin{...}, i.e.
This is automatically handled for headings (cf. 6.1.3 in the doc), but I cannot figure out how to configure this for environments (if this is possible)...
Any idea?