BibTeX, biblatex and biberNatbib square and numbers do not work

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
daavidb
Posts: 6
Joined: Mon Feb 21, 2011 3:38 pm

Natbib square and numbers do not work

Post by daavidb »

To be able to use the sort option I switched to natbib. Sort seems to work, but the style of citation was switched from numeric with square brackets to author-year with paranthesis. I tried using:

\usepackage[numbers,square,sort]{natbib}

..but I still see:

"Aldous and Fill (200X); Dembo et al. (2004)"

...instead of [1,2], which is what I want.

Here is an example .tex file:

Code: Select all

\documentclass{article}
\usepackage[numbers,square,sort]{natbib}

\begin{document}

\title{Natbib doesn't work}

\section*{0 Introduction}


See for instance \cite{DemboPeresEtAl-CoverTimesforBMandRWin2D,aldous-fill:book}.


\bibliographystyle{plainnat}
\bibliography{bibliography}

\end{document}
And here is the file bibliography.bib:

Code: Select all

@Book{ aldous-fill:book,
	Author = "David J. Aldous and James A. Fill",
	Title = "{Reversible {M}arkov Chains and Random Walks on Graphs}",
	Publisher = "Book in preparation, \texttt{http://www.stat.berkeley.edu/\char126aldous/RWG/book.html}",
	Year = "200X"
}


@Article{ DemboPeresEtAl-CoverTimesforBMandRWin2D,
	author = "Amir Dembo and Yuval Peres and Jay Rosen and Ofer Zeitouni",
	title = "{Cover times for Brownian motion and random walks in two dimensions.}",
	year = "2004",
	doi = "10.4007/annals.2004.160.433"
}
Attachments
natbibproblem.tex
(296 Bytes) Downloaded 312 times
bibliography.bib
(523 Bytes) Downloaded 333 times
Last edited by daavidb on Mon Feb 21, 2011 7:08 pm, edited 1 time in total.

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Natbib square and numbers do not work

Post by localghost »

Your example works fine for me as is. Did you test especially this code before asking?


Best regards and welcome to the board
Thorsten
daavidb
Posts: 6
Joined: Mon Feb 21, 2011 3:38 pm

Natbib square and numbers do not work

Post by daavidb »

localghost wrote:Source code in every form has to be tagged as such by using the »Code« environment of the forum software (see Board Rules, to be read before posting). This keeps a post clear and legible.
Fixed. Sorry about that.
localghost wrote: Your example works fine for me as is. Did you test especially this code before asking?
Just tried again and exactly that code yields the attached PDF file, which has "See for instance Aldous and Fill (200X); Dembo et al. (2004)." instead of the expected "See for instance [1,2]". You really get the latter? Could you attach your natbib.sty file to a message with exactly the commands you use to compile the file so I can try with that*?

David

* If I put your natbib.sty file in the directory of the .tex-file latex will use that instead of the pre-installed natbib, right?
Attachments
natbibproblem.pdf
(55.33 KiB) Downloaded 299 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Natbib square and numbers do not work

Post by localghost »

daavidb wrote:[…] You really get the latter? Could you attach your natbib.sty file to a message with exactly the commands you use to compile the file so I can try with that*? […]
Yes I did. But it is not necessary to attach the package file. Just add the \listfiles command as very first line to your example and search the log file for the list of used files.

Code: Select all

*File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
natbib-prblm.bbl
 ***********
So this might be a matter of an outdated package and you should update your TeX system. Works for me also with version 8.31a of the natbib package.
daavidb wrote:[…] * If I put your natbib.sty file in the directory of the .tex-file latex will use that instead of the pre-installed natbib, right?
That's correct. But also this version seems to be outdated on your machine.
daavidb
Posts: 6
Joined: Mon Feb 21, 2011 3:38 pm

Natbib square and numbers do not work

Post by daavidb »

localghost wrote:
daavidb wrote:[…] You really get the latter? Could you attach your natbib.sty file to a message with exactly the commands you use to compile the file so I can try with that*? […]
Yes I did. But it is not necessary to attach the package file. Just add the \listfiles command as very first line to your example and search the log file for the list of used files.

Code: Select all

*File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
natbib-prblm.bbl
 ***********
I have:

Code: Select all

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
  natbib.cfg
natbibproblem.bbl
 ***********
I seem to be using the exact same files except that I have natbib.cfg in there. Could this be messing things up?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Natbib square and numbers do not work

Post by localghost »

daavidb wrote:I have:

Code: Select all

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
  natbib.cfg
natbibproblem.bbl
 ***********
I seem to be using the exact same files except that I have natbib.cfg in there. Could this be messing things up?
This might be the culprit. But this file list alone doesn't help us in this case. I suggest to attach the complete log file to your next post by uploading it to the forum server. This way we can find out where »natbib.cfg« is located on your machine. The natbib manual mentions this file as option for general settings. So I assume that deleting this file will solve the problem.
daavidb
Posts: 6
Joined: Mon Feb 21, 2011 3:38 pm

Natbib square and numbers do not work

Post by daavidb »

localghost wrote:
daavidb wrote:I have:

Code: Select all

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
  natbib.sty    2010/09/13 8.31b (PWD, AO)
  natbib.cfg
natbibproblem.bbl
 ***********
I seem to be using the exact same files except that I have natbib.cfg in there. Could this be messing things up?
This might be the culprit. But this file list alone doesn't help us in this case. I suggest to attach the complete log file to your next post by uploading it to the forum server. This way we can find out where »natbib.cfg« is located on your machine. The natbib manual mentions this file as option for general settings. So I assume that deleting this file will solve the problem.
Problem solved!

Creating an empty natbib.cfg file in the directory of the tex-file solved it. There must be a bad natbib.cfg somewhere on my system (haven't found it yet), which was overriding the square option.

Thank you very much for the help localghost!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Natbib square and numbers do not work

Post by localghost »

daavidb wrote:[…] Creating an empty natbib.cfg file in the directory of the tex-file solved it. There must be a bad natbib.cfg somewhere on my system (haven't found it yet), which was overriding the square option. […]
That's why I asked for the complete log file. I think it's better to delete this configuration file in order to avoid future problems. The log file will allow us to find out where it is.

But now that the problem is solved, please mark the topic (not the last post) accordingly.
Post Reply