Weird interaction between `shorttitle` quotation marks and `\uspunctuation`
There's a weird interaction with \uspunctuation and enquoted shorttitle fields.
Consider the following example and notice the extra quotation marks at the start of the bibliography entry.
(Things get even more weird if you add a list of shorthands.)
This does not happen with \stdpunctuation. And obviously isn't exhibited for fields that are not formatted to be quoted.
\documentclass{article}
\begin{filecontents}[overwrite]{\jobname.bib}
@misc{test,
author = {Family, Given},
title = {A Long Title},
shorttitle = {Tit\adddot},
}
\end{filecontents}
\usepackage[style=verbose]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{title}{\mkbibquote{#1}}
\DeclareFieldFormat{shorttitle}{\mkbibquote{#1}}
\uspunctuation
\begin{document}
\cite{test}
\printbibliography
\end{document}
I have worked around this in my actual style by not giving shorttitle a format and instead doing something like:
\printfield[title]{shorttitle}
Thanks for reporting this.
Last time I looked (https://github.com/plk/biblatex/issues/1077) the whole \uspunctuation implementation appeared to be pretty complex. Any pointers are appreciated. We also have https://github.com/plk/biblatex/issues/499 and https://github.com/plk/biblatex/issues/266.
Oh dear. I seem to be the source of many of the \usepunctuation problems…
For this one, I suspect it has to do with label width calculations.
If you add:
\DeclareFieldFormat{shorttitlewidth}{#1}
Then the extra quotation mark disappears.
Although the width will be incorrect of course.
In fact, this makes a difference:
\makeatletter
\def\blx@setlabwidth#1#2{%
\begingroup
\stdpunctuation
\settowidth{\@tempdima}{\bibfont#2}%
\ifnum\@tempdima>#1%
\global#1\@tempdima
\fi
\endgroup}
\makeatother
I think the width is calculated correctly, but it still prints wrong below. Perhaps the moral of the story is don't use quotes in abbreviations (which I don't—I was filtering them out, but clearly the width calculation was still running somewhere with the way I was filtering things).
\documentclass{article}
\pagestyle{empty}
\begin{filecontents}[overwrite]{\jobname.bib}
@misc{test,
author = {Family, Given},
title = {A Long Title},
shorttitle = {XXX},
}
\end{filecontents}
\usepackage[style=verbose]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{title}{\mkbibquote{#1}}
\DeclareFieldFormat{shorttitle}{\mkbibquote{#1}}
\uspunctuation
\DeclareBibliographyDriver{abbreviations}{%
\renewcommand*{\finentrypunct}{}%
\usebibmacro{begentry}%
\printfield{title}%
\usebibmacro{finentry}}
\defbibenvironment{abbreviations}
{\list
{\printfield{shorttitle}}
{\setlength{\labelwidth}{\shorttitlewidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{0pt}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{##1\hss}}}
{\endlist}
{\item}
\makeatletter
\def\blx@setlabwidth#1#2{%
\begingroup
\stdpunctuation
\settowidth{\@tempdima}{\bibfont#2}%
\ifnum\@tempdima>#1%
\global#1\@tempdima
\fi
\endgroup}
\makeatother
\begin{document}
\cite{test}
\printbiblist{abbreviations}
\printbibliography
\end{document}
Thanks for the sleuthing! I guess we're missing some sort of "quotation mark reset". Maybe that would also help with some of the other issues - if we find the right situations in which we need this reset...
I can't promise that I will have the time to investigate this more closely in the next couple of days/weeks, but I hope to be able to get back to this at some point.
A fix isn't priority for me. Knowing source of the problem I can work around.