I would like to know what is forcing a middle vertical alignment in the following example in the main table. The inner tables are OK but the outer table does not respect the different alignments, which are defined in the line colspec = {Q[l,t] Q[r,b]}
.
Thanks
\documentclass{article}
\usepackage{tikz}
\usepackage{tabularray}
\NewDocumentEnvironment{mathtask}{+b}{%
\begin{tblr}{
colspec={Q[r,b,1cm] Q[c,b,1cm] Q[l,mode=math,1cm]},
vlines,hlines,
}
#1
\end{tblr}}{}
\begin{document}
\centering%
\begin{tblr}{
vlines, hlines,
columns = {0.5\textwidth-13pt, colsep=6pt},
rows = {4cm, rowsep=2pt},
colspec = {Q[l,t] Q[r,b]},
}
\begin{mathtask}
{aaa\\bbb\\ccc\\ddd} & {xx\\yy} & c
\end{mathtask}
&
\begin{mathtask}
{aaa\\bbb} & xxxx & d
\end{mathtask}
\\
\begin{mathtask}
{aaa\\bbb\\ccc\\ddd\\eee\\ff} & {xx\\yy} & e
\end{mathtask}
&
\begin{mathtask}
{aaa\\bbb\\ccc} & {xx\\yy} & f
\end{mathtask}
\end{tblr}
\end{document}
EDIT. The original problem.
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{tabularray}
\usepackage[showframe]{geometry}
\newlength{\cwidth} \setlength{\cwidth}{0.49\textwidth}
\newlength{\cheight} \setlength{\cheight}{0.49\textheight}
\newcommand\tasknumber[1]{%
\begin{tikzpicture}[
inner sep=0pt,outer sep=0pt, minimum size=21pt,
baseline={([yshift=-3pt]current bounding box.center)},
]
\node [draw,circle,color=white,fill=white!45!black,] {#1};
\end{tikzpicture}}
\setlength{\tabcolsep}{3pt}
\NewDocumentEnvironment{mathtask}{+b}{%
\begin{tblr}{
colspec={l l l},
column{2}={font=\bfseries},
column{3}={mode=math},
columns={colsep=3pt},
}
#1
\end{tblr}
}{}
\pagestyle{empty}
\begin{document}
\centering
\begin{tblr}{
colspec={l l},
columns={\cwidth-3pt, colsep=3pt},
rows={\cheight, rowsep=3pt},
vline{2} = solid,
hline{2} = solid,
}
\begin{mathtask}
\tasknumber{1} &
Solve the system: &
\begin{cases}
x + y + = 1 \\
x + y + = 1 \\
x + y + = 1 \\
x + y + = 1 \\
x + y + z = 2
\end{cases}
\end{mathtask}
&
\begin{mathtask}
\tasknumber{2} &
Solve the system: &
\begin{cases}
x + y + = 1 \\
x + y + = 3 \\
x + y + z = 2
\end{cases}
\end{mathtask}
\\
\begin{mathtask}
\tasknumber{3} &
Solve the equation: &
x + y + z = 2
\end{mathtask}
&
\begin{mathtask}
\tasknumber{50} &
Solve the system: &
\begin{cases}
x + y + = 1 \\
x + y + z = 2
\end{cases}
\end{mathtask}
\end{tblr}
\end{document}
Best Answer
When each cell has only a single line of text in a row, the vertical alignment options
t
/m
/b
are the same for this row. This is true also for traditionaltabular
environment (except that there is still an aligmment bug intabular
environment).Although
mathtask
environment consists of a complicated table, TeX still treats it as a box, so those cells are of single line (you can see it more clearly by adding some text before and aftermathtask
environment). Therefore in outer table for examplecolspec={Q[t]Q[b]}
andcolspec={Q[b]Q[m]}
andcolspec={Q[m]Q[t]}
will produce the same result.I am not sure what you really want from your code. But you could change the alignment of the inner tables:
EDIT: For your original problem, you need to move
\tasknumber
out ofmathtask
and set vertical alignmenth
for these new columns: