Open dahosek opened 1 year ago
@dahosek maybe cmd
option is what you want:
\documentclass{article}
\usepackage{tabularray,graphicx}
\begin{document}
\newcommand{\obliqueheader}[1]{\rotatebox{45}{#1}}
\begin{tblr}{colspec=lrr,row{1}={cmd=\obliqueheader}}
Paper size & Height (mm) & Width (mm) \\
\hline
A4 & 297 & 210 \\
B4 & 353 & 250 \\
C4 & 324 & 229
\end{tblr}
\end{document}
maybe
cmd
option is what you want:
I would recommend to use in addition a box with null width:
\documentclass{article}
\usepackage{tabularray,graphicx}
\begin{document}
\newcommand{\obliqueheader}[1]{\rotatebox{45}{\makebox[0pt][l]{#1}}}
\begin{tblr}{colspec=lrr,row{1}={cmd=\obliqueheader}}
Paper size & Height (mm) & Width (mm) \\
\hline
A4 & 297 & 210 \\
B4 & 353 & 250 \\
C4 & 324 & 229
\end{tblr}
\end{document}
@dahosek maybe
cmd
option is what you want:
I’m aware of that (the ergonomics of cmd
aren’t great though), I guess the point of clarification is that \NewTableCommand
, it’s not possible to do what I was thinking I could and it should only be used to make a shortcut for a single table command without any other typesetting involved. This is all directed towards providing good documentation of tabularray
in my book. I see a different way to manage this though that would provide better ergonomics—
@dbitouze I was leaving that out as I worked out the rest of the issue around the table typesetting. You will notice that without overriding the header formatting, by the way, that the placement of the height and width headers is off. I also, would tend to put the \makebox
around the \rotatebox
rather than the other way around. With your approach, if there’s text above, it will overprint the oblique header.
@dahosek In fact, this is a duplicate of #98. In the future, you will be able to write
\NewTableCommand\obliqueheader{\SetCell{rotate=45}}
Setting also the origin of the rotation would be nice, e.g. \NewTableCommand\obliqueheader{\SetCell{rotate=45,origin=c}}
.
@lvjr A bit of confusion in that I was perhaps oversimplifying what I was trying to do with \NewTableCommand
where I wanted to have more happening than just a call to \SetCell
and I removed the \SetCell
to show the minimal result. I need to update the section of my book that discusses \NewTableCommand
to make it clear that it can only provide a shortcut for a single (is this correct?) tblr
command.
@dahosek Maybe the manual is not clear enough about the usage of \NewTableCommand
. In the code, tabularray
extracts and executes table commands from the beginning of each cell before typesetting any cell. So the manual states:
And you can not put cell text inside any table command defined with \NewTableCommand.
Table commands are used to change the specifications of tables. Normally it is a shortcut for some \Set***
commands (you can use several of them in one table command) provided by tabularray
. But in general you can use any commands without output (such as \empty
, relax
or conditionals) in a table commands.
Demonstration of bug:
Correct behavior shown with:
(I had hoped to be able to use
\SetCell
in my\obliqueheader
definition which is why I was using\NewTableCommand