csquotes icon indicating copy to clipboard operation
csquotes copied to clipboard

Bug when enquote starts with duplicated character in section with Hyperref.

Open LustigePerson opened this issue 1 year ago • 1 comments

I found a really weird behavior: If I "enquote" (csquotes) something that starts with two identical characters in a section header AND use hyperref I get the error:

! Argument of \csq@pdf@quote@ii has an extra }.
<inserted text> 
                \par 
l.19 \section{Foo Bar \enquote{AA}}

When the "double" character is not at the start everything is fine.

MWE:

\documentclass{article}

\usepackage{csquotes}

%Hyperref
\usepackage{hyperref}
 
 
\begin{document}
\section{Foo Bar \enquote{AA}}
\end{document}

See here for discussion.

There is also an explanation from another user. I quote his comment here: It's a bug in csquotes: if I modify two definitions to have \if*#1 instead of \if#1*, the run is successful.

The \if#1* test is obviously wrong: with \tracingmacros=1 I get

\enquote #1->\if #1*\relax \expandafter \@firstoftwo \else \expandafter \@secon
doftwo \fi {\csq@pdf@quote@ii } {\csq@pdf@quote@i {#1}}
#1<-AA

but clearly the macro is supposed to check if there's a leading *.

\usepackage{csquotes}
 
%Hyperref
\usepackage{hyperref}

% fix the bugs
\makeatletter
\long\def\csq@pdf@quote#1{%
  \if*#1\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
    {\csq@pdf@quote@ii}
    {\csq@pdf@quote@i{#1}}}
\long\def\csq@pdf@fquote#1{%
  \if*#1\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
    {\expandafter\csq@pdf@quote@ii\@gobble}
    {\csq@pdf@quote@i}}
\makeatother

\begin{document}

\section{Foo Bar \enquote{AA}}

\end{document}

LustigePerson avatar Apr 03 '24 17:04 LustigePerson

Duplicate of #60

josephwright avatar Apr 04 '24 12:04 josephwright