latexindent.pl icon indicating copy to clipboard operation
latexindent.pl copied to clipboard

Preventing indentation of in macro after newline

Open sw-dbrown opened this issue 2 years ago • 2 comments

original .tex code

xxxx-xxxxxxxxxxxxxx xxxxxx xxxxxxxxxx, xx xxxx xxxxxxxxxxx xxxxxxxx \emph{xxx
xxx xxx} xxxxx xxxxxxxxxxxxx, xxxxxxxxxxxxxx xxx xxxxxxxxxx xxx xxxxxxxxxx
xxxxxxxx xxx xxxxxxxxxxxxxxxxxxx xxxxx xxx xxxxxxxx xxx xxxxx xxx xxx
xxxxxxxxxxx xxxxxxxxxxx.

yaml settings

I do have customer settings but the shown indentation stems from the default configuration. I can reproduce it with --onlydefault.

actual/given output

xxxx-xxxxxxxxxxxxxx xxxxxx xxxxxxxxxx, xx xxxx xxxxxxxxxxx xxxxxxxx \emph{xxx
	xxx xxx} xxxxx xxxxxxxxxxxxx, xxxxxxxxxxxxxx xxx xxxxxxxxxx xxx xxxxxxxxxx
xxxxxxxx xxx xxxxxxxxxxxxxxxxxxx xxxxx xxx xxxxxxxx xxx xxxxx xxx xxx
xxxxxxxxxxx xxxxxxxxxxx.

desired or expected output

xxxx-xxxxxxxxxxxxxx xxxxxx xxxxxxxxxx, xx xxxx xxxxxxxxxxx xxxxxxxx \emph{xxx
xxx xxx} xxxxx xxxxxxxxxxxxx, xxxxxxxxxxxxxx xxx xxxxxxxxxx xxx xxxxxxxxxx
xxxxxxxx xxx xxxxxxxxxxxxxxxxxxx xxxxx xxx xxxxxxxx xxx xxxxx xxx xxx
xxxxxxxxxxx xxxxxxxxxxx.

(the same as the original tex code)

anything else

Specifically I would like to not have \emph{} (and potentially other) macros indented when they contain a newline. Thank you for your tool and your time!

sw-dbrown avatar Oct 14 '22 12:10 sw-dbrown

Thanks for this :)

Does the following help:

https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#commands-with-arguments

cmhughes avatar Oct 14 '22 12:10 cmhughes

See also

https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#summary

cmhughes avatar Oct 14 '22 14:10 cmhughes

More details....

option 1 (emph only)

Using

noAdditionalIndent:
    emph: 1

gives

xxxx-xxxxxxxxxxxxxx xxxxxx xxxxxxxxxx, xx xxxx xxxxxxxxxxx xxxxxxxx \emph{xxx
xxx xxx} xxxxx xxxxxxxxxxxxx, xxxxxxxxxxxxxx xxx xxxxxxxxxx xxx xxxxxxxxxx
xxxxxxxx xxx xxxxxxxxxxxxxxxxxxx xxxxx xxx xxxxxxxx xxx xxxxx xxx xxx
xxxxxxxxxxx xxxxxxxxxxx.

but this will only apply to the emph command.

option 2 (global commands)

Using

noAdditionalIndentGlobal:
    mandatoryArguments: 1

gives the same output

xxxx-xxxxxxxxxxxxxx xxxxxx xxxxxxxxxx, xx xxxx xxxxxxxxxxx xxxxxxxx \emph{xxx
xxx xxx} xxxxx xxxxxxxxxxxxx, xxxxxxxxxxxxxx xxx xxxxxxxxxx xxx xxxxxxxxxx
xxxxxxxx xxx xxxxxxxxxxxxxxxxxxx xxxxx xxx xxxxxxxx xxx xxxxx xxx xxx
xxxxxxxxxxx xxxxxxxxxxx.

but this applies to all mandatory arguments.

cmhughes avatar Oct 15 '22 11:10 cmhughes

Let me know if you need anything further :)

cmhughes avatar Oct 16 '22 06:10 cmhughes

@cmhughes Sorry for the late reply and thank you very much for your time! Your suggestion is exactly what I was looking for and it works as expected.

sw-dbrown avatar Oct 24 '22 06:10 sw-dbrown