2

The following example:

\documentclass{standalone}

\begin{document} % outer minipages are not part of the test, and just demonstrate the inconsistency \begin{minipage}[t]{0.5\textwidth}

This is an equation
\begin{equation}
    x = 1,
\end{equation}
which ends in a comma.

\end{minipage}% \begin{minipage}[t]{0.5\textwidth}

This is a minipage equation\par
\begin{minipage}[t]{\textwidth}
    \begin{equation}
        x = 1,
    \end{equation}
    \par\nointerlineskip\xdef\tpd{\the\prevdepth}
\end{minipage}%
\par\prevdepth\tpd\noindent
which ends in a comma.

\end{minipage}%

\end{document}

where the prevdepth stuff is taken from https://tex.stackexchange.com/a/34982/41112, renders as

output

How can I make the column on the right match the one on the left, without removing the minipage? Note that the $x=1$ line is also misaligned, though only very slightly.


Edit: It turns out this is an XY problem, and the solution to my question above doesn't actually work for real problem. That is:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\begin{document}

This is some text that is long enough to wrap across multiple lines, or at least it ought to be. This gap is too big:\par\nointerlineskip\noindent \begin{minipage}[t]{.5\textwidth}% \begin{subequations}\label{eq:tensor_tensor_tensor_left}% \begin{alignat}{2}% & (M \otimes_{\color{red} R} N) \otimes_{\color{blue} A} (P \otimes_{\color{red} R} Q) \nonumber \ \cong_{\color{blue} A} {}& ((M \otimes_{\color{red} R} N) \otimes_{\color{blue} A} P) \otimes_{\color{red} R} Q) \label{eq:ttt-left-assoc-1} \end{alignat}% \end{subequations}% \end{minipage}% \begin{minipage}[t]{.5\textwidth}% \begin{subequations}\label{eq:tensor_tensor_tensor_right}% \begin{alignat}{2}% & (M \otimes_{\color{red} R} N) \otimes_{\color{blue} A} (P \otimes_{\color{red} R} Q) \nonumber \ \cong_{\color{blue} A} {}& M \otimes_{\color{red} R} (N \otimes_{\color{blue} A} (P \otimes_{\color{red} R} Q) \label{eq:ttt-right-assoc-1} \end{alignat}% \end{subequations}% \par\xdef\tpd{\the\prevdepth}% \vspace{\belowdisplayskip}\vspace{-\baselineskip}% \end{minipage}\par\prevdepth=\tpd\noindent and some more unindented text. The gap above is too small. Toegther they add to the right amount. \begin{alignat}{2}% & (M \otimes_{\color{red} R} N) \otimes_{\color{blue} A} (P \otimes_{\color{red} R} Q) \nonumber \ \cong_{\color{blue} A} {}& M \otimes_{\color{red} R} (N \otimes_{\color{blue} A} (P \otimes_{\color{red} R} Q) \label{eq:ttt-right-assoc-1} \end{alignat}% These two gaps are just right, and is a bit bigger than the one above

\end{document}

which gives: enter image description here

Eric
  • 669

1 Answers1

2

Let me modify your example, so the second outer minipage is just to show the effect side-by-side with the first minipage. In the second minipage, the first line and the equation are in a minipage and the text that follows is outside.

\documentclass{article}

\begin{document} % outer minipages are not part of the test, and just demonstrate the inconsistency \noindent \begin{minipage}[t]{0.5\textwidth} This is an equation \begin{equation} x = 1, \end{equation} which ends in a comma. \end{minipage}% \begin{minipage}[t]{0.5\textwidth} \begin{minipage}[t]{\linewidth} This is a minipage equation \begin{equation} x = 1, \end{equation} \par\xdef\tpd{\the\prevdepth}% \vspace{\belowdisplayskip}\vspace{-\baselineskip} \end{minipage}\par\prevdepth=\tpd which ends in a comma. \end{minipage}

\end{document}

However this could fail in several ways, because the skip after the equation might be \belowdisplayshortskip and a rather complex routine would be needed to ascertain it.

enter image description here


About the real problem, I suggest to manage along the lines of https://tex.stackexchange.com/a/550010/4427

Prefer \mathcolor{red}{R} to \color{red} R.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}

\newcommand{\sidebysidesubequations}[5][0.5]{% $$% Yes! We're consciously doing it \begin{minipage}{#1\displaywidth}% \setlength{\abovedisplayskip}{0pt}% \begin{subequations}\label{#2} \noindent#3 \end{subequations} \end{minipage} \begin{minipage}{\dimeval{\displaywidth-#1\displaywidth}} \setlength{\abovedisplayskip}{0pt}% \begin{subequations}\label{#4} \noindent#5 \end{subequations} \end{minipage} $$% }

\begin{document}

This is some text that is long enough to wrap across multiple lines, or at least it ought to be. \sidebysidesubequations{eq:tensor_tensor_tensor_left}{ \begin{align} & (M \otimes_{\mathcolor{red}{R}} N) \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \nonumber \ \cong_{\mathcolor{blue}{A}} {}& M \otimes_{\mathcolor{red}{R}} (N \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \label{eq:ttt-left-assoc-1} \ & (M \otimes_{\mathcolor{red}{R}} N) \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \nonumber \ \cong_{\mathcolor{blue}{A}} {}& M \otimes_{\mathcolor{red}{R}} (N \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \label{foo1} \end{align} }{eq:tensor_tensor_tensor_right}{ \begin{align} & (M \otimes_{\mathcolor{red}{R}} N) \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \nonumber \ \cong_{\mathcolor{blue}{A}} {}& M \otimes_{\mathcolor{red}{R}} (N \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \label{eq:ttt-right-assoc-1} \ & (M \otimes_{\mathcolor{red}{R}} N) \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \nonumber \ \cong_{\mathcolor{blue}{A}} {}& M \otimes_{\mathcolor{red}{R}} (N \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \label{foo2} \end{align} } and some more unindented text and some more unindented text and some more unindented text and some more unindented text. \begin{align} & (M \otimes_{\mathcolor{red}{R}} N) \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \nonumber \ \cong_{\mathcolor{blue}{A}} {}& M \otimes_{\mathcolor{red}{R}} (N \otimes_{\mathcolor{blue}{A}} (P \otimes_{\mathcolor{red}{R}} Q) \label{eq:ttt-right-assoc-2} \end{align} These two gaps are just right, and is a bit bigger than the one above

\end{document}

enter image description here

egreg
  • 1,121,712
  • Unfortunately this didn't quite work for my real example. I've update my question, let me know if you think I should ask it as a new question. Thanks! – Eric Jan 15 '24 at 23:34
  • "In the second minipage, the first line and the equation are in a minipage and the text that follows is outside." - oh, I completely missed this on first reading! Unfortunately I don't think this works for my two-column scenario – Eric Jan 15 '24 at 23:36
  • @Eric I added a solution for your real problem. – egreg Jan 16 '24 at 08:34
  • Thanks! I really do want separate subequation numbering for the left and right column. In my real version there is more than one labeled line on each side, but I figured that wasn't relevant to my layout concern – Eric Jan 16 '24 at 08:37
  • 1
    @Eric Added a new implementation. Of course, there can be no guarantee whatsoever on the inner alignments. – egreg Jan 16 '24 at 12:57
  • Superimposing the first half of your screenshot onto the second half shows that the spacings are not consistent: https://i.stack.imgur.com/tL3ME.png; the space at the top of the first half is too big, while the one at the bottom of the first half is too small. – Eric Jan 17 '24 at 11:54