3

I am attempting to use tabularx to put multiple numbered equations on the same line, as suggested in this answer.

MWE 1:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
blah blah text

\noindent\begin{tabularx}{\linewidth}{@{}XX@{}}
\begin{equation}
1+1+2
\end{equation}
&
\begin{equation}
2+2=4
\end{equation}
\end{tabularx}
%
blah blah text
\end{document}

This produces

this

MWE 2:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
blah blah text

\noindent\begin{tabularx}{\linewidth}{@{}XX@{}}
asdfasfd
&
asfdasdf
\end{tabularx}
%
blah blah text
\end{document}

This produces

this

MWE 2 is fine, the spacing is the same on the top and the bottom. What gives for MWE 1 though? How do I get it such that the spacing before and after the tabularx environment is the same as what I would normally get from an equation environment?

2 Answers 2

1

To economize drastically on (vertical) whitespace, you could encase the equation environments in minipage environments (of width \hsize). Alternatively, don't use equation environments at all; instead, use low-level code to display the math material, to increment the equation counter, and to display the equation number.

enter image description here

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\hrule
\noindent%
\begin{tabularx}{\linewidth}{@{}XX@{}}
\begin{minipage}{\hsize}
\begin{equation}
1+1+2
\end{equation}
\end{minipage}
&
\begin{minipage}{\hsize}
\begin{equation}
2+2=4
\end{equation}
\end{minipage}
\end{tabularx}
\hrule

\bigskip
\hrule
\noindent%
\begin{tabularx}{\linewidth}{@{}XX@{}}
\hfill$\displaystyle 1+1=2$\hfill
\refstepcounter{equation}(\theequation)
&
\hfill$\displaystyle 2+2=4$\hfill
\refstepcounter{equation}(\theequation)
\end{tabularx}
\hrule

\bigskip
\hrule
\noindent
\begin{tabularx}{\linewidth}{@{}XX@{}}
asdfasfd & asfdasdf
\end{tabularx}
\hrule

\end{document}
1
  • thank you! egreg's solution worked too but I am having trouble getting his way to play nicely with autonum. The only issue I am having is how to get the vertical spacing around the tabularx environment to be the same as what I would get around a normal equation environment. I have something that looks like this, where the space at the top is higher than the bottom, but both of them are smaller that what I would get from an equation environment. I think some vspace commands should fix it, I am just not sure on the lengths I need to use.
    – teerav42
    Commented Jun 28, 2019 at 22:34
1

You can (locally) set the spacing parameters above and below displays to zero.

It's easier if you also define a proper environment. If you need consecutive equation environments (but you shouldn't), use the shown trick.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{environ}

\usepackage{lipsum}% just for the example

\newlength{\savedbdss}
\NewEnviron{multieq}[1]{%
  \[
  \begin{minipage}{\displaywidth}
  \setlength{\savedbdss}{\belowdisplayshortskip}
  \setlength{\abovedisplayshortskip}{0pt}%
  \setlength{\belowdisplayshortskip}{0pt}%
  \begin{tabularx}{\displaywidth}{@{}*{#1}{>{\noindent\vspace*{-\baselineskip}}X}@{}}
  \BODY
  \end{tabularx}
  \vspace{-\belowdisplayskip}
  \vspace{-\savedbdss}
  \end{minipage}
  \]
}

\begin{document}

\lipsum[1][1-4]
\begin{multieq}{2}
\begin{equation}
1+1+2
\end{equation}
&
\begin{equation}
2+2=4
\end{equation}
\end{multieq}
\lipsum[2][1-3]
\begin{multieq}{2}
\begin{equation}
1+1+2
\end{equation}
&
\begin{equation}
2+2=4
\end{equation}
\\[-\savedbdss]
\begin{equation}
1+1+2
\end{equation}
&
\begin{equation}
2+2=4
\end{equation}
\end{multieq}
\lipsum[2][1-3]

\end{document}

enter image description here

4
  • What do you mean when you say that I shouldn't need consecutive equation environments? How else would I achieve what I am going for here?
    – teerav42
    Commented Jun 28, 2019 at 20:52
  • @teerav42 Already having two numbered equations side-by-side is confusing…
    – egreg
    Commented Jun 28, 2019 at 21:28
  • You think so @egreg ? The alternative is having short and skinny equations stacked on top of each other, which results in lots of unused whitespace on either side. Perhaps there's a compelling argument for one or the other that I am missing, but it seems to me to be a matter of stylistic preference, no?
    – teerav42
    Commented Jun 28, 2019 at 21:51
  • Also, @egreg : this seems like a pretty good solution in general but I am having trouble when I add label's to the equations. I think the problem is coming because I am also using autonum, and there seems to be an incompatibility. Mico's solution might be better for me, I just need to figure out how to get the spacing around the environment correct!
    – teerav42
    Commented Jun 28, 2019 at 22:25

You must log in to answer this question.

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