1

I am trying to typeset a math paper in two column mode using the amsmath package (in fact, using mathtools), making equation numbers appear in the margins. To be clear: I want equations in the left column to have their equation number in the left margin, and equation in the right column to have their number in the right margin. So far, I have been able to make some progress with…

\makeatletter
\renewenvironment{equation}{%
  \refstepcounter{equation}
  \begin{equation*}%
}{%
  \end{equation*}%
  \marginpar{(\theequation)}
}
\makeatother

…but the number isn't centered on the equation, and the space between the number and the text block is not the same on both sides:

tag placement is wrong

Here is a minimum working example:

\documentclass[a4paper,twocolumn,oneside]{article}

\usepackage{amsmath,kantlipsum}

\begin{document}

\kant[2]
\begin{equation}
  y = \int_{-\infty}^{\infty} \exp(-x^2) \operatorname{d}x
\end{equation}
\kant[3-4]
\begin{equation}
  y = \int_{-\infty}^{\infty} \exp(-x^2) \operatorname{d}x
\end{equation}

\end{document}

I am not opposed to using other packages, but a simple solution would be best. Thanks for the help.

1 Answer 1

0
% Compiled with TexStudio; XeLaTex
% Made it work by adding \vspace{-2\baselineskip} 
\documentclass[a4paper,twocolumn,oneside]{article}

\usepackage{amsmath,kantlipsum}

\makeatletter
\renewenvironment{equation}{%
  \refstepcounter{equation}
  \begin{equation*}%
                           }{%
  \end{equation*}%
  
  \marginpar{\vspace{-2\baselineskip}(\theequation)}
                            }
\makeatother

\begin{document}

\kant[2]
\begin{equation}
  y = \int_{-\infty}^{\infty} \exp(-x^2) \operatorname{d}x
\end{equation}
\kant[3-4]
\begin{equation}
  y = \int_{-\infty}^{\infty} \exp(-x^2) \operatorname{d}x
\end{equation}

\end{document}
2
  • Hmmm, I thought that adding four spaces, then inserting the code would show it compiled(?) Oct 4, 2023 at 2:29
  • You need to add four spaces to all code lines, not just to the firs one. Simpler is insert ``` before and after code (as I did in my editing your answer).
    – Zarko
    Oct 4, 2023 at 3:40

You must log in to answer this question.

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