I'm trying to include the cite key in references. It works except when the cite key includes the "&" character - which will occur as the 6th, 7th or 8th character in the some cite key strings. A typical string including '&' is 2006A&A...448..955I Some cite keys (most) do not include an '&'.
The cite keys are 18 or 19 characters long. I want to be able to print the cite key in the reference and still include the '&' where it occurs.
Is it feasible to chop up and reassemble strings in Bibtex before outputting them?
Currently I have a line in my .bst file, in FUNCTION {article} (etc) that says (in simplified form):
cite$ output
This delivers the cite key string to the output, and, with a console error, the keys that contain '&', but with the & dropped.
I'm using Mac OS X, TexShop, Latex2e, the current Bibtex, and a Bibdesk database. I'm using the natbib package.
BibTeX, biblatex and biber ⇒ Parsing cite$ to replace "&" with "\&"
-
- Posts: 2
- Joined: Sun Oct 18, 2009 2:32 pm
Parsing cite$ to replace "&" with "\&"
Solved.
It needed the package xstring and a \newcommand macro in the Latex file, called from within Bibtex.
This is what I used in the Latex file:
And in the .bst file within the {article} function (etc):
May not be elegant (or even correct) but it works.
DN
It needed the package xstring and a \newcommand macro in the Latex file, called from within Bibtex.
This is what I used in the Latex file:
Code: Select all
\newcommand{\ampersandmacro}[1]{%
\IfSubStr{#1}{&}{\StrBefore{#1}{&}\&\StrBehind{#1}{&}}{[#1]}
}
Code: Select all
"\ampersandmacro{" cite$ *
"}" *
output
DN