8

This should be a relatively quick question. I'm using Biblatex's authoryear(-icomp, not that that really matters here) citation style, but there are a small number of works where the author-year format makes no sense, and I'd rather have them show up as author-title. For example, I would like that for the following bibliography entry

@BOOK{JahizBayaan,
  title = {al-Bayān wa-al-tabyīn},
  author = {al-Jāḥiẓ, Abū ʻUthman ibn Baḥr},
  editor = {Hārūn, ʻAbd al-Salām Muḥammad},
  year = {1968},
  owner = {Alexander},
  timestamp = {2011.12.23}
}

the command

\citet{JahizBayaan}

produce

Al-Jahiz (Al-Bayaan wa-Tabyiin)

rather than what I currently get, which is

Al-Jahiz (1968)

I could obviously make a command specifically for this author, or for works of this type, but I would really like it if there was a way to do this per-entry in the bibliography.

  • Welcome to TeX.SX! A tip: if you highlight code snippets and press the {} button, the code will appear as such. – egreg Dec 23 '11 at 19:08
  • You can redefine citet or you create a new cite command via DeclareCiteCommand. – Marco Daniel Dec 23 '11 at 19:15
  • Thanks egreg, I tried to do that but got confused by the interface here. Marco - I would like if it was more seamless, so that I could cite multiple keys, including this one, i.e.: \citet{Ferguson59,JahizBayaan,Chomsky64} and it would produce "Ferguson (1959); Jahiz (Al-Bayaan wa-t-tabyiin); Chomsky (1964)" without the need to redefine a command. – Skander Dec 23 '11 at 19:19
  • At the moment I can't test but you can try something like this: \AtEveryCitekey{\iffieldequalstr{entrykey}{JahizBayaan}{True}{FALSE}} – Marco Daniel Dec 23 '11 at 20:36
7
\documentclass{article}

\usepackage[style=authoryear]{biblatex}

\DeclareBibliographyCategory{notyear}
\addtocategory{notyear}{A01}

\AtEveryCitekey{%
  \ifcategory{notyear}{%
    \DeclareFieldFormat{labelyear}{\printfield{title}}%
    \DeclareFieldFormat{extrayear}{}%
  }{%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\textcite{A01}

\textcite{B02}

\textcite{C03}

\printbibliography

\end{document}

enter image description here

  • I'm afraid I don't understand what's going on here. The .bib entries and the citations look identical as far as I can tell, so I don't understand what's causing the citation for "Author" to show up differently. – Skander Dec 24 '11 at 0:57
  • @Skander: The citekey for "Author" is A01, and it has been added to a category "notyear" for which the year in citations (labelyear plus extrayear) is replaced with the content of the title field. – lockstep Dec 24 '11 at 6:35
  • Ok, this works. It would be nice if I could just include some property in the bibliography entry itself, but this is workable. Thanks! – Skander Dec 24 '11 at 23:12
  • Thanks, I think I'm going to try using \ifkeyword and putting a keyword into the bibliography, and that should give me the behavior I'm looking for. – Skander Dec 24 '11 at 23:51
  • @Skander: I checked the manual, and \ifkeyword seems like a good idea indeed. Please don't forget to upvote my answer (this has to be done separately from accepting it). – lockstep Dec 24 '11 at 23:54
3

I altered this so that it is based on keywords in the bibliography, and thus will translate more easily between documents.

\documentclass{article}

\usepackage[style=authoryear]{biblatex}


\AtEveryCitekey{%
  \ifkeyword{notyear}{% Here I use \ifkeyword instead of \ifcategory
    \DeclareFieldFormat{labelyear}{\printfield{title}}%
    \DeclareFieldFormat{extrayear}{}%
  }{%
  }%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
  keywords = {notyear}
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\textcite{A01}

\textcite{B02}

\textcite{C03}

\printbibliography

\end{document}

The output is identical.

  • If you are using Biber, you can also add such keywords automatically during parsing by matching the AUTHOR field, for example. This is useful if you can't or don't want to change the .bib. See section 3.1.1 of the Biber manual. – PLK Dec 25 '11 at 7:57

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.