2

I'm using a lot of articles from multi-volume encyclopedias in my work. To this end, I've set the articles up using the crossref attribute in the bibliography file. The citation style used is authoryear-icomp which is fine, basically.

To cite an encyclopedia article I use (\citetitle[\emph{ML:}][]{ml:thermoskanne}) at the moment, with the result being:

(ML: Thermoskanne)

Instead I'd love to be able to say something like \parencitetitle{ml:thermoskanne} instead and automagically get this (with Biblatex looking at both the @incollection as well as the @mvcollection:

(ML:Thermoskanne)

with the initial letters extracted from the @mvcollection's title attribute and without a space. Is there a Biblatex command you can use for something like this, or if not, how could a new command be programmed?

Edit: here's a full MWE using cfr's answer, which seems to work perfectly!

\documentclass{scrartcl}

\usepackage{csquotes}
\usepackage{polyglossia}
\setmainlanguage[spelling=new]{german}

% example bib file

\begin{filecontents}{test.bib}
  @mvcollection{ml,
    title = {Müllers Lexikon},
  }

  @incollection{ml:thermoskanne,
    crossref = {ml},
    title = {Thermoskanne},
    volume = {2},
  }
\end{filecontents}

\usepackage[backend=biber,citestyle=authoryear-icomp]{biblatex}
\addbibresource{test.bib}

% no quotes, italic font instead

