0

I am trying to construct a macro to use the editor field of @thesis entries to assign the supervisors of the thesis. I used the following post as a starting point How to add the name of the supervisor in a @thesis field? but this prints out the supervision and joint supervision strings in bold fonts (not sure why) instead that using the same fnt than the rest of the reference.

Here an MWE taken from How to add the name of the supervisor in a @thesis field? that I cannot get to output what the post intended to help doing as is provided. Perhaps the first would be to help me understand why this code does not print the supervisors and then how to give the supervision and joinsupervision strings an italic rather than bold font:

\documentclass[british,12pt,a4paper]{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@thesis{geer,
        author       = {de Geer, Ingrid},
        title        = {Earl, Saint, Bishop, Skald~-- and Music},
        type         = {phdthesis},
        institution  = {Uppsala Universitet},
        date         = 1985,
        subtitle     = {The Orkney Earldom of the Twelfth Century. A Musicological
            Study},
        location     = {Uppsala},
        supervisor       = {James Oint and Stan Upervisor},
    }

    @thesis{loh,
        author       = {Loh, Nin C.},
        title        = {High-Resolution Micromachined Interferometric Accelerometer},
        type         = {mathesis},
        institution  = {Massachusetts Institute of Technology},
        date         = 1992,
        location     = {Cambridge, Mass.},
        supervisor       = {Stan Upervisor},
    }
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{xpatch}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{hyperref}


\begin{filecontents*}{english-thesis.lbx}
    \ProvidesFile{english-thesis.lbx}[2014/06/14 english for thesis]
    \InheritBibliographyExtras{english}
    \NewBibliographyString{supervision,jointsupervision}
    \DeclareBibliographyStrings{%
        inherit           = {english},
        supervision       = {{under the supervision of}{under sup\adddotspace of}},
        jointsupervision  = {{under the joint supervision of}{under joint sup\adddotspace of}},
    }
\end{filecontents*}

\DeclareLanguageMapping{english}{english-thesis}

\newbibmacro*{thesissupervisor}{%
    \ifnameundef{editor}{}{%
        \ifnumgreater{\value{editor}}{1}
        {\bibstring{jointsupervision}}
        {\bibstring{supervision}}
        \printnames{editor}}}

\xpatchbibdriver{thesis}
{\printfield{type}}
{\printfield{type}
    \newunit
    \usebibmacro{thesissupervisor}}
{\typeout{yep}}
{\typeout{no}}

\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
    \printbibliography
\end{document}
aff
  • 13
  • 1
    aff, you've been previously suggested (here) to provide a minimal working example with bibliography (MWEB). Would you please consider (again) doing so? A MWEB should start with \documentclass and end with \end{document}. This would help others to get the general context of what you are trying to do and make it easier for them to be able to assist. – gusbrs Jun 06 '17 at 21:19
  • OK, here it goes. Part of my problem is that the MWE I saw in a previous post was not really working for me and my query was part of the process of solving this. – aff Jun 06 '17 at 22:20
  • Well, you adapted the code of the original post. Particularly, your macro thesissupervisor never calls the field supervisor. The macro starts with \ifnameundef{editor}{}, which essentially it telling biblatex to print nothing if the entryfield editor is empty, which is the case. Why does the original code does not work for you? What happens? – gusbrs Jun 06 '17 at 23:45

1 Answers1

1

I think I understood what's the problem. You are mixing parts of the first and second of moewe's solutions (from https://tex.stackexchange.com/a/184878/105447). The second one presupposes that the supervisor information will be inserted in the editor field. In your MWE, if you just change the supervisor field names to editor in the bibentries, it should work as desired. Like:

\documentclass[british,12pt,a4paper]{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@thesis{geer,
        author       = {de Geer, Ingrid},
        title        = {Earl, Saint, Bishop, Skald~-- and Music},
        type         = {phdthesis},
        institution  = {Uppsala Universitet},
        date         = 1985,
        subtitle     = {The Orkney Earldom of the Twelfth Century. A Musicological
            Study},
        location     = {Uppsala},
        editor       = {James Oint and Stan Upervisor},  % <-- This changes (should be "editor", not "superviser")
    }

    @thesis{loh,
        author       = {Loh, Nin C.},
        title        = {High-Resolution Micromachined Interferometric Accelerometer},
        type         = {mathesis},
        institution  = {Massachusetts Institute of Technology},
        date         = 1992,
        location     = {Cambridge, Mass.},
        editor       = {Stan Upervisor},  % <-- This changes (should be "editor", not "superviser")
    }
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{xpatch}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{hyperref}


\begin{filecontents*}{english-thesis.lbx}
    \ProvidesFile{english-thesis.lbx}[2014/06/14 english for thesis]
    \InheritBibliographyExtras{english}
    \NewBibliographyString{supervision,jointsupervision}
    \DeclareBibliographyStrings{%
        inherit           = {english},
        supervision       = {{under the supervision of}{under sup\adddotspace of}},
        jointsupervision  = {{under the joint supervision of}{under joint sup\adddotspace of}},
    }
\end{filecontents*}

\DeclareLanguageMapping{english}{english-thesis}

\newbibmacro*{thesissupervisor}{%
    \ifnameundef{editor}{}{%
        \ifnumgreater{\value{editor}}{1}
        {\bibstring{jointsupervision}}
        {\bibstring{supervision}}
        \printnames{editor}}}

\xpatchbibdriver{thesis}
{\printfield{type}}
{\printfield{type}
    \newunit
    \usebibmacro{thesissupervisor}}
{\typeout{yep}}
{\typeout{no}}

\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
    \printbibliography
\end{document}

As moewe himself stated in his solution, this involves abusing the editor field, and making it take the role of supervisor for @thesis.

gusbrs
  • 13,740
  • Still, I believe this one should be labeled a duplicate of the linked question. – gusbrs Jun 07 '17 at 00:24
  • I agree. This will facilitate things and also show that the solutions still work today. However, can I also ask you to recheck the solutions given in the linked post? I am not able to check it now but I believe the code I copied above is a literal copy of the last solution offered in the linked question so this would imply that some of the solutions given were wrong before. – aff Jun 07 '17 at 07:56
  • I tested this example and it works for me now. Thanks! It also has the correct format of the field. A further question on the same MWE. Say I would like now to have the name of the PhD student in bold, followed by the year of the thesis (also in bold and in parenthesis) and then the phrase "Under the supervision" to be in italic. How should I get around this? Thanks! – aff Jun 07 '17 at 08:12
  • @aff, there is no need for me to test the solutions in the previous post. If experienced users such as samcarter and moewe did it and said they work, it's because they do. When this happens to me, I usually try to find what's going wrong on my side, and not to say the solution no longer works. In this case, I can tell you what went wrong. The second of moewe's solutions was made to work not only with biber but also with bibtex, and he loaded biblatex with bibtex as backend. So if you tried to compile it with pdflatex -> biber -> pdflatex and so on, it would of course not work. – gusbrs Jun 07 '17 at 10:51
  • Notice I was only able to help you this time, because you provided a MWE. Which they asked you the first time. Regarding your further questions, I suggest that you dig the site for there are plenty of examples of such formatting of bibfields with biblatex in this site. If they do not address what you want, you can ask a new question. But you should show what you tried by means of a MWE. I hope you get the hang of it, and I believe you understood why it is important. And, by the way, if the solution worked for you, you should consider marking it as accepted. – gusbrs Jun 07 '17 at 11:02