2

MWE:

\documentclass{book}
\usepackage{a4wide}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{polyglossia}
\setmainlanguage[spelling=new,babelshorthands=true]{german}
\usepackage[autostyle]{csquotes}
\usepackage[style=authortitle-icomp,backref=true,backrefstyle=two+,hyperref=true,isbn=false,backend=biber,citereset=chapter,bibencoding=utf8]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{file.bib}
@BOOK{b1,
  author = { first1 last1},
  title = {title1},
  year = {1993},
  note = {tt}
}
@BOOK{b2,
    author = { first2 last2},
    title = {title2},
    year = {1994}
}
\end{filecontents}

\addbibresource{file.bib}
\begin{document}
text \footcite{b1} text.
text \footcite{b2} haha. 
\end{document}

I want to achieve that the author of b1, which has some keyword in the note field, in this case tt, is formatted with \texttt{} while entries which don't have the keyword in the note field, are formatted in a standard way. There is nothing else in the note field than the keyword.

So, expanded it should give

\texttt{last1}, title1
last2, title2

in the footnotes as well as in the bibliography instead of this current result.

Thanks for the help.

Philipp
  • 887
  • You are looking for the \iffieldequalstr command. In the current version of the biblatex documentation it is in section 4.6.2 on page 182. – Willie Wong Sep 15 '15 at 19:21
  • If you can use the keyword field (which will not be printed, unlike the note field) you just need \ifkeyword{tt}. Alternatively you can use the options field but then you will have to do a bit more work to set things up nicely. What do you need this for in your document? Maybe there is an easier solution. – moewe Sep 15 '15 at 19:30
  • I just have a lot of anonymous sources which are formatted like author = {P/L/51-65/T} and want to use a monospace font for the author to line them all up nicely to be easier to read. – Philipp Sep 15 '15 at 19:32
  • OK, would using they keywords field be an option for you? Or do you prefer the note field? (That is do you want the output or not?) But maybe using an author field for anonymous sources such as this isn't the best idea in the first place ... – moewe Sep 15 '15 at 19:36
  • Ok but how do I actually do the formatting? in the preamble I guess. I'd have to read through the biblatex docs. Any biblatex pros here? – Philipp Sep 15 '15 at 19:36
  • keywords is fine – Philipp Sep 15 '15 at 19:37
  • Oh, didn't know. What's the best way for anonymous source. Would it change my problem? – Philipp Sep 15 '15 at 19:37
  • I'm not sure what your actual sources look like. There is always the option to leave the author field blank. What you seem to put there is some kind of call number (?), but then certain kinds of "archive material" can be hard to handle. – moewe Sep 15 '15 at 19:43
  • it's some kind of chiffre, with some info after every slash. sth like country/city/age/alphacode. the chiffre is explained in the text. – Philipp Sep 15 '15 at 19:49
  • If that in a way (uniquely) "identifies" an author (much like pseudonym) it is probably still suited for the author field. – moewe Sep 15 '15 at 20:06
  • @WillieWong Do you want to write up an answer? Maybe not only using \iffieldequalstr but also \ifkeyword (I find the latter cleaner in this situation). – moewe Sep 15 '15 at 20:07
  • Would it make sense to define a new type for such anonymous sources? Then you could define an author format for that type. – Alan Munn Sep 15 '15 at 20:27
  • whatever works, really. I can just search and replace book with [new type here] for my anonymous sources. – Philipp Sep 15 '15 at 20:32
  • found \DeclareFieldFormat[anonymous]{author}{\texttt{#1}\space}. How do I declare my new anonymous type? – Philipp Sep 15 '15 at 21:01
  • @Philipp Here's a fully worked out example that might help: Creating Entry in Bibtex for Executive Orders – Alan Munn Sep 15 '15 at 21:35
  • @moewe: go ahead. I don't have much time to write up a complete answer (hence the comment). I agree that \ifkeyword would be cleaner. After reading the comments I personally prefer Alan's option of creating a new entry type. But I can see situations where having the keyword based answer can be helpful (for example, multiple different keywords that can stack). – Willie Wong Sep 16 '15 at 01:03
  • For name-like fields, you cannot use \DeclareFieldFormat you need \DeclareNameFormat. But for changes in the font for names you will want to use \mkbibnamelast and friends. – moewe Sep 16 '15 at 09:20

1 Answers1

2

Depending on what you are trying to do here it might be a good idea to create a new entry type, see Creating Entry in Bibtex for Executive Orders and the slightly more involved How can I create entirely new data types with BibLaTeX/Biber?.

Changing the author font depending on the keywords field, which I think is better suited for this task than the note field, is not very hard

\renewcommand*\mkbibnamelast[1]{\ifkeyword{chiffreauthor}{\texttt{#1}}{#1}}

makes sure to print all entries with the keyword chiffreauthor in a typewriter font.

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage[autostyle]{csquotes}
\usepackage[style=authortitle-icomp,backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@BOOK{b1,
  author   = {first1 last1},
  title    = {title1},
  year     = {1993},
  keywords = {chiffreauthor},
}
@BOOK{b2,
    author = { first2 last2},
    title  = {title2},
    year   = {1994}
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\renewcommand*\mkbibnamelast[1]{\ifkeyword{chiffreauthor}{\texttt{#1}}{#1}}

\begin{document}
text \footcite{b1} text.
text \footcite{b2} haha. 
\end{document}

enter image description here

If you want to make use of the note field, which is going to be printed, you can use

\renewcommand*\mkbibnamelast[1]{\iffieldequalstr{note}{chiffreauthor}{\texttt{#1}}{#1}}
moewe
  • 175,683
  • Note that I would strongly advocate creating a new type if the relevant entries don't fit into the existing scheme of entry types, if they are interviews, survey/study reports or the like. But I don't see a point in creating a different entry types for say books with "anonymous" authors, when there is already the type @book. – moewe Sep 16 '15 at 09:18
  • What version was this tested on? Running texlive 2015.20160320 on Kubuntu 16.04, the above MWE produces identical formatting for both footnotes. – Supernormal Aug 08 '18 at 14:23
  • 1
    @Supernormal Judging by the date it would have been either biblatex 3.0 or 3.1, so quite a few versions ago. If you are running 3.3 or above you need \mkbibnamefamily instead of \mkbibnamelast, see https://tex.stackexchange.com/q/299036/35864 – moewe Aug 08 '18 at 14:26
  • @Supernormal Depending on what exactly you want to do there are more elegant methods to do this and related things now. Field annotations come to mind: https://tex.stackexchange.com/q/349570/35864 – moewe Aug 08 '18 at 14:48