为什么 csquotes 包会改变空间因子?

为什么 csquotes 包会改变空间因子?

当在引号中使用时,此包会更改几个标点符号的 。在 中, 和 分别从 更改为 和。csquotes在中,的分别从更改为、、、、和。我已通过测试(参见我的 MWE)和文件的行到验证了这一点。尽管 的变化很小(<1%)且难以通过视觉观察到,但从印刷角度来看这可能并不可取。我无法想象有哪个出版商或风格指南会认真推荐如此微小的间距变化。此外,除非我弄错了,否则我怀疑包作者是否真的想要这种间距变化。也许这是对包进行编程的一种 hack 或有趣的方式。\spacefactor\nonfrenchspacing\spacefactor?!300030023001\frenchspacing\spacefactor. ? ! : ; ,1000100610081007100510041003653673csquotes.sty\spacefactorcsquotes

在下面的 MWE 中,我首先显示\spacefactor不同标点符号的 。值得注意的是,右双花引号 ( \textquotedblright) 的 是\spacefactor1000,而它可能应该是 0。(\spacefactor0 表示在计算尾随单词间空间时,该字符基本上被忽略。)我还没有弄清楚如何更改这一点。无论\sfcode\textquotedblright=0出于什么原因, 都不起作用。

我使用定义而不使用包\@savsf来创建解决方法。我定义这样的行为就像它是 0 一样。(我使用了美式英语风格的引号。)这使我能够创建引号而不必不必要地更改并产生略微不太理想的排版。当然,将右双花引号的改为 0 可能更容易。\enquote\csquotes\enquote\textquotedblright\spacefactor\spacefactor\spacefactor

\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}

编辑:我发现我可以\spacefactor改变\textquotedblright0: Spacefactor 和 Unicode 花括号

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

所以

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

\spacefactor之后会有正确的尾随\textquotedblright

答案1

我们来做一个实验:

\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}

控制台将显示

> \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

拉伸分量增加了 0.00333pt,略小于 0.012 毫米。确实小于 1%,实际上小于 0.001%。空间不是按原样添加的,只会使用其中的一小部分。没什么可担心的。

相反,可以使用不同的空间因子来知道最后一个字符是什么标点符号。在 中使用了相同的策略amsthm.sty,将 修改\frenchspacing

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

对于\@addpunct宏来说。拉伸和收缩分量的变化可以忽略不计。

相关内容