Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The BibLaTeX documentation mentions a field authortype:

authortype field (key)

The type of author. This field will affect the string (if any) used to introduce the author. Not used by the standard bibliography styles.

I was wondering whether this was intended to and/or could be used to set definite article in front of citations automatically. Consider the following short text:

\documentclass{article}
\usepackage[style=numeric]{biblatex}
\bibliography{foo}
\begin{document}
\Textcite{soc} thinks pine trees are really bad off
while \textcite{guy} begs to differ.
\Citeauthor{guy} and \citeauthor{soc} both love pine trees though.

\printbibliography

\end{document}

with the following example .bib file:

@misc{soc,
author={{Pine Tree Society}},
title={On the Mistreatment of Pine Trees through the Ages},
authortype={body}
}

@misc{guy,
author={Woodman, Hans},
title={Pine Trees -- A Natural Success Story},
authortype={person}
}

What this currently gives me is this:

current result

What I would rather like to have is this:

desired result

Did anybody ever try something like this? Does anybody have any idea how to do this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Yes, you can. But it's the Wrong Thing to Do (!) because authortype has a different reason to exist: it's suppose to indicate the role of the author in relation to the work, like "redactor", and it's supposed to be printed, directly or as a bibstring That's why you get it in your bibliography. We could fiddle around clearing fields before printing the bibliography, but there must be a better way.

So let's not do that (though we could). Instead let's use an option that will say if an author is corporate. I've used "body", so one can set "body=true" or just "body". That way we don't have to worry about using for a "meta-" purpose something that is intended to be printed. We don't need a "person" option, because we can just assume that's the default. Options are a good way of communicating this sort of "meta" information, to be used in formatting but not printed.

Having done that we need to fiddle slightly with \textcite and \citeauthor to get them to print a definite article before the name of the author if the option "body" has been chosen. In each case in fact we are only changing one line to include a call to a command we have defined called \defarticle which uses internal punctuation tracking to decide whether to use a capital or not.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{soc,
author={{Pine Tree Society}},
title={On the Mistreatment of Pine Trees through the Ages},
options = {body},
}

@misc{guy,
author={Woodman, Hans},
title={Pine Trees -- A Natural Success Story},
}
\end{filecontents}
\usepackage[style=numeric]{biblatex}
\addbibresource{\jobname}
\newtoggle{isbody}
\DeclareEntryOption{body}[true]{%
  \settoggle{isbody}{#1}}

\newcommand\defarticle{%
  \iftoggle{isbody}{\ifcapital{The}{the}\space}{}}

\makeatletter
\renewbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\multicitedelim}
    {\cbx@tempa
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printtext{\defarticle}\printnames{labelname}}%
     \addspace\bibopenbracket}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \savefield{namehash}{\cbx@lasthash}%
  \gdef\cbx@tempa{\bibclosebracket\multicitedelim}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext{\defarticle}\printnames{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother
\begin{document}
\Textcite{soc} thinks pine trees are really bad off
while \textcite{guy} begs to differ.
\Citeauthor{guy} and \citeauthor{soc} both love pine trees though.


\printbibliography

\end{document}

enter image description here

share|improve this answer
    
Wow, great! Thanks for explaining the true meaning of authortype and proposing an alternative solution :) –  Christian Jul 7 '12 at 11:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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