# Bibliography with some specific entries, independently of the global bibliography

I have a long document with a (single) bibliography at the end. For some reason, at some point in the middle I cite 3 sources and I need to typeset their bibliography entries right there on the spot. How can I do that?

I'm using bibtex, but not biblatex. (For now.)

I'll also mention that those happen to be the only citations in a certain \chapter*, so a chapter-bibliography-based solution is relevant, though it's not exactly what I want.

This works if the cited sources appear also in the final bibliography; they will appear only when the complete bibliography has been produced, as we read the same .bbl file.

The command \partialcites takes as first argument the widest label (I'm afraid it would be quite difficult to compute it automatically) and as second argument the citation keys you need.

\documentclass{article}
\usepackage{xstring}

\makeatletter
\newcommand{\partialcites}[2]{%
\begingroup
\let\etalchar\@undefined
\def\thebibliography##1{%
\list{\@biblabel{\@arabic\c@enumiv}}%
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty thebibliography' environment}}%
}
\let\endthebibliography\endlist
\def\bibitem[##1]##2##3\par{\IfSubStr{,#2,}{,##2,}{\item[\cite{##2}]##3}{}}%
\@input{\jobname.bbl}%
\endgroup}
\makeatother

\begin{document}

\partialcites{AFKS00}{key1,key2}

\nocite{*}
\bibliographystyle{alpha}
\bibliography{mybib}

\end{document}


Limitation: the argument to \partialcites must have no spaces around the commas. The problem of substrings is actually very easy to solve.

• I'm using the alpha bibliography style, so my entries look like \bibitem[AFKS00]{AFKS}, newline, Noga Alon, Eldar Fischer etc. etc. – einpoklum Jan 19 '12 at 16:05
• Also, this needs to work with hyperref... well, trying to work on it a bit myself. – einpoklum Jan 19 '12 at 16:10
• This will work with hyperref. The "short bibliography" items will link to the final one, as we use \cite to typeset the label. – egreg Jan 19 '12 at 16:30
• Umm, I didn't say all my entries had AFKS00 at the beginning... I just tweaked your previous answer to have \bibitem[##1]##2##3 etc. and that worked. Why the complication? – einpoklum Jan 19 '12 at 16:40
• The first argument to \partialcites is just the largest label: with the previous solution you won't get a good alignment when the labels are wide. – egreg Jan 19 '12 at 16:46

You should use bibentry.sty, it's designed to do exactly what you want.

• This is really a comment, not an answer to the question. Please use "add comment" to leave feedback for the author. – percusse Aug 18 '12 at 9:34
• @percusse, what's wrong with my answer? It tells the OP how to solve the problem. There's no need to reinvent the wheel. Did I miss something in the problem that bibentry.sty does not handle straightforwardly? – alexis Aug 19 '12 at 20:06
• The problem is precisely that. If you check the answers on this site, rarely you would see one-liner pointers. Suppose I don't know what bibentry.sty is or where it is located, it's a style file is it on CTAN? I found it then what? Note also that this site is closely tracked by Google and many other not-so-proficient TeXers are also reading these stuff. Your answer can be revived by giving a simple demostration. This will also ensure that the solution is a tested one, just see the ones above. Thus, as it is your answer is a comment (more of a pointer) but not an answer. – percusse Aug 19 '12 at 20:20

egreg's early solution, with several tweaks/ideas/suggestions by egreg:

• Supporting 'alpha' style (and probably many others unlike plain).
• Allowing the command to be used after the main bibliography.
• A somewhat ugly hack supporting cite keys being substrings of each other.

\documentclass{article}
\usepackage{xstring}

\makeatletter
\newcommand{\partialcites}[1]{%
\begingroup
\let\etalchar\@undefined
\def\thebibliography##1{\begin{itemize}}%
\def\endthebibliography{\end{itemize}}%
% for plain style
%\def\bibitem##1##2\par{\IfSubStr{#1}{##1}{\item[\cite{##1}]##2}{}}%
\def\bibitem[##1]##2##3\par{\IfSubStr{,#1,}{,##2,}{\item[\cite{##2}]##3}{}}%
\@input{\jobname.bbl}%
\endgroup}
\makeatother
\begin{document}

\partialcites{AB,CD}

Now for a real cite. \cite{AB}. \cite{CD}.

%\nocite{*}
%\bibliographystyle{plain}
\bibliographystyle{alpha}
\bibliography{mybib}

\end{document}

• Of course such a definition will not work (the second \partialcites should be \partialcites@inner). However, it's sufficient to add the commas around the first argument to \IfSubStr. – egreg Jan 19 '12 at 22:09
• @egreg: Umm, yeah, I mis-copy-pasted. But - how would it be sufficient to add the commas around the first arg to \IfSubStr? The first and last keys are not surrounded by commas... – einpoklum Jan 19 '12 at 22:49
• In your macros, the first argument to \IfSubStr is #1, which is the argument to \partialcites@inner, which is just the argument to \partialcites with initial and final commas added. So it's sufficient to say \IfSubStr{,#1,}..., without \partialcites@inner, isn't it? See my edited answer. – egreg Jan 19 '12 at 22:54