| 1 |
% |
| 2 |
% This example demonstrates how hybrid citations, i.e., two |
| 3 |
% citations styles in a single document, may be implemented. |
| 4 |
% Note that the default styles which ship with bibatex do not |
| 5 |
% support hybrid citation schemes out of the box. This example |
| 6 |
% is merely a proof of concept. |
| 7 |
% |
| 8 |
\documentclass[a4paper,oneside]{article} |
| 9 |
\usepackage[T1]{fontenc} |
| 10 |
\usepackage[american]{babel} |
| 11 |
\usepackage[utf8]{inputenc} |
| 12 |
\usepackage{csquotes} |
| 13 |
% We use the authoryear style as a basis but we want numerical |
| 14 |
% labels for all online references. Therefore, we request numeric |
| 15 |
% labels by setting 'labelnumber=true'. We also set |
| 16 |
% 'defernumbers=true'. This will be required by the 'omitnumbers' |
| 17 |
% option used below. |
| 18 |
\usepackage[style=authoryear,labelnumber,defernumbers,backend=biber]{biblatex-ms} |
| 19 |
\usepackage{hyperref} |
| 20 |
\usepackage{nameref} |
| 21 |
\addbibresource{biblatex-examples.bib} |
| 22 |
|
| 23 |
% We define a dedicated citation command for online references which |
| 24 |
% uses numerical labels instead of the author-year scheme. Instead |
| 25 |
% of defining a dedicated command, it is also possible (and usually |
| 26 |
% preferable) to build smart citation commands which are able to |
| 27 |
% switch citation styles depending on the entry type (or other |
| 28 |
% criteria). It's just easier to demonstrate the point of the |
| 29 |
% 'omitnumbers' option this way: |
| 30 |
|
| 31 |
\DeclareCiteCommand{\citeonline}[\mkbibbrackets] |
| 32 |
{\usebibmacro{prenote}} |
| 33 |
{\usebibmacro{citeindex}% |
| 34 |
\printtext[bibhyperref]{% |
| 35 |
\printfield{labelprefix}% |
| 36 |
\printfield{labelnumber}}} |
| 37 |
{\multicitedelim} |
| 38 |
{\usebibmacro{postnote}} |
| 39 |
|
| 40 |
% The matching environment for the online sub-bibliography: |
| 41 |
|
| 42 |
\defbibenvironment{online} |
| 43 |
{\list |
| 44 |
{\printtext[labelnumberwidth]{% |
| 45 |
\iffieldundef{shorthand} |
| 46 |
{\printfield{labelprefix}% |
| 47 |
\printfield{labelnumber}} |
| 48 |
{\printfield{shorthand}}}} |
| 49 |
{\setlength{\labelwidth}{\labelnumberwidth}% |
| 50 |
\setlength{\leftmargin}{\labelwidth}% |
| 51 |
\setlength{\labelsep}{\biblabelsep}% |
| 52 |
\addtolength{\leftmargin}{\labelsep}% |
| 53 |
\setlength{\itemsep}{\bibitemsep}% |
| 54 |
\setlength{\parsep}{\bibparsep}}% |
| 55 |
\renewcommand*{\makelabel}[1]{\hss##1}} |
| 56 |
{\endlist} |
| 57 |
{\item} |
| 58 |
|
| 59 |
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}} |
| 60 |
|
| 61 |
\begin{document} |
| 62 |
|
| 63 |
\section*{Hybrid citations} |
| 64 |
|
| 65 |
\subsection*{Regular citations (author-year)} |
| 66 |
|
| 67 |
\cite{augustine}, |
| 68 |
\cite{bertram}, |
| 69 |
\cite{companion} |
| 70 |
|
| 71 |
\subsection*{Online citations (numeric)} |
| 72 |
|
| 73 |
\citeonline{ctan}, |
| 74 |
\citeonline{markey} |
| 75 |
|
| 76 |
% Let's print the overall heading of the bibliography first: |
| 77 |
\printbibheading |
| 78 |
|
| 79 |
% We set omitnumbers=true for the author-year sub-bibliography. |
| 80 |
% Without that, the first item of the online bibliography would be |
| 81 |
% labeled as "[4]". |
| 82 |
\printbibliography[heading=subbibliography,title={Printed References},nottype=online,omitnumbers] |
| 83 |
|
| 84 |
% The online sub-bibliography requires a different environment: |
| 85 |
\printbibliography[heading=subbibliography,title={Online References},env=online,type=online] |
| 86 |
|
| 87 |
\end{document} |