4

I think most people will agree that the vertical alignment in the table cells below is less than ideal--especially if I want to remove the \cmidrule to be more in line with accepted "best practices" for tables. enter image description here What I'd like is the following: For every cell in the lower two rows of the table, the content should be flush with the top of the cell. (Possible exception: I'm not entirely convinced this is right for the leftmost column.) The headings E1|C, etc. should remain vertically centered.

Important note: ideally, all the columns except the leftmost column should have their width determined automatically. I would prefer not to have to specify the width of a parbox or similar (although if you can solve it using these, that is still better than I have been able to do so far).

I'm sure the solution to this is contained somewhere in the labyrinth of related questions, but...well...the related questions are a labyrinth, and I was unable to find what I was looking for.

Here's the code for this example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs,array}

\newcommand*{\sheaf}[1]{\mathcal{#1}}

\begin{document}
\begin{tabular}{@{}>{\raggedright}m{10.5em} l l l l@{}}
\toprule
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ 
\\ \midrule 
$[-s t^{8}+2s^{8} t+2s^{9},\linebreak[0]-s^{4} t^{5},\linebreak[0]s^{5} t^{4}-s^{9},\linebreak[0]2t^{9}-s^{9}]$ 
& $\begin{aligned}&\sheaf O(-3)^{3}\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-2)^{8}\\ &\oplus \sheaf O(-1)^{11}\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{30}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-1)^{45}\\ &\oplus \sheaf O^{10}\end{aligned}$ 
%
\\ 
\cmidrule(l){2-5}
%
$[s t^{8}-s^{2} t^{7},\linebreak[0]2t^{9}-s^{8} t,\linebreak[0]-s^{9},\linebreak[0]t^{9}]$ 
& $\begin{aligned}&\sheaf O(-6)\\ &\oplus \sheaf O(-2)\\ &\oplus \sheaf O(-1)\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-4)\\ &\oplus \sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{12}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{25}\\ &\oplus \sheaf O^{4}\end{aligned}$ 
& $\begin{aligned}&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{39}\\ &\oplus \sheaf O^{13}\end{aligned}$ 
\\ \bottomrule
\end{tabular}

\end{document}
4

You can use t for the optional argument of aligned to get top alignment; I also changed the first column to be of type p{...}:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs,array}

\newcommand*{\sheaf}[1]{\mathcal{#1}}

\begin{document}
\noindent\begin{tabular}{@{}>{\raggedright}p{10.5em} l l l l@{}}
\toprule
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ 
\\ \midrule 
$[-s t^{8}+2s^{8} t+2s^{9},\linebreak[0]-s^{4} t^{5},\linebreak[0]s^{5} t^{4}-s^{9},\linebreak[0]2t^{9}-s^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-3)^{3}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{8}\\ &\oplus \sheaf O(-1)^{11}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{30}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-1)^{45}\\ &\oplus \sheaf O^{10}\end{aligned}$ 
%
\\ 
\cmidrule(l){2-5}
%
$[s t^{8}-s^{2} t^{7},\linebreak[0]2t^{9}-s^{8} t,\linebreak[0]-s^{9},\linebreak[0]t^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-6)\\ &\oplus \sheaf O(-2)\\ &\oplus \sheaf O(-1)\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-4)\\ &\oplus \sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{12}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{25}\\ &\oplus \sheaf O^{4}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{39}\\ &\oplus \sheaf O^{13}\end{aligned}$ 
\\ \bottomrule
\end{tabular}

\end{document}

enter image description here

Using a \parbox for the first entry of the first row, gives vertically centered entries for the row:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs,array}

\newcommand*{\sheaf}[1]{\mathcal{#1}}

\begin{document}
\noindent\begin{tabular}{@{}>{\raggedright}p{10.5em} l l l l@{}}
\toprule
\parbox{10.5em}{Rational curve: \\$[t,s] \mapsto$} & $\sheaf E_{1} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ 
\\ \midrule 
$[-s t^{8}+2s^{8} t+2s^{9},\linebreak[0]-s^{4} t^{5},\linebreak[0]s^{5} t^{4}-s^{9},\linebreak[0]2t^{9}-s^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-3)^{3}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{8}\\ &\oplus \sheaf O(-1)^{11}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{30}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-1)^{45}\\ &\oplus \sheaf O^{10}\end{aligned}$ 
%
\\ 
\cmidrule(l){2-5}
%
$[s t^{8}-s^{2} t^{7},\linebreak[0]2t^{9}-s^{8} t,\linebreak[0]-s^{9},\linebreak[0]t^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-6)\\ &\oplus \sheaf O(-2)\\ &\oplus \sheaf O(-1)\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-4)\\ &\oplus \sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{12}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{25}\\ &\oplus \sheaf O^{4}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{39}\\ &\oplus \sheaf O^{13}\end{aligned}$ 
\\ \bottomrule
\end{tabular}

