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.

Often while writing papers I find the need to cite particular equations from other papers. For example, the landmark paper by Einstein, Newton, and White (2015) lays out the theory of everything in the equation immutably numbered 42. In some other paper I'd like to cite this equation by number, using exactly the same formatting that would be applied to \eqref from amsmath, whatever that may be. Essentially, I want to be able to say something like

One can see that \eqref{eq:my_above_equation} above is a specific case of
\pseudoeqref{42} from \citet{ENW2015}.

The two equation numbers should be typeset identically. I could just hard-code in the (admittedly simple) formatting, but this seems against the spirit of LaTeX, with the same formatting being done both automatically and manually in different places. It also occurred to me to create a ghost equation somewhere at the end of the document, manually set its number, and give it a normal \label{}, but this idea seems wrong on many levels.

Is there a simple solution for matching the format of eqref but with hard-coded equation numbers?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

It would be completely acceptable to create a macro that does all of that for you. That is, both set a \label and immediately \eqref it:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcounter{peqrefcntr}
\makeatletter
\newcommand{\pseudoeqref}[1]{{% \pseudoeqref{<whatever>}
  \refstepcounter{peqrefcntr}% Increment the pseudo \eqref counter (for uniqueness)
  \def\@currentlabel{#1}% Updated the label to be stored
  \label{peqref-\thepeqrefcntr}\eqref{peqref-\thepeqrefcntr}}}% \label and \ref
\makeatother
\begin{document}
\begin{equation}
  f(x) = ax^2 + bx + c \label{eq:my_above_equation}
\end{equation}
One can see that~\eqref{eq:my_above_equation} above is a specific case of~\pseudoeqref{42} from~XYZ.
\begin{equation}
  g(x) = ax^2 + bx + c
\end{equation}
Also see~\pseudoeqref{41} of~XYZ.
\end{document}

The above defines \pseudoeqref{<whatever>} that does an automated \label-\ref (requiring at least two compiles on the first run). The motivation for grouping the entire macro is to localize the effect of updating \@currentlabel; it may not be entirely necessary. Also, the use of \refstepcounter allows for an appropriate \phantomsection (or hyperlink anchor) if you plan on using hyperref.

With every call to \pseudoeqref, a unique label peqref-<num> is created, where <num> is stepped at every call.

share|improve this answer
add comment

Just look at the definition of \eqref in amsmath.sty:

\newcommand{\eqref}[1]{\textup{\tagform@{\ref{#1}}}}

Then it's easy to define your personal command in the preamble:

\makeatletter
\newcommand{\pseudoeqref}[1]{\textup{\tagform@{#1}}}
\makeatother

Complete example:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\pseudoeqref}[1]{\textup{\tagform@{#1}}}
\makeatother

\begin{document}
\begin{equation}

One can see that~\eqref{eq:my_above_equation} above is a specific
case of~\pseudoeqref{42} from~XYZ.

\end{document}
share|improve this answer
add comment

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.