8

The last equation is slighter higher placed than the two others and I don't know why.

Current output

enter image description here

Current code

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

\begin{document}

\noindent\begin{tabularx}{\textwidth}{@{}XXX@{}}
  \begin{equation}
    P_1 = \frac{(1+4\omega)^2}{2(3+9\omega)}
  \end{equation} &
    \begin{equation}
    P_2 = \frac{1}{2}-\frac{\omega}{1+4\omega}
  \end{equation} &
      \begin{equation}
    P_3 = \frac{1}{2}
  \end{equation}
\end{tabularx}

\end{document}
  • 1
    Have a look at the align environment or other alternatives for the equation environment. – Karlo Jul 31 '16 at 15:55
  • Hmm, but when I plug in a longer expression for P_3 (e.g. the expression for P_1) they are perfectly aligned. – Saud Jul 31 '16 at 16:00
7

The curious problem is due to the fact that the third equation is quite short, so TeX inserts \abovedisplayshortskip instead that \abovedisplayskip.

You can do it without tabularx: it's just a sequence of minipages:

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum} % just for the example

\begin{document}

\lipsum*[2]
\[
\setlength{\abovedisplayshortskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\begin{minipage}{.33333\textwidth}
  \vspace*{-\baselineskip}
  \begin{equation}
    P_1 = \frac{(1+4\omega)^2}{2(3+9\omega)}
  \end{equation}
\end{minipage}
%
\begin{minipage}{.33333\textwidth}
  \vspace*{-\baselineskip}
  \begin{equation}
  P_2 = \frac{1}{2}-\frac{\omega}{1+4\omega}
  \end{equation}
\end{minipage}
%
\begin{minipage}{.33333\textwidth}
  \vspace*{-\baselineskip}
  \begin{equation}
  P_3 = \frac{1}{2}
  \end{equation}
\end{minipage}
\]
\lipsum[3]

\end{document}

The \vspace*{-\baselineskip} is necessary to nullify the one line empty paragraph that's inserted before equation. Moreover I set \abovedisplayshortskip to equal \abovedisplayskip and, for symmetry, also the “below” skips.

enter image description here

After seeing this you might want to manually modify the widths of the minipages. This is with .35\textwidth for the first, .4\textwidth for the second and .2\textwidth for the last one.

enter image description here

4

I have no idea why it works, but just loading geometry solves the problem!!

Actually, I had some time ago defined a tabequation environment, more or less defined as in your code, and I always load geometry with option showframe, just to check there's no overflow in the margin. I never observed a similar problem, so I wondered what difference in code explained the behaviour difference.

Just in case you're interested, here are both codes. Note they work with subequations, if necessary:

        \documentclass{article}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{lmodern}%
         \usepackage{tabularx, mathtools}
        \usepackage[showframe]{geometry}

        \newcolumntype{E}[1]{>{\equation}>{\hsize=#1\hsize}X<{\endequation}}
        \newcolumntype{Y}{>{\equation}X<{\endequation}}

        \newenvironment{tabequations}[1]{%
        \vspace{\abovedisplayskip}\par\noindent\setlength\tabcolsep{2pt}\setlength\abovedisplayskip{0pt}
        \tabularx{\linewidth}{#1}}%
        {\endtabularx\par}

        \begin{document}

      Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.%

  \begin{subequations}
    \noindent\begin{tabularx}{\linewidth}{@{}XXX@{}}
      \begin{equation}
        P_1 = \frac{(1+4\omega)^2}{2(3+9\omega)}
      \end{equation} &
        \begin{equation}
        P_2 = \frac{1}{2}-\frac{\omega}{1+4\omega}
      \end{equation} &
          \begin{equation}
        P_3 = \frac{1}{2}
      \end{equation}
    \end{tabularx}
  \end{subequations}
     Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.%
\begin{subequations}
     \begin{tabequations}{@{}*{4}{Y}@{}}
     P_1 = \frac{(1+4\omega)^2}{2(3+9\omega)}
     & P_2 = \frac{1}{2}-\frac{\omega}{1+4\omega}%
     & P_3 = \frac{1}{2}
     \end{tabequations}
\end{subequations}

        \end{document} 

enter image description here

4

With tabularx and gather instead of equation (gather has more consistent defined vertical space above and below of a math expression):

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

\begin{document}
some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text\\
\begin{tabularx}{\textwidth}{@{}XXX@{}}
  \begin{gather}
    P_1 = \frac{(1+4\omega)^2}{2(3+9\omega)}
  \end{gather} &
    \begin{gather}
    P_2 = \frac{1}{2}-\frac{\omega}{1+4\omega}
  \end{gather} &
      \begin{gather}
    P_3 = \frac{1}{2}
  \end{gather}
\end{tabularx}\\
some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text

some text some text some text some text some text some text some text some text some text 
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.