3

I've seen Use BibTeX key as the cite key, and it's quite close to what I'm looking for, but doesn't quite make it - for a start I can't get biblatex to run over my document, and second

What I'm trying to achieve is for the reference list to display, instead of reference numbers (or author-year pairs, but I'm using the super natbib style) the key, as in \cite(key).

This is partly a debugging issue, hence the tag, but partly as I'm required to port some existing work to word. I have no influence over that requirement, and I've written something to parse the .tex (excluding equations), leaving me with the cite keys inline - hence I'd like get a references section I can copy into the word document for shared editing.

Edit - more detail on biblatex The error I see is:

! LaTeX Error: Command \bibhang already defined.
           Or name \end... illegal, see p.192 of the manual.

If I comment out \usepackage{natbib} in an attempt to fix that, I break some custom cite commands I added. Replacing those with a simple \cite allows it to compile.

The top answer linked above doesn't help much, new keys are generated, which is why I didn't put too much effort into getting it to run before.

Edit2: The following compiles, but generates new keys.

\documentclass[preview]{article} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{preview}
\usepackage[backend=bibtex,style=alphabetic,sorting=debug]{biblatex}
\usepackage{filecontents}


\begin{filecontents}{\jobname.bib}
@article{Jones_article1,
    author = {A. . Jones and C. D. Smith},
    title = {article1},
}
@article{Bloggs_article2,
    author = {E. F. Bloggs},
    title = {article title 2}
    journal = {Journal of stuff},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
foo\cite{Jones_article1} and bar\cite{Bloggs_article2}

\printbibliography
\end{document}

example of above code

Edit3: This doesn't run:

\documentclass[preview]{article} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{preview}
\usepackage[backend=bibtex,natbib=true,style=alphabetic,sorting=debug]{biblatex}
\usepackage{filecontents}

\DeclareFieldFormat{labelalpha}{\thefield{entrykey}}\DeclareFieldFormat{extraal??pha}{}

\begin{filecontents}{\jobname.bib}
@article{Jones_article1,
    author = {A. . Jones and C. D. Smith},
    title = {article1},
}
@article{Bloggs_article2,
    author = {E. F. Bloggs},
    title = {article title 2}
    journal = {Journal of stuff},
}
\end{filecontents}
\addbibresource{\jobname.bib}

%citenumns provides the reference number for a citation, not superscripted or bracketed
\makeatletter
\newcommand*{\citenumns}[2][]{%
  \begingroup
  \let\NAT@mbox=\mbox
  \let\@cite\NAT@citenum
  \let\NAT@space\NAT@spacechar
  \let\NAT@super@kern\relax
  \renewcommand\NAT@open{}%
  \renewcommand\NAT@close{}%
  \cite[#1]{#2}%
  \endgroup
}
\makeatother

\begin{document}
foo\cite{Jones_article1} and bar ref. \citenumns{Bloggs_article2}

%\bibliographystyle(super)
\printbibliography
\end{document}

instead giving

! LaTeX Error: \NAT@open undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.40 ...} and bar ref. \citenumns{Bloggs_article2}
7
  • 1
    Don't use biblatex and natbib: biblatex is incompatible with virtually all other bibliograpphy-related packages (but it incorporates their functionality and then some). An minimal example (or here) would still be helpful at this point.
    – jon
    Sep 18, 2013 at 13:49
  • @jon, that's why I didn't want to use biblatex. I now have something that might be an MWE using biblatex, even though I'd like to avoid it, because that breaks some of my other stuff. It will take a little while to reduce it though.
    – Chris H
    Sep 18, 2013 at 14:08
  • @jon, I probably won't use it again, I only meant there was no point in me uploading any code without it: the only example for me to start from used it, and I have no idea of the internals of bibtex or biblatex.
    – Chris H
    Sep 18, 2013 at 14:27
  • You are missing @lockstep's \DeclareFieldFormat{labelalpha}{\thefield{entrykey}}\DeclareFieldFormat{extraalpha}{} from this answer.
    – jon
    Sep 18, 2013 at 14:31
  • @Jon, I think you've cracked it - in removing the stuff that was breaking biblatex, that fell away.
    – Chris H
    Sep 18, 2013 at 14:33

1 Answer 1

2

If you want some (but not all!) natbib functionalities add the option natbib or natbib=true (the same) to the call of biblatex.

To change the keys in your resulting list you missed to add \DeclareFieldFormat{labelalpha}{\thefield{entrykey}}\DeclareFieldFormat{extraal‌​pha}{} in your MWE. There is also a missing comma in your second bib entry.

Your macro \citenumbers is not working with biblatex.

The following MWE should run and help you:

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{Jones_article1,
    author = {A. . Jones and C. D. Smith},
    title = {article1},
}
@article{Bloggs_article2,
    author = {E. F. Bloggs},
    title = {article title 2},
    journal = {Journal of stuff},
}
\end{filecontents*}

\documentclass[preview]{article} 
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{preview}
\usepackage[%
  backend=bibtex
 ,style=alphabetic
 ,sorting=debug
 ,natbib             % to add some natbib functions, nou all!
]{biblatex}
% change key in bib list
\DeclareFieldFormat{labelalpha}{\thefield{entrykey}}\DeclareFieldFormat{extraalpha}{}

\addbibresource{\jobname.bib}


\begin{document}
foo~\cite{Jones_article1} and bar~\cite{Bloggs_article2}.

\printbibliography
\end{document} 

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