0

I'm trying to include equations in a table, I know I need to use minipage to do so. But for some reason it is creating a gap between where the row would usually start and where it does when I include the minipage/math combination.

I have tried using abovedisplayskip to no avail. As well as trimbox and raisebox, both of which succeeded in shifting the equations higher but the text in the first two columns was still offset.

I have the same issue occur with subequations, but the gap is even larger.

Does anyone know why this is happening and/or how to fix it?

\documentclass{article}

\usepackage{xcolor, colortbl}
\usepackage{array,booktabs,tabularx,rotating,amsmath}

\begin{document}
    \begin{sidewaystable}          
        \begin{tabularx}{\textwidth}{X>{$}>{\raggedright\arraybackslash}p{3cm}<{$}l}
        \toprule
        \textbf{Section}  & \textbf{Variables}  & \multicolumn{1}{c}{\textbf{Constraints}}  \\
        \midrule        
        Section 1  & (0 \le a \le 100)\newline
                     (0 \le b \le 100)  &   \begin{minipage}{13cm}
                                                \begin{gather} 
                                                    a+b \ge 42 \\
                                                    a \ge 11
                                                \end{gather}
                                          \end{minipage}\\
        \rowcolor{gray!50}
        Section 2 & (0 \le c \le 100) \newline
                    (0 \le d \le 100) &\begin{minipage}{13cm}
                                            \begin{subequations}                                                    
                                                \begin{gather} 
                                                    \text{Given a bunch of stuff define:} \notag \\                                                        
                                                    \sum_{\mathclap{\substack{a bunch of really\\long stuff}}} (a*d)\\
                                                    c=d                                                          
                                                \end{gather}                                                
                                        \end{subequations}
                                    \end{minipage}\\
             Usually & there & is no vertical space\\
            \bottomrule
        \end{tabularx}     
    \end{sidewaystable}
\end{document}

enter image description here

This is how I would like the table to be aligned. (This was done by putting the the minipage on a separate row and then using raisebox to lift it into place. But this feels very hacky, there must be an actual way to specify the alignment.) enter image description here

13
  • Putting an \fbox{} around the minipage shows that the extra line is inside. I can't figure out where it comes from, though. Aug 24, 2016 at 3:57
  • I believe the gather is what is causing the line. Ah, I only added abovedisplayskip not the short version too. though that still isn't helping. Regardless of where the minipage/gather appears (I can adjust them using boxes) the first two columns are no longer aligned at the top of their cells, like they usually would be, even given a multiline cell.
    – Adriala
    Aug 24, 2016 at 4:17
  • Why can't you use \mathclap with inline maths?
    – Bernard
    Aug 24, 2016 at 9:19
  • 1
    this answer is relevant to all multi-line display environments defined by amsmath. Aug 24, 2016 at 13:04
  • 1
    what if you use the position option: \begin{minipage}[t]{...} ? my guess is that the extra "height" on the other columns may be caused by the vertical centering of the minipage. Aug 24, 2016 at 14:40

1 Answer 1

0

@barbarabeeton @JohnKormylo Thank-you for the assistance to answering this question.

The answer to this post explained why the minipage/math environment combination caused a gap (the etoolbox \kern part). Specifying the minipage placement [t] the corrected the alignment of the first two columns. an additional .4/normalbaselineskip was also added to the \kern adjustment to remove the remaining space above the equation.

\documentclass{article}

\usepackage{xcolor, colortbl}
\usepackage{array,booktabs,tabularx,rotating,amsmath}
\usepackage{adjustbox}
\usepackage{amsthm}
\usepackage{mathtools}

\usepackage{etoolbox}
\makeatletter
\pretocmd\start@gather{%
    \if@minipage\kern-\topskip\kern-\abovedisplayskip\kern-.4\normalbaselineskip\fi
}{}{}
\makeatother

\begin{document}
    \begin{sidewaystable}          
        \begin{tabularx}{\textwidth}{X>{$}>{\raggedright\arraybackslash}p{3cm}<{$}l}
            \toprule
            \textbf{Section}  & \textbf{Variables}  & \multicolumn{1}{c}{\textbf{Constraints}}  \\
            \midrule        
            Section 1  & (0 \le a \le 100)\newline
                         (0 \le b \le 100)  &   \begin{minipage}[t]{13cm}
                                                    \begin{gather} 
                                                        a+b \ge 42 \\
                                                        a \ge 11
                                                    \end{gather}
                                              \end{minipage}\\
            \rowcolor{gray!50}
            Section 2 & (0 \le c \le 100) \newline
                        (0 \le d \le 100) & \begin{minipage}[t]{13cm}
                                                \begin{subequations}   \label{broke}                                                 
                                                    \begin{gather} 
                                                        \text{Given a bunch of stuff define:} \notag \\                                                        
                                                        \sum_{\mathclap{\substack{a bunch of really\\long stuff}}} (a*d)\\
                                                        c=d                                                          
                                                    \end{gather}                                                
                                            \end{subequations}
                                        \end{minipage}\\            
            Usually & there \newline is \newline no & space\\
                \bottomrule
            \end{tabularx}     
        \end{sidewaystable}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .