2

How does one tag an equation with both words and numbers?

\documentclass{article}
\usepackage{mathtools}
\newenvironment{Dequation}
{%                                                                                  
  \def\tagform@##1{%                                                                
    \maketag@@@{\makebox[0pt][r]{(\ignorespaces##1\unskip\@@italiccorr)}}}%         
  \ignorespaces                                                                     
}
{%                                                                                  
  \def\tagform@##1{\maketag@@@{(\ignorespaces##1\unskip\@@italiccorr)}}%            
  \ignorespacesafterend                                                             
}
\makeatother
\begin{document}
\begin{Dequation}
\begin{align*}
3 &= 3\\
4 &= 4\\
6 &= 6\tag{since $x_0 = 0$}\label{six}
\end{align*}
\end{Dequation}
\end{document}

So I want to reference my equation, but I want the reference to be equation (1). Therefore, it would seem strange if the equation wasn't numbered if someone was looking for that reference.

4
  • Should you use the regular align environment instead of the * version? Then you would write in your document ... Equation \ref{six}... I think that's what you're asking. If not, can you make the question more clear?
    – darthbith
    Commented Aug 13, 2013 at 3:50
  • @darthbith if I specify a named tag, I won't have a number tag. I need both a name and a number (for refence) that doesn't look awkward.
    – dustin
    Commented Aug 13, 2013 at 4:12
  • In written form, authors should not do this. It is considered bad style. Either write it in the text, or use the method described by Andrew.
    – daleif
    Commented Aug 13, 2013 at 7:48
  • @dustin Hmm thanks for clarifying. Guess I misunderstand your intent!
    – darthbith
    Commented Aug 13, 2013 at 10:00

2 Answers 2

3

You should not be abusing \tag to set side comments. Just use an alignment to place them:

Sample output

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{alignat}{2}
3 &= 3&\qquad& \notag\\
4 &= 4&&\text{(since \( p \) is prime)} \notag\\
6 &= 6&&\text{(since \( x_0 = 0 \))}\label{six}
\end{alignat}

By equation~\eqref{six}\dots

\end{document}
2

Here is one, rather hackish, way to obtain this dual numbering/tagging label:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\newenvironment{Dequation}
{%                                                                                  
  \def\tagform@##1{%                                                                
    \maketag@@@{\makebox[0pt][r]{(\ignorespaces##1\unskip\@@italiccorr)}}}%         
  \ignorespaces                                                                     
}
{%                                                                                  
  \def\tagform@##1{\maketag@@@{(\ignorespaces##1\unskip\@@italiccorr)}}%            
  \ignorespacesafterend                                                             
}
\makeatother
\begin{document}

\refstepcounter{equation}\label{six}
\begin{Dequation}
\begin{align*}
3 &= 3\\
4 &= 4\\
6 &= 6\tag{since $x_0 = 0$\upshape{)\,(}\ref{six}}
\end{align*}
\end{Dequation}
See~\eqref{six}.
\end{document}

It's an easy way out, yet definitely viable means, to obtain the output. You manually step the relevant equation counter outside the Dequation environment and label it. Then use it in reference form as part of the \tag. Note that hyperref might not be happy with this approach.


A far more common approach to tagging and labelling is by setting the \tag as a descriptor (and thus part of the equation). Here's a way that doesn't affect the horizontal alignment:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\newenvironment{Dequation}
{%                                                                                  
  \def\tagform@##1{%                                                                
    \maketag@@@{\makebox[0pt][r]{(\ignorespaces##1\unskip\@@italiccorr)}}}%         
  \ignorespaces                                                                     
}
{%                                                                                  
  \def\tagform@##1{\maketag@@@{(\ignorespaces##1\unskip\@@italiccorr)}}%            
  \ignorespacesafterend                                                             
}
\makeatother
\newcommand{\eqcomment}[1]{\makebox[0pt][l]{\quad\upshape(#1)}}
\begin{document}

\begin{Dequation}
\begin{align}
3 &= 3 \nonumber \\
4 &= 4 \nonumber \\
6 &= 6 \eqcomment{since $x_0 = 0$}\label{six}
\end{align}
\end{Dequation}
See~\eqref{six}.
\end{document}

You must log in to answer this question.

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