\DeclareFieldFormat*{citetitle}{\emph{#1}}

% cfr's first suggestion

\usepackage{xparse}
\NewDocumentCommand \parencitetitle { > { \SplitArgument { 1 } { : } } m }
{%
  \myparencitetitle #1}
\NewDocumentCommand \myparencitetitle { m m }
{%
  \parentext {\mkbibemph{\MakeUppercase{#1}}:\citetitle{#1:#2}}}

% some sample text, etc.

\begin{document}

Some things need to be said, some things need to be written. One place to put them in is an encyclopedia.
This is what it should look like, just without the space: (\citetitle[\emph{ML:}][]{ml:thermoskanne}).
And this is what it looks like right now: \parencitetitle{ml:thermoskanne}.

Wow! It already works!

\printbibliography

\end{document}
  • Welcome! This won't solve the problem but it might be better to use @inreference etc. here. – cfr Jul 27 '15 at 22:15
  • Thank you! And yes, I'd love to do that, but have problems getting Better BibTeX to in turn convince Zotero to change the reference type. On the other hand it probably doesn't matter much since, according to the BibLaTeX manual, "the standard styles will treat this entry type as an alias for @mvcollection." – Rainer Verteidiger Jul 27 '15 at 22:18
  • Yes. But it will be a pain if you later need a non-standard style which treats them differently. – cfr Jul 27 '15 at 22:57
  • It would be helpful if you'd post a Minimum Working Example people can fiddle with in trying to come up with a solution. – cfr Jul 27 '15 at 22:58
  • Regarding @mvcollection vs. @mvreference: 9 days left to go on the thesis, no change of bibliography style wanted at this point ;). Regarding the MWE: Where should I even start? I do know some things about using LaTeX, but I'm not sure if this problem here might not require real programming work. If you mean that I should make the example code I've shown into an MWE, I'll happily do that, but it doesn't actually do anything, right? – Rainer Verteidiger Jul 27 '15 at 23:12
2

If we use @inreference to properly distinguish reference works, we can then use \ifentrytype{inreference}. Additionally, I would add the two letters ML as shorthand to ml.

@mvreference{ml,
  title = {Müllers Lexikon},
  shorthand = {ML},
  options = {skipbib},
}

@inreference{ml:thermoskanne,
  crossref = {ml},
  title = {Thermoskanne},
  volume = {2},
}

Here I also added skipbib to ml, such that it is not shown in the bibliography, you can of course get rid of that.

Then we define the bibmacro for citations to treat @inreferences differently

\makeatletter
\renewbibmacro*{cite}{%
\ifboolexpr{test {\ifentrytype{inreference}} and not test {\iffieldundef{crossref}}}
  {\entrydata{\thefield{crossref}}{%
     \printfield[citetitle]{shorthand}}%
   \setunit{\addcolon}%
   \usebibmacro{cite:label}}%
  {%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
          {\usebibmacro{cite:label}%
           \setunit{\addspace}%
           \usebibmacro{cite:labelyear+extrayear}%
           \usebibmacro{cite:reinit}}
          {\iffieldequals{namehash}{\cbx@lasthash}
             {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                          \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
                {\setunit{\addcomma}%
                 \usebibmacro{cite:extrayear}}
                {\setunit{\compcitedelim}%
                 \usebibmacro{cite:labelyear+extrayear}%
                 \savefield{labelyear}{\cbx@lastyear}}}
             {\printnames{labelname}%
              \setunit{\nameyeardelim}%
              \usebibmacro{cite:labelyear+extrayear}%
              \savefield{namehash}{\cbx@lasthash}%
              \savefield{labelyear}{\cbx@lastyear}}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}}%
  \setunit{\multicitedelim}}
\makeatother

This is just a copy of authoryear-icomp.cbx plus a few modifications at the begin.

Since we use the crossref mechanisms we also need mincrossrefs=1.

MWE

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
  @mvreference{ml,
    title = {Müllers Lexikon},
    shorthand = {ML},
    options = {skipbib},
  }

  @inreference{ml:thermoskanne,
    crossref = {ml},
    title = {Thermoskanne},
    volume = {2},
  }
\end{filecontents*}

\usepackage[backend=biber,citestyle=authoryear-icomp,mincrossrefs=1]{biblatex}
\addbibresource{\jobname.bib}

% no quotes, italic font instead

\DeclareFieldFormat*{citetitle}{\emph{#1}}


\makeatletter
\renewbibmacro*{cite}{%
\ifboolexpr{test {\ifentrytype{inreference}} and not test {\iffieldundef{crossref}}}
  {\entrydata{\thefield{crossref}}{%
     \printfield[citetitle]{shorthand}}%
   \setunit{\addcolon}%
   \usebibmacro{cite:label}}%
  {%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
          {\usebibmacro{cite:label}%
           \setunit{\addspace}%
           \usebibmacro{cite:labelyear+extrayear}%
           \usebibmacro{cite:reinit}}
          {\iffieldequals{namehash}{\cbx@lasthash}
             {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                          \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
                {\setunit{\addcomma}%
                 \usebibmacro{cite:extrayear}}
                {\setunit{\compcitedelim}%
                 \usebibmacro{cite:labelyear+extrayear}%
                 \savefield{labelyear}{\cbx@lastyear}}}
             {\printnames{labelname}%
              \setunit{\nameyeardelim}%
              \usebibmacro{cite:labelyear+extrayear}%
              \savefield{namehash}{\cbx@lasthash}%
              \savefield{labelyear}{\cbx@lastyear}}}}}
    {\usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}}%
  \setunit{\multicitedelim}}
\makeatother

\begin{document}
And this is what it looks like right now \cite{ml:thermoskanne}.

\printbibliography

\end{document}

Output: ML:Thermoskanne

  • Given that this functions like one would expect a Biblatex cite command to work, I now accepted it, instead of @cfr's version (which hopefully, cfr won't be holding against me :)). What I find interesting (and a litlte frightening) about it is that the whole \cite command basically had to be repeated to be changed. – Rainer Verteidiger Jul 29 '15 at 15:06
  • @RainerVerteidiger I won't ;). – cfr Jul 29 '15 at 15:45
  • @RainerVerteidiger Well, in order to change the macro I had to copy it and make the necessary modifications. Unfortunately, the cite macro in authoryear-icomp.cbx is quite a chunk of code (if you had asked for a solution for authoryear.cbx, say, the solution would have been quite a bit shorter)- There are ways to change macros without copying the entire definition (the xpatch for example), but I didn't use that here. – moewe Jul 29 '15 at 15:57
  • @RainerVerteidiger Please note that initially I had forgotten to wrap the code in \makeatletter/\makeatother, which could lead to unwanted behaviour in some cases. The problem has now been fixed. – moewe Jul 29 '15 at 16:00
2

Try this but I can't test without a proper example and biblatex-examples.bib doesn't include anything suitable.

\usepackage{xparse}
\NewDocumentCommand \parencitetitle { > { \SplitArgument { 1 } { : } } m }
{%
  \myparencitetitle #1}
\NewDocumentCommand \myparencitetitle { m m }
{%
  \parentext {\mkbibemph{\MakeUppercase{#1}}:\citetitle{#1:#2}}}

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.