Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructs like {a}_{{b}} prevent correct parsing of mandatory arguments #563

Open
torik42 opened this issue Sep 17, 2024 · 1 comment
Open
Labels
bug unexpected behaviour; should be a priority for fixing

Comments

@torik42
Copy link

torik42 commented Sep 17, 2024

For some reason, mandatory arguments containing constructs like {a}_{{b}} or {a}^{{b}} are not recognized properly. Neither for indentation nor for line breaks. Unfortunately, this happens quite regularly in math material. (I also add a more realistic example, as for me the mechanism is not yet clear.)

Example for indentation

% 1-input.tex
\cmd{
	{a}_{{b}}
}

\cmd{
	{a}^{{b}}
}

\cmd{
	{a}_{b}
}

\cmd{
	\othercmd{a}_{b_{c}}
}

with

latexindent.pl 1-input.tex -o=1-output.tex

gives

% 1-output.tex
\cmd{
{a}_{{b}}
}

\cmd{
{a}^{{b}}
}

\cmd{
	{a}_{b}
}

\cmd{
\othercmd{a}_{b_{c}}
}

but I expect the first two commands to be indented as the third one which is there for comparison

% 1-expected.tex
\cmd{
	{a}_{{b}}
}

\cmd{
	{a}^{{b}}
}

\cmd{
	{a}_{b}
}

\cmd{
	\othercmd{a}_{b_{c}}
}

For some reason, without \othercmd, the last example is indented correctly. But one can put more additional commands and it still fails.

Example for modifylinebreaks

% 2-input.tex
\cmd{{a}^{{b}}}

\cmd{{a}^{b}}
# 2-config.yaml
modifyLineBreaks:
  mandatoryArguments:
    cmd:
      MandArgBodyStartsOnOwnLine: 1
      RCuBStartsOnOwnLine: 1

upon running

latexindent.pl -m 2-input.tex -l=2-config.yaml -o=2-output.tex 

produces

% 2-output.tex
\cmd{{a}^{{b}}}

\cmd{
	{a}^{b}
}

while I expect

% 2-expected.tex
\cmd{
	{a}^{{b}}
}

\cmd{
	{a}^{b}
}
@cmhughes
Copy link
Owner

Apologies for the delay I'm hoping to get to this soon

@cmhughes cmhughes added the bug unexpected behaviour; should be a priority for fixing label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected behaviour; should be a priority for fixing
Projects
None yet
Development

No branches or pull requests

2 participants