John Stone
John Stone

Reputation: 715

biblatex for the unsrt style with super-compact-numeric in square brackets in latex or rmarkdown

My problem arises from here, with the help of @shafee and @samcarter_is_at_topanswers.xyz, where the demo .tex and .rmd are also supplied therein.

My idea is that I want to use biblatex other than natbib to get the same goals. There are several obstacles, since the default biblatex doesn't hold for the unsrt style with super-compact-numeric in square brackets. I try my best to solve them one by one.

the unsrt style (bibstyle)

From https://tex.stackexchange.com/questions/58152/ , we resort to style=trad-unsrt in biblatex-trad, i.e.

\usepackage[backend=bibtex,style=trad-unsrt]{biblatex}

the compact numeric (citestyle)

From https://tex.stackexchange.com/questions/61524, we resort to citestyle=numeric-comp in biblatex, i.e.

\usepackage[backend=bibtex,style=trad-unsrt,citestyle=numeric-comp]{biblatex}

the super style (citestyle; position-of-citation)

From https://tex.stackexchange.com/questions/355111/, we resort to autocite=superscript in biblatex, i.e.

\usepackage[backend=bibtex,style=trad-unsrt,citestyle=numeric-comp,autocite=superscript]{biblatex}

finally; current .tex and .rmd files

tex

\documentclass{article}

\usepackage[hidelinks]{hyperref}
\usepackage[backend=bibtex,style=trad-unsrt,citestyle=numeric-comp,autocite=superscript]{biblatex}
\addbibresource{ref.bib}

\newcommand{\citep}[1]{\autocite{#1}}

\begin{document}

statistics \citep{anderson2003introduction,efron2004least,hastie2009elements}

\printbibliography[heading=bibliography,title=References]
\nocite{*}

\end{document} 

rmd

---
output: 
  pdf_document:
    keep_tex: yes
    citation_package: biblatex
bibliography: ref.bib
biblatexoptions:
  - backend=biber
  - style=trad-unsrt
  - citestyle=numeric-comp
  - autocite=superscript
link-citations: yes
colorlinks: no
header-includes:
  - \newcommand{\citep}[1]{\autocite{#1}}
---

statistics [@anderson2003introduction; @efron2004least; @hastie2009elements]

\nocite{*}

question?

Both .tex and .rmd can compile smoothly and it is nearly successful, while the remaining one thing is that I don't know how to add square brackets to the super-compact-numeric citation. Btw, I also search for similar issues such as here, where the biblatex-ext therein maybe helpful. However, I don't know how to make compatible between biblatex-ext and biblatex-trad. Any other ways?

Upvotes: 3

Views: 1186

Answers (2)

You could use the chem-angew style:

\documentclass{article}

\usepackage[hidelinks]{hyperref}
\usepackage[style=chem-angew,autocite=superscript]{biblatex}
\addbibresource{ref.bib}

\newcommand{\citep}[1]{\autocite{#1}}


\begin{document}

statistics \citep{anderson2003introduction,efron2004least,hastie2009elements}

\printbibliography[heading=bibliography,title=References]
\nocite{*}

\end{document} 

enter image description here

Upvotes: 2

Normally you could redefine the \mkbibsuperscript macro to add the square brackets. Unfortunately rmarkdown for some inexplicable reasons delays loading the biblatex package until after the header includes, so one needs to hack a bit:

---
output: 
  pdf_document:
    keep_tex: yes
    citation_package: biblatex
bibliography: ref.bib
biblatexoptions:
  - backend=biber
  - style=trad-unsrt
  - citestyle=numeric-comp
  - autocite=superscript
link-citations: yes
colorlinks: no
header-includes:
  - \newcommand{\citep}[1]{\autocite{#1}}
  - \makeatletter\AtEndPreamble{\renewrobustcmd{\mkbibsuperscript}[1]{\unspace\allowhyphens\textsuperscript{[\begingroup\protected\long\def\mkbibsuperscript##1{\blx@warning{Nested superscript}\mkbibbrackets{##1}}#1\endgroup]}}}\makeatother
---

statistics [@anderson2003introduction; @efron2004least; @hastie2009elements]

\nocite{*}

enter image description here

Upvotes: 3

Related Questions