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 would like to have multiple bibliographies (reference lists) as described in Airminded · Multiple bibliographies in LaTeX (TeX Frequently Asked Questions -- question label "multbib").

However, I'd like to use with a single .tex file, which would contain the bibliography database embedded, as in LaTeX/Bibliography Management: #1 Embedded system ...

Now, I want to use letter documentclass, for which the bibliography needs to be defined (Re: Environment thebibliography undefined when using letter)

So what I end up is with this example (code below, compiled with just pdflatex, no bibtex(which I'd like to avoid in this case)):

multibib-embedded.png

... obviously, something works (multibib recognized primary and secondary cites, assigning them number "1" as start) -- however I don't get two, separate primary and secondary list of references; would that be possible in this context? (doesn't have to be with multibib, but I'd like to avoid a separate .bib file and a bibtex call)

EDIT: I'd also like separate cite keys (i.e. rendered as [a1] and [b1]; not yet sure if multibib can do that; edit: no it cant, multibib.pdf says "You can also edit the .bbl files created by BibTEX and add 'a', 'b',. . . to the labels, but your changes will be overwritten by subsequent BibTEX runs." and recommends \cite[a]{key}) - how possible would that be?

 

The code is this:

\documentclass{letter}

% Environment thebibliography undefined when using letter: http://www.latex-community.org/forum/viewtopic.php?f=4&t=3359
\makeatletter
\setlength \labelsep {.5em}
\newcommand\newblock{\hskip
  .11em\@plus.33em\@minus.07em} \let\@openbib@code\@empty
\newcommand\refname{References}
\newcommand\section{\@startsection
  {section}{1}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\normalfont\Large\bfseries}}
\newenvironment{thebibliography}[1]
{\section*{\refname}%
  \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
  \list{\@biblabel{\@arabic\c@enumiv}}%
  {\settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin\labelwidth \advance\leftmargin\labelsep \@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}}%
      \endlist}
\makeatother

\usepackage{multibib}
\newcites{pri}{Primary sources}
\newcites{sec}{Secondary sources}

\begin{document}


\begin{letter}{Addressee}
Blah, blah - content...

Primary cite: \citepri{lamport94} ...

Secondary cite: \citesec{lamport94} ...


\begin{thebibliography}{9}

\bibitem{lamport94}
  Leslie Lamport,
  \emph{\LaTeX: A Document Preparation System}.
  Addison Wesley, Massachusetts,
  2nd Edition,
  1994.

\bibitem{lamport95}
  Leslie Lamport,
  \emph{\LaTeX: A Document Preparation System}.
  Addison Wesley, Massachusetts,
  2nd Edition,
  1995.

\end{thebibliography}

\end{letter}


\end{document}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

Under your keyword filter approach with biblatex, superficial adjustments to the labelnumber field (such as adding the suffix a or b and resetting the secondary entry count) can be made by redefining the labelnumber format. Here's an example.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[colorlinks=true,citecolor=red]{hyperref}
\usepackage[defernumbers=true]{biblatex}

\newcounter{bbx:primcount}
\setcounter{bbx:primcount}{0}

% Count number of  primary entries; expand labelnumberwidth
% to accommodate suffixes (NB: this might need tweaking when there
% are relatively many more secondary entries)
\makeatletter
\AtDataInput{%
  \ifkeyword{secondary}
    {}
    {\addtocounter{bbx:primcount}{1}%
     \blx@setlabwidth{\labelnumberwidth}{%
       \csuse{abx@ffd@*@labelnumberwidth}{\thefield{labelnumber}a}}}}
\makeatother

