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

Incorrect column breaking when using multiColumnGrouping #301

Closed
qiancy98 opened this issue Nov 9, 2021 · 8 comments
Closed

Incorrect column breaking when using multiColumnGrouping #301

qiancy98 opened this issue Nov 9, 2021 · 8 comments
Labels
align-at-ampersand-routine the align at ampersand; documented in lookForAlignDelims bug unexpected behaviour; should be a priority for fixing implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix

Comments

@qiancy98
Copy link
Contributor

qiancy98 commented Nov 9, 2021

Please provide the following when posting an issue:

original .tex code

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{array}{ccc*{19}{c@{}}cr}
	n & r & k & \multicolumn{20}{l}{\operatorname{DT}(n+1,r+1,k)}   & \# (n-r) \text{-LEO}  \\
	\hline
	2           & 2           & 1  & +& & & & & & & & & & & & & & & & & & &  & 24          \\
\end{array}
\]
\end{document}

yaml settings

Please paste your YAML settings (if any) here

actual/given output

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
	\begin{array}{ccc*{19}{c@{}}cr}
		n & r & k & \multicolumn{20}{l}{\operatorname{DT}(n+1,r+1,k)} & \# (n-r) \text{-LEO}                                     \\
		2 & 2 & 1 & + &                                               &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  & 24 \\
	\end{array}
\]
\end{document}

desired or expected output

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
	\begin{array}{ccc*{19}{c@{}}cr}
		n & r & k & \multicolumn{20}{l}{\operatorname{DT}(n+1,r+1,k)}          & \# (n-r) \text{-LEO} \\
		2 & 2 & 1 & + &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  & 24                   \\
	\end{array}
\]
\end{document}

anything else

We should use #1 in \multicolumn#1 for the columns it occupies, instead of the fixed number 2.

@cmhughes
Copy link
Owner

cmhughes commented Nov 9, 2021

Please see https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#lst-tabular2yaml

You will need to specify it for the array environment.

@cmhughes cmhughes added question user-centred question about behaviour of latexindent.pl answered question has been answered labels Nov 9, 2021
@qiancy98
Copy link
Contributor Author

qiancy98 commented Nov 9, 2021

I use the yaml setting

lookForAlignDelims:
   tabular: 
      multiColumnGrouping: 1

but I forgot to put it here.
I mean, when we turn on this switch, we view \multicolumn#1#2#3 as two columns, but I think we should view it as #1 columns.
For this example, it is 20.

@cmhughes
Copy link
Owner

cmhughes commented Nov 9, 2021

Your example uses an array, so your yaml needs to use array.

@cmhughes
Copy link
Owner

cmhughes commented Nov 9, 2021

I mean, when we turn on this switch, we view \multicolumn#1#2#3 as two columns,

That's not correct.

but I think we should view it as #1 columns.

This already happens.

@qiancy98
Copy link
Contributor Author

qiancy98 commented Nov 10, 2021

File example1.tex

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
	\begin{array}{c*{20}{c}r}
		n & \multicolumn{20}{l}{abc} & hello                                                    \\
		2 & + &                      &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  & 24 \\
	\end{array}
\]
\end{document}

File example1.yaml (I have committed all lines of indentconfig.yaml.)

lookForAlignDelims:
   array: 
      multiColumnGrouping: 1

powershell command:latexindent .\example1.tex -l .\example1.yaml -o .\example1.out
File example1.out.tex (the same as example.tex)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
	\begin{array}{c*{20}{c}r}
		n & \multicolumn{20}{l}{abc} & hello                                                    \\
		2 & + &                      &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  &  & 24 \\
	\end{array}
\]
\end{document}

It is not desired.

Edit: make the example smaller.


Sorry I forget the changing of indentconfig.yaml, resulting the difficulty in testing. This time it should be OK.

@cmhughes
Copy link
Owner

I can confirm the results you describe. This is not intended behaviour. I'll look into it, thanks for reporting!

@cmhughes cmhughes added bug unexpected behaviour; should be a priority for fixing align-at-ampersand-routine the align at ampersand; documented in lookForAlignDelims and removed question user-centred question about behaviour of latexindent.pl answered question has been answered labels Nov 10, 2021
@cmhughes
Copy link
Owner

cmhughes commented Jan 8, 2022

This is fixed as of 54438d6. It'll be part of the next release.

I'll keep this issue open until the release.

Thanks for reporting!

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Jan 8, 2022
@cmhughes
Copy link
Owner

cmhughes commented Jan 8, 2022

resolved as of https://github.com/cmhughes/latexindent.pl/releases/tag/V3.14 upload to ctan imminent.

@cmhughes cmhughes closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
align-at-ampersand-routine the align at ampersand; documented in lookForAlignDelims bug unexpected behaviour; should be a priority for fixing implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix
Projects
None yet
Development

No branches or pull requests

2 participants