Closed kiryph closed 2 years ago
Thanks for this, it looks interesting! I appreciate you using the issue template, that's really helpful.
I hope to get to this over the next few days, and I'll post back with details.
Thanks, this was interesting!
Put the following in latexindent.yaml
noAdditionalIndent:
tblr:
mandatoryArguments: 1
fineTuning:
keyEqualsValuesBracesBrackets:
name: |-
(?x)
[ # |
a-z # |
A-Z # at least one of these
0-9 # |
@\* # |
_\/.:\#\- # |
]+ # |
[ # <
a-z # <
A-Z # <
0-9 # 0 or more of these
@\* # <
_\/. # <
\h\{\}:\#\- # <
, # <!-------NEW BIT: allow commas
]*? #
and run
latexindent.pl -l myfile.tex
and you receive your desired output
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
hlines = {white},
vlines = {white},
cell{1,6}{odd} = {teal7},
cell{1,6}{even} = {green7},
cell{2,4}{1,4} = {red7},
cell{3,5}{1,4} = {purple7},
cell{2}{2} = {r=4,c=2}{c,azure7},
}
Alpha & Beta & Gamma & Delta \\
Epsilon & Zeta & Eta & Theta \\
Iota & Kappa & Lambda & Mu \\
Nu & Xi & Omicron & Pi \\
Rho & Sigma & Tau & Upsilon \\
Phi & Chi & Psi & Omega \\
\end{tblr}
\end{document}
The part that causes the default behaviour to struggle is the lines
cell{1,6}{odd} = {teal7},
From latexindent.pl
point of view, this is not a key=<braces/brackets> code block, because, by default, commas are not allowed in the "name" part. So, we change the default by using the fineTuning
field. So, using
fineTuning:
keyEqualsValuesBracesBrackets:
name: |-
(?x)
[ # |
a-z # |
A-Z # at least one of these
0-9 # |
@\* # |
_\/.:\#\- # |
]+ # |
[ # <
a-z # <
A-Z # <
0-9 # 0 or more of these
@\* # <
_\/. # <
\h\{\}:\#\- # <
, # <!-------NEW BIT: allow commas
]*? #
gives
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
hlines = {white},
vlines = {white},
cell{1,6}{odd} = {teal7},
cell{1,6}{even} = {green7},
cell{2,4}{1,4} = {red7},
cell{3,5}{1,4} = {purple7},
cell{2}{2} = {r=4,c=2}{c,azure7},
}
Alpha & Beta & Gamma & Delta \\
Epsilon & Zeta & Eta & Theta \\
Iota & Kappa & Lambda & Mu \\
Nu & Xi & Omicron & Pi \\
Rho & Sigma & Tau & Upsilon \\
Phi & Chi & Psi & Omega \\
\end{tblr}
\end{document}
This is good, but not exactly what you wanted; to remove the indentation from the mandatory argument, we modify https://latexindentpl.readthedocs.io/en/latest/sec-default-user-local.html#lst-myenv-noadd5 and use
noAdditionalIndent:
tblr:
mandatoryArguments: 1
fineTuning:
keyEqualsValuesBracesBrackets:
name: |-
(?x)
[ # |
a-z # |
A-Z # at least one of these
0-9 # |
@\* # |
_\/.:\#\- # |
]+ # |
[ # <
a-z # <
A-Z # <
0-9 # 0 or more of these
@\* # <
_\/. # <
\h\{\}:\#\- # <
, # <!-------NEW BIT: allow commas
]*? #
and then receive
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
hlines = {white},
vlines = {white},
cell{1,6}{odd} = {teal7},
cell{1,6}{even} = {green7},
cell{2,4}{1,4} = {red7},
cell{3,5}{1,4} = {purple7},
cell{2}{2} = {r=4,c=2}{c,azure7},
}
Alpha & Beta & Gamma & Delta \\
Epsilon & Zeta & Eta & Theta \\
Iota & Kappa & Lambda & Mu \\
Nu & Xi & Omicron & Pi \\
Rho & Sigma & Tau & Upsilon \\
Phi & Chi & Psi & Omega \\
\end{tblr}
\end{document}
Let me know if you need any further details on this.
Thanks for your help. Sorry for the delayed reply.
original .tex code
from the documentation of tabularray: Section 2.4.1 Cells and Spancells in New Interfaces, page 18.
default yaml settings
actual/given output
desired or expected output
the last mandatory argument and the closing
}
of the mandatory arguments should not get extra indentation.I am not sure whether the closing
}
of the mandatory arguments should have no indentation at all (see original code). Is there an option for this?