1

This question already has an answer here:

I have the following code

\usepackage{tabularx}
\begin{document}

\begin{table}[t]
\begin{center}
\renewcommand{\arraystretch}{1.3}
\begin{tabularx}{\textwidth}{crX}
\hline
\textbf{Chapter} & & \textbf{Reference} \\
\hline \\ \vspace{-11mm} \\
1 & \small{a} & \small{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
2 & \small{b} & \small{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
3 & \small{c} & \small{text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
\end{tabularx}
\end{center}
\end{table}

\end{document}

which produces this

enter image description here

Now, in the first column, I'd like to have "1" aligned at the top, "2" aligned at the center, and "3" aligned at the bottom. How can I obtain this? Thanks in advance.

marked as duplicate by David Carlisle, Svend Tveskæg, Peter Jansson, Claudio Fiandrino, Thomas F. Sturm Apr 1 '14 at 13:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • And, just to confirm other points: is it the case that (1) "a", "b", and "c" must remain in their own tabularx column and be top-aligned with the text?; and (2) the "text" column must be a fill-all-available-width type, rather than fixed-width? – Steven B. Segletes Apr 1 '14 at 11:17
2

This isn't automated, but you didn't say it had to be (8^b)

What I did was define length \tmplength equal to the line-skip length inside the table (11pt), and used \raisebox{-n\tmplength}{number} to place "number" n-multiples of 11pt below the top line. The manual part of this solution is that you have to count lines of reference "text", to know how many multiples of \tmplength the number needs moving.

In the case of the middle row, it needed to move down 2\tmplength to get to subrow 3, whereas in the 3rd row, 5\tmplength was required to get it to the 6th subrow.

Thanks to David for bypassing the extra package and going straight to the \raisebox.

EDIT, I provide a secondary alternative way that avoids counting rows, but it requires that the 3rd row not be type X, but type p with a specified width. It also accomplishes the 2nd column as an \llap which is certainly not preferable nor standard.

\documentclass{article}
\usepackage{tabularx}
\newlength{\tmplength}
\begin{document}
Using X column in 3rd column

\begin{table}[ht]
\begin{center}
\def\stacktype{L}
\tmplength=11pt
\renewcommand{\arraystretch}{1.3}
\begin{tabularx}{\textwidth}{crX}
\hline
\textbf{Chapter} & & \textbf{Reference} \\
\hline \\ \vspace{-11mm} \\
1 & \small{a} & \small{text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
\raisebox{-2\tmplength}{2} & \small{b} & \small{text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
\raisebox{-5\tmplength}{3} & \small{c} & \small{text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text} \\
\\ \vspace{-12mm} \\ \hline \\ \vspace{-12mm} \\
\end{tabularx}
\end{center}
\end{table}

Alternate way, avoids counting, but must specify text-column width

\begin{table}[ht]
\begin{center}
\def\stacktype{L}
\tmplength=11pt
\renewcommand{\arraystretch}{1.3}
\begin{tabularx}{\textwidth}{cXp{3.64in}}
\hline
\textbf{Chapter} & & \textbf{Reference} \\
\hline \\ \vspace{-11mm} \\
1 & ~ & \parbox[t]{3.64in}{\strut\small\llap{a\hspace{0.4cm}}%
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text\strut} \\
\hline
2 & ~ & \parbox[c]{3.64in}{\strut\small\llap{b\hspace{0.4cm}}%
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text\strut} \\[-0.4mm]
\hline
3 & ~ & \parbox[b]{3.64in}{\strut\small\llap{c\hspace{0.4cm}}%
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text\strut} \\[-1mm]
\hline 
\end{tabularx}
\end{center}
\end{table}
\end{document}

enter image description here

  • 3
    so here you wouldn't really need a package, you could just use \raisebox instead of \stackunder? – David Carlisle Apr 1 '14 at 11:52
  • @DavidCarlisle You are right, correction under way. – Steven B. Segletes Apr 1 '14 at 12:12
  • Is it possible to make it automated, i.e., without having to count the rows? In my actual table, I'll have several entries with ever-changing length... – TheDon Apr 1 '14 at 12:36
  • @ItaAtz That's the challenge, isn't it. I think it beyond my capabilities, but if any one can solve it, it would be David Carlisle, who has already weighed in on the topic. – Steven B. Segletes Apr 1 '14 at 12:42
  • @ItaAtz I would only add that the challenge is made even more difficult because the column that needs adjustment (the first) is typeset prior to the column that is supposed to dictate the vertical behavior (the third). – Steven B. Segletes Apr 1 '14 at 13:04

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