BibTeX, biblatex and biberAcronyms in references

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

Acronyms in references

Post by snowfrog »

Hi,

I use natbib, \bibliographystyle{apalike}.

When I reference websites from institutions in the text, I would like the acronyms of those institutions to show, for example
(NERC, 2009)
.

In my bibliography however, I would like the institution's full name to appear, e.g.
Natural Environment Research Council, 2009, etc...
I've tried to specify a new comand without success. At the start of my *.bib I have

Code: Select all

@preamble{"\def\shortref#1{}"}
then in the bib reference I have

Code: Select all

@misc{NERC09,
author = " Natural Environment Research Council\shortref{NERC}",
In the *tex file in the preamble I have

Code: Select all

\newcommand{\shortref}[1]{#1}
In the text I have tried

Code: Select all

\citep{NERC09}
or

Code: Select all

\shortref{NERC09}


but to no avail.

Could anyone tell me where I'm going wrong or simply another way?

Thanks!

Recommended reading 2024:

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

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

olofos
Posts: 56
Joined: Tue Nov 24, 2009 10:37 pm

Acronyms in references

Post by olofos »

You could use the alias functions of natbib:

Code: Select all

\documentclass{article}
\usepackage{natbib}

\usepackage{filecontents}

\defcitealias{NERC09}{NERC, 2009}

\begin{document}

\citepalias{NERC09}

\bibliographystyle{apalike}
\bibliography{test}

\begin{filecontents}{test.bib}
@Misc{NERC09,
  author = "Natural{ }Environment{ }Research{ }Council",
  year = 2009
}
\end{filecontents}

\end{document}
However, you then need to always use the \citepalias macro for this reference.
olofos
Posts: 56
Joined: Tue Nov 24, 2009 10:37 pm

Acronyms in references

Post by olofos »

I played a little with a hack to let you add a short hand name to use in a citation:

Code: Select all

\documentclass{article}
\usepackage{natbib}

\makeatletter
\def\setshort#1#2{%
\@ifundefined{b@#1}{}{%
\NAT@reset@parser%
\NAT@parse{#1}%
\expandafter\edef\csname old@b@#1\endcsname{\csname b@#1\endcsname}%
\expandafter\edef\csname b@#1\endcsname{{\NAT@num}{\NAT@date}{#2}{\NAT@all@names}}%
\AtEndDocument{\expandafter\edef\csname b@#1\endcsname{\csname old@b@#1\endcsname}}%
}}
\makeatother

\begin{document}

\setshort{NERC09}{NERC}

\citep{NERC09}

\citep*{NERC09}

\bibliographystyle{apalike}
\bibliography{test}

\end{document}
The shorthand is used by the \citep macro, while the original (full) name is used by \citep*. I have just tested it briefly so it's probably not very stable.
snowfrog
Posts: 38
Joined: Wed Jan 06, 2010 8:11 pm

Re: Acronyms in references

Post by snowfrog »

Thanks. I tried what you suggested in your second post but it didn't work for me. Possibly something I didn't apply right.

That said the alias function in the natbib package worked a treat. Thank you very much!
Post Reply