2

My @thesis entries in my .bib file have in the field institution information about both department and school. I'm creating a style sheet for a journal where only the name of the school (i.e. university, college, vel sim.) is needed.

As a result, I'm looking for some code that will scan the field institution in the @thesis entries and delete text from the beginning until (and including) the final instance of . (period + space).

If no such cases are found, as in miller1923 below, it shouldn't do anything. If multiple cases are found, as in anderson2008 below, it should delete all of them. In the end, only the names of the universities should remain.

\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@thesis{miller1923,
    AUTHOR = "Oscar Miller",
    INSTITUTION = "Harvard University",
    TITLE = "War -- what is it good for?",
    TYPE = "Ph.D. dissertation",
    YEAR = "1923"}
@thesis{smith2003,
    AUTHOR = "Peter Smith",
    INSTITUTION = "Department of Chemistry. Stanford University",
    TITLE = "Oxygen and stuff",
    TYPE = "Ph.D. dissertation",
    YEAR = "2003"}
@thesis{anderson2008,
    AUTHOR = "John Anderson",
    INSTITUTION = "Department of Lang. \& Litt. Swarthmore College",
    TITLE = "Shakespeare and the English he wrote",
    TYPE = "MA thesis",
    YEAR = "2008"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

enter image description here

3

You should be using biber as a backend for biblatex in order to do things like this. Then it's quite easy. Add this to your preamble:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{thesis}
       \step[fieldsource=institution, match=\regexp{\A.+\.\s*(.+)\z}, replace=\regexp{$1}]
    }
  }
}

Since you mentioned that this is for a style, you should really use \DeclareStyleSourcemap instead of \DeclareSourcemap (same syntax, just replace the macro call). This can then be put in your style files.

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.