10

I am writing a book and I want to show the formats of equation numbering; I mean, I want to tell the students that they can put the numbering at the beginning or at the end of the formula's line in their documents such as papers or assignments.

So, in an example, I want to bring equation numbering in the right side of the equation and in another example I want to show the equation number in the left side of the equation at the beginning of the line. I did try the following answers but they change the numbering format in the whole document. How can I do it locally?

Placing equation numbers on the right

How can I position equation numbers always to the left side?

This is what I tried based on a comment to my question and it's linked question with use of the amsmath package:

Switch between leqno and reqno options (of amsmath) in the same document

%pdflatex
\documentclass{article}
\usepackage[leqno]{amsmath}

\makeatletter
\newcommand{\leqnomode}{\tagsleft@true}
\newcommand{\reqnomode}{\tagsleft@false}
\makeatother

\begin{document}
\reqnomode
\begin{align}\tag{1}
\frac{{{\partial ^2}u}}{{\partial {r^2}}} + \frac{1}{r}\frac{{\partial u}}{{\partial r}} - \frac{u}{{{r^2}}} = \frac{1}{{{c_1}^2}}\frac{{{\partial ^2}u}}{{\partial {t^2}}}
\end{align}
\\[-10pt]
\leqnomode
\begin{align}\tag{1}
\frac{{{\partial ^2}u}}{{\partial {r^2}}} + \frac{1}{r}\frac{{\partial u}}{{\partial r}} - \frac{u}{{{r^2}}} = \frac{1}{{{c_1}^2}}\frac{{{\partial ^2}u}}{{\partial {t^2}}}
\end{align}
\end{document}

enter image description here

However, when I was writing my file first, I was not using the amsmath package because in my document I had only two equations just as examples. I was not aiming to write complicated mathematical equations to use that package. So, I am looking for an easy way to make such equation's tag.

11
  • Since you only have to show your students once what they might do in their own documents, construct an example with numbers on the left by hand (assuming you do numbers on the right as your TeX default in the rest of the book). Oct 16, 2014 at 14:54
  • 2
    if you are using amsmath, this question gives a reliable answer: Switch between leqno and reqno options {of amsmath} in the same document Oct 16, 2014 at 15:13
  • What if I am not using that package?
    – enthu
    Oct 22, 2014 at 11:28
  • 3
    I voted to leave the question closed. It's not clear at all why amsmath, the most commonly loaded math packages, is not a way to go for you. Please, construct a MWE, and as well, explain your motivation for avoiding amsmath. Without that, the question is just an off-topic what-if stuff.
    – yo'
    Oct 22, 2014 at 11:55
  • 1
    And can you show us the minimal first code (without package amsmath? Without a MWE it hard to understand what your real problem is ...
    – Mensch
    Oct 22, 2014 at 12:30

3 Answers 3

9

Others have now posted answers, but for the record this is what I had in mind. It works with all the standard classes (article, memoir, scrartcl, etc.), but not if you load amsmath, so the AMS classes, see below.

Sample output

\documentclass{article}

\makeatletter
\let\r@eqnnum\@eqnnum
\input{leqno.clo}
\let\l@eqnnum\@eqnnum
\newcommand{\leqnos}{\let\@eqnnum\l@eqnnum}
\newcommand{\reqnos}{\let\@eqnnum\r@eqnnum}
\reqnos
\makeatother

\begin{document}

\begin{equation}
  \label{eq:x}
  x = y
\end{equation}

\begingroup\leqnos
\begin{equation}
  \label{eq:a}
  a = b
\end{equation}\endgroup
and
\begin{equation}
  \label{eq:b}
  b = a.
\end{equation}

\end{document}

If you load amsmath (directly or indirectly, via e.g. mathtools or an AMS documentclass), then as Silvio Levy points the position of the labelling is controlled by different variables. In this case you can use, the following:

\documentclass{article}

\usepackage{amsmath}
\makeatletter
\newcommand{\leqnos}{\tagsleft@true\let\veqno\@@leqno}
\newcommand{\reqnos}{\tagsleft@false\let\veqno\@@eqno}
\reqnos
\makeatother

\begin{document}

\begin{equation}
  \label{eq:x}
  x = y
\end{equation}

\begingroup\leqnos
\begin{equation}
  \label{eq:a}
  a = b
\end{equation}\endgroup
and
\begin{equation}
  \label{eq:b}
  b = a.
\end{equation}

\end{document}
2
  • This didn't work for me with the the ams classes; what worked was \let\veqno=\@@leqno to switch to the left, and \let\veqno=\@@reqno to the right. Jul 5, 2017 at 17:54
  • @SilvioLevy Many thanks. Answer updated. I suggest one toggles tagsleft@ too. Jul 6, 2017 at 8:30
6

A closer look at class option leqno reveals that it loads leqno.clo with just one redefinition:

\ProvidesFile{leqno.clo}
        [1998/08/17 v1.1c Standard LaTeX option
                                   (left equation numbers)]
\renewcommand\@eqnnum{\hb@[email protected]\p@{}%
                      \rlap{\normalfont\normalcolor
                        \hskip -\displaywidth(\theequation)}}
\endinput

The following example just locally loads leqno.clo to get the equation number to the left for one of the examples:

\documentclass{article}

\begin{document}
\noindent
First example with equation number to the right (default):
\begin{equation}
  \frac{\partial ^2 u}{\partial r^2} + \frac{1}{r}
  \frac{\partial u}{\partial r} - \frac{u}{r^2}
  = \frac{1}{c_1^2}\frac{\partial^2 u}{\partial t^2}
\end{equation}
Second example applies class option \texttt{leqno} in a group:
\begingroup
  \makeatletter
  \input{leqno.clo}
  \makeatother
  \begin{equation}
    \frac{\partial ^2 u}{\partial r^2} + \frac{1}{r}
    \frac{\partial u}{\partial r} - \frac{u}{r^2}
    = \frac{1}{c_1^2}\frac{\partial^2 u}{\partial t^2}
  \end{equation}
\endgroup
\end{document}

Result

5

Whenever your document has extensive math, you should load amsmath.

However, just to answer your question, the simplest way is to use, once in a lifetime, the “forbidden” $$. After all, we know what we're doing in this particular case.

\documentclass[leqno]{article}

\usepackage{lipsum}

\begin{document}

\lipsum*[2]
\begin{equation}
\frac{\partial^2u}{\partial r^2} +
  \frac{1}{r}\frac{\partial u}{\partial r} -
  \frac{u}{r^2} =
\frac{1}{c_1^2}\frac{\partial^2u}{\partial t^2}
\end{equation}
\lipsum*[3]
$$
\frac{\partial^2u}{\partial r^2} +
  \frac{1}{r}\frac{\partial u}{\partial r} -
  \frac{u}{r^2} =
\frac{1}{c_1^2}\frac{\partial^2u}{\partial t^2}
\refstepcounter{equation}
\label{whatever}
\eqno{(\theequation)}
$$
\lipsum[2]

\end{document}

enter image description here

Note. You have way too many braces. And {c_1}^2 wants to be c_1^2: really.

0

You must log in to answer this question.

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