Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

First: Some days ago I posted this question on The LaTeX Community but I have not gotten an answer so I post it here.

Consider the following MWE:

\documentclass[danish]{article}
\usepackage{babel}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{hyperref}

\mathtoolsset{showonlyrefs}
\newcommand*{\hv}[1]{\label{eqn:#1}\stackrel{\mathclap{(#1)}}{=}}
\newcommand*{\fk}[1]{\item[\eqref{eqn:#1}]}

\begin{document}

We have
\begin{align}
  \Delta y
  &\hv{1} m(x_{0}+h) - m(x_{0})\\
  &\hv{2} \frac{f(x_{0}+h)}{g(x_{0}+h)} - \frac{f(x_{0})}{g(x_{0})}\\
  &\hv{3} \frac{f(x_{0}+h) \cdot g(x_{0})}{g(x_{0}+h) \cdot g(x_{0})} - \frac{f(x_{0}) \cdot g(x_{0}+h)}{g(x_{0}) \cdot g(x_{0}+h)}\\
  &= \dots
\end{align}
Explanations:
\begin{enumerate}
  \fk{1} A
  \fk{2} B
  \fk{3} C
\end{enumerate}

\end{document}

Issues:

  1. This way of refering to the lines in the align expression seems wierd. Is there a better way of doing this?
  2. I will like the labels (1), (2), ... to be printed above = only and not flushed right too. I there a way of doing this?

Ad 2. I have tried putting \notag at the end of each line but then I get the following error:

Package amsmath Error: Multiple \label's: label 'eqn:1' will be lost.
share|improve this question
    
Ad 1: Yes, that is the purpose of the “flushed-right” equation-number. Ad 2: With \notag there is no actual equation-number to refer to. I would at least use (\theequation) instead of (#1) above the = to get the right \eqref later. #1 is only the name of your label (\label{eqn:#1}), not the actual number of your equation. The label can be any arbitrary text. –  Qrrbrbirlbel Jan 2 '13 at 6:17
    
@Qrrbrbirlbel Thanks for the explanations. –  Svend Tveskæg Jan 2 '13 at 16:45

1 Answer 1

up vote 6 down vote accepted

I initially thought of suppressing the equation numbering, and using a custom numbering, but it turns out that \refstepcounter{...} was being ignored at runtime inside the math environment.

Managed to get a workaround, which produces the following output. I started the equation numbering at 10, to make sure the numbers correlated.

The key was in the label being assigned inside \makeatletter to \makeatother via the \ltx@label variable. The base numbering was suppressed via \begin{align*} to \end{align*} math environment.

The following is a sample output:

Output

Which was produced with the following code:

\documentclass[danish]{article}
\usepackage{babel}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{hyperref}

%\usepackage[color]{showkeys}
\mathtoolsset{showonlyrefs}

\setcounter{equation}{10}

\makeatletter
\newcommand*{\hv}[1]{%
    \refstepcounter{equation}%
    \ltx@label{EQ:#1}% Label%
    \stackrel{\mathclap{(\theequation)}}{=}%
}
\makeatother
\newcommand*{\fk}[1]{\item[\eqref{EQ:#1}]}

\begin{document}
We have
\begin{align*}
  \Delta y  &\hv{A} m(x_{0}+h) - m(x_{0})\\
            &\hv{B} \frac{f(x_{0}+h)}{g(x_{0}+h)} - \frac{f(x_{0})}{g(x_{0})}\\
            &\hv{C} \frac{f(x_{0}+h) \cdot g(x_{0})}{g(x_{0}+h) \cdot g(x_{0})} - \frac{f(x_{0}) \cdot g(x_{0}+h)}{g(x_{0}) \cdot g(x_{0}+h)}\\
            &= \dots
\end{align*}
Explanations:
\begin{enumerate}
  \fk{A} DESCA
  \fk{B} DESCB 
  \fk{C} DESCC
\end{enumerate}
\end{document}
share|improve this answer
    
Great; thanks a lot. –  Svend Tveskæg Jan 2 '13 at 16:44
    
My Pleasure.... –  Nicholas Hamilton Jan 2 '13 at 16:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.