5

I’d like to have the superscript numbers for citation when using \autocite{} on top of the punctuation sign (comma or full stop only; obviously it won’t work properly with exclamation or quotation marks) instead of next to it. I saw that way of formatting superscript references at Siarhei Khirevich's site under the section Superscripts and punctuation and liked the look of the outcome.

What would be the best/easiest way—ideally without having to use a new command instead of \autocite—to achieve that? Bonus question: Is the same possible for the \footnote command and references thereof?

MWE

test.tex

\documentclass[parskip=half]{scrartcl}

\usepackage[autocite=superscript]{biblatex}
\addbibresource{test.bib}

\begin{document}

This is not the greatest example in the world---this is just a tribute.\autocite{A01}

The peculiar thing is this, my friend, the greatest example doesn't actually look anything like this one\autocite{B02}.

\printbibliography

\end{document}

test.bib

@book{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}

Output

Screenshot showing that reference number is next to full stop instead of on top

1 Answer 1

5

Here is a solution that uses the autopunct facilities of \autocite. Which means it can only be used for \autocite and not \footcite. It would not be too difficult to also do this for \footcite, but it would require more works in the internals (see also https://github.com/plk/biblatex/issues/733 - to be fair though, this solution already meddles with the internals enough). The code here works for autocite=superscript, but the same strategy could also be applied to autocite=footnote.

You can define which punctuation marks have subsequent footnotes moved with \DeclareFootnoteMovePunct. In the example below only . and , have their footnotes moved as defined with \DeclareFootnoteMovePunct{.,{,}}. The starred version \DeclareFootnoteMovePunct* resets the list of punctuation before adding the new ones while the unstarred \DeclareFootnoteMovePunct always appends its argument to the existing list.

The footnote is not moved the exact length of the punctuation mark but only 80% of it. You can adjust this value as you see fit.

\documentclass[parskip=half]{scrartcl}

\usepackage[autocite=superscript]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\newcommand*{\blx@fnpct@movefor}{}
\newcommand*{\DeclareFootnoteMovePunct}{%
  \@ifstar
    {\let\blx@fnpct@movefor\@empty}
    {}
  \blx@def@fnpct@movefor}
\newcommand*{\blx@def@fnpct@movefor}{%
  \def\do##1{\blx@thecheckpunct{\listadd{\blx@fnpct@movefor}}##1}%
  \docsvlist}

\DeclareFootnoteMovePunct{.,{,}}

\newlength{\blx@fnpct@movelength}
\newcommand*{\blx@fnpct@footnotemover}[1]{%
  #1%
  \ifinlist{#1}{\blx@fnpct@movefor}
    {\settowidth{\blx@fnpct@movelength}{#1}%
     \hspace{-.8\blx@fnpct@movelength}}
    {}%
}

\protected\csedef{blx@acitei@superscript}#1#2#3#4#5{%
  \begingroup
  \blx@citeinit
    \noexpand\blx@fnpct@footnotemover{#5}%
    \blxcitecmd{supercite#1}{#2}{#3}{#4}{}%
  \endgroup}%
\protected\csedef{blx@macitei@superscript}#1#2#3{%
  \noexpand\blx@fnpct@footnotemover{#3}%
  #1{#2}%
  \endgroup}
\makeatother


\begin{document}
Lorem\autocite{sigfridsson}.

Ipsum\autocite{nussbaum,worman}.

Lorem\autocite{sigfridsson}, ipsum.
Dolor\autocite{sigfridsson}!

Lorem\autocite{worman} ipsum dolor sit amet. Ipsum\autocite{nussbaum}foo.

\printbibliography
\end{document}

enter image description here

You must log in to answer this question.

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