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
867 stars 84 forks source link

Unexpected indent of curly braces block #501

Closed MrConnorKenway closed 9 months ago

MrConnorKenway commented 9 months ago

original .tex code

\section { hi }
abc
{ xyz }

actual/given output

\section { hi }
abc
    { xyz }

desired or expected output

\section { hi }
abc
{ xyz }

anything else

I'm sorry I didn't use a template. Could you help me understand why latexindent adds a tab before { xyz }?

cmhughes commented 9 months ago

Please use the issue template and I'll try to help.

On Thu, 14 Dec 2023, 13:44 MrConnorKenway, @.***> wrote:

image.png (view on web) https://github.com/cmhughes/latexindent.pl/assets/32333772/f67588d4-9be6-4639-8599-63f72bf1b3a1

How can I remove the tab before { xyz }? The log says that "named grouping braces found: abc", why abc is considered to be named grouping braces?

indent.log https://github.com/cmhughes/latexindent.pl/files/13673959/indent.log

— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/501, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYAIPNZILERJQF3LZXLYJL7CJAVCNFSM6AAAAABAU33Y46VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DCNZTGEZDKNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MrConnorKenway commented 9 months ago

Hi, I've updated the issue. Sorry for the trouble : (

cmhughes commented 9 months ago

Thanks, that's great.

If we use

noAdditionalIndentGlobal:
  namedGroupingBracesBrackets: 1    # 0/1

then we receive

\section { hi }
abc
{ xyz }
MrConnorKenway commented 9 months ago

Thank you for your help! It indeed works, but when combining with other configs, it doesn't work again.

The original tex

\section { hi }
abc abc abc abc abc abc
{ xyz }

The command

latexindent -m -y "modifyLineBreaks:textWrapOptions:columns:25,modifyLineBreaks:textWrapOptions:blocksBeginWith:other:\\\\,noAdditionalIndentGlobal:namedGroupingBracesBrackets:1"

Actual output

\section { hi }
abc abc abc abc abc abc
        { xyz }
cmhughes commented 9 months ago

I'll happily look at this again, but before I do, can you provide your complete configuration.

MrConnorKenway commented 9 months ago

That's all the config, I'm using the command line and I don't have any local config. image

cmhughes commented 9 months ago

You need to use non-capturing parenthesis (?:\\\\) in your call, as in the following:

latexindent -m -y "modifyLineBreaks:textWrapOptions:columns:25,modifyLineBreaks:textWrapOptions:blocksBeginWith:other:(?:\\\\),noAdditionalIndentGlobal:namedGroupingBracesBrackets:1" issue-501a.tex
MrConnorKenway commented 9 months ago

Thank you so much for answering my dumb question!