# Tabular vertical alignment

I need to make a command that may be used like in table on the left but create vertical alignment like in table on the right.

I mean left column in table is top aligned. Right column is vertically centred to the middle of content in the left if it's lower than the left column. If the right column is equal or higher than the left, then the right column is top aligned.

\documentclass[12pt,a4paper]{article}
\usepackage{geometry,array,graphicx,multicol}
\begin{document}

\newcommand{\myrow}[1]{
\hline
\scalebox{3}{A} & #1 \\
\hline
}

\begin{multicols}{2}

\begin{tabular}{|m{2em}|m{7em}|}
\myrow{a a a}
\myrow{a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\end{tabular}

\begin{tabular}{|m{2em}|m{7em}|}
\hline
\scalebox{3}{A} & a a a \\
\hline
\scalebox{3}{A} & a a a a a a a a a a a a \\
\hline
\scalebox{3}{A} & a a a a a a a a a a a a a a a a a a a a a \\
\hline
\scalebox{3}{A} & a a a a a a a a a a a a a a a a a a a a a a a a a a a \\
& a a a \\
\hline
\scalebox{3}{A} & a a a a a a a a a a a a a a a a a a a a a a a a a a a \\
& a a a a a a a a a \\
& a a a \\
\hline
\scalebox{3}{A} & a a a a a a a a a a a a a a a a a a a a a a a a a a a \\
& a a a a a a a a a \\
& a a a a a a a a a \\
& a a a \\
\hline
\end{tabular}

\end{multicols}

\end{document}


Lower the big letter by the proper amount (adding some space below for avoiding it touching the rule). The second column specifier should be p.

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\newcommand{\bigletter}[1]{%
\raisebox{\dimexpr1ex-\height}{%
\scalebox{3}{#1\rule[-1pt]{0pt}{1pt}}}%
}

\newcommand{\myrow}[1]{%
\bigletter{A} & #1 \\
\hline
}

\begin{document}

\begin{tabular}{|c|p{7em}|}
\hline
\myrow{a a a}
\myrow{a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\end{tabular}

\end{document}


A different solution with centering in case the big letter is vertically bigger than the text. Note: I assume that the big letter will always be uppercase.

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\makeatletter
\newcommand{\myrow}[2]{%
\sbox{\z@}{\scalebox{3}{#1}}%
\sbox{\z@}{\vrule height \dimexpr\ht\z@+4pt depth 2pt width 0pt \box\z@}%
\sbox{\tw@}{\parbox{7em}{#2}}%
\ifdim\ht\z@>\dimexpr\ht\tw@+\dp\tw@\relax
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\begin{tabular}{@{}c@{}}\box\z@\end{tabular} & \parbox{7em}{#2}}%
{\raisebox{\dimexpr1ex+4pt-\height}{\box\z@} & #2}%
\\ \hline
}
\makeatother

\begin{document}

\begin{tabular}{|c|p{7em}|}
\hline
\myrow{A}{a a a}
\myrow{A}{a a a a a a a a a a a a}
\myrow{A}{a a a a a a a a a a a a a a a a a a a a a}
\myrow{A}{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{A}{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\myrow{A}{a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a}
\end{tabular}

\end{document}

• Thank you. It's nice but in the first two rows right column isn't vertically centred. Later rows are OK :) – Simon Sep 25 '18 at 12:43
• @Simon I'm not sure I'd like that arrangement, but that's done. – egreg Sep 25 '18 at 13:10
• The second version is perfect. In fact I need something like \includegraphics[width=1.5cm,height=1.5cm]{example-image} instead of big A but it works very well too. Thank you very much :) – Simon Sep 25 '18 at 14:42