7

I want to modify the format of title field in references entries of both article and phdthesis. It is odd that the modification only applies to article but not to phdthesis. See the MWE:

\documentclass{article}

\usepackage[%
        backend=biber,
        style=authoryear,
        %citestyle=authoryear,
        labelnumber=true,
        doi=true,
        url=true
        ]{biblatex}

        \makeatletter
        \input{numeric.bbx}
        \makeatother

        \DeclareFieldFormat[article,phdthesis]{title}{\textit{#1}}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
    @book{Foo,
        title={Book title1 whatever whatever whatever and tuff tuff
        and gong gong},
        author={Author1, AB and Author2, CD and Author3, EF},
        year= {Year1},
    }
    @book{Bar,
        title={Book title2},
        author={Author2, AB},
        year= {Year2},
    }
    @phdthesis{xyz,
        title={why declarefieldformat command doesn't apply to phdthesis},
        author={Author4, AB},
        year={2000},
    }
    @article{abc,
        author = {Author, New},
        year = {2014},
        title = {the format of article entry could be changed with D.},
        pages = {16--25},
        number = {9},
        journal = {Biblatex },
    }
\end{filecontents}

\addbibresource{test.bib}
\begin{document}

text\footcite{Foo}, and text\footcite{Bar}
text\footcite{xyz}, and text\footcite{abc}

%\nocite{*}

\printbibliography

\end{document}

Did I do something wrong?

Qiuyew
  • 105

1 Answers1

10

The phdthesis type is an alias to the @thesis type, since biblatex uses @thesis as the entry with the type field to specify the kind of thesis.

But the alias points to the actual type, and so can't be used in the DeclareFieldFormat command. So instead use:

\DeclareFieldFormat[article,thesis]{title}{\mkbibemph{#1}}

Also, it's better to use \emph or \mkbibemph than \textit since it does italic correction and will also embed other \emph inside the title. (As noted in the comments, \mkbibemph behaves just like \emph so using \emph is fine.)

Alan Munn
  • 218,180
  • Of course it is even better to use \mkbibemph{#1} :-), although I will admit that \newrobustcmd*{\mkbibemph}{\emph}... – moewe Aug 12 '15 at 18:24
  • @moewe Yes, I was going to do that but it seemed excessive. But I've updated the answer nonetheless. :) – Alan Munn Aug 12 '15 at 18:37
  • 1
    Thank you. Excessive or not, the definitions in biblatex.def always use \mkbibemph{#1}, so I think it is a nice note to also keep doing it in one's modifications. – moewe Aug 12 '15 at 19:18