Is it possible to define a LaTeX command that takes as input a citation
key and gives as output the section of the article, in which this key
appeared the first time (inside \cite{}
), i.e. where this given
reference was first referred to? (not using bibtex or biblatex)
2 Answers
I'm not sure about your use case, but here a starting point for you with package backref
. At least, it prints the number of section(s) where each bib.-item was cited after the item itself.
\documentclass[a4paper]{article}
\usepackage[ref]{backref}
\renewcommand*{\backref}[1]{}
\renewcommand*\backrefalt[4]{%
\ifcase #1 %
No citations.%
\or
One citation in section #2.%
\else
#1 citations in sections #2.%
\fi
}
\begin{document}
\section{First Section}
\cite{Rei91}
\section{Second Section}
\cite{CA}, \cite{MSW00}, \cite{Rei91}
\section{Third Section}
\cite{MSW00}, \cite{Rei91}
\section{Fourth Section}
\cite{CA}, \cite{MSW00}, \cite{Rei91}
\begin{thebibliography}{99}
\bibitem{HB98} Huynen, M.~A. and Bork, P. 1998. Measuring genome
evolution. {\itshape Proceedings of the National Academy of Sciences
USA} 95:5849--5856.
\bibitem{CA} Caprara, A. 1997. Sorting by reversals is difficult. In:
{\itshape Proceedings of the First Annual International Conference
on Computational Molecular Biology (RECOMB 97),} New York: ACM.
pp. 75--83.
\bibitem{MSW00} McLysaght, A., Seoighe, C. and Wolfe, K.~H. 2000. High
frequency of inversions during eukaryote gene order evolution. In
Sankoff, D. and Nadeau, J.~H., editors, {\itshape Comparative
Genomics}, Dordrecht, NL: Kluwer Academic Press. pp. 47--58.
\bibitem{Rei91} Reinelt, G. 1991. {\itshape The Traveling Salesman -
Computational Solutions for TSP Applications.} Berlin: Springer
Verlag.
\end{thebibliography}
\end{document}
-
The case is, that a book contains a bibliography after each section. To avoid repeating printing references again, it would be useful to say that you can find the reference in the bibliography of this section. An example: You have a citation
\cite{MSW00}
in section 2. You cite it again in a later section, and you can then cite it as, let's say [2.3] (third reference in section 2).– MoppeFeb 26, 2016 at 11:13
A colleague had a solution for the problem:
\documentclass[a4]{article}
\makeatletter
\renewcommand\@bibitem[1]{\item\if@filesw\immediate\write\@auxout
{\string\bibcite{#1}{\theenumiv}}\fi\ignorespaces}
\renewenvironment{thebibliography}[1]
{\section*{\refname}% %% use \bibname instead of
% %% \refname if using the
% %% report or book document classes
\@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
\list{\@biblabel{\the\c@section.\@arabic\c@enumiv}}%
% %% ^^ added \the\c@section
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\advance\leftmargin\labelsep
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty`
\renewcommand\theenumiv{\the\c@section.\@arabic\c@enumiv}}%
% %% ^^ added \the\c@section
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist}
\makeatother
\begin{document}
\section{Foo}
Blah blah blah~\cite{cite1}, and see later~\cite{cite2}.
\begin{thebibliography}{99}
\bibitem{cite1} Foo bar.
\end{thebibliography}
\section{Bar}
Bleh bleh bleh~\cite{cite2}. And also~\cite{cite1}.
\begin{thebibliography}{99}
\bibitem{cite2} Baz bof.
\end{thebibliography}
\end{document}
thebibliography
environment?