josephwright / csquotes

Con­text sen­si­tive quo­ta­tion fa­cil­i­ties
LaTeX Project Public License v1.3c
28 stars 18 forks source link

\enquote is not guarding againsts internal font changes #29

Open FrankMittelbach opened 5 years ago

FrankMittelbach commented 5 years ago

If there is a font change inside \enquote it affects the right quote!

Example:

\documentclass{article}

\usepackage{csquotes}

\begin{document}

\fontfamily{Overlock-LF}\selectfont

A \enquote{test}.

And another \enquote{\fontfamily{cmr}\selectfont test}.

\showoutput

\end{document}

Which gives

enquote-bug.pdf

josephwright commented 5 years ago

Suggestions? I'm not clear what would be a 'good' fix for the font situation.

FrankMittelbach commented 5 years ago

Suggestions? I'm not clear what would be a 'good' fix for the font situation.

assumption you want the same "outer" font for both left and right quote,

so save the current font away roughly in \csq@bqgroup (I guess) and restore it just before you typeset the right quote.

Might need some stack handling but perhaps not.

FrankMittelbach commented 3 years ago

Might actually be enough to add an inner group around the argument use, e.g., \enquote{{\fontfamily{cmr}\selectfont test}} already works but of course that should be done internally by \enquote and not something the user needs to do.

FrankMittelbach commented 2 years ago

Any update on this? I would presume that all this is in fact needed is to ensure that the argument is processed locally by surrounding it with a brace group inside the definition, i.e.,

\long\def\csq@quote@i#1#2#3{%
  \csq@bqgroup#1\csq@oqopen@i{#3}\csq@qclose@i{#2}}
\long\def\csq@quote@ii#1#2#3{%
  \csq@bqgroup#1\csq@iqopen@i{#3}\csq@qclose@i{#2}}

to localize any font changes in #3.

schlcht commented 2 years ago

This fix doesn't seem to be a good idea as the kerning around quotation marks will no longer be restored:

\documentclass{article}
\usepackage{csquotes}
\DeclareQuoteStyle{test}{V}{V}{v}{v}
\ExecuteQuoteOptions{style=test}
\begin{document}
\enquote{A}

VAV

\makeatletter
\long\def\csq@quote@i#1#2#3{% original definition
  \csq@bqgroup#1\csq@oqopen@i#3\csq@qclose@i{#2}}
\enquote{A}
\showoutput
\end{document}
FrankMittelbach commented 2 years ago

Ah, good point, then perhaps it has to be somewhat more convoluted, e.g.

\long\def\csq@quote@i#1#2#3{%
\csq@bqgroup\expandafter\let\expandafter\myfont\the\font#1\csq@oqopen@i#3\expandafter\ifx\the\font\myfont\else\myfont\fi\csq@qclose@i{#2}}