I'm trying to suppress the year
field when I'm citing \ifentrytype{book}
. I thought to be able to use \AtEveryCitekey{\ifentrytype{book}{\clearfield{year}}{}}
, but for some reason it doesn't have the intended effect. Any ideas how to solve that?
Thanks in advance!
I've included a working sample:
EDIT: Now I'm using the authoryear.cbx
\documentclass{scrartcl}
%
\usepackage[%
backend=biber,%
citestyle=authoryear,%
bibstyle=authortitle,%
]{biblatex}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{filecontents}
\usepackage{verbatim}
\usepackage{csquotes}
%
\addbibresource{\jobname.bib}
% ===
%
\newbibmacro*{cite:extrainfo:shorttitle}{%
\newunit
\printfield{shorttitle}
}
%
\makeatletter
\newbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\ifentrytype{book}%
{\usebibmacro{cite:extrainfo:shorttitle}}{}% shorttitle in footnote
\setunit{\printdelim{nameyeardelim}}}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
% ===
\makeatletter
\AtEveryCitekey{%
\ifentrytype{book}{%
\clearfield{year}%
}{%
}%
}
\makeatother
% ===
% === BIB
\begin{filecontents}{\jobname.bib}
@book{test2,
author = {Max Mustermann},
shortauthor = {M-M},
title = {Musterbuch},
shorttitle = {MB},
year = {2018},
}
\end{filecontents}
%
\begin{document}
% ===
\printbibliography[title=Bibliography]
I want to achieve a that if I'm citing a book it won't cite the year. I thought I could achieve that with \verb|\AtEveryCitekey{\ifentrytype{book}{\clearfield{year}}{}}|. But it seems like the year is still being printed. Do I have to replace \verb|{year}| with another argument? \\\footcite[p. 85]{test2}
How can I make it work?
\end{document}
labeldate
, so clearingyear
at that point indeed is not much help. There are certainly ways to achieve the result, but you are using anauthoryear
citation style, if you clear the date you will likely end up with ambiguous citations. Are you really, really sure that's what you want?comp
variant ofauthoryear
, so a lot of possible cases emerge. Technically the place to intervene would becite
bibmacro, which you already redefine. You can see there that several cases must be dealt with. E.g. suppose you cite an article and a book by the same author on the same year, should the date be maintained, or excluded? Should the year be present in the bibliography? Should the extradate exist for the book or not? And so on. I really advise against your attempt in these terms...@book
s by the same author? What happens if you cite a@book
and an@article
by the same author (you have a-comp
style, so normally you'd get "Knuth (1984,1986)", assume the 84 work is a book the 86 work an article, would you want "Knuth (,1986)" - surely not, what about "Knuth, Knuth (1986)")? May I ask why you want to remove the year for@books
- maybe there is a more elegant way overall to do this, what makes@book
s special?\footcite[85]{test2}
is enough, you don't need to (and should not) include thep.~
prefix