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

the future of multirows in _tabularray_ package would let latexindent format the code incorrectly #543

Open
Mikachu2333 opened this issue May 10, 2024 · 8 comments
Labels
align-at-ampersand-routine the align at ampersand; documented in lookForAlignDelims enhancement enhancement which might be to an existing feature or the development of a new feature

Comments

@Mikachu2333
Copy link
Contributor

Mikachu2333 commented May 10, 2024

When using the tabularray package to merge cells (multiple rows), latexindent always incorrectly recognizes multiple rows cells.

MWE (After formatted)

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}{
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {f      \\g} \\ %multirows
    d       & h       \\
    e       & {i      \\j}    %multirows
\end{tblr}
\end{document}

yaml settings

No changes have been made except defaultindent: 4spaces. Others have no impact on the results.

actual/given output

Success with no error
pkZrYy8.jpg

desired or expected output

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}
    {
    cells={c,m},
    hlines,
    vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {f      \\
	      g}      \\
    d       & h       \\
    e       & {i      \\
              j}
\end{tblr}
\end{document}
@Mikachu2333 Mikachu2333 changed the title the future of mutilrows in _tabularray_ package would let latexindent format the code incorrectly the future of multirows in _tabularray_ package would let latexindent format the code incorrectly May 10, 2024
@cmhughes
Copy link
Owner

The actual/given output should be tex code, not a screen shot.

@Mikachu2333
Copy link
Contributor Author

The actual/given output should be tex code, not a screen shot.

The MWE is also what latexindent output show.

@cmhughes
Copy link
Owner

cmhughes commented May 10, 2024 via email

@Mikachu2333
Copy link
Contributor Author

Mikachu2333 commented May 11, 2024

[13:08:15.182][Format][TeX] Start formatting with latexindent.
[13:08:15.182][Format][TeX] Checking latexindent: which latexindent
[13:08:15.187][Format][TeX] Checking latexindent is ok: /usr/local/texlive/2024/bin/x86_64-linux/latexindent

[13:08:15.188][Format][TeX] Formatting LaTeX. The command is latexindent:["--cruft=%WS1%/","%WS1%/__latexindent_temp_main.tex","--modifylinebreaks","--GCString","--yaml=defaultIndent: '    '"].
[13:08:15.311][Format][TeX] Formatted %WS1%/main.tex

Latex output after latexindent formatted.

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}
    {
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {f      \\
    g}                \\
    d       & h       \\
    e       & {i
    \\j}
\end{tblr}
\end{document}

@cmhughes
Copy link
Owner

When I start with

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}{
		cells={c,m},
		hlines,
		vlines,
	}
	AAAAAAA & BBBBBBB \\
	c       & {f      \\g} \\ %multirows
	d       & h       \\
	e       & {i      \\j}    %multirows
\end{tblr}
\end{document}

and run

latexindent.pl myfile.tex

then I receive

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}{
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {f      \\g} \\ %multirows
    d       & h       \\
    e       & {i      \\j}    %multirows
\end{tblr}
\end{document}

which is what I would expect.

@cmhughes cmhughes added question user-centred question about behaviour of latexindent.pl align-at-ampersand-routine the align at ampersand; documented in lookForAlignDelims answered question has been answered labels May 11, 2024
cmhughes added a commit that referenced this issue May 11, 2024
@Mikachu2333
Copy link
Contributor Author

Mikachu2333 commented May 12, 2024

I apologize for not understanding what you said and answering irrelevantly.

What i input

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}{
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {g\\h}  \\ %multirows (g&h)
    d       & i       \\
    {e\\f}  & j          %multirows (e&f)
\end{tblr}
\end{document}

Command I use

latexindent main.tex --modifylinebreaks --GCString --yaml=defaultIndent: '    '

Latexindent output

(Success without error or warning as yours)

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}
    {
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {g      \\h}  \\
    d       & i       \\
    {e                \\f}       & j
\end{tblr}
\end{document}

BUT What I want

(Same as what i input, want latexindent understand the multirow style cell and normal cell)

\documentclass{ctexrep}%Chinese report
\usepackage{tabularray}%tabular

\begin{document}
\begin{tblr}{
        cells={c,m},
        hlines,
        vlines,
    }
    AAAAAAA & BBBBBBB \\
    c       & {g\\h}  \\ %multirows (g&h)
    d       & i       \\
    {e\\f}  & j          %multirows (e&f)
\end{tblr}
\end{document}

@cmhughes cmhughes added enhancement enhancement which might be to an existing feature or the development of a new feature and removed question user-centred question about behaviour of latexindent.pl answered question has been answered labels May 13, 2024
@cmhughes
Copy link
Owner

Thanks, that's clear.

I think we need a new feature to specify the double back slash regex within each lookForAlignDelims field.

Leave it with me, I hope to get to it soon, but time is pressured for me at the moment.

@Mikachu2333
Copy link
Contributor Author

Thanks for timely answer!

Please prioritize your own tasks. This issue is just a improvement, not an extremely harmful crash or bug, there's no need to rush to finish it.

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 enhancement enhancement which might be to an existing feature or the development of a new feature
Projects
None yet
Development

No branches or pull requests

2 participants