6

I would like to cite some sofware libraries I am using in a program using bibtex, but I can't quite figure out how to make that work properly. An entry might look like this:

@misc{CGAL,
  key   = "CGAL",
  title = "\textsc{Cgal}, {C}omputational {G}eometry {A}lgorithms {L}ibrary",
  note  = "http://www.cgal.org"
}

The problem is that @misc is not working optimally for me: Specifically the key (using \bibliographystyle{alpha}) is "CGA" instead of "CGAL", and I don't know how to fix that. Can I define my own style for citing software or can I at least change the key that is used for referencing?

5
  • I'm not sure I understand; have you directly downloaded the .bib citation file somewhere? I believe you are free to define your own citekey as it will not appear in the final document. It is just an internal reference for BibTeX.
    – Corentin
    Sep 10, 2013 at 20:52
  • I mean the key that does appear in the document: If I put \cite{CGAL} in my tex file, then the result is [CGA] and not [CGAL], which I would prefer
    – hfhc2
    Sep 10, 2013 at 20:57
  • Oh, I see, sorry for being so thick. I think the key that you enter in the .bib entry is not supposed to be the citekey which appears in the document, and which is generated by the BibTeX style that you choose: a number if you use unsrt for instance, or a combination of letters with alpha.
    – Corentin
    Sep 10, 2013 at 21:04
  • 2
    The problem with key is that it does not force the label (see tame the beast § 6.1, p. 13 "[key is] [u]sed for defining the label, in case it cannot be computed by BibTeX. It does not force the label, but defines the label when BibTeX needs one but can’t compute it."). Would you terribly mind using biblatex? biblatex provides shorthand (§ 2.2.2, p. 22: "This field is intended for citation aliasing. If defined, it overrides the default label.").
    – moewe
    Sep 11, 2013 at 10:11
  • I'd like to emphasize that, as noted by moewe, biblatex provides the shorthand key serving this purpose and easily fixing this issue.
    – ebosi
    Jun 9, 2017 at 20:09

1 Answer 1

1

You may want to load the natbib citation management package and use that package's \defcitealias macro to define, you guessed it, a "citation alias" of the form "CGAL". Then, use \citetalias{CGAL} instead of \cite{CGAL} to generate a citation call-out that uses the alias.

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@misc{CGAL,
  key   = "CGAL",
  title = {{CGAL, Computational Geometry Algorithms Library}},
  note  = "\url{http://www.cgal.org}",
}
\end{filecontents}

\documentclass{article}
\usepackage{natbib}
\defcitealias{CGAL}{CGAL}
\bibliographystyle{alpha}

\usepackage{geometry}
\usepackage{url,hyperref}
\hypersetup{colorlinks,citecolor=blue,urlcolor=red} % just for this example

\begin{document}
\noindent
\cite{CGAL} or \citetalias{CGAL} or [\citetalias{CGAL}]

\bibliography{mybib}
\end{document}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .