# Vertical cell alignment in tables?

This problem drives me crazy right now. How can I draw a table with the following properties in Latex?

• width = \textwidth

• 1 column: horizontal alignment = left, vertical alignment = bottom

• 2 column: horizontal alignment = center, vertical alignment = bottom

• 3 column: horizontal alignment = center, vertical alignment = bottom

MWE:

\documentclass{scrartcl}
\usepackage{tabularx}
\usepackage{blindtext}

\begin{document}
\begin{tabularx}{\textwidth}{|X|p{0.4cm}|p{3cm}|}
\hline
\blindtext & \begin{center}A\end{center} & \begin{center}B\end{center} \\
\hline
\end{tabularx}
\end{document}


You can collect the cell contents using collcell and pass it to a \parbox:

\documentclass{scrartcl}% http://ctan.org/pkg/KOMA-script
\usepackage{array,blindtext,collcell}% http://ctan.org/pkg/{array,blindtext,collcell}
\newcommand{\leftcol}[1]{\parbox[b]{\dimexpr\linewidth-6\tabcolsep-4\arrayrulewidth-4mm-3cm}{\strut #1\strut}}
\newcommand{\middlecol}[1]{\parbox[b]{4mm}{\centering\strut #1\strut}}
\newcommand{\rightcol}[1]{\parbox[b]{3cm}{\centering\strut #1\strut}}
\newcolumntype{L}{>{\collectcell\leftcol}l<{\endcollectcell}}
\newcolumntype{C}{>{\collectcell\middlecol}l<{\endcollectcell}}
\newcolumntype{R}{>{\collectcell\rightcol}l<{\endcollectcell}}
\begin{document}
\noindent
\begin{tabular}{|L|C|R|}
\hline
\cci\blindtext & A & B \\
\hline
\end{tabular}
\end{document}


Each column's contents is captured and passed to a column-specific macro, detailing the required formatting.

\cci may not be necessary. See the collcell documentation.

For example (one line of your code commented, three added; line with babel only for my needs):

\documentclass{scrartcl}

\usepackage{tabularx}
\usepackage{blindtext}
\usepackage[english,polish]{babel}

\begin{document}

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

\begin{tabularx}{\textwidth}{|X|p{0.4cm}|p{3cm}|}
\hline
%  \blindtext & \begin{center}A\end{center} & \begin{center}B\end{center} \\
\blindtext & \hfil A \hfil& \hfil B \hfil\\
\hline
\end{tabularx}

\end{document}


• Thanks for your help. If I could accept two answers I would also accept your solution. I have voted for the solution from Werner because it is more "general" and easier to adapt to other tables (with other alignment requirements) although your solution is short and sweet. – user4811 Oct 26 '13 at 14:42

Here is a rather minimal answer, similar in some ways to both of the others, but not requiring extra commands or extra \hfils in the table body:

\documentclass{scrartcl}
\usepackage{tabularx}
\usepackage{array}
\usepackage{blindtext}
\begin{document}
\renewcommand\tabularxcolumn[1]{b{#1}}
\begin{tabularx}{\textwidth}{|X|>{\centering}b{0.4cm}|>{\centering
\arraybackslash}b{3cm}|}
\hline
\blindtext & A& B\\
\hline
\end{tabularx}
\end{document}