Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I get the last column text to be at the bottom of the row?

enter image description here

That is I want the XXX to be aligned with the line containing the arrow.

I tried playing around with \multirow{3}{-3ex}{XXX}, but obviously I don't understand \multirow.

Code:

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
    \begin{tabularx}{\linewidth}[t]{l X p{1.3cm}}
        & Header & Title \\\cmidrule(lr){2-2}\cmidrule(lr){3-3}
        a. & Some text text text text text text text text text text text text text text 
            text text text text text text text text text text 
            Want XXX on this line $\rightarrow$%
         & XXX\\
    \end{tabularx}
\end{document}
share|improve this question
    
Is this answer helpful? –  Adam Liter Mar 21 at 5:53
    
@Adam: Yep, very useful, but surprisingly different answers than here. –  Peter Grill Mar 21 at 7:23
    
Oh I just saw the link Adam gave is same as answer I just posted. Probably close this as dup? –  David Carlisle Mar 21 at 8:31
    
I don't think it's a duplicate. OP wants two different vertical alignments in same row. –  Ignasi Mar 21 at 8:40
    
@Ignasi OK new answer posted:-) –  David Carlisle Mar 21 at 10:25

3 Answers 3

up vote 4 down vote accepted

(Edited answer, using different mechanism)

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}

\makeatletter
\def\foo#1{\leavevmode
\expandafter\ifx\csname PDFSAVE#1\endcsname\relax
\expandafter\gdef\csname PDFSAVE#1\endcsname{0sp}%
\fi
\pdfsavepos\write\@auxout{\gdef\string\PDFSAVE#1{\the\pdflastypos}}}
\makeatother
\begin{document}
    \noindent
    \begin{tabularx}{\linewidth}[t]{l X p{1.3cm}}
        & Header & Title \\\cmidrule(lr){2-2}\cmidrule(lr){3-3}
        a. & \foo{a}Some text text text text text text text text text text text text text text 
            text text text text text text text text text text 
            Want XXX on this line $\rightarrow$\foo{b}%
         & \smash{\raisebox{\dimexpr\PDFSAVEb sp-\PDFSAVEa sp\relax}{XXX}}\\
    \end{tabularx}
\end{document}

The original answer moved the baseline of the X column to the bottom using

\renewcommand\tabularxcolumn[1]{b{#1}}

But that affects all X columns, and also makes the a. align on the bottom row. The latter problem could be fixed by moving the a. into the second column (with a hanging indent)

If you only want to change the alignment of some X columns in a table, then you can use:

>{\begin{minipage}[b]{\hsize}}X<{\end{minipage}} :-) 
share|improve this answer
2  
But this solution also aligns first column a to the bottom. –  Ignasi Mar 21 at 8:35
    
Yes or rather it doesn't move the 1st and 3rd columns down all, it moves the 2nd column up. (the a. could be moved to the start of the paragraph in the X column, where it belongs:-) –  David Carlisle Mar 21 at 9:14
    
@DavidCarlisle: But what if it was not part of the 2nd column? I don't really like your \parbox solution at the other answer. Can't you have two different X column types in the same table: One b{#1} and another t{#1}? –  Peter Grill Mar 21 at 9:18
    
You can if you want, yes (or simpler just use minipipage withing the column spec so) >{\begin{minipage}{\hsize}[b]}X<{\end{minipage}} is a one-off b-alignment in an otherwise p (top) aligned table –  David Carlisle Mar 21 at 10:01
    
The minipage idea works better with >{\begin{minipage}[b]{\hsize}}X<{\end{minipage}} :-) But it is kind of weird to apply something to column 2, to get the desired positioning in column 3 -- same reason I dislike the \parbox solution in Vertical alignment in tabular cells with variable height. –  Peter Grill Mar 21 at 15:15

If you want to play with \multirow, you can use the second optional argument, which is the "fixup", a length for fine tuning the position.

In your case it should be -2\baselineskip

MWE:

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
    \noindent
    \begin{tabularx}{\linewidth}[t]{l X p{1.3cm}}
        & Header & Title \\\cmidrule(lr){2-2}\cmidrule(lr){3-3}
        a. & Some text text text text text text text text text text text text text text
            text text text text text text text text text text
            Want XXX on this line $\rightarrow$%
         & \multirow{1}{*}[-2\baselineskip]{XXX}\\
    \end{tabularx}
\end{document} 

Output:

enter image description here

share|improve this answer

Depending on the type of content associated with XXX, the following is an easy way of obtain the bottom-alignment that doesn't require knowledge of the preceding column entries:

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\noindent
\begin{tabularx}{\linewidth}[t]{l X p{1.3cm}}
  & Header & Title \\\cmidrule(lr){2-2}\cmidrule(lr){3-3}
  a. & Some text text text text text text text text text text text text text text 
      text text text text text text text text text text 
      Want XXX on this line $\rightarrow$
   & \\[-\normalbaselineskip] && XXX
\end{tabularx}
\end{document}

Idea: Set XXX on its own line, but overlaid with the bottom of the previous line using \\[-\normalbaselineskip].

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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