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.

enthu
  • 3,795
  • 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). – Ethan Bolker Oct 16 '14 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 – barbara beeton Oct 16 '14 at 15:13
  • What if I am not using that package? – enthu Oct 22 '14 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 '14 at 11:55
  • @tohecz First I posted this question, I was not using that package, and I did not find any way to solve my problem. After I saw that question, I added that package and I solved my problem. I am just looking back to my original question to see whether these is a way to locally change the tag place without loading extra packages. – enthu Oct 22 '14 at 12:07
  • 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 '14 at 12:30
  • This is not so hard, but the answer is different to the amsmath one. – Andrew Swann Oct 22 '14 at 12:38
  • @AndrewSwann how? – enthu Oct 22 '14 at 15:14
  • By using the code from the leqno.clo class option. I'll post a solution when the question gets reopened. – Andrew Swann Oct 22 '14 at 15:47
  • @tohecz This question seems to have an answer. Please vote to reopen to see the solution. – enthu Oct 22 '14 at 15:54
  • @AndrewSwann The question is re-opened – enthu Oct 22 '14 at 16:36

3 Answers3

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}
Andrew Swann
  • 95,762
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@xt@.01\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

Heiko Oberdiek
  • 271,626
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.

egreg
  • 1,121,712