Based on Tabular alignment of text and figure, my question is how can I get t
, c
, b
alignment of all 3 elements that make part of tabular. The t
and c
works fine, but not the b
.
\documentclass[10pt,a4paper]{scrartcl}
\usepackage[pass,showframe]{geometry}
\usepackage{graphicx}
\usepackage{array}
\usepackage{varwidth}
\newcommand*{\mtab}[2][]{\begin{tabular}[#1]{@{}l@{}} #2 \end{tabular}}
\newcommand*{\pbox}[2][c]{\mtab[#1]{\begin{varwidth}[#1]{\linewidth}#2\end{varwidth}}}
\newcommand*{\Logo}{\includegraphics[width=\linewidth]{example-image}}
\begin{document}
\begingroup
\noindent
\begin{tabular}{@{}p{0.15\textwidth}<{\hfill}>{\centering}p{0.5\textwidth}>{\hfill}p{\dimexpr 0.35\textwidth-4\tabcolsep\relax}@{}}
\pbox[b]{\raisebox{\dimexpr-\height+\ht\strutbox\relax}{\Logo}} & \pbox[b]{aaa\\ bbb\\ ccc\\ ddd} & \pbox[b]{eee\\ fff\\ hhh hhh hhh hhh hhh hhh}
\end{tabular}
\endgroup
\end{document}
Best Answer
You've got so many nested boxes; it's very hard to tell what purpose you're expecting them all to serve. I'm also not sure why you need a tabular environment for any of this. Perhaps, if you could make that need a bit more clear, I could give you a better answer.
Also, it seems that you are under the impression that the alignment commands of the boxes and tabular environments are relative to each other. They're not. The alignment commands are relative to the baseline that each box sits on. In the MWE I'm posting, I construct a red line to show where the baseline is and how everything else is being aligned with respect to it.
Here's an example which hugely cuts down on the number of boxes. I then illustrate different ways of aligning the various elements: either through the alignment argument to
tabular
or through using\raisebox
and its ability to access the dimensions of the box its working on.Certainly, by nesting boxes, you can achieve various effects in terms of alignment. But, you can also make things unexpectedly more complicated because you're essentially creating multiple baselines: the main baseline of your text and the baselines within each box you're working with. This can work against you. And, I believe this is what's leading to your frustration.