BibTeX, biblatex and biberTwo References Sections

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

I use Bibtex and Natbib to do my references, and I am wondering whether I can divide my references into 2 distinct sections using the same .bst and .bib files.

Basically, I want the document to appear as follows after it is compiled:

1. Article
2. References for Article
3. Appendix
4. References for Appendix

Currently, I can get the article to format as:

1. Article
2. Appendix
3. References for both

or

1. Article
2. References for both
3. Appendix

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Two References Sections

Post by 5gon12eder »

This is not exactly, what you had in mind, but you can use the bibtopic package to produce independent bibliographies from two *.bib files. This might help you somewhat.

The other solution I can think of is to compile the appendix as a separate document and then either merge the PDFs or \input the bibliography.
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

Dear 5gon12eder,

I really appreciate your response and your taking the time to help me. Neither solution is quite what I have in mind, however. At least that's what I think unless I am operating under some wrong assumptions.

As I wrote before, I am wondering whether I can produce from 1 Latex document 2 reference sections using only 1 .bib file. So that would already knock off the first solution, which requires using 2 .bib files (though not the worst thing to do.)

My concern with the second solution is how that will affect using hyperref. I suppose I can always just mannually update the page count in the second latex document by setting the page counter, right? However, I'm worried that merging the 2 .pdf files will mess up the hyperref. Are you suggesting using Adobe Professional for that?

Please let me know if I am misunderstanding what you are saying or I am generally not correct in how I'm thinking about Bibtex. My deepest apologies if that is the case.

Again, I really appreciate your thoughts on the subject.
5gon12eder wrote:This is not exactly, what you had in mind, but you can use the bibtopic package to produce independent bibliographies from two *.bib files. This might help you somewhat.

The other solution I can think of is to compile the appendix as a separate document and then either merge the PDFs or \input the bibliography.
5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Two References Sections

Post by 5gon12eder »

This issue is interesting for me as well so I did a little more research. I found the article at the UK TeX FAQ very helpful.

One solution would be to use the bibunits package. It allows you to define environments in your document that have all their own bibliographies. Unfortunately, hyperref doesn't seem to detect its citations and doesn't link them. Here is an example:

Code: Select all

\documentclass{article}
\usepackage{bibunits}
\usepackage{hyperref}

\title{A Document With Two Bibliographies}
\author{The Unreasonable Man}

\begin{document}
  \begin{bibunit}[plain]
    \maketitle
    \tableofcontents
    
    \section{The Art of Computer Programming}
    You can look this up in Knuth's famous books
    \cite{ArtCompProg1:2011,ArtCompProg2:1998,ArtCompProg3:2004}.
    
    \putbib[literature]
  \end{bibunit}
  
  \begin{bibunit}[plain]
    \appendix
    \section{Note on Sorting and Searching}
    Well, have a look at the book mentioned before \cite{ArtCompProg3:2004}.
    
    \putbib[literature]
  \end{bibunit}
  
\end{document}
Supposed this file is named bibunits.tex, run

Code: Select all

pdflatex bibunits
bibtex bu1
bibtex bu2
pdflatex bibunits
pdflatex bibunits
The other -- more flexible but also requiring somewhat more typing -- solution would be to use multibbl and it works with hyperref! Here is the same example:

Code: Select all

\documentclass{article}
\usepackage{multibbl}
\usepackage{hyperref}

\newbibliography{main}
\newbibliography{appendix}

\title{A Document With Two Bibliographies}
\author{The Unreasonable Man}

\begin{document}
  \maketitle
  \tableofcontents
  
  \section{The Art of Computer Programming}
  You can look this up in Knuth's famous books
  \cite{main}{ArtCompProg1:2011,ArtCompProg2:1998,ArtCompProg3:2004}.
  
  \bibliographystyle{main}{plain}
  \bibliography{main}{literature}{References}
  
  \appendix
  \section{Note on Sorting and Searching}
  Well, have a look at the book mentioned before \cite{appendix}{ArtCompProg3:2004}.
  
  \bibliographystyle{appendix}{plain}
  \bibliography{appendix}{literature}{References}
  
\end{document}
Now typesetting would be a matter of

Code: Select all

pdflatex multibbl
bibtex main
bibtex appendix
pdflatex multibbl
pdflatex multibbl
supposing the file is named multibbl.tex. I have attached the typeset example.

To try the examples, the following bibliography file, that should be named literature.bib may be used:

Code: Select all

@book{ArtCompProg1:2011,
  author = "Knuth, Donald E.",
  title = "The art of computer programming",
  volume = "1: Fundamental algorithms",
  publisher = "Addison-Wesley",
  address = "Reading, Mass.",
  year = "2011",
  edition = "3",
}

@book{ArtCompProg2:1998,
  author = "Knuth, Donald E.",
  title = "The art of computer programming",
  volume = "2: Seminumerical algorithms",
  address = "Reading, Mass.",
  publisher = "Addison-Wesley",
  year = "1998",
  edition = "3",
}

@book{ArtCompProg3:2004,
  author = "Knuth, Donald E.",
  title = "The art of computer programming",
  volume = "3: Sorting and searching",
  address = "Reading, Mass.",
  publisher = "Addison-Wesley",
  year = "2004",
  edition = "2",
}
I don't know about Adobe Professional as it is proprietary software but I'm almost certain that it will be able to join two PDFs preserving internal links. However, it might be difficult -- as you've already mentioned -- to get them point to the correct page number. My tool of choice to manipulate PDFs is pdftk. Anyhow, the TeXnical solution using either of the above packages is definitely more elegant.

