# Citing the source of an equation?

I cant find a good way of adding a \cite to an equation. I'd like to give a reference to the equation's source, but I can't figure out how to typeset it nicely. If I include it in with the equation itself, it pushes the alignment leftwards and feel too much like it's invading the equation's space. I've tried putting an \hfill\cite{example} on the line after the equation, but there's too much vertical space between the equation and the reference.

I'd love to know if there's a commonly accepted way of doing this that I haven't managed to find. Failing that, if anyone has any not-too-inelegant compromises, that'd be great too.

-
Welcome to TeX.SE! It would be also great if you canadd a minimal working example (MWE) that illustrates your problem. – percusse Nov 14 '12 at 23:49
What would be wrong with something like $$\label{1}...$$, and then Equation~\ref{1} can be found in \cite{} (or before the equation, maybe)? – T. Verron Nov 14 '12 at 23:56
@Tbbe: you can always use the marginnote package. Compare this question‌​. – canaaerus Jun 19 at 9:45
Thank you @ canaaerus it could be a solution! I'll dig deeper into marginnote and see what it can. – Tbb Jun 19 at 19:54

You shouldn't add the references inside the equation IMO, but outside as in this code:

% arara: pdflatex: {synctex: yes}
% arara: biber
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: yes}
%
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\begin{document}
From the famous inequality math relation~\cite{companion}
$$y \neq x$$
%
Or you can also say:
$$y \neq x$$
as proved by~\cite{companion}
\printbibliography
\end{document}


Thus leaving equations to themselves. This reduces the confusion between the parameters and the citation number. (Equations are equations - Don't put something else inside :-))

-
Fair enough - I wasn't sure if there was a commonly-accepted way to incorporate the reference into the equation line, but if not, then that'll have to do. Thanks very much! – TroyHurts Nov 18 '12 at 19:17
Equations are equations - Don't put something else inside :-): except punctuation marks maybe. Touchy topic :D – anderstood Jun 17 at 20:59
I would write the second reference as as proved in Ref.~\cite{companion}. or as proved by~\citeauthor{companion}.. Oh, and add punctuation to the equations. – Jost Jun 20 at 9:35

The following solution only works for the standard environment equation without package amsmath. It stores the cite command in macro \@eqcite, which is then set left to the equation number:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}

\makeatletter
\newcommand*{\eqcite}[1]{%
\def\@eqcite{\org@cite{#1}}%
}
\let\@eqcite\@empty
\def\@eqnnum{%
{%
\normalfont
\normalcolor
\ifx\@eqcite\@empty
\else
\@eqcite\space
\fi
(\theequation)%
}%
}
\let\org@cite\cite
\let\cite\eqcite
}
\let\org@cite\cite
\makeatother

\begin{document}
The famous inequality math relation:
$$y \neq x \cite{companion}$$
\printbibliography
\end{document}


The MWE is based on Harish Kumar's answer.

# Different lines

As requested in the comment, a version with the equation number and citation on different lines. IMHO, also this does not look better. The implementation can be done via a tabular. The optional argument controls the vertical alignment of the two lines with respect to the base line of the equation.

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{lipsum}

\makeatletter
\newcommand*{\eqcite}[1]{%
\def\@eqcite{\org@cite{#1}}%
}
\let\@eqcite\@empty
\def\@eqnnum{%
{%
\normalfont
\normalcolor
\ifx\@eqcite\@empty
(\theequation)%
\else
\begin{tabular}[t]{@{}r@{}}(\theequation)\\\@eqcite\end{tabular}%
\fi
}%
}
\let\org@cite\cite
\let\cite\eqcite
}
\let\org@cite\cite
\makeatother

\begin{document}
The famous inequality math relation:
$$y \neq x \cite{companion}$$
\lipsum[2]
\printbibliography
\end{document}


# Citation in line below with \vadjust

In the previous example, the equation moves to the left, because the available space is reduced by the longer citation in the author/year style.

\llap could be used for the citation, but the risk for overprinting the equation is much too large. The following example puts the citation below the equation via \vadjust. Again it only works for LaTeX without package amsmath:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{lipsum}

\newcommand*{\eqcite}[1]{%
\smallskip
\hbox to \linewidth{\hfill\cite{#1}}%
}%
}

\begin{document}
The famous inequality math relation:
$$y \neq x \eqcite{companion}$$
\lipsum[2]
\printbibliography
\end{document}


-
Yes, that is very neat and use of LaTeX script at a level I'd never find out myself! – Tbb Jun 24 at 20:13
Sorry to ask for more, but is there an easy way to update the macro and place equation number and citation on different lines? – Tbb Jun 24 at 21:27
@Tbbe See updated answer. – Heiko Oberdiek Jun 24 at 21:35
It's just perfect! It also inspires me to learn more. – Tbb Jun 24 at 21:50