GeneralAny way to only show the authors last name when citing?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Monkey D
Posts: 22
Joined: Thu Nov 01, 2007 6:12 pm

Any way to only show the authors last name when citing?

Post by Monkey D »

I started making my bib database with the names as accurate as possible, but now that I'm using natbib authoryear mode things get a bit cluttered sometimes... E.g. when I have two authors and it gets displayed: <John K. Smith and Linux Pinguin Machina, 2008>
Is there any way to short it to: <Smith and Machina, 2008>


Thank you. :geek:

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

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Any way to only show the authors last name when citing?

Post by josephwright »

Can you post a short example of how you have your LaTeX source and an example BibTeX entry. For example, the following example works okay for me.

\documentclass{article}
\begin{filecontents}{test.bib}
@article{Test2008,
author = {A. N. Other and von Secondauthor, Longfirstname},
title = {Some things we wrote},
year = {2008},
journal = {J. Irrep. Res.},
volume = {111},
page = {1-2},
}
\end{filecontents}
\usepackage{natbib}
\begin{document}
Some text \cite{Test2008}.

\bibliographystyle{unsrtnat}
\bibliography{test}
\end{document}

Joseph Wright
Joseph Wright
Monkey D
Posts: 22
Joined: Thu Nov 01, 2007 6:12 pm

Any way to only show the authors last name when citing?

Post by Monkey D »

After lots of time testing I figured out where the problem is...

Using this in my bib:

Code: Select all

@ARTICLE{GOOD,
author = {{E}. {H}. {A}delson and {B}ergen, {J}ames {R}. },
title = {Some things we wrote},
year = {2008},
journal = {J. Irrep. Res.},
volume = {111},
page = {1-2},
}

@ARTICLE{BAD,
author = {{E}dward {H}. {A}delson and {J}ames {R}. {B}ergen},
title = {Some things we wrote},
year = {2008},
journal = {J. Irrep. Res.},
volume = {111},
page = {1-2},
}
And citing it:

Code: Select all

\citep{GOOD}
\par
\citep{BAD}.
This is the result:

Code: Select all

[Adelson and Bergen, 2008]
[Edward H. Adelson and James R. Bergen, 2008].


Conclusion: I would have to use commas to put the last name as the first one in my bib. Or replace the first names with the initial.


Now... what's the best way to solve this on a bib with about 200 refs.


Thank you.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Any way to only show the authors last name when citing?

Post by josephwright »

I think the issue is the braces in the names. For example, try

\documentclass{article}
\begin{filecontents}{test.bib}
@article{Test2008,
author = {Andrew N. Other and von Secondauthor, Longfirstname},
title = {Some things we wrote},
year = {2008},
journal = {J. Irrep. Res.},
volume = {111},
page = {1-2},
}

@article{Bad,
author = {Edward H. Adelson and James R. Bergen},
title = {Some things we wrote},
year = {2008},
journal = {J. Irrep. Res.},
volume = {111},
page = {1-2},
}
\end{filecontents}
\usepackage{natbib}
\begin{document}
Some text \cite{Test2008,Bad}.

\bibliographystyle{unsrtnat}
\bibliography{test}
\end{document}

and see that everything works. I'd suggest using something like JabRef to open and re-save your database. It allows you to specify which fields have braces added to capital letters. I've never seen a style that case-changes names, so I suspect the extra braces here are not needed. Usually, it would only be corporate names that need braces, such as "{Person and Sons}".

Joseph Wright
Joseph Wright
Monkey D
Posts: 22
Joined: Thu Nov 01, 2007 6:12 pm

Re: Any way to only show the authors last name when citing?

Post by Monkey D »

Yes, you are right. It's the braces around each inicial.
I'm using Jabref and it was it that put those braces.

I've looked on how to remove them but didn't find anything. Where is that option?

Thank you very much.
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: Any way to only show the authors last name when citing?

Post by josephwright »

In JabRef:

Options -> Preferences -> File -> Store the following fields with braces around capital letters

This is just a semi-colon separated list: delete "author", and all should e fine once you save the file.

Joseph Wright
Joseph Wright
Monkey D
Posts: 22
Joined: Thu Nov 01, 2007 6:12 pm

Re: Any way to only show the authors last name when citing?

Post by Monkey D »

Thanks!
I must be getting blind :-/

That solved the problem :D
Post Reply