8

I'm using biblatex-apa to define the layout of my bibliography. Now I'm citing several (internal) documents from institutions or news websites, which now appear in the document using their abbreviation. I would like to make these abbreviations appear in small caps. Actually, I want all abbreviated institutions to appear in small caps. Is this possible? I now split my bibliography using tags (exported from Zotero), so I assume a tag might also enable the citation to appear as small caps in the text? Anyone knows how to do this?

My MWE:

\documentclass[10pt,a4paper,twoside]{book}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=apa, date=year, natbib=true, sorting=nyt, sortcites=true]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\bibliography{Zotero}
\begin{document}
\chapter{Literature review}
This is some text with a double reference \cite{nos_weeralarm_2009, ns_volle_2013}.


\printbibliography[notkeyword=internal]
\printbibliography[title={Internal Documents}, keyword=internal]
\end{document}

And the content of my Zotero.bib:

@online{nos_weeralarm_2009,
title = {Weeralarm en verkeeralarm ingetrokken},
url = {http://nos.nl/l/124074},
titleaddon = {{NOS.nl}},
author = {{NOS}}, %THIS AUTHOR MUST BE PRINTED IN SC
urldate = {2014-02-12},
date = {2009-12-20},
keywords = {gladheid, ijs, ongeluk, openbaar vervoer, schiphol, sneeuw}
}
@report{ns_volle_2013,
location = {Utrecht},
title = {Internal document title}},
institution = {NS},
type = {Internal Document},
author = {{NS}}, % THIS AUTHOR MUST BE PRINTED IN SC
date = {2013},
keywords = {internal}
}
5
  • 4
    What part is the 'abbreviated institition'? It is easy to make the field institution appear in small caps, even on a per-type basis; e.g., \DeclareListFormat[report]{institution}{\textsc{#1}}, would make institution fields for entry type @report appear in small caps. If some reports need to not have the institution field appear in small caps, then it becomes a little more elaborate. – jon Mar 18 '14 at 17:53
  • For both entries it concerns the author field, since the author is the reference that appears in the text [example: (NOS, 2009) and (NS, 2013)]. Is there some kind of IF condition you can add to your suggestion? Then it might work! – Trappelaar Mar 18 '14 at 21:14
  • You mean [in pseudocode]: if keywords=internal, then \textsc{author}; else print author normally ..? – jon Mar 18 '14 at 23:09
  • Don't you want \textsc{\lowercase {#1}}? – cfr Mar 19 '14 at 2:49
  • jon, that is exactly what I mean. cfr, true, since the author is mostly in caps, without '\lowercase' the smallcaps won't make any sense. – Trappelaar Mar 19 '14 at 10:21
3

If all your citations that require a small caps institution do indeed have the same tag, then it should be possible.

In your MWE however, the two entries do not share a keyword, so I added the keyword instauth to check for.

What we do is very simple: At every citation command, and before every bibliography entry we check, if the entry has the keyword instauth, if so the last name format is set to produce acronyms via biblatex's \mkbibacro macro (note that for this to work "[t]he acronym should be given in uppercase letters.", p. 89, the biblatex documentation).

\AtEveryCitekey{%
  \ifkeyword{instauth}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibacro{#1}}}
    {}%
}
\AtEveryBibitem{%
  \ifkeyword{instauth}
    {\renewcommand*{\mkbibnamelast}[1]{\mkbibacro{#1}}}
    {}%
}

An alternative redefinition is the shorter

\renewcommand*{\mkbibnamelast}[1]{%
  \ifkeyword{instauth}
    {\mkbibacro{#1}}
    {#1}}

Where the conditional is inside the formatting directive. Then there is no need to hook the change into groups where \ifkeyword is defined, as was necessary above.

We can even make the detection of instauth automatic up to some point. With

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=author, match=\regexp{^\{.+?\}$}, final]
      \step[fieldset=keywords, append, fieldvalue={,instauth}]
    }
  }
}

all author fields that contain a string wrapped in double curly braces are classed as instauth. This might brake down in some corner cases - as do so many automatic solutions.

MWE

\documentclass[a4paper]{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\usepackage[backend=biber, style=apa, date=year, natbib=true, sorting=nyt, sortcites=true]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{filecontents*}{\jobname.bib}
@online{nos_weeralarm_2009,
title = {Weeralarm en verkeeralarm ingetrokken},
url = {http://nos.nl/l/124074},
titleaddon = {{NOS.nl}},
author = {{NOS}}, %THIS AUTHOR MUST BE PRINTED IN SC
urldate = {2014-02-12},
date = {2009-12-20},
keywords = {gladheid, ijs, ongeluk, openbaar vervoer, schiphol, sneeuw}
}
@report{ns_volle_2013,
location = {Utrecht},
title = {Internal document title},
institution = {NS},
type = {Internal Document},
author = {{NS}}, % THIS AUTHOR MUST BE PRINTED IN SC
date = {2013},
keywords = {internal},
}
\end{filecontents*}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=author, match=\regexp{^\{.+?\}$}, final]
      \step[fieldset=keywords, append, fieldvalue={,instauth}]
    }
  }
}

\renewcommand*{\mkbibnamelast}[1]{%
  \ifkeyword{instauth}
    {\mkbibacro{#1}}
    {#1}}


\begin{document}
This is some text with a double reference \cite{nos_weeralarm_2009, ns_volle_2013, wilde, cicero}.


\printbibliography[notkeyword=internal]
\printbibliography[title={Internal Documents}, keyword=internal]
\end{document}

enter image description here

1
  • Awesome! That is exactly what I meant. Thnx a lot :) – Trappelaar Mar 19 '14 at 10:29
0

Note: As of March 2016 (biblatex 3.3), you need to change \mkbibnamefamily instead of \mkbibnamelast. See also Biblatex 3.3 name formatting.

3
  • 1
    Mhhh, I don't know if it is a good idea to edit/answer all questions/answers on this site that mention \mkbibnamelast. But this creates a lot of noise. If people run into trouble we can point them to a canonical question. (Note also that the upcoming version of biblatex will have a backwards compatibility mode for \mkbibname... macros.) – moewe Mar 24 '16 at 16:08
  • fair enough. I just wasted an hour trying to figure out what's wrong with my old document and thought I'd help people avoid that. We'll see how often people will ask the question these days.... – Berry Mar 24 '16 at 16:11
  • Yes, the situation is a bit unfortunate. But a short search revealed that there are 158 mentions of \mkbinamelast alone. I don't think it is a good idea to edit all of them. As I said, if people come here to ask why things don't work we already have a question to point them to. – moewe Mar 24 '16 at 16:14

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.