0

I wanted to use this solution for having possessive citations in BibLaTeX, but extend it to account correctly for names ending in 's' (at least in english). The solution posted in that question does not account for these, but does compile fine on my machine.

I thought that I could extend it easily enough by just using xstring to check whether the name ended with 's', and if did then only adding ' to the end, rather than 's. I tried the below mwe, but I got a compilation error:

error

ERROR: Illegal parameter number in definition of \xs_arg_i.

--- TeX said --- <to be read again> = l.51 \posscite{crane22_plural} is the easy case.

MWE

\documentclass{article}
\author{ModallyFragile}
\title{Foo}

\usepackage{xstring} \usepackage{filecontents} \usepackage[style=authoryear]{biblatex} \addbibresource{\jobname.bib}

% Support possessive citation \DeclareNameWrapperFormat{labelname:poss}{\IfEndWith{#1}{s}{#1'}{#1's}} \DeclareFieldFormat{shorthand:poss}{\ifnameundef{labelname}{\IfEndWith{#1}{s}{#1'}{#1's}}{#1}} \DeclareFieldFormat{citetitle:poss}{\mkbibemph{\IfEndWith{#1}{s}{#1'}{#1's}}} \DeclareFieldFormat{label:poss}{\IfEndWith{#1}{s}{#1'}{#1's}}

\newrobustcmd*{\posscitealias}{% \AtNextCite{% \DeclareNameWrapperAlias{labelname}{labelname:poss}% \DeclareFieldAlias{shorthand}{shorthand:poss}% \DeclareFieldAlias{citetitle}{citetitle:poss}% \DeclareFieldAlias{label}{label:poss}}}

\newrobustcmd*{\posscite}{% \posscitealias% \textcite}

\newrobustcmd*{\Posscite}{\bibsentence\posscite}

\newrobustcmd*{\posscites}{% \posscitealias% \textcites}

\begin{filecontents}{\jobname.bib} @Article{crane22_plural, date = {2022}, title = {Plurals are easy!}, author = {Crane, Tim}, timestamp = {2023-07-23 20:44:43 (BST)} }

@Article{mills23_plural, date = {2023}, title = {Plurals are hard}, author = {Mills, Charles W.}, timestamp = {2023-07-23 20:44:18 (BST)} } \end{filecontents}

\begin{document}

\posscite{crane22_plural} is the easy case.

But \posscite{mills23_plural} is the hard case.

\end{document}

I've isolated the error to my use of IfEndWith inside DeclareNameWrapperFormat.

What is causing this (and how can I stop it happening)?

  • 1
    Sorry, but your argument #1 contains the instructions to print the family name, not the family name itself and these instructions are not fully expandable. This will lead to low level errors, as you found out. There is no reference to the answer you tried to modify, can you please add it? – egreg Jul 23 '23 at 20:36
  • Sorry, forgot to actually include the link. Now fixed. – modallyFragile Jul 23 '23 at 21:21

0 Answers0