# Suppress month and day for journal articles and maintain for a newspaper articles

I haven't found a solution yet for this problem. I want to suppress month and day (if present) from all journal articles in bibliography but I at the same time I want to indicate year, month and day for newspaper or magazine article.

This is complicated by the fact that journal and newspaper articles are all labelled as @article in bibtex. A possible solution would be to remove month and day selectively only IF the @article entry contains one or both of the fields volume or number (thus assuming that it is in fact a journal article).

I though about something like this, but my TeX is not that good...

\AtEveryBibitem{%
\ifentrytype{article}{%
% AND IF entry contains {number} and/or {volume}
\clearfield{month}%
\clearfield{day}%
}{%
}%
}


Here a MWE

\documentclass[a4paper]{article}

\RequirePackage{filecontents}

\begin{filecontents*}{mybib.bib}
@article{test1,
title = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
url = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
urldate = {2014-01-14},
journal = {New {York} {Times}},
author = {Harmon, Amy},
day = {01},
month = jan,
year = {2004},
}
@article{test2,
title = {Social movement networks virtual and real},
volume = {3},
issn = {1369-118X},
url = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
doi = {10.1080/13691180051033333},
number = {3},
urldate = {2013-05-31},
journal = {Information, {Communication} \& {Society}},
author = {Diani, Mario},
month = jan,
year = {2000},
pages = {386--401}
}
}
\end{filecontents*}

% Set the values for the bibliography
\usepackage[
style=apa,
backend=biber
]{biblatex}

\usepackage[utf8]{inputenc}

% Set language
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\begin{document}

\cite{test1}

\cite{test2}

\printbibliography
\end{document}

• Maybe you could use entrysubtype instead of this guessing conditional (newspaper articles could have entrysubtype = {newspaper}, you could filter those very easily). – moewe Apr 20 '14 at 4:47

The magic conditional can be built using etoolbox's \ifboolexpr (etoolbox is loaded by biblatex; see also the etoolbox manual and the biblatex documentation, esp. §4.6.3 Tests with \ifboolexpr and \ifthenelse, pp. 179 sq.).

In an \ifboolexpr we can use all the test provided by biblatex (see §4.6.2 Stand-alone Tests, p. 171-179 of the biblatex documentation): we just add a test before the test and wrap the command in curly braces, we also omit the "true" and "false" branch. So \iffieldundef{volume}{true}{false} becomes \ifboolexpr{test {\iffieldundef{volume}}}{true}{false}; the beauty of \ifboolexpr is that we can use logical operator to connect expressions.

In the case at hand, we then have

\AtEveryBibitem{%
\ifboolexpr{test {\ifentrytype{article}} and (not test {\iffieldundef{number}} or not test {\iffieldundef{volume}})}
{\clearfield{month}%
\clearfield{day}}
{}%
}


this deletes the month and day fields for @articles that have a number or volume field (or both, as the or is the logical inclusive or).

You could also make use of the entrysubtype field, just add entrysubtype = {newspaper} to every @article entry that is from a newspaper (surprise, surprise).

@article{test1,
title         = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
url           = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
urldate       = {2014-01-14},
journal       = {New {York} {Times}},
author        = {Harmon, Amy},
day           = {01},
month         = jan,
year          = {2004},
entrysubtype  = {newspaper},%<---- here it is
}


We then use the conditional

\AtEveryBibitem{%
\ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
{\clearfield{month}%
\clearfield{day}}
{}%
}


to delete month and day from @articles that are not newspaper @articles.

MWE

\documentclass[a4paper]{article}
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{test1,
title         = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
url           = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
urldate       = {2014-01-14},
journal       = {New {York} {Times}},
author        = {Harmon, Amy},
day           = {01},
month         = jan,
year          = {2004},
%entrysubtype  = {newspaper},
}
@article{test2,
title     = {Social movement networks virtual and real},
volume    = {3},
issn      = {1369-118X},
url       = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
doi       = {10.1080/13691180051033333},
number    = {3},
urldate   = {2013-05-31},
journal   = {Information, {Communication} \& {Society}},
author    = {Diani, Mario},
month     = jan,
year      = {2000},
pages     = {386--401},
}
\end{filecontents*}

\usepackage[
style=apa,
backend=biber
]{biblatex}

\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\AtEveryBibitem{%
\ifboolexpr{test {\ifentrytype{article}} and (not test {\iffieldundef{number}} or not test {\iffieldundef{volume}})}
%\ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
{\clearfield{month}%
\clearfield{day}}
{}%
}

\begin{document}
Lorem \parencite{test1} ipsum \parencite{test2}.

\printbibliography
\end{document}


• Cool, this is surprisingly simple, yet could be adapted for many situations. – doncherry Apr 20 '14 at 9:34
• @doncherry Yes, \ifboolexpr really is an awesome tool together with all the tests biblatex offers. – moewe Apr 20 '14 at 10:55

The new Bibulous project provides an alternative solution for what the OP asks for. Although Bibulous can check for the presence of a field that acts as a flag (in the BibLatex solution provided by @moewe, using the entrysubtype field), a cleaner solution for Bibulous is to simply define a new entrytype for newspaper articles that differentiate them from journal articles. Thus, using the following database file main.bib

@newsarticle{test1,
title = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
url = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
urldate = {2014-01-14},
journal = {New York Times},
author = {Harmon, Amy},
day = {1},
month = jan,
year = {2004}
}

@article{test2,
title = {Social movement networks virtual and real},
volume = {3},
issn = {1369-118X},
url = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
doi = {10.1080/13691180051033333},
number = {3},
urldate = {2013-05-31},
journal = {Information, Communication \& Society},
author = {Diani, Mario},
month = jan,
year = {2000},
pages = {386--401}
}


we can develop a Bibulous-format style file main.bst such as

TEMPLATES:
article = <au> (<year>). <title>. \textit{<journal>} \textit{<volume>}(<number>),{ }...
[<startpage>--<endpage>|<startpage>|<eid>|].[ doi:\url{<doi>}| url:\url{<url>}]
newsarticle = <au> (<year>, <month.monthname()> <day>). <title>.{ }...
\textit{<journal>}. Retrieved <urldate>, from \url{<url>}.

SPECIAL-TEMPLATES:
authorlist = <author.to_namelist()>
editorlist = <editor.to_namelist()>
au = <authorlist.format_authorlist()>
ed = <editorlist.format_editorlist()>
citelabel = (<authorlist.0.last>, <year>)

OPTIONS:
namelist_format = last_name_first


(The above block shows the entire style file.) Finally, we need to redefine the \@biblabel and \@cite macros to make Latex use the correct citation labels in the text. Thus, the main.tex file will look like

\documentclass{article}
\usepackage[paper=letterpaper, text={6.2in,8.5in},centering]{geometry}

\makeatletter
\renewcommand{\@biblabel}[1]{}
\renewcommand{\@cite}[2]{{#1\if@tempswa , #2\fi}}
\makeatother

\begin{document}

Lorem \cite{test1} ipsum \cite{test2}.

\bibliography{example9}
\bibliographystyle{example9}

\end{document}


When compiled, this produces the formatted reference list shown below: