7

My question is related to this question (shameless copy pasta of MWE).

I would like to obtain the same citation style, so a \textcite that results in the author followed by a superscript reference. The standard for biblatex-nature however is a "full sized" reference

\documentclass{report}

\usepackage[style=nature]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{ABib.bib}
@article {article1,
 AUTHOR = {Author, A. N.},
 TITLE = {A sample paper},
 JOURNAL = {Sample journal},
 VOLUME = {1},
 YEAR = {2013},
 NUMBER = {1},
 PAGES = {1--2}}
\end{filecontents}

\addbibresource{ABib.bib}

\begin{document}
Someone saw something \autocite{article1}.

\textcite{article1} saw something.
\end{document}

However, the answer given on the previous linked question gives the following error when used in combination with the style=nature command;

! Package biblatex Error: Bibliography macro 'cite' undefined.

1 Answers1

6

Assuming you don't want 'auto-cite' magic, then

\makeatletter
\renewbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\usebibmacro{cite:comp}}
    {\usebibmacro{cite:dump}%
     \ifbool{cbx:parens}
       {\bibclosebracket\global\boolfalse{cbx:parens}}
       {}%
     \iffirstcitekey
       {}
       {\textcitedelim}%
     \usebibmacro{cite:init}%
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \addspace
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \mkbibsuperscript{\usebibmacro{cite:comp}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}}
\makeatother

will do the job. This works for any style derived from numeric-comp (which includes the nature style): the compressed style uses a multi-part approach to the citation numbers so the 'simple' solution does not apply.

Note that this approach does not move punctuation if the citation comes for example at the end of a sentence.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • This method doesn't work if you have multiple citations inside \textcite{article1, article2} (or \textcites{article1, article2}). It will print Author A and Author B then the first number in superscript, but will then print the delimiter and any subsequent reference numbers as normal text. – tmgriffiths Dec 14 '16 at 04:03
  • 1
    This solution works for me. I would like to add square brackets to the superscripted reference numbers. How can I do that? – Godey Jun 06 '18 at 07:53
  • 1
    I solved my issue by replacing these lines \mkbibsuperscript{% \bibopenbracket %added to get bracket[ \usebibmacro{cite:comp}% \bibclosebracket} % added to get bracket]. Don't know if it'll cause any other issues yet – Godey Jun 06 '18 at 08:49