5

I have the following table in latex:

\usepackage{booktabs}
\usepackage{amsmath}
%%%
\begin{table}
\begin{tabular}{l@{\hskip 4.8cm} c} 
\toprule

\multicolumn{1}{l}{Conversion} & \multicolumn{1}{c}{Formula} \\ 
\midrule

RR to OR & $\mbox{OR} = \cfrac{1-\mbox{p}_{\mbox{\textit{non-exposed}}}}{1-\mbox{p}_{\mbox{\textit{exposed}}}}$ \\ \addlinespace[0.5cm]
d to OR  & $\mbox{OR} = \exp(\mbox{d} \cfrac{\pi}{\sqrt{3}})$ \\ \addlinespace[0.5cm]
r to d   & $\mbox{d} = \cfrac{2\mbox{r}}{\sqrt{1-\mbox{r}^2}} $ \\ \addlinespace[0.5cm]
g to d   & $\mbox{d} = \cfrac{1}{\mbox{J} \left( \mbox{df} \right)} \times \mbox{g} $ \\

\bottomrule
\end{tabular}
\end{table}

My table

I would like to align the equations in the right column, but for some reason I just cannot figure out how to do it. I have found a few similar questions on stackexchange (e.g., here). Most of the solutions use \begin{aligned} and \end{aligned}. The problem with that is that I do not know where to place the aligned environment since I only need it for the right-hand column.

Thanks a million!

  • 1
    You could use a three column tabular and split up the equations at the = sign into a right and a left aligned column. The spacing between the columns can be adjusted using @{width of your choice}. – leandriis Jun 06 '19 at 18:41
  • 1
    Related and most likely interesting: https://tex.stackexchange.com/q/78788/134144 – leandriis Jun 06 '19 at 18:47

2 Answers2

5

Unless you need a caption, you can obtain the desired layout without a table. Only alignedat, and a shorter code with the spreadlines environment from mathtools:

\documentclass{article} 

\usepackage{mathtools}
\usepackage{booktabs}

\begin{document}

\begin{spreadlines}{0.5cm}
\[%
 \begin{alignedat}{2}
\toprule
\enspace & \text{Conversion} & &\phantom{ = }\hspace{1.5em}\text{Formula} \\
 \midrule
 & \text{RR to OR} & \hskip 4.8cm\mbox{OR} & = \cfrac{1-\mathrm{p}_{\textit{non-exposed }}}{1-\mathrm{p}_{\textit{exposed}}}\enspace \\
 &\text{d to OR} & \mbox{OR} & = \exp\biggl(\mathrm{d} \cfrac{\pi}{\sqrt{3}}\biggr) \\
 & \text{r to d} & \mbox{d} & = \cfrac{2\mathrm{r}}{\sqrt{1-\mathrm{r}^2}} \\
 & \text{g to d} & \mbox{d} & = \cfrac{1}{\mathrm{J \left(df \right)}} \times \mathrm{g} \\
\bottomrule
\end{alignedat}
\]%
\end{spreadlines}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Thanks! In this particular case, I actually do need a caption and notes (I just deleted all the unnecessary parts from my code). But it is good to know that you can get the same layout without using a table! – Matthias Jun 06 '19 at 19:45
  • You can put an equation in a table environment (preferably unnumbered…) – Bernard Jun 06 '19 at 19:55
4

Well, one possibility is to change second column c to use three columns rcl and divide your formula into three parts: left part of formula, =, right part of formula.

Please see the following mwe

\documentclass{article}

\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}

\begin{table}
\begin{tabular}{l@{\hskip 4.8cm} rcl} % <===============================
\toprule

\multicolumn{1}{l}{Conversion} & \multicolumn{3}{c}{Formula} \\ % <=====
\midrule

RR to OR & $\mbox{OR}$ & = & $\cfrac{1-\mbox{p}_{\mbox{\textit{non-exposed}}}}{1-\mbox{p}_{\mbox{\textit{exposed}}}}$ \\ \addlinespace[0.5cm] % <================================
d to OR  & $\mbox{OR}$ & = & $\exp(\mbox{d} \cfrac{\pi}{\sqrt{3}})$ \\ \addlinespace[0.5cm]
r to d   & $\mbox{d}$  & = & $\cfrac{2\mbox{r}}{\sqrt{1-\mbox{r}^2}} $ \\ \addlinespace[0.5cm]
g to d   & $\mbox{d}$  & = & $\cfrac{1}{\mbox{J} \left( \mbox{df} \right)} \times \mbox{g} $ \\
%                   ^^^^^^^^^^  <=======================================

\bottomrule
\end{tabular}
\end{table}

\end{document}

and its result:

resulting pdf

Mensch
  • 65,388