Recently @moewe kindly produced custom code in order to add full page-ranges to first-time citations of articles and book chapters.
This code works well but results in a small bug I just noticed: when the output of a citation ends in a close-parenthesis mark (e.g., citations of books or PhD dissertations), the following punctuation mark is changed from a semi-colon to a comma.
Output:
Desired output: same but with a semicolon after the first citation instead of a comma.
Is there a simple way to fix this? I see that the custom code uses \addcomma twice, but I'm not sure if this is the problem or how to change it.
MWE:
\documentclass{article}
\usepackage[notes]{biblatex-chicago}
\addbibresource{biblatex-examples.bib}
\DefineBibliographyStrings{english}{
thiscite = {at},
}
\newtoggle{cbxchic:hadpages}
\renewbibmacro*{fullpostnote}{%
\global\toggletrue{cbxchic:hadpages}%
\iffieldundef{chapter}%
{\iffieldundef{pages}%
{\postnotewrapper
\global\togglefalse{cbxchic:hadpages}}%
{\postnotedelim%
\printfield{pages}}}%
{\postnotedelim%
\printfield{chapter}}%
\ifboolexpr{
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
and
test {\iffieldpages{postnote}}
and
togl {cbxchic:hadpages}
}
{\setunit{\addcomma\space}%
\bibstring{thiscite}%
\setunit{\addspace}}
{}%
\usebibmacro{semel:postnote}}
\renewbibmacro*{eid+fullpostnote}{%
\global\toggletrue{cbxchic:hadpages}%
\iffieldundef{chapter}%
{\iffieldundef{pages}%
{\iffieldundef{eid}%
{\postnotewrapper
\global\togglefalse{cbxchic:hadpages}}%
{\postnotedelim%
\printfield{eid}%
\clearfield{eid}}}%
{\postnotedelim%
\printfield{pages}}}%
{\postnotedelim%
\printfield{chapter}}%
\ifboolexpr{
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
and
test {\iffieldpages{postnote}}
and
togl {cbxchic:hadpages}
}
{\setunit{\addcomma\space}%
\bibstring{thiscite}%
\setunit{\addspace}}
{}%
\usebibmacro{semel:postnote}}
\begin{document}
\cite{worman};
\cite{hyman}.
\end{document}
Update based on moewe's answer
@moewe's answer below solves the problem I posed but seems to have created a new problem: when a book (or anything else whose output ends in a close-parenthesis, including PhD dissertations or even articles where the page range is blank in the bib entry) is cited with pages on the first citation, the page citation appears after the close-parenthesis without a comma or a space.
Thus for example the output of the following code based on @moewe's answer but with a final book-citation-with-page added is:
Code that produced that output:
\documentclass{article}
\usepackage[notes]{biblatex-chicago}
\addbibresource{biblatex-examples.bib}
\DefineBibliographyStrings{english}{
thiscite = {at},
}
\newtoggle{cbxchic:hadpages}
\renewbibmacro*{fullpostnote}{%
\global\toggletrue{cbxchic:hadpages}%
\iffieldundef{chapter}%
{\iffieldundef{pages}%
{\global\togglefalse{cbxchic:hadpages}}%
{\postnotedelim%
\printfield{pages}}}%
{\postnotedelim%
\printfield{chapter}}%
\ifboolexpr{
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
and
test {\iffieldpages{postnote}}
and
togl {cbxchic:hadpages}
}
{\setunit{\addcomma\space}%
\bibstring{thiscite}%
\setunit{\addspace}}
{}%
\usebibmacro{semel:postnote}}
\renewbibmacro*{eid+fullpostnote}{%
\global\toggletrue{cbxchic:hadpages}%
\iffieldundef{chapter}%
{\iffieldundef{pages}%
{\iffieldundef{eid}%
{\global\togglefalse{cbxchic:hadpages}}%
{\postnotedelim%
\printfield{eid}%
\clearfield{eid}}}%
{\postnotedelim%
\printfield{pages}}}%
{\postnotedelim%
\printfield{chapter}}%
\ifboolexpr{
test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
and
test {\iffieldpages{postnote}}
and
togl {cbxchic:hadpages}
}
{\setunit{\addcomma\space}%
\bibstring{thiscite}%
\setunit{\addspace}}
{}%
\usebibmacro{semel:postnote}}
\begin{document}
\cite{worman};
\cite{hyman}.
\citereset
\cite{worman,hyman}.
\citereset
\cite[20]{worman}.
\end{document}
For clarity, here are all the instances I can think of that one needs to juggle here (all first-time citations, since short citations aren't presenting a problem):
- book with no page citation: subsequent punctuation should be left alone or, in multicites, rendered as a semicolon or period as the case may be, not a comma
Author, Title (Cambridge: Cambridge University Press, 2000); ...
- book with page citation: after close-parenthesis it should be comma-space then the page
Author, Title (Cambridge: Cambridge University Press, 2000), 35
- phd dissertation: same as book
Author, "Title" (PhD diss., Arizona State University, 2000); ...
Author, "Title" (PhD diss., Arizona State University, 2000), 35
- article with no page range specified: there should be no colon at the end of the output, and subsequent punctuation should be left alone / rendered as semicolon or period
Author, "Title," Journal 12, no. 1 (1910); ...
Author, "Title," Journal 12, no. 1 (1910): 40 [when citing a specific page within an article whose full page-range is unknown/unspecified]
- book chapter with no page range specified: the same
Author, "Title," in Book, ed. Editor (Cambridge: Cambridge University Press, 2020); ...
Author, "Title," in Book, ed. Editor (Cambridge: Cambridge University Press, 2020), 22 [when citing a specific page within a book chapter whose full page-range is unknown/unspecified]
There are probably further instances I'm not thinking of, but hopefully this is a good start.


