# How to vertically align the three columns of my table top, top, middle

This is rather hard: the problem is that you want to align the middle box in two ways: on the left along the baseline, on the right along the center. This type of table normally requires either nesting of tables (which is difficult with tabularx) or measuring some of the content to use \llap tricks.

We are missing here tabular code based on xcoffins which has more than one handle ...

```
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}
\usepackage{caption,xcoffins}
\newlength\colA
\begin{document}
\begin{table}[htb]
\centering
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\settowidth\colA{\begin{tabular}{l}Name\\Ducks\\Lions\end{tabular}}
\caption{I would like the formulae here to be vertically at the middle of the two lines of text}
\begin{tabularx}{\linewidth}{p{\dimexpr\colA-2\tabcolsep}X>{$}c<{$}}
\toprule
Name & Description & \multicolumn{1}{c}{Formula}\\
\midrule
&\leavevmode\llap{\makebox[\colA][l]{Ducks}}Something which goes on two lines, something which goes on two lines &
A=\dfrac{B}{C}\\
&\leavevmode\llap{\makebox[\colA][l]{Lions}}Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line &
D=\dfrac{E}{F}\\
\bottomrule
\end{tabularx}
\end{table}
%Only for show some coffin code:
\NewCoffin\CoffinA
\NewCoffin\CoffinB
\NewCoffin\CoffinC
\SetHorizontalCoffin\CoffinA{Ducks}
\SetHorizontalCoffin\CoffinC{$D=\dfrac{E}{F}$}
\SetVerticalCoffin\CoffinB{\dimexpr \textwidth-\CoffinWidth\CoffinA-\CoffinWidth\CoffinC-6\tabcolsep}{\noindent Something which goes on two lines, something which goes on two lines and on one more line and on one more line and on one more line}
\JoinCoffins\CoffinA[H,r]\CoffinB[T,l](2\tabcolsep,0pt)
\JoinCoffins\CoffinA[vc,r]\CoffinC[vc,l](2\tabcolsep,0pt)
\noindent\hspace*{\tabcolsep}\TypesetCoffin\CoffinA
\end{document}
```

Here a solution based on the redefinition of the `X`

column type, and two possible hacks for the first column (they may have to be adapted to the real contents):

```
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx, booktabs, makecell}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{document}
\begin{table}[htb]
\centering
\begin{tabularx}{\linewidth}{lX>{$}c<{$}}
\toprule
Name & Description & \multicolumn{1}{c}{Formula}\\
\midrule
\makecell[l]{Ducks\\\mbox{}} & Something which goes on two lines, something which goes on two lines &
A=\dfrac{B}{C}\\
\addlinespace
\makecell[l]{Lions\\\mbox{}} & Something which goes on two lines, something which goes on two lines &
D=\dfrac{E}{F}\\
\addlinespace
\raisebox{1.4ex}{Lions} & Something which goes on two lines, something which goes on two lines &
D=\dfrac{E}{F}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
```

Like this:

**Edit:**

Position of columns contents are determined by row baseline, which (unfortunately) cannot be changed from column to column.

So far I don't see any other possibility than to use boxes either in the last or the first column, which align their baseline. A good candidate for your particular case is `\adjustbox`

:

```
\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}
\usepackage{caption}
\usepackage{adjustbox}
\begin{document}
\begin{table}[htb]
\centering
\caption{I would like the formulae here to be vertically at the middle of the two lines of text}
\begin{tabularx}{\linewidth}{lXc}
\toprule
Name & Description & Formula \\
\midrule
Ducks & Something which goes on two lines, something which goes on two lines &
\adjustbox{valign=t}{$A=\dfrac{B}{C}$}\\
Lions & Something which goes on two lines, something which goes on two lines &
\adjustbox{valign=t}{$D=\dfrac{E}{F}$}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
```

For more convenient writing of the table, you can define a new column type:

```
\newcolumntype{E}{>{\begin{adjustbox}{valign=t}$}c<{$\end{adjustbox}}}
```

and then write the table (body) as:

```
\begin{tabularx}{\linewidth}{lXE}
\toprule
Name & Description & Formula \\
\midrule
Ducks & Something which goes on two lines, something which goes on two lines &
A=\dfrac{B}{C}\\
Lions & Something which goes on two lines, something which goes on two lines &
D=\dfrac{E}{F}\\
\bottomrule
\end{tabularx}
```

If the text in cells of the middle column has arbitrary number of lines, or if the equation has only one line, the result is worse. In such case a possible solution is the use of `multirow`

in the first column and manually adjust the number of columns which those cells spans, and in the second column set baseline in vertical middle:

```
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs, multirow, tabularx}
\usepackage{caption}
\usepackage{adjustbox}
\usepackage{lipsum}
\begin{document}
\begin{table}[htb]
\centering
\renewcommand\tabularxcolumn[1]{m{#1}} % <---
\caption{I would like the formulae here to be vertically at the middle of the two lines of text}
\begin{tabularx}{\linewidth}{lX>{$}c<{$}}
\toprule
Name & Description & Formula \\
\midrule
\multirow{-6}{*}{Ducks} % <--- manually adjusted
& \lipsum[66] & A=\dfrac{B}{C}\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
```

or use solution proposed in @Bernard's answer.