2

The biblatex package comes with a bunch of example files. One of them is called 18-numeric-hybrid.tex. It contains the following text:

We define a dedicated citation command for online references which uses numerical labels instead of the author-year scheme. Instead of defining a dedicated command, it is also possible (and usually preferable) to build smart citation commands which are able to switch citation styles depending on the entry type (or other criteria).

Can anyone give me a hint how I can implement such a smart citation command the best way?

1
  • 1
    Most of the example documents were written by Philipp Lehman, who has sadly been MIA since late 2011. It's hard to tell exactly what he had in mind. Here I integrate numeric labels via the shorthand field. The OP designated numeric labels via the keywords field, but you can make the approach entrytype-specific by using the \ifentrytype test in place of \ifkeyword.
    – Audrey
    Aug 25 '13 at 19:50
2

First of all I think Audrey is right in saying that one can only guess what the creator of the mentioned file has meant by "smart citation commands".

The link - Audrey posted - kind of helped me to come up with this MWE (please note, that my example is based on the idea of an hybrid style such as described in the 18-numeric-hybrid.tex example file of the biblatex package):

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[
    style=alphabetic,
    labelnumber,
    defernumbers,
    backend=biber,
]{biblatex}
\addbibresource{test.bib}

\begin{filecontents}{test.bib}
@BOOK{Author2001,
  author = {Alastname1, Afirstname1},
  title = {Title},
  year = {2001},
}
@BOOK{Author2002,
  author = {Blastname1, Bfirstname1 and Blastname2, Bfirstname2},
  title = {Title},
  year = {2002},
}
@ONLINE{Online2001,
  author = {Olastname1, Ofirstname},
  title = {Test Website},
  year = {2001},
  url = {http://www.test.de},
  urldate = {2013-08-28},
}
@ONLINE{Online2002,
  author = {Olastname2, Ofirstname},
  title = {Test Website},
  year = {2002},
  url = {http://www.test.de},
  urldate = {2013-08-28},
}
\end{filecontents}

% Renew \cite command for entries of the type online
\renewbibmacro*{cite}{%
    \ifentrytype{online}{%
        \printtext[bibhyperref]{%
            \printfield{prefixnumber}%
            \printfield{labelnumber}}}{%
        \printtext[bibhyperref]{%
            \printfield{prefixnumber}%
            \printfield{labelalpha}%
            \printfield{extraalpha}}}}

% Setup "online" environment for sub-bibliography
\defbibenvironment{online}
    {\list{
        \printtext[labelnumberwidth]{%
            \iffieldundef{shorthand}{%
                \printfield{prefixnumber}\printfield{labelnumber}}{%
                \printfield{shorthand}}}}{%
            \setlength{\labelwidth}{\labelnumberwidth}%
            \setlength{\leftmargin}{\labelwidth}%
            \setlength{\labelsep}{\biblabelsep}%
            \addtolength{\leftmargin}{\labelsep}%
            \setlength{\itemsep}{\bibitemsep}%
            \setlength{\parsep}{\bibparsep}}%
    \renewcommand*{\makelabel}[1]{\hss##1}}
    {\endlist}
    {\item}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}


\begin{document}
Published source \cite{Author2002}. Online source \cite{Online2002}. Published source \cite{Author2001}. Online source \cite{Online2001}.

\printbibheading

\printbibliography[heading=subbibliography,title={Published Sources},nottype=online,omitnumbers]

\printbibliography[heading=subbibliography,title={Internet Sources},env=online,type=online,sorting=none]
\end{document}

MWE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.