ctex-kit icon indicating copy to clipboard operation
ctex-kit copied to clipboard

xeCJK: 在改变字形时引入额外的间距

Open Liam0205 opened this issue 9 years ago • 1 comments

应该还是 #241 引入的问题。

\documentclass{ctexart}
\begin{document}
名字\texttt{name}名字name名字

名字 \texttt{name} 名字 name 名字
\end{document}

qq 20160818145843

 *File List*
 ctexart.cls    2016/05/16 v2.4.2 Chinese adapter for class article (CTEX)
   expl3.sty    2016/05/18 v6512 L3 programming layer (loader) 
expl3-code.tex    2016/05/18 v6512 L3 programming layer 
l3xdvipdfmx.def    
  xparse.sty    2016/05/18 v6512 L3 Experimental document command parser
l3keys2e.sty    2016/05/18 v6512 LaTeX2e option processing using LaTeX3 keys
ctexhook.sty    2016/05/16 v2.4.2 Document and package hooks (CTEX)
ctexpatch.sty    2016/05/16 v2.4.2 Patching commands (CTEX)
  fix-cm.sty    2015/01/14 v1.1t fixes to LaTeX
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
everysel.sty    2011/10/28 v1.2 EverySelectfont Package (MS)
ctexopts.cfg    2016/05/16 v2.4.2 Option configuration file (CTEX)
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size10.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
ctex-engine-xetex.def    2016/05/16 v2.4.2 XeLaTeX adapter (CTEX)
   xeCJK.sty    2016/05/14 v3.4.0 Typesetting CJK scripts with XeLaTeX
xtemplate.sty    2016/05/18 v6512 L3 Experimental prototype document functions
fontspec.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
fontspec-xetex.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
 fontenc.sty
  eu1enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
 eu1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2016/06/02 v1.0s Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
   xetex.def    2016/04/06 v4.08 LaTeX color/graphics driver for XeTeX (TeX Liv
e/RRM/JK)
infwarerr.sty    2016/05/16 v1.4 Providing info/warning/error messages (HO)
 ltxcmds.sty    2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
fontspec.cfg
xunicode-addon.sty    2016/05/14 v3.4.0 addon file for xunicode
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
xunicode-extra.def    2016/05/14 v3.4.0 extra definition for xunicode
   xeCJK.cfg    2016/05/14 v3.4.0 Configuration file for xeCJK package
xeCJKfntef.sty    2016/05/14 v3.4.0 xeCJK font effect
    ulem.sty    2012/05/18
 environ.sty    2014/05/04 v0.3 A new way to define environments
trimspaces.sty    2009/09/17 v1.1 Trim spaces around a token list
CJKfntef.sty    2015/04/18 4.8.4
zhnumber.sty    2016/05/14 v2.4 Typesetting numbers with Chinese glyphs
zhnumber-utf8.cfg    2016/05/14 v2.4 Chinese numerals with UTF8 encoding
ctex-scheme-chinese-article.def    2016/05/16 v2.4.2 Chinese scheme for article
 (CTEX)
ctex-name-utf8.cfg    2016/05/16 v2.4.2 Caption with encoding UTF8 (CTEX)
ctex-c5size.clo    2016/05/16 v2.4.2 c5size option (CTEX)
ctex-fontset-windows.def    2016/05/16 v2.4.2 Windows fonts definition (CTEX)
ctex-fontset-windowsnew.def    2016/05/16 v2.4.2 Windows fonts definition for V
ista or later version (CTEX)
    ctex.cfg    2016/05/16 v2.4.2 Configuration file (CTEX)
   t3cmr.fd    2001/12/31 TIPA font definitions
 eu1lmtt.fd    2009/10/30 v1.6 Font defs for Latin Modern
 ***********

Liam0205 avatar Aug 18 '16 07:08 Liam0205

这是老问题了。第一行的间距是自动加上的,默认是一个空格。空格的具体长度跟字体有关,并且这个空格是在 \texttt 的分组内加入的,所以第一行的空格长度取 lmtt 的值,为

.\glue 5.53317 plus 2.76659 minus 1.84439
.\EU1/lmtt/m/n/10.53937 name

第二行的空格就是 lmr 中的空格长度,为

.\glue 3.50961 plus 1.7548 minus 1.16986
.\EU1/lmtt/m/n/10.53937 name

这个问题比较难于解决。部分的解决办法是,将 CJKecglue 设置成 \normalfont 中的空格长度:

\documentclass{ctexart}

\ExplSyntaxOn
\makeatletter

\skip_new:N \l_@@_ecglue_skip
\xeCJKsetup { CJKecglue = { \skip_horizontal:N \l_@@_ecglue_skip } }
\ctex_add_to_selectfont:n { \ctex_update_ecglue: }
\cs_new_protected_nopar:Npn \ctex_update_ecglue:
  {
    \xeCJK_glue_to_skip:nN
      {
        \str_if_eq_x:nnF
          { \curr@fontshape }
          { \encodingdefault / \familydefault / \seriesdefault / \shapedefault }
          { \normalfont }
        \c_space_tl
      }
      \l_@@_ecglue_skip
  }

\makeatother
\ExplSyntaxOff

\begin{document}
名字\texttt{name}名字name名字

名字 \texttt{name} 名字 name 名字
\end{document}

qinglee avatar Aug 18 '16 12:08 qinglee