2

I want to remove all vertical space below an align environment, but inside a tabularx environment. I tried setting belowdisplayskip and belowdisplayshortskip to 0 (as suggested here), but while this removed some vertical space, the result still looks like this:

What can I do to remove the vertical space directly after the a+b=c equation? The above image has been obtained using the following code:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\linewidth}{|l|X|}
\hline
some & text 
\setlength{\belowdisplayskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt} 
\begin{align*}
a + b = c
\end{align*} 
\\
\hline 
* & this row should be directly under the equation with no vertical space in between. \\
\hline
\end{tabularx}

\end{document}

Note that it works fine if...

  • I simply remove the equation;
  • there is another line of text after the equation in the same table cell;
  • or the equation contains a cases environment with at least two lines

... as can be seen in this image:

3
  • What happens, if you set \setlength{\belowdisplayskip}{0pt} to -1em, instead of 0?
    – gilu
    Commented May 23, 2017 at 7:19
  • @gilu Then it looks fine in the first example I've posted, but it ruins the output for the second and third example in my last image (i.e. if the equation is followed by another line of text or contains a cases environment). Ideally, I'd like a solution that works regardless of whether the equation contains cases / is followed by text or not.
    – vauge
    Commented May 23, 2017 at 7:25
  • I don't have the code for your other three examples, but you could make new commands \newcommand{\minusspace}{\setlength{\belowdisplayskip}{-1em}\setlength{\belowdisplayshortskip}{0pt}} \newcommand{\nospace}{\setlength{\belowdisplayskip}{0em}\setlength{\belowdisplayshortskip}{0pt}} and call the one you need before align*.
    – gilu
    Commented May 23, 2017 at 7:31

1 Answer 1

1

it gets a bit confused over inserted struts....

simplest is probably just to detect this case and back up:

enter image description here

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{tabularx}
\showoutput
\begin{document}

\noindent
\begin{tabularx}{\linewidth}{|l|
>{\setlength{\belowdisplayskip}{0pt}%
\setlength{\belowdisplayshortskip}{0pt}%
}
X
<{\ifhmode\ifnum\prevgraf>0 \vskip-\normalbaselineskip \mbox{}\fi\fi}
|}
\hline
some & text 
\begin{align*}
a + b = c
\end{align*}
\\
\hline 
* & this row should be directly under the equation with no vertical space in between. \\
\hline
\end{tabularx}

\end{document}

You must log in to answer this question.

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