1

I am using the excellent template written by @moewe biblatex: how to match the Journal of Finance bibliographic style?.

Unfortunately, I just noticed that working papers (techreports) need to have a little different style than regular articles.

Specifically, they should follow all of the conventions of regular articles (which are already specified in moewe's script) EXCEPT that for techreports the title that should NOT be in italic.

Here is an example (just use these two bib items with the template):

@article{johndoe_article,
  title={good morning everyone},
  author={Doe, John},
  journal={Journal of Stackoverlow},
  volume={13},
  number={1},
  pages={27--61},
  year={2014},
}


@techreport{johndoe_techreport,
title = {good morning everyone},
author = {Dow, John},
year = {2017},
institution = {Stackoverflow University},
type = {working paper},
}

gives:

enter image description here

As you can see

  • the techreport's title is in italic, instead of being in normal
  • the title, the type (working paper) and institution (stackoverflow university) are separated by a . instead of a comma ,

How can I tweak the code to get these two little changes for techreports? Thanks!!

  • 5
    Does this help? \DeclareFieldFormat command doesn't apply to phdthesis? (In your case, you want simply \DeclareFieldFormat[unpublished]{title}{#1}. – Alan Munn Jul 14 '17 at 17:31
  • thanks @AlanMunn but this does not seem to work. Actually, when you look at the example this is a techreport because the working paper has an institution field. I used your suggestion as \DeclareFieldFormat[techreport]{title}{#1} but the title still appears in italic... Do you have an idea? – ℕʘʘḆḽḘ Jul 14 '17 at 19:49
  • 2
    Then please put the example into a minimal document that shows the problem, with some specific code, and a specific .bib item. – Alan Munn Jul 14 '17 at 19:52
  • @AlanMunn edited my question completely. I hope everything is clear now. Thanks so much!!! – ℕʘʘḆḽḘ Jul 14 '17 at 20:28
2

The techreport entry type is an alias for the report type. So the correct field format command you need is:

\DeclareFieldFormat[report]{title}{#1}

For the separation of the elements with commas you need to patch the bibliography driver for the report type. I've used the xpatch package to do that. The xpatch package provides various commands specifically designed for changing biblatex macros, both of the \bibmacro type and the \BibliographyDriver type (among others). For this solution, I found where the bibliography driver for the report type was (in standard.bbx, the core code loaded by most .bbx files) and then used the \xpatchbibdriver command.

This command has the syntax:

\xpatchbibdriver{<driver name>}{<search code>}{<replace code}{<success>}{<failure>}

In this case, what needed to be done was to set the punctuation to \addcomma\addspace before printing the type field and the institution field.

Here's a complete example:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{johndoe_article,
  title={good morning everyone},
  author={Doe, John},
  journal={Journal of Stackoverlow},
  volume={13},
  number={1},
  pages={27--61},
  year={2014},
}


@techreport{johndoe_techreport,
title = {good morning everyone},
author = {Dow, John},
year = {2017},
institution = {Stackoverflow University},
type = {working paper},
}
\end{filecontents}
\usepackage[style=authoryear, 
backend=biber, 
giveninits=true,
uniquelist = false, 
uniquename=init,
isbn=false, 
maxcitenames=3, 
maxbibnames=999,
doi=false,
url=false]{biblatex}

\usepackage{xpatch}
\addbibresource{\jobname.bib}

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}

%\setlength{\bibhang}{0pt}

\DeclareNameAlias{sortname}{family-given}

\renewcommand*{\labelnamepunct}{\addspace}


\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished,report]
  {title}{#1}

\DeclareFieldFormat{titlecase}{\MakeSentenceCase*{#1}}


\renewbibmacro*{in:}{%
  \ifentrytype{article}
    {\setunit{\addcomma\space}}
    {\printtext{\bibstring{in}\intitlepunct}}}

\DeclareFieldFormat{journaltitlecase}{#1}

\renewbibmacro*{journal}{%
  \ifboolexpr{
    test {\iffieldundef{journaltitle}}
    and
    test {\iffieldundef{journalsubtitle}}
  }
    {}
    {\printtext[journaltitle]{%
       \printfield[journaltitlecase]{journaltitle}%
       \setunit{\subtitlepunct}%
       \printfield[journaltitlecase]{journalsubtitle}}}}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \setunit{\addcomma\space}%
  \printfield{eid}}


\xpatchbibdriver{report}{\newunit\newblock\printfield{type}}
    {\setunit{\addcomma\addspace}\newblock\printfield{type}}{}{}
\xpatchbibdriver{report}{\newunit\newblock\usebibmacro{institution+location+date}}
    {\setunit{\addcomma\addspace}\newblock\usebibmacro{institution+location+date}}{}{}

\DeclareFieldFormat[article,periodical]{volume}{\mkbibbold{#1}}% volume of a journal

\DeclareFieldFormat{pages}{#1}

\begin{document}
\textcite{johndoe_article,johndoe_techreport}


\printbibliography
\end{document}

[![output of code][1]][1]
  • thanks !! that fixes the italic, but the title, the type (working paper) and institution are still separated by a . instead of being separated by a comma ,. Can we change that easily as well? – ℕʘʘḆḽḘ Jul 14 '17 at 20:45
  • maybe by having the report type inheriting these features from the regular article type? Thanks again!! – ℕʘʘḆḽḘ Jul 14 '17 at 23:13
  • 1
    @Noobie I've updated the answer. – Alan Munn Jul 15 '17 at 17:08
  • 1
    @Noobie The syntax itself is not so much the problem as much as knowing where to look to find the things to change. There's a lot of code, and it distributed among a few different files. I don't have time to answer this now. But I actually think it would be a worthwhile question to ask on its own (something like "How do I know where to find things I can change in biblatex or something). You could link it to this question. There are quite a few extremely good biblatex users around who would probably have better answers than I could give to that question. – Alan Munn Jul 15 '17 at 17:27
  • 1
    @Noobie I've added some more explanation of what I did, but the general question would be a really useful one to have. – Alan Munn Jul 15 '17 at 17:33

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.