Closed dpo closed 1 year ago
Thanks for this, and apologies for delay (various internet/operating system issues).
You can use the following settings
modifyLineBreaks:
environments:
BodyStartsOnOwnLine: 2 # add % after \begin{env} to preserve page reference
replacements:
-
when: after
substitution: |-
s/%%/%/sg
and call latexindent
using the -r
switch, such as
latexindent.pl -l -m -r myfile.tex
Referencing https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#poly-switches-for-other-code-blocks we see that for environments BodyStartsOnOwnLine
refers to the content immediately after the begin
statement. During the poly-switch adjustment latexindent
LSqBStartsOnOwnLine
(optional arguments) and LCuBStartsOnOwnLine
(mandatory arguments) and then makes necessary adjustments; in your example, because you haven't specified that either type of argument should start on their own line, latexindent
removes the linebreak added in step 1At the end of the indentation algorithm, latexindent
checks for comments that are not at the end of their line, and then moves them. In your case, this results in two comments.
So, finally in the settings above, we instruct latexindent
to replace two comment symbols with a single comment symbol. You might like to use
replacements:
-
when: after
substitution: |-
s/%{2,}/%/sg
which would replace two or more comment symbols with a single comment symbol.
I hope this helps!
Thank you. Strangely, -r
works but -rv
does not.
Please provide the following when posting an issue:
original .tex code
yaml settings
actual/given output
(Note the extra
%
.)desired or expected output
(NB: only one
%
.)anything else
Starting with
no second
%
gets added. There seems to be an interaction with the optional[h]
argument.