3

The csquotes package changes the \spacefactor of several punctuation characters when they are used inside quotations. In \nonfrenchspacing, the \spacefactor of ? and ! are changed from 3000 to 3002 and 3001, respectively. In \frenchspacing, the \spacefactor of . ? ! : ; , change from 1000 to 1006, 1008, 1007, 1005, 1004, and 1003, respectively. I have verified this via testing (see my MWE) and lines 653 to 673 of the csquotes.sty file. Although the change in \spacefactor is small (<1%) and hard to observe visually, it is probably not typographically desirable. I cannot imagine any publisher or style guide seriously recommending such tiny changes in spacing. Furthermore, unless I am mistaken, I doubt the package authors actually want this change in spacing. Maybe it is a hack or funny way of programming the csquotes package.

In my MWE below, I first display the \spacefactor of different punctuation characters. Notably, the closing double curly quote (\textquotedblright) has a \spacefactor of 1000 when it probably should be 0. (A \spacefactor of 0 means that the character is essentially ignored when calculating trailing interword space.) I haven't figured out how to change this. \sfcode\textquotedblright=0 doesn't work for whatever reason.

I use \@savsf to create a workaround by defining \enquote without using the \csquotes package. I define \enquote such that \textquotedblright acts as if its \spacefactor is 0. (I've used American English style quotations.) This lets me create quotations without unnecessarily changing the \spacefactor and producing ever-so-slightly suboptimal typography. Of course, it would likely be easier to just change the \spacefactor of the closing double curly quote to 0.

\documentclass{article}
\def\pangram{The quick brown fox jumps over the lazy dog}
\usepackage{stix2}
\parindent=0pt
\parskip=4pt
\raggedright
%\usepackage{csquotes}
\makeatletter
\NewDocumentCommand{\enquote}{ s m }{%
    \IfBooleanTF{#1}%
    {\textquoteleft#2\textquoteright}%
%   {\textquotedblleft#2\textquotedblright}%results in incorrect trailing spacefactor
    {%
        \textquotedblleft{}%
        #2%
        \@savsf\spacefactor%stores current spacefactor
        \textquotedblright{}%
        \spacefactor=\@savsf%outputs stored spacefactor
        %\textquotedblright has a spacefactor of 1000 and I haven't figured out how to change it to 0
    }%
}
\makeatother
%\sfcode\textquotedblright=0%doesn't work
\begin{document}
I display the \verb|\spacefactor| of different punctuation characters with \verb|\nonfrenchspacing|.
\par
period . = \the\sfcode`\.
\par
exclamation mark ? = \the\sfcode`\?
\par
question mark ! = \the\sfcode`\!
\par
colon : = \the\sfcode`\:
\par
semi-colon ; = \the\sfcode`\;
\par
comma , = \the\sfcode`\,
\par
single straight quote \textquotesingle{} = \the\sfcode`'
\par
double straight quote \textquotedbl{} = \the\sfcode\textquotedbl
\par
opening double curly quote \textquotedblleft{} = \the\sfcode\textquotedblleft
\par
closing double curly quote \textquotedblright{} = \the\sfcode\textquotedblright
\par
opening single curly quote \textquoteleft{} = \the\sfcode\textquoteleft
\par
closing single curly quote \textquoteright{} = \the\sfcode\textquoteright
\par
\medskip
\nonfrenchspacing
Testing \verb|\enquote{\pangram{}<punc char>}\the\spacefactor| with \verb|\nonfrenchspacing|
\par
\enquote{\pangram{}.}\the\spacefactor
\par
\enquote{\pangram{}?}\the\spacefactor
\par
\enquote{\pangram{}!}\the\spacefactor
\par
\enquote{\pangram{}:}\the\spacefactor
\par
\enquote{\pangram{};}\the\spacefactor
\par
\enquote{\pangram{},}\the\spacefactor
\par
\medskip
Testing \verb|\enquote*{\pangram{}<punc char>}\the\spacefactor| with \verb|\nonfrenchspacing|
\par
\enquote*{\pangram{}.}\the\spacefactor
\par
\enquote*{\pangram{}?}\the\spacefactor
\par
\enquote*{\pangram{}!}\the\spacefactor
\par
\enquote*{\pangram{}:}\the\spacefactor
\par
\enquote*{\pangram{};}\the\spacefactor
\par
\enquote*{\pangram{},}\the\spacefactor
\par
\medskip
\frenchspacing
Testing \verb|\enquote{\pangram{}<punc char>}\the\spacefactor| with \verb|\frenchspacing|
\par
\enquote{\pangram{}.}\the\spacefactor
\par
\enquote{\pangram{}?}\the\spacefactor
\par
\enquote{\pangram{}!}\the\spacefactor
\par
\enquote{\pangram{}:}\the\spacefactor
\par
\enquote{\pangram{};}\the\spacefactor
\par
\enquote{\pangram{},}\the\spacefactor
\par
\medskip
Testing \verb|\enquote*{\pangram{}<punc char>}\the\spacefactor| with \verb|\frenchspacing|
\par
\enquote*{\pangram{}.}\the\spacefactor
\par
\enquote*{\pangram{}?}\the\spacefactor
\par
\enquote*{\pangram{}!}\the\spacefactor
\par
\enquote*{\pangram{}:}\the\spacefactor
\par
\enquote*{\pangram{};}\the\spacefactor
\par
\enquote*{\pangram{},}\the\spacefactor
\end{document}

EDIT: I found that I can change the \spacefactor of \textquotedblright from 1000 (default) to 0 via this code snippet: Spacefactor & Unicode Curly Quotes

\sfcode\csname\encodingdefault\string\textquotedblright\endcsname=0

So

\NewDocumentCommand{\enquote}{ s m }{%
\IfBooleanTF{#1}%
    {\textquoteleft#2\textquoteright}%
    {\textquotedblleft#2\textquotedblright}
}

would have the correct trailing \spacefactor after the \textquotedblright.

User23456234
  • 1,808
  • 1
    The spacefactor doesn't change spacing. It is a number that allows you to detect chars "through" other chars. csquotes assigns different numbers to be able to distinguish the various punctuation commands. – Ulrike Fischer Apr 21 '23 at 16:07
  • According to TeX by Topic, "The stretch component of the interword space is multiplied by the space factor divided by 1000; the shrink component is divided by this factor." (see section on Spacing) If I understand correctly, the \spacefactor increases the interword stretch and decreases the interword shrink, even when used with csquotes's \enquote. – User23456234 Apr 21 '23 at 16:14
  • 1
    a right, it affects that. – Ulrike Fischer Apr 21 '23 at 16:44

1 Answers1

5

Let's do an experiment:

\documentclass{article}

\begin{document}

\showboxbreadth=1000 \showboxdepth=1000 \tracingonline=1

\sfcode`?=3000 \setbox0=\hbox{a? x} \showbox0

\sfcode`?=3002 \setbox0=\hbox{a? x} \showbox0

\end{document}

The console will show

> \box0=
\hbox(6.94444+0.0)x19.44449
.\OT1/cmr/m/n/10 a
.\OT1/cmr/m/n/10 ?
.\glue 4.44444 plus 4.99997 minus 0.37036
.\OT1/cmr/m/n/10 x

! OK. l.12 \showbox0

? > \box0= \hbox(6.94444+0.0)x19.44449 .\OT1/cmr/m/n/10 a .\OT1/cmr/m/n/10 ? .\glue 4.44444 plus 5.0033 minus 0.37012 .\OT1/cmr/m/n/10 x

! OK. l.16 \showbox0

The stretch component is increased by 0.00333pt, which is a tad less than 0.012 millimeters. It's indeed less than 1%, actually less than 0.001%. The space is not added as is, only a fraction of it would be used. Nothing to worry about.

To the contrary, different space factors can be used to know what punctuation sign is the last character. The same strategy is used in amsthm.sty, which modifies \frenchspacing to be

\def\nopunct{\spacefactor 1007 }
\def\frenchspacing{\sfcode`\.1006\sfcode`\?1005\sfcode`\!1004%
  \sfcode`\:1003\sfcode`\;1002\sfcode`\,1001 }

for the \@addpunct macro. The changes in the stretch and shrink components are negligible.

egreg
  • 1,121,712