Best
Attachments
multibbl.pdf
Typeset example using the multibbl package.
(82.38 KiB) Downloaded 1340 times
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

I do not know how to thank you enough! I am so very excited about working with it.

The second case is exactly what I would like to do. However, I have a few questions.

Primarily, I cannot understand what you mean by the following:
5gon12eder wrote:

Code: Select all

pdflatex multibbl
bibtex main
bibtex appendix
pdflatex multibbl
pdflatex multibbl
I work with TeXnicCenter and I executive files by doing Build -> Current File -> Build.

So I cannot understand how to run the code. What does it mean to do bibtex main and bibtex appendix? I thought that the bibtex files had a different name. I realize I am not doing anything for the 2 bibtex lines, and so I am not able to get the references to work.

Second, I have traditionally been using natbib. Does this replace that?

Lastly, I use a customized .sty file. Could I still incorporate it?
5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Two References Sections

Post by 5gon12eder »

Hello latexhelp1,

sorry for answering late.

The commands were meant to be run on a terminal. I don't know about TeXnicCenter. Maybe someone else here can help you how to get it invoke these commands. At least for testing you can invoke them by hand from the terminal.

bibtex is processing the aux files and the package makes LaTeX write different aux files for the different reference sections. You'll see it when you run latex on the document.

In a one-minute try I was able to use the plainnat citation style within the example to produce [Author (Year)] style citations without any further changes. However, loading the natbib package seems to be somewhat more tricky and I don't know if it will work at all. The problem is that both, natbib and multibbl redefine the \cite macro.

Best
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

I am so grateful for your help.

I normally do the Build file I talked to you about. That is the equilvalent of the pdflatex multibbl. And normally bibtex gets called/complied automatically in the process....

But that does not seem to the be the case now. I keep getting told "no file main.bbl" and "no file appendix .bbl" as warnings.

So I guess my question is how to I exceutive/run the bibtex main and bibtex appendix lines?
5gon12eder wrote: pdflatex multibbl
bibtex main
bibtex appendix
pdflatex multibbl
pdflatex multibbl
Best
Last edited by latexhelp1 on Sun Nov 13, 2011 11:35 pm, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Two References Sections

Post by localghost »

latexhelp1 wrote:[…] So I guess my question is how to I exceutive/run the bibtex main and bibtex appendix lines?
Steps 2 and 3 of the procedure that 5gon12eder has given have to be done on the command line. You should find the command line window (command prompt?) somewhere in your »Start« menu under »Tools« or so. If I remember right, you can also invoke it by pressing the key combination "Windows"+"R", then typing »cmd« and confirming with "Enter". If you are successful, a window with black background opens where there is a flashing cursor. There you type consecutively

Code: Select all

bibtex main
and

Code: Select all

bibtex appendix
and each time confirm with enter. BibTeX will generate the bibliographies for your main part and for your appendix. The rest has been explained by 5gon12eder.


Thorsten
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

Hello 5gon12eder (and anybody else),

I really like the second solution because I want to use hyperref! And thanks to localghost's earlier note, I am able to compile it! :)

However, I still have two questions.

1. I do not quite understand what you mean by plainnat. I am not sure how to cite within the text.

Currently, I use \usepackage{natbib}. And with that, in the text, I use \citet to cite like Author (Year), \citep to cite like (Author, Year), \citealp* for multiple citations, and \defcitealias{citation}{Citation)}\citepalias{citation} to customize the citation.

What are you saying I should do instead?

2. I have a customized .bst file that I must use for formatting the bibliography section. Currently I use \bibliographystyle{customized} for the customized.sty. When I try this with the new file, \bibliographystyle{main}{customized}, it does not work. It only works with \bibliographystyle{main}{plain}

How would I incorporate this new .bst?

I suspect that my .bst is based on using natbib, which is why I asked before about how to incorporate natbib...

Thank you very much for your help!

P.S. The following example suggests that it is possible to use natbib:
http://www.latex-community.org/forum/vi ... 09&start=0

I cannot understand how to modify it per your example, however. Yours I understand much better.
5gon12eder wrote:Hello latexhelp1,

In a one-minute try I was able to use the plainnat citation style within the example to produce [Author (Year)] style citations without any further changes. However, loading the natbib package seems to be somewhat more tricky and I don't know if it will work at all. The problem is that both, natbib and multibbl redefine the \cite macro.

Best
latexhelp1
Posts: 141
Joined: Sun Jun 12, 2011 6:30 am

Two References Sections

Post by latexhelp1 »

Not that I understand any of the following, but I figured out that using multibib but incorporating natbib features requires adding the following lines of code to the preamble:

Code: Select all

\makeatletter
\providecommand\@newciteauxhandle{\@auxout}
\def\@restore@auxhandle{\gdef\@newciteauxhandle{\@auxout}}
\AtBeginDocument{%
\@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}}
\makeatother
See: http://ctan.org/pkg/multibib

HOWEVER, I have NO idea how to use natbib with this syntax!! I just understand that the code will compile with these lines and yet they are required to do natbib like things (e.g. \citet, citep).

Any further help would be much appreciated!! I have tried to read the manual!! I promise :)
Post Reply