% Print labelnumbers with suffixes, adjust secondary labelnumber
\DeclareFieldFormat{labelnumber}{%
  \ifkeyword{secondary}
    {{\number\numexpr#1-\value{bbx:primcount}}b}
    {#1a}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Filler text \cites[10--15]{aristotle:anima}{aristotle:physics}.
Filler text \cite[23--25]{nussbaum}. Filler text \cite{hyman}.
\printbibheading
\printbibliography[keyword=primary,heading=subbibliography,title={Primary Sources (a)}]
\printbibliography[keyword=secondary,heading=subbibliography,title={Secondary Sources (b)}]
\end{document}

enter image description here

This solution assumes that all entries are assigned one of the keywords primary or secondary, but entries without the latter keyword can be treated as primary by replacing the filter keyword=primary with notkeyword=secondary.

The same problem but with prefixes to the labelnumber is relatively easy using the prefixnumbers option.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[colorlinks=true,citecolor=red]{hyperref}
\usepackage[defernumbers=true]{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document}
Filler text \cites[10--15]{aristotle:anima}{aristotle:physics}.
Filler text \cite[23--25]{nussbaum}. Filler text \cite{hyman}.
\printbibheading
\printbibliography[keyword=primary,heading=subbibliography,title={Primary Sources},prefixnumbers={A}]
\printbibliography[keyword=secondary,heading=subbibliography,title={Secondary Sources},prefixnumbers={B}]
\end{document}
share|improve this answer
    
Fantastic - thanks for that, @Audrey; it looks great with labelnumber like this :) Cheers! –  sdaau Sep 28 '11 at 16:47
    
Just a few notes to self: first, note both \ifkeywords refer to "secondary" ('primary' is not processed explicity); also, if you want to change the label display to, say, [A1] [B1] - then only the second \ifkeyword needs to be changed, i.e. '\ifkeyword{secondary} {B{\number\numexpr#1-\value{bbx:primcount}}} {A#1}'... Cheers! –  sdaau Sep 29 '11 at 21:36
    
Many thanks for those clarifications, @Audrey - cheers! –  sdaau Oct 4 '11 at 6:11

Hmm.. from Re: Biblatex package and multiple biliographies, I got that "Biblatex provides native support for multiple bibliographies.", and in that case multibib is not needed, and you can still have an inline file.

So, just with using biblatex (using example in 2905#2922), I managed to get - more or less - what I wanted (all in one file, no bibtex calls, split bibliographies):

biblatex-multi

... and here is the code:

\documentclass{letter}

\usepackage{biblatex} % tlmgr install biblatex etoolbox logreq
\usepackage{filecontents} % tlmgr install filecontents
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, urlcolor=blue}

% unicode characters
% note \usepackage[utf8x]{inputenx} breaks biblatex
%  with "Package biblatex Error: Incompatible package 'ucs'"
\usepackage[utf8]{inputenx} %

% letter doesn't have \section,\subsection, so:
\def\section*#1{#1}
\def\subsection*#1{#1}

\begin{filecontents}{\jobname.bib}
@article{Bli74,
  keywords = {primary},
  author = {Blinder, Alan S.},
  year = {1974},
  title = {The economics of brushing teeth},
  journaltitle = {Journal of Political Economy},
  volume = {82},
  number = {4},
  pages = {887--891},
}
@article{audactor2005pflanzen,
  keywords = {secondary},
  title = {Wie Pflanzen hören... die Geheimnisse der Sonobotanik},
  author = {Prof. Dr. Hortensia Audactor},
  journal = {Draft: \url{http://www.inventionen.de/vortrag_audactor.html}},
  year = {2005}
}
\end{filecontents}

\bibliography{\jobname}

% \usepackage{multibib} % incompatible


\begin{document}


\begin{letter}{Addressee}
Blah, blah - content...

Primary cite: \cite[\nopp a]{Bli74},

Secondary cite:  \cite[\nopp b]{audactor2005pflanzen}

\ \\

\hrule
\printbibheading
\hrule

\printbibliography[keyword=primary,heading=subbibliography,%
title={Primary Sources (a)}]
\printbibliography[keyword=secondary,heading=subbibliography,%
title={Secondary Sources (b)}]


\end{letter}
\end{document}

EDIT: note the use of keywords to split the bibliographies; The Biblatex Package pdf notes some other methods too.

share|improve this answer

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.