\end{document}

enter image description here

Personally, I would opt for the first option (everything top aligned).

Perhaps you could also use aligned environments on the first column too to get a little more spacing between the consecutive lines?

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs,array}

\newcommand*{\sheaf}[1]{\mathcal{#1}}

\begin{document}
\noindent\begin{tabular}{@{}>{\raggedright}p{10.5em} l l l l@{}}
\toprule
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ 
\\ \midrule 
$\begin{aligned}[t]
&[-s t^{8}+2s^{8} t+2s^{9},\\[-0.65ex]
&-s^{4} t^{5}, s^{5} t^{4}-s^{9}, \\[-0.65ex]
&2t^{9}-s^{9}]
\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-3)^{3}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{8}\\ &\oplus \sheaf O(-1)^{11}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{30}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-1)^{45}\\ &\oplus \sheaf O^{10}\end{aligned}$ 
%
\\ 
\cmidrule(l){2-5}
%
$\begin{aligned}[t]
&[s t^{8}-s^{2} t^{7},2t^{9}-s^{8} t, \\[-0.65ex]
& -s^{9}, t^{9}]
\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-6)\\ &\oplus \sheaf O(-2)\\ &\oplus \sheaf O(-1)\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-4)\\ &\oplus \sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{12}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{25}\\ &\oplus \sheaf O^{4}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{39}\\ &\oplus \sheaf O^{13}\end{aligned}$ 
\\ \bottomrule
\end{tabular}

\end{document}

enter image description here

Using the tabularx package, you can avoid having to guess the right width for the first column:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs,array,tabularx}

\newcommand*{\sheaf}[1]{\mathcal{#1}}

\begin{document}
\noindent\begin{tabularx}{\textwidth}{@{}>{\raggedright}X l l l l@{}}
\toprule
Rational curve: \\$[t,s] \mapsto$ & $\sheaf E_{1} |_C$ & $\sheaf E_{3} |_C$ & $\sheaf E_{4} |_C$ & $\sheaf E_{5} |_C$ 
\\ \midrule 
$[-s t^{8}+2s^{8} t+2s^{9},\linebreak[0]-s^{4} t^{5},\linebreak[0]s^{5} t^{4}-s^{9},\linebreak[0]2t^{9}-s^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-3)^{3}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{8}\\ &\oplus \sheaf O(-1)^{11}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{30}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-1)^{45}\\ &\oplus \sheaf O^{10}\end{aligned}$ 
%
\\ 
\cmidrule(l){2-5}
%
$[s t^{8}-s^{2} t^{7},\linebreak[0]2t^{9}-s^{8} t,\linebreak[0]-s^{9},\linebreak[0]t^{9}]$ 
& $\begin{aligned}[t]&\sheaf O(-6)\\ &\oplus \sheaf O(-2)\\ &\oplus \sheaf O(-1)\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-4)\\ &\oplus \sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{12}\\ &\oplus \sheaf O\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-3)\\ &\oplus \sheaf O(-2)^{4}\\ &\oplus \sheaf O(-1)^{25}\\ &\oplus \sheaf O^{4}\end{aligned}$ 
& $\begin{aligned}[t]&\sheaf O(-2)^{3}\\ &\oplus \sheaf O(-1)^{39}\\ &\oplus \sheaf O^{13}\end{aligned}$ 
\\ \bottomrule
\end{tabularx}

\end{document}
  • You also need to put a parbox around the contents of row 1 column 1, in order to make keep the headings vertically centered once you've changed the m to p. However, I consider this "legal" since there's no good way to get around artificially imposing the width of the first column. – Charles Staats May 15 '13 at 2:27
  • @CharlesStaats Ah, then perhaps I misunderstood part of your request. I thought everything should be aligned on top. Do you want the first column content to be vertically centered? – Gonzalo Medina May 15 '13 at 2:32
  • I see your point about entries of the first column being a bit crowded vertically, but the real tables I'm making include several pages worth of computer-generated examples, and breaking all the lines by hand is not practical. (On the other hand, programming my computer to output \linebreak[0] after every comma is quite easy.) – Charles Staats May 15 '13 at 2:33
  • I want every row to be aligned on top except the top row, which should be vertically centered. (Although you are free to persuade me otherwise.) – Charles Staats May 15 '13 at 2:34
  • 1
    @CharlesStaats I added another option, in the last code of my answer, using the tabularx package to avoid manual calculations. – Gonzalo Medina May 15 '13 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.