3

The exact demand is that I want to put the citation on the left and the usual arabic label on the right.

I've found 3 solutions so far:

  1. Use environment flalign. Source: How to number math equations from both sides?
  2. Use \makebox to create an environment from scratch, with the help of \hfill. Source: https://tex.stackexchange.com/a/574793/199226
  3. Use package zref or tikz to fetch the exact coordinates and place the text there with other packages, i.e. tikz, textpos or eso-pic.

The following MWE contains the default equation for alignment reference, solution 1, solution 2 and an instance of solution 3.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikzpagenodes}

% source: https://tex.stackexchange.com/a/574795/199226
\newcommand{\ltag}[1]{
    \begin{tikzpicture}[baseline=(tmp.base),remember picture]
        \node[inner sep=0pt](tmp){\vphantom{1}};
        \begin{scope}[overlay]
            \path (current page text area.west|-tmp.base)
                node[anchor=base west,inner sep=0pt,outer sep=0pt]{#1};
        \end{scope}
    \end{tikzpicture}
}

\begin{document}
\begin{equation}
    \frac{Example}{Equation}
\end{equation}
\begin{equation}
    \frac{Example}{Equation}\ltag{tikz}
\end{equation}
\begin{flalign}
    \rlap{\text{flalign with balancing}}%
    \phantom{(\theequation)}%
    &&\frac{Example}{Equation}&&
\end{flalign}
\begin{flalign}
    \rlap{\text{flalign}}%
    &&\frac{Example}{Equation}&&
\end{flalign}
\makebox[\linewidth]{
    \refstepcounter{equation}
    \rlap{makebox}\hfill
    $\displaystyle \frac{Example}{Equation}$
    \hfill\llap{(\theequation)}
}
\end{document}

enter image description here

The problem of solution 1 is that the equation is not exactly centered. I've tried adding \phantom{(\theequation)} on the left for balancing, but there is still a small offset compared to the usual equation environment. See also: https://latex.org/forum/viewtopic.php?t=31268 Also notice that flalign has different line spacing.

Solution 2 also has alignment issues. See MWE.

Solution 3 can give the desired result, but I suppose there should be a cleaner way that operates locally, instead of saving some data globally.

PS: I also want \eqref and \autoref to work properly.

1 Answer 1

6

You can add the text to the right aligned label, but shifted to the left.

enter image description here

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\def\ltag#1{%
\stepcounter{equation}%
\tag*{}%
\def\df@tag{(\theequation)\llap{\rlap{#1}\hspace{\columnwidth}}}%
}
\makeatother
\begin{document}

\noindent X\dotfill X
\begin{equation}\label{aa}
    \frac{Example}{Equation}
\end{equation}

\noindent X\dotfill X
\begin{equation}
\ltag{left text}\label{bb}
    \frac{Example}{Equation}
\end{equation}


\noindent X\dotfill X
\begin{equation}
    \frac{Example}{Equation}
\end{equation}


aa\eqref{aa} aa\eqref{bb}
\end{document}
9
  • Almost perfect. One thing is that eqref has two pairs of parenthesis for your solution. \tag{\theequation\llap{\rlap{\phantom{(}aaa}\hspace{\textwidth}}} seems to work. Commented Nov 6, 2022 at 19:26
  • Out of curiousity, does \tag stop the automatic counter? Commented Nov 6, 2022 at 19:27
  • @putianyi888 No it is worse than that the left side text appears in eqref off the left margin try \hspace*{\textwidth}aa\eqref{bb} I will fix... Commented Nov 6, 2022 at 19:33
  • @putianyi888 updated answer Commented Nov 6, 2022 at 21:31
  • Can you make it work for other environments like align, multline and possibly in subequations and multicols? Shall I make another question for this? Commented Nov 7, 2022 at 17:53

You must log in to answer this question.

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