Document ClassesNatbib numerical mode problem

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
markcs
Posts: 2
Joined: Mon Jul 28, 2008 2:32 am

Natbib numerical mode problem

Post by markcs »

Hi all,

I'm using WinEdit and JabRef to write my thesis. Wanting to cite documents in Author,Year style.

Has been working fine but then *something* has changed and all my in-text citations have switched into numerical.

Reading the natbib documentation I discovered that if natbib can't produce an author,year citation it will switch to numerical mode. So I vetted all my citations and discovered some of them did not have a year or an author so I fixed those. Unfortunately this did not fix my problem.

Nothing obvious shows up in the log. No errors come up if I run bibtex from the command line.

The "references.bib" file is in the same directory as the main tex document. Relevant parts of the main document:

\usepackage[authoryear]{natbib}
\usepackage{graphicx,enumerate}
\bibliographystyle{apalike}

\bibliography{references}

Changing the bibliographystyle to say, plainnat, changes the in-text citations into square parentheses but doesn't change them back to author,date.

Any ideas would be greatly appreciated.

Thanks,

Mark.

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

Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Natbib numerical mode problem

Post by Ted »

markcs wrote:Changing the bibliographystyle to say, plainnat, changes the in-text citations into square parentheses but doesn't change them back to author,date.
Your problem typically occurs when the bibliography style file you use is not compatible with natbib.

When you changed your bibliogrpahy style to plainnat, were you sure to re-run bibtex after running latex once?

Can we have a look at a snippet out of your BBL file? In particular, what do the \bibitem lines look like? The optional argument is what stores what natbib uses to generate the in-text citations. IIRC, the format is something like...

Code: Select all

\bibitem[Short text form(year)Long text form]{bibkey}
and bibliography format after that. If that optional argument doesn't exist, then there's something wrong with your style file.

You're using the apacite bibliography style. Have you tried using the apacite package instead of natbib? Their documentation comments on apacite's compatibility with natbib (near the bottom of the doc, on page 39): Finally, if worse comes to worst, try generating your own natbib-compatible bibliography style using makebst. Execute:

Code: Select all

latex makebst
from anywhere on your system. Follow the prompts to design a bibliography style that works for you. It will be compatible with natbib, and so it shouldn't cause you any problems.
-- Ted [home/blog]
markcs
Posts: 2
Joined: Mon Jul 28, 2008 2:32 am

Re: Natbib numerical mode problem

Post by markcs »

Hi Ted,

I am pretty sure you are correct because I found in an aux file this line "\bibstyle{pub-unsrt}".

I'm using a custom-defined document class created by someone since left in my research centre. Part of it creates a list of the author's publications which appears in the introductory section of the thesis. If I comment out the command (macro?) in the main document which creates the list of publications the in-text citations in the rest of the document go back to the correct author,date format that I want.

I think the document class is using pub-unsrt as a style but I can't figure how to change it.

In any case, I'm just going to manually write out the publications list at the beginning of the thesis and not use the pre-defined macro for doing so.

Its not a great solution but it works and hopefully if someone comes across a similar problem in the future they can investigate style files.

Thanks,

Mark.
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Natbib numerical mode problem

Post by Ted »

markcs wrote:I am pretty sure you are correct because I found in an aux file this line "\bibstyle{pub-unsrt}".
Can you find pub-unsrt.bst somewhere on your system? If so, you might be able to generate your own (using latex makebst as discussed above) that matches and is compatible with natbib.
markcs wrote:I'm using a custom-defined document class created by someone since left in my research centre. Part of it creates a list of the author's publications which appears in the introductory section of the thesis. If I comment out the command (macro?) in the main document which creates the list of publications the in-text citations in the rest of the document go back to the correct author,date format that I want.
I had a similar problem with my thesis. I ended up doing the same thing you did. To generate the properly formatted entries, I copied the lines out of the BBL file that natbib/bibtex formatted for me. I recommend that you do the same.

Other options include using biblatex instead of natbib.
The biblatex package allows you to run "queries" on your bibliography database and dump the results to different parts of your document. It's not quite perfect yet, but it's ... close?
-- Ted [home/blog]
Post Reply