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.

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.

share|improve this question
1  
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
2  
What would be wrong with something like \begin{equation}\label{1}...\end{equation}, and then Equation~\ref{1} can be found in \cite{} (or before the equation, maybe)? –  T. Verron Nov 14 '12 at 23:56
1  
@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. –  Tbbe Jun 19 at 19:54

2 Answers 2

up vote 20 down vote accepted

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}
\addbibresource{biblatex-examples.bib}
\begin{document}
From the famous inequality math relation~\cite{companion}
\begin{equation}
  y \neq x
\end{equation}
%
Or you can also say:
\begin{equation}
  y \neq x
\end{equation}
as proved by~\cite{companion} 
\printbibliography
\end{document}

enter image description here

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 :-))

share|improve this answer
1  
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
2  
Equations are equations - Don't put something else inside :-): except punctuation marks maybe. Touchy topic :D –  anderstood Jun 17 at 20:59
1  
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}
\addbibresource{biblatex-examples.bib}

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

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

Result

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}
\addbibresource{biblatex-examples.bib}
\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
  }%
}
\g@addto@macro\equation{%
  \let\org@cite\cite
  \let\cite\eqcite
}
\let\org@cite\cite
\makeatother

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

Result different lines

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}
\addbibresource{biblatex-examples.bib}
\usepackage{lipsum}

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

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

Result with citation below equation using \vadjust

share|improve this answer
    
Yes, that is very neat and use of LaTeX script at a level I'd never find out myself! –  Tbbe 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? –  Tbbe Jun 24 at 21:27
1  
@Tbbe See updated answer. –  Heiko Oberdiek Jun 24 at 21:35
    
It's just perfect! It also inspires me to learn more. –  Tbbe Jun 24 at 21:50

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.