5

I'm having a great deal of difficulty with defining a newspaper entrytype and adjusting the citation style to match my university's guidelines. I'm required to use Harvard format, so my newspaper entries need to look like:

Norton, A 2011, 'Why teaching must be rated', The Age, 11 October, viewed 13 October 2011, link

@Article format is close, and looks like: LaTeX example

but I need to know how to insert the day and month after the journaltitle.

MWE

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage[style=authoryear,backend=biber,eprint=false]{biblatex}
\usepackage{csquotes}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@online{VCAA,
  Author  = {{Victorian Curriculum and Assessment Authority}},
  Title   = {The {Australian} Curriculum in {Victoria}},
  Year    = 2015,
  url     = {<http://ausvels.vcaa.vic.edu.au/>},
  Urldate = {2015-03-18}}

@article{SMH,
  Author  = {McNeilage, A.},
  Title   = {Computer science reforms to test teachers' skills},
  Journal = {Sydney Morning Herald},
  Month   = jan,
  day     = 12,
  Year    = 2014,
  url     = {<http://www.smh.com.au/national/computer-science-reforms-to-test-teachers-skills-20140111-30nj4.html>},
  urldate = {2015-03-18},
  entrysubtype = {newspaper}}

@article{DigitalNative,
  Author      = {Demirbilek, M.},
  Title       = {The ‘digital natives’ debate: an investigation of the digital
                  propensities of university students},
  Journaltitle = {Eurasia Journal of Mathematics, Science \& Technology Education},
  Year        = {2014},
  volume      = {10},
  number      = {2},
  pages       = {115--123}}

@article{scratch,
  Author = {Resnick, M. and Maloney, J. and  Monroy-Hern\'andez, A. and others},
  title = {Scratch: programming for all},
  Journaltitle = {Communications of the ACM},
  number = {11},
  year = {2009},
  volume = {52},
  pages = {60--67}}

@article{itwire,
  Author = {Philipson, G.},
  Title = {Parents ‘want kids taught digital skills’},
  Year = 2015,
  Month = feb,
  day = 23,
  url = {<http://www.itwire.com/government-tech-news/govenrment-tech-policy/67067-parents-%E2%80%98want-kids-taught-digital-skills%E2%80%99>},
  urldate={2015-03-18},
  Journal = {iTwire},
  entrysubtype = {newspaper}}

@article{guardian,
  Author = {Williams, R.},
  Title = {Why, and how, to teach computer hacking.},
  Year = {2015},
  Month = feb,
  url =  {<http://www.theguardian.com/education/2015/jan/06/computer-hacking-security-teaching-schools>},
  day = {6},
  urldate={2015-03-20},
  Journal = {The Guardian},
  entrysubtype = {newspaper}}
\end{filecontents*}

\addbibresource{\jobname.bib}
\DefineBibliographyStrings{english}{%
  urlseen = {Accessed},
}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{default}{last-first}
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}} % suppress in if not article
}
\DeclareFieldFormat{url}{\url{#1}}

\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{}
\begin{document}
Critics to this sort of adjustment may well point to under-training
of teachers  as a significant barrier to implement any kind of drastic
overhaul of the ICT curriculum \parencite{guardian}.
\end{document}

My bib file is here, and an example .tex is here.

If there's a step by step guide to doing this for those who are new to BibLaTeX that would elaborate how to make new entrytypes based on existing ones, that would be most helpful.

3
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. When you provide a MWE it is encouraged to make it so minimal that you can post it in source-code form verbosely into your question. (I have copy-pasted your MWE to here and only deleted a few lines that have nothing to do with the problem at hand.) – moewe Mar 22 '15 at 6:46
  • @moewe I am looking for answer to a very similar question. Can you or someone else may be able to help with this? – Dr Krishnakumar Gopalakrishnan Feb 8 '19 at 19:46
  • @Krishna I suggest you ask a new question with your requirements and what you have so far. I don't remember why this question here in particular got nowhere, but it is always easier if there can be direct communication and it doesn't have to go via a third-party question. If it turns out that the questions are extremely similar we can always close this one here as a duplicate of the new one (some purists might object, but I think that would be reasonable if they are similar enough). – moewe Feb 9 '19 at 7:07
2

Interesting exercise. Definition of "like" is going to be key.

First step is seeing what styles are closest. The @article bib entry type contains only data; all formatting, parsing and processing is done by the style coding.

Before we start: Some minor things in the .bib file, not crucial, but helps keep things tidier for later.

For quotation marks in titles, do not hard code them, use \mkbibquote instead. It will take care of quote nesting, and work in conjunction with the csquotes package.

Title = {Parents \mkbibquote{want kids taught digital skills}},

For dates, I put them in ISO format in the date field.

date = {2014-01-12}

Biblatex is quite adept at dates (and names) and will parse them into their components and recombine and reformat them as required.

Having the newspapers in their own entry, a @periodical entry, is also handy. The child @article entry then needs a crossref field, to inherit everything from the parent @periodical.

@periodical{j1,journaltitle={The Sydney Morning Herald},location={Sydney},date = {2014-01-12}}


@article{SMH,
  Author  = {McNeilage, A.},
  Title   = {Computer science reforms to test teachers' skills},
  url     = {<http://www.smh.com.au/national/computer-science-reforms-to-test-teachers-skills-20140111-30nj4.html>},
  urldate = {2015-03-18},
  entrysubtype = {newspaper},
  crossref={j1},
  }

Part 1 A whirlwind tour of some biblatex styles that do author-year ("Harvard") styling in various ways.

OXYEAR

oxyear

BATH

bath

NOTTINGHAM

nottingham

PHILOSOPHY-MODERN

philosophy-modern Rather elegant.

TRAD-ALPHA

trad-alpha

MLA

mla

Wise choice when it comes to URLs.

APA

apa

Part 2

Now, biblatex is, in effect, a programming language, and what the biblatex style writers do is, using the raw input data from the .bib file, fields and constraints are defined; parts of components are derived and calculated; components are built up into citation and bibliographic component blocks and sub-blocks, then into bibmacros (which can then form part of more complex bibmacros) and then those go in the entry type's "driver".

In the case at hand, randomly taking the oxyearbiblatex style as a starting point (and it is already building on the default biblatex styles and defining and redefining and xpatching all over the place, across multiple files, very astutely), and stepping through our required changes one at a time:

First: Tracking down the part that prints the url and date, it turns out to be a bibmacro called url+urldate

Here it is:

\newbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \usebibmacro{urldate}}}

It prints the URL, and, if there is a URL-seen date, prints that date with a space before the date. We need to reverse the seen-date and the URL, so that the URL comes last.

Let's redefine the bibmacro to print space + seen-date + colon + space + URL (we'll do this in the preamble of our current document, but in a proper style definition, the code would be in its own file(s)).

\newbibmacro*{url+urldate}{%
  \iffieldundef{urlyear}
        {}
        {\setunit*{\addspace}%
     \usebibmacro{urldate}%
     \addcolon\addspace\usebibmacro{url}
        }%if
}

But urldate is formatted to have the local language equivalent of the word "seen" + space put before the date.

\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}

We want it to say "viewed" (when the language is English).

All string constants are defined in the matching .lbx file, usually named after the language. We'll make a custom file (call it pcc\jobname.lbx). It will contain:

\NewBibliographyString{urlviewed}
 \DeclareBibliographyStrings{%
    inherit   = {english},
        urlviewed     = {{viewed}{viewed}},
 }

The bibstring urlviewed is defined with the full form of the string constant that we want, and the abbreviated form. In this case, both are the same.

The inherit is important, because otherwise biblatex will not know, for example, what "Jan" means.

And in our preamble we map to the file with:

\DeclareLanguageMapping{english}{pcc\jobname}

Running the code produces output, including a dot at the end of the item in the bibliography: the reader will ask, "Is the dot part of the URL?"

To visually identify the URL, we will wrap it with "<" and ">".

Back to the .lbx, which now reads:

\NewBibliographyString{urlviewed,urlleftangle,urlrightangle}
 \DeclareBibliographyStrings{%
    inherit   = {english},
        urlviewed     = {{viewed}{viewed}},
        urlleftangle     = {{<}{<}},
        urlrightangle     = {{>}{>}},
 }

We need to update the bibmacro definition to include these bibstrings.

\newbibmacro*{url+urldate}{%
  \iffieldundef{urlyear}
        {}
        {\setunit*{\addspace}%
     \usebibmacro{urldate}%
     \addcolon\addspace\bibstring{urlleftangle}\usebibmacro{url}\bibstring{urlrightangle}
        }%if
}

Note for the curious: for items without a URL, what in the code above stops "<>" from being printed at the end of the item?

Next is converting the newspaper name (journaltitle) to plain text, not italics. That is (luckily) done within this style by redefining the formatting directive to just print the value (#1, for the current bib item being processed) without any adornment:

\DeclareFieldFormat{journaltitle}{#1}

The original definition doing the emphasis is:

\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}}

Next is the date with brackets after the author name. That is done via bibmacro date+extradate, with the year part of date coming from the internally-derived field labelyear, so we can redefine the bracketless bibmacro as:

\renewbibmacro{date+extradate}{%
    \addspace\printfield{labelyear}%
}

Next is the (day-month-year) after the newspaper name: remove the brackets, and only show day and month (and a comma). Luckily, the style writers are consistent, and the day and month components of date are stored in labelday and labelmonth (in this style). There is also a handy biblatex macro that can convert the year-month-day numbers into text (remember the .lbx file, with its inherit?). So we have:

\renewbibmacro{issue+date}{%
\addcomma\addspace\mkbibdatelong{}{labelmonth}{labelday}%
}

That's it.

Result:

tweaked

(except for removing the dot after the author's name - that may be left as an exercise for the reader).

MWE:

\documentclass[a4paper,10pt]{article}
%\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\newcommand\abibstyle{style=oxyear}
\usepackage[
    \abibstyle , 
%   style=authoryear-ibid, 
%   backend=biber, 
    eprint=false,
        ]{biblatex}
\newcommand\mynote{biblatex option used: \texttt{\abibstyle}, tweaked in half a dozen places.}
\defbibnote{abibnote}{\mynote}
\usepackage{csquotes}



\usepackage{filecontents}

\begin{filecontents*}{pcc\jobname.lbx}
\NewBibliographyString{urlviewed,urlleftangle,urlrightangle}
 \DeclareBibliographyStrings{%
    inherit   = {english},
        urlviewed     = {{viewed}{viewed}},
        urlleftangle     = {{<}{<}},
        urlrightangle     = {{>}{>}},
 }
\end{filecontents*}



\begin{filecontents*}{\jobname.bib}
@online{VCAA,
  Author  = {{Victorian Curriculum and Assessment Authority}},
  Title   = {The {Australian} Curriculum in {Victoria}},
  Year    = 2015,
  url     = {<http://ausvels.vcaa.vic.edu.au/>},
  Urldate = {2015-03-18}}

@periodical{j1,journaltitle={The Sydney Morning Herald},location={Sydney},date = {2014-01-12}}


@article{SMH,
  Author  = {McNeilage, A.},
  Title   = {Computer science reforms to test teachers' skills},
  url     = {<http://www.smh.com.au/national/computer-science-reforms-to-test-teachers-skills-20140111-30nj4.html>},
  urldate = {2015-03-18},
  entrysubtype = {newspaper},
  crossref={j1},
  }

@article{DigitalNative,
  Author      = {Demirbilek, M.},
  Title       = {The \mkbibquote{digital natives} debate: an investigation of the digital
                  propensities of university students},
  Journaltitle = {Eurasia Journal of Mathematics, Science \& Technology Education},
  Year        = {2014},
  volume      = {10},
  number      = {2},
  pages       = {115--123}}

@article{scratch,
  Author = {Resnick, M. and Maloney, J. and  Monroy-Hern\'andez, A. and others},
  title = {Scratch: programming for all},
  Journaltitle = {Communications of the ACM},
  number = {11},
  year = {2009},
  volume = {52},
  pages = {60--67}}

@periodical{j2,journaltitle={iTwire},date = {2015-02-23},}

@article{itwire,
  Author = {Philipson, G.},
  Title = {Parents \mkbibquote{want kids taught digital skills}},
%  Year = {2015},
%  Month = {2},
%  day = {23},
  url = {<http://www.itwire.com/government-tech-news/govenrment-tech-policy/67067-parents-%E2%80%98want-kids-taught-digital-skills%E2%80%99>},
  urldate={2015-03-18},
%  Journal = {iTwire},
  entrysubtype = {newspaper},
    crossref={j2},
    }

@periodical{j3,journaltitle={The Guardian},date={2015-02-06},}

@article{guardian,
  Author = {Williams, R.},
  Title = {Why, and how, to teach computer hacking.},
%  Year = {2015},
%  Month = feb,
  url =  {<http://www.theguardian.com/education/2015/jan/06/computer-hacking-security-teaching-schools>},
%  day = {6},
  urldate={2015-03-20},
  entrysubtype = {newspaper},
  crossref={j3},
  }
\end{filecontents*}

\addbibresource{\jobname.bib}

%The .lbx file: has the string definitions:
\DeclareLanguageMapping{english}{pcc\jobname}



%\DefineBibliographyStrings{english}{%
%  urlseen = { {Accessed}{Accessed}},
%}

%\DeclareNameAlias{sortname}{last-first}
%\DeclareNameAlias{default}{last-first}
%\renewbibmacro{in:}{%
%  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}} % suppress in if not article
%}
%\DeclareFieldFormat{url}{\url{#1}}
%
%\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{}



%Orig: biblatex.def
%\DeclareFieldFormat{urldate}{\mkbibparens{\bibstring{urlseen}\space#1}}
\DeclareFieldFormat{urldate}{\bibstring{urlviewed}\space#1}

%Orig:
%\newbibmacro*{url+urldate}{%
%  \usebibmacro{url}%
%  \iffieldundef{urlyear}
%    {}
%    {\setunit*{\addspace}%
%     \usebibmacro{urldate}}}

%redefine as without italics:
\DeclareFieldFormat{journaltitle}{#1}

%For exploring:
%\newbibmacro*{url+urldate}{%
%  \iffieldundef{urlyear}
%       {}
%       {\setunit*{\addspace}%
%     \usebibmacro{urldate}%
%     \addcolon\addspace\bibstring{urlleftangle}\usebibmacro{url}\bibstring{urlrightangle}\usebibmacro{date} \printfield{title} \printnames{author} xxx\printfield{datelabel} yyy\printfield{labeldate} zzz \usebibmacro{date+extradate} aaa \printfield{labelyear} bbb \printfield{labelday} ccc \printfield{labelmonth} ddd \printfield{title} \usebibmacro{title} \usebibmacro{labeltitle} eee \mkbibdatelong{}{labelmonth}{labelday}       fff \printfield{citetitle} ggg \printfield{shorttitle} hhh \usebibmacro{title} iii \usebibmacro{journal+issuetitle} jjj \printfield{issuetitle} kkk \printfield{title} lll \printfield{journaltitle} mmm \usebibmacro{date} nnn \usebibmacro{issue} ooo  \usebibmacro{issue+date}%
%   }%if
%}


\newbibmacro*{url+urldate}{%
  \iffieldundef{urlyear}
        {}
        {\setunit*{\addspace}%
     \usebibmacro{urldate}%
     \addcolon\addspace\bibstring{urlleftangle}\usebibmacro{url}\bibstring{urlrightangle}
        }%if
}



%(yyyy) > yyyy
\renewbibmacro{date+extradate}{%
    \addspace\printfield{labelyear}%
}

%(dd mmm yyyy) > dd mmm, 
\renewbibmacro{issue+date}{%
\addcomma\addspace\mkbibdatelong{}{labelmonth}{labelday}%
}


%italic journal title (issue date) > plain title, date, :
%\newbibmacro
%\renewbibmacro{journal+issuetitle}{%
%   \def\mytemp{\usebibmacro{journal+issuetitle}}
%   \mytemp\addcomma\addspace\mkbibdatelong{}{labelmonth}{labelday}\addcomma\addspace
%}


%\renewbibmacro{journaltitle}{%
%   \addspace\printfield{labelyear}%
%}

%\DeclareFieldFormat{datelabel}{\mkbibparens{#1}}
%\DeclareFieldFormat{labeldate}{%
%  \iflabeldateisdate{%
%    \def\currentfield{date}%
%  }{%
%    \iflabeldateisanydate{%
%      \def\currentfield{\thefield{labeldatesource}date}%
%    }{%
%      \def\currentfield{\thefield{labeldatesource}}}}%




%\newbibmacro*{date}{\mkbibbold{\printdate{date}}}
%\renewbibmacro*{date}{xxx\printdate}



\begin{document}
Need to format \texttt{@article} entry \texttt{newspaper} subentry in the bibliography as \begin{quotation}Norton, A 2011, 'Why teaching must be rated', The Age, 11 October, viewed 13 October 2011, link\end{quotation}

Critics to this sort of adjustment may well point to under-training
of teachers  as a significant barrier to implement any kind of drastic
overhaul of the ICT curriculum \autocite{guardian}.

And also \autocite{SMH}. Text itwire \autocite{itwire}.

Not online: \autocite{scratch}.

\printbibliography[prenote=abibnote]
\end{document}

Part 3

That took about six or so (leisurely-paced) hours. What we need is a plug-and-playable modification ability. Currently, the code is, shall I say?, "linear" and layered, and style-builders may easily get their declarations and IFs "interlocked" in terms of logic and sequence. On the other hand, there is a linguistic-like elegance in the structures at a meta-level, so open-ended and not constrained.

P.S. IN terms of time to expend, I expect your university was asking you to do something like Part 1. If you were being asked to do Part 2, could you please also invent a new three-dimensional Dewey classification system at the same time? :) It would be a great addition and handy to see knowledge as if along the planes and orientations of a crystalline or snowflake structure.

Part 4 To answer the question, a similar type of exercise would have to be done with the original MWE's style=authoryear style, if that were the one to be used.

=== Edit:

Moewe is quite right in the comments, from the contents of the bib file all the way to the methods of assembling the units, there are better and more efficient ways than the rudimentary hacks presented here. (In effect, the intention was to see how and what a set of change instructions would begin to look like, and the time and effort involved; there is not even a logical certainty that the changes would even work in the @article class beyond the four bib entries in the example (indeed, as moewe shows, in items 3, 5 and 6 on the comments)).

Note the date hack breaks very easily in other styles.

Further, the changes done do not take into consideration all possible scenarios that a usable style should and ought (missing data, different data, non-article entry types, or in combinations, for example like "when the url was seen in footcites too when the author is unknown" as a different question asks). Something may break anywhere along there.

Also, testing the changes on the other styles revealed that most of them will need additional general tweaking, especially so for the date processing. Different style authors do things different ways.

So tweaking must then have a defined purpose and a specific boundary of application.

How well do the changes live with other styles?

Testing against other styles:

authoryear - OK

apa - different date fields used for the article; URL date missing the 'viewed' text

mla - different date fields used; long journal title difference (treated like a name?); URL has doubled << and >>; style uses a print bibstring for ending the segment, and the bibstring is undefined (unstranslated) for the non-online entry

trad-alpha - different date fields

philosophy-modern - different date fields; it affected indentation of the first line

nottsclassic - OK; viewed date doesn't convert to month-name, though

bath - OK; adds [Online] to journal title; but inserts "Available from: " in front of the URL, before the < and > are added.

4
  • 1
    +1: Interesting read. May I suggest one or two things, though? In no particular order (1) When you clean up the .bib entries I would also remove the <...> in the url fields. It seems that Biber strips outer <...> from URLs automatically, but this is not something I would want to rely on (and BibTeX users can't rely on that) and it breaks with the "The url field should contain only the raw URL" rule, which I like. (2) You can redefine the predefined bibstring urlseen instead of a new string urlviewed. – moewe Mar 30 '19 at 15:55
  • (3) It is a bit of judgement call, but I would not use bibstrings to wrap the URL in <...> instead I would probably define a macro for that (cf. \mkbiburlangle in tex.stackexchange.com/q/446633/35864) and apply it in the field format. (4) If at all possible I would avoid bare \add... punctuation commands in bibmacros: they should either be wrapped in a \setunit/\printunit or appear in a field format. (In the case of \addcolon\addspace in url+urldate I would probably use the \setunit.) – moewe Mar 30 '19 at 16:00
  • (5) The redefinition of date+extradate as \addspace\printfield{labelyear} also breaks the "no bare \add..." rule. It also completely disables the mergedate feature (that might be desired to some degree) and other date controls that biblatex offers. You will also not get the little disambiguation letter for works by the same author from the same year. For the standard styles the parentheses can be removed as explained in tex.stackexchange.com/q/428190/35864 for oxref styles you can just say \DeclareFieldFormat{datelabel}{#1}. – moewe Mar 30 '19 at 16:07
  • ... cf tex.stackexchange.com/q/476416/35864 for biblatex-bath, which was written by the same author. (6) Structurally similar issues apply to the redefinition of issue+date. I don't quite like the raw \mkbibdatelong{}{labelmonth}{labelday} but I have to admit that I have no idea at the moment for a better alternative. – moewe Mar 30 '19 at 16:11

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.