1

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.

TheDon
  • 755
  • 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 01 '14 at 11:17

1 Answers1

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 01 '14 at 11:52
  • @DavidCarlisle You are right, correction under way. – Steven B. Segletes Apr 01 '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 01 '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 01 '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 01 '14 at 13:04
  • @ItaAtz see the answer given in the duplicate question which automates this using the \pdfsavepos primitive – David Carlisle Apr 01 '14 at 13:12
  • @StevenB.Segletes that's exactly why I opened a new thread for my problem. – TheDon Apr 01 '14 at 13:27
  • @ItaAtz: Do you mean the placement sould be top, middle, bottom, in repeating order? – Bernard Apr 01 '14 at 15:10
  • @ItaAtz See alternative approach in my EDITED answer, if for some reason David's approach in the referenced answer is otherwise incompatible with your need. – Steven B. Segletes Apr 01 '14 at 15:38