[Tex/LaTex] Creating a Pretty RevTex Table with Long Equations

equationsrevtextables

I want to create a large RevTex compatible table that has a variable name in the first column and its expression in the right column. An example with only two rows (more in reality) is below:

\documentclass[aps, pre, reprint]{revtex4-1}
\usepackage{graphicx,color}
\usepackage{amsmath}
\usepackage[table]{xcolor}

\begin{document}
\renewcommand*{\arraystretch}{1.5}
\begin{table*}
\rowcolors{2}{gray!25}{white}
\begin{ruledtabular}
\begin{tabular}{p{1in} p{6in}}
Variable & Expression \\
\hline
$\alpha$ & $\begin{aligned} &-2 q_1^2 (6 \alpha _4 A_1^4-A_1^2 (\alpha _2+20 \alpha _4 A_2^2+32 \alpha _4 A_3 A_2-4 \alpha _3 A_3+40 \alpha _4 A_3^2)+ \\ & 2 (6 \alpha _4 A_2^4+A_2^2 (\alpha _2+4 A_3 (4 \alpha _3+9 \alpha _4 A_3))+2 A_3^2 (\alpha _2+6 \alpha _4 A_3^2))) \end{aligned}$ \\

$\gamma$ & $\begin{aligned} &\frac{1}{3} q_1^4 (12 \alpha _4 A_1^4-A_1^2 (\alpha _2+4 (11 \alpha _4 A_2^2+32 \alpha _4 A_3 A_2-7 \alpha _3 A_3+58 \alpha _4 A_3^2))+ \\ & 2 (24 \alpha _4 A_2^4+A_2^2 (\alpha _2+204 \alpha _4 A_3^2+40 \alpha _3 A_3)+8 A_3^2 (\alpha _2+12 \alpha _4 A_3^2))) \end{aligned}$ \\
\end{tabular}
\end{ruledtabular}
\end{table*}

\end{document}

What is the simplest way to make this look nice? The obvious problems are:

  1. The awkward white column between $\gamma$ and its expression
  2. How the fraction $\frac{1}{3}$ goes outside the gray.
  3. The exponents in the first line don't have enough space.

Best Answer

i would:

  • use tabularx for table environment
  • not use colored rows
  • in table body separate rows with tiny Xhline{0.1pt} from the package makecell
  • for vertical spaces above/below cell content use macro\makegapedcells from the package makecell:

    \documentclass[aps, pre, reprint]{revtex4-1}
    \usepackage{mathtools}
    \usepackage{makecell,tabularx}
    \setcellgapes{3pt}
    
    %---------------- show page layout. don't use in a real document!
    \usepackage{showframe}
    \renewcommand\ShowFrameLinethickness{0.15pt}
    \renewcommand*\ShowFrameColor{\color{red}}
    %---------------------------------------------------------------%
    
    \begin{document}
        \begin{table*}
    \makegapedcells
    \setlength\tabcolsep{6pt}
        \begin{tabularx}{\linewidth}{c X}
       \Xhline{0.8pt}
    Variable    &   Expression      \\
       \hline
    $\alpha$
        &  $\begin{multlined}[0.95\linewidth]
            -2 q_1^2 (6 \alpha_4 A_1^4-A_1^2 (\alpha_2+20 \alpha_4 A_2^2+32 \alpha_4 A_3 A_2-4 \alpha_3 A_3+40 \alpha_4 A_3^2) + \\
            2 (6 \alpha_4 A_2^4+A_2^2 (\alpha_2+4 A_3 (4 \alpha_3+9 \alpha_4 A_3))+2 A_3^2 (\alpha_2+6 \alpha_4 A_3^2)))
            \end{multlined}$          \\
        \Xhline{0.1pt}
    $\gamma$
        &   $\begin{multlined}[0.95\linewidth]
            \frac{1}{3} q_1^4 (12 \alpha_4 A_1^4-A_1^2 (\alpha_2+4 (11 \alpha_4 A_2^2+32 \alpha_4 A_3 A_2-7 \alpha_3 A_3+58 \alpha_4 A_3^2))+ \\
            2 (24 \alpha_4 A_2^4+A_2^2 (\alpha_2+204 \alpha_4 A_3^2+40 \alpha_3 A_3)+8 A_3^2 (\alpha_2+12 \alpha_4 A_3^2)))
            \end{multlined}$          \\
        \Xhline{0.8pt}
    \end{tabularx}
        \end{table*}
    \end{document}
    

enter image description here

(red lines indicate page layout)

Related Question