Skip to content

Commit

Permalink
ctex: fix toc number width when loading titletoc
Browse files Browse the repository at this point in the history
Fix #472.
  • Loading branch information
stone-zeng committed Jan 11, 2020
1 parent ce8a975 commit 6047a4c
Show file tree
Hide file tree
Showing 23 changed files with 2,463 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push]
env:
CTAN_URL: https://mirrors.rit.edu/CTAN
TL_PACKAGES: adobemapping amsfonts amsmath atbegshi cjk cjkutils cm ctablestack currfile dvipdfmx epstopdf-pkg etex etoolbox euenc fancyhdr fandol filehook fontspec graphics graphics-cfg graphics-def iftex l3build l3experimental l3kernel l3packages latex-bin lm lm-math ltxcmds lualatex-math lualibs luaotfload luatex luatex85 luatexbase luatexja metafont mfware ms oberdiek platex-tools tex tex-ini-files tools trimspaces ucharcat ulem unicode-data uplatex varwidth xcolor xetex xkeyval xunicode
TL_EXTRA_PACKAGES: amscls atveryend auxhook beamer bibunits bigintcalc bitset booktabs caption cjkpunct context enumitem environ eso-pic etexcmds everyhook fontaxes footmisc geometry gettitlestring hycolor hyperref infwarerr intcalc kastrup koma-script kvdefinekeys kvoptions kvsetkeys letltxmacro mweights natbib newtx notoccite ntheorem pdfescape pdflscape pdfpages pdftexcmds pgf pkuthss psnfss refcount rerunfilecheck sansmathaccent setspace svn-prov tex-gyre tex-gyre-math thuthesis tocloft translator txfonts unicode-math uniquecounter url xecjk xits zhmetrics zhmetrics-uptex zhnumber
TL_EXTRA_PACKAGES: amscls atveryend auxhook beamer bibunits bigintcalc bitset booktabs caption cjkpunct context enumitem environ eso-pic etexcmds everyhook fontaxes footmisc geometry gettitlestring hycolor hyperref infwarerr intcalc kastrup koma-script kvdefinekeys kvoptions kvsetkeys letltxmacro mweights natbib newtx notoccite ntheorem pdfescape pdflscape pdfpages pdftexcmds pgf pkuthss psnfss refcount rerunfilecheck sansmathaccent setspace svn-prov tex-gyre tex-gyre-math thuthesis titlesec tocloft translator txfonts unicode-math uniquecounter url xecjk xits zhmetrics zhmetrics-uptex zhnumber
NOTO_URL: https://noto-website-2.storage.googleapis.com/pkgs

jobs:
Expand Down
4 changes: 4 additions & 0 deletions ctex/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `\ctex_if_platform_macos:TF`: 改用 `/System/Library/Fonts/Menlo.ttc` 为特征文件 - [#455](https://github.com/CTeX-org/ctex-kit/issues/455)
- `windows` 使用环境变量代替绝对路径查找字体,即改用 `$WINDIR/Fonts/msyh.ttc` 为特征文件

### Fixed

- 兼容 `titletoc`,防止目录中章节名和标题现重合 - [#472](https://github.com/CTeX-org/ctex-kit/issues/472)

### Deprecated

- 不再支持 Windows XP 系统,`windowsold``windowsnew` 成为过时字库选项
Expand Down
32 changes: 23 additions & 9 deletions ctex/ctex.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -7978,7 +7978,7 @@ Copyright and Licence
%
% \subsubsection{目录标签的宽度}
%
% \begin{macro}[int]{\numberline}
% \begin{macro}{\CTEX@toc@width@n}
% \begin{macrocode}
\cs_new_protected:Npn \CTEX@toc@width@n #1
{
Expand All @@ -7989,6 +7989,15 @@ Copyright and Licence
{ \box_wd:N \l_@@_tmp_box + \f@size \p@ / 2 }
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\numberline,\@@_patch_toc_width:n}
% 为 \tn{numberline} 命令打补丁,并兼容 \pkg{tocloft} 和 \pkg{titletoc} 宏包。
%
% 这里需要替换 |#| 本身,因此需要先切换为 other 类。表示参数的 |#| 用
% \cs{c_parameter_token} 代替。
% \begin{macrocode}
\group_begin:
\char_set_catcode_other:N \#
\use:n
Expand All @@ -7998,19 +8007,24 @@ Copyright and Licence
{ \CTEX@toc@width@n {#1} }
{ }
{ \ctex_patch_failure:N \numberline }
\@ifpackageloaded { tocloft }
{ }
\cs_new_protected:Npn \@@_patch_toc_width:n \c_parameter_token 1
{
\ctex_at_end_package:nn { tocloft }
\@ifpackageloaded { \c_parameter_token 1 }
{ }
{
\ctex_preto_cmd:NnnTF \numberline
{ \char_set_catcode_letter:n { 64 } }
{ \CTEX@toc@width@n {#1} }
{ }
{ \ctex_patch_failure:N \numberline }
\ctex_at_end_package:nn { \c_parameter_token 1 }
{
\ctex_preto_cmd:NnnTF \numberline
{ \char_set_catcode_letter:n { 64 } }
{ \CTEX@toc@width@n {#1} }
{ }
{ \ctex_patch_failure:N \numberline }
}
}
}
}
\@@_patch_toc_width:n { tocloft }
\@@_patch_toc_width:n { titletoc }
% \end{macrocode}
% \end{macro}
%
Expand Down
155 changes: 155 additions & 0 deletions ctex/test/testfiles/github472-01.luatex.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Author: Xiangdong Zeng
============================================================
TEST 1: \tableofcontents with titletoc
============================================================
(github472-01.toc)
\tf@toc=\write...
Completed box being shipped out [2]
\vbox(627.36243+0.0)x434.0, direction TLT
.\whatsit4=[]
.\glue 22.0
.\vbox(605.36243+0.0)x345.0, shifted 89.0, direction TLT
..\whatsit4=[]
..\vbox(12.0+0.0)x345.0, glue set 12.0fil, direction TLT
...\whatsit4=[]
...\glue 0.0 plus 1.0fil
...\hbox(0.0+0.0)x345.0, direction TLT
....\whatsit4=[]
..\glue 18.06749
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0, glue set 361.5896fil, direction TLT
...\whatsit4=[]
...\write-{}
...\write-{}
...\glue(\topskip) 10.0
...\rule(0.0+0.0)x*
...\penalty 10000
...\glue 50.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 15.01617
...\hbox(19.43259+2.6499)x345.0, glue set 150.41751fil, direction TLT
....\whatsit4=[]
....\glue(\leftskip) 0.0 plus 1.0fil
....\localpar
.....\localinterlinepenalty=0
.....\localbrokenpenalty=0
.....\localleftbox=null
.....\localrightbox=null
....\hbox(0.0+0.0)x0.0, direction TLT
....\hbox(19.43259+2.6499)x22.08249, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/22.08249 目
....\penalty 500
....\glue 0.0 plus 2.75732
....\hbox(19.43259+2.6499)x22.08249, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/22.08249 录
....\penalty 10000
....\glue(\parfillskip) 0.0
....\glue(\rightskip) 0.0 plus 1.0fil
...\mark{{\protect \MakeUppercase {目录}}{\protect \MakeUppercase {目录}\
ETC.}
...\penalty 10000
...\glue 40.0
...\glue 10.53937 plus 1.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 4.5169
...\hbox(9.27464+1.26472)x345.0, glue set 267.53558fil, direction TLT
....\whatsit4=[]
....\glue(\leftskip) 15.80905
....\localpar
.....\localinterlinepenalty=0
.....\localbrokenpenalty=0
.....\localleftbox=null
.....\localrightbox=null
....\hbox(0.0+0.0)x0.0, direction TLT
....\glue -15.80905
....\hbox(9.27464+1.26472)x40.04962, glue set 5.26968fil, direction TLT
.....\whatsit4=[]
.....\hbox(9.27464+1.26472)x10.53937, direction TLT
......\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 第
.....\glue 0.0 plus 0.60931
.....\norule(9.27464+1.26472)x0.0
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 一
.....\glue 0.0 plus 0.60931
.....\hbox(9.27464+1.26472)x10.53937, direction TLT
......\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 章
.....\glue 3.16183
.....\glue 0.0 plus 1.0fil
....\penalty 0
....\hbox(9.27464+1.26472)x10.53937, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 测
....\penalty 500
....\glue 0.0 plus 0.60931
....\hbox(9.27464+1.26472)x10.53937, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 试
....\penalty 10000
....\glue 0.0 plus 1.0fil
....\penalty 10000
....\hbox(6.90329+0.11594)x16.33604, glue set 10.27591fil, direction TLT
.....\whatsit4=[]
.....\glue 0.0 plus 1.0fil minus 1.0fil
.....\TU/lmr/bx/n/10.53937 3
.....\kern-1.0
.....\kern1.0
....\penalty 10000
....\glue(\parfillskip) -16.33604
....\glue(\rightskip) 16.33604
...\penalty 301
...\penalty -301
...\glue 10.53937 plus 1.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.90208
...\hbox(9.27464+1.26472)x345.0, glue set 267.53558fil, direction TLT
....\whatsit4=[]
....\glue(\leftskip) 15.80905
....\localpar
.....\localinterlinepenalty=0
.....\localbrokenpenalty=0
.....\localleftbox=null
.....\localrightbox=null
....\hbox(0.0+0.0)x0.0, direction TLT
....\glue -15.80905
....\hbox(9.27464+1.26472)x40.04962, glue set 5.26968fil, direction TLT
.....\whatsit4=[]
.....\hbox(9.27464+1.26472)x10.53937, direction TLT
......\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 第
.....\glue 0.0 plus 0.60931
.....\norule(9.27464+1.26472)x0.0
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 二
.....\glue 0.0 plus 0.60931
.....\hbox(9.27464+1.26472)x10.53937, direction TLT
......\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 章
.....\glue 3.16183
.....\glue 0.0 plus 1.0fil
....\penalty 0
....\hbox(9.27464+1.26472)x10.53937, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 测
....\penalty 500
....\glue 0.0 plus 0.60931
....\hbox(9.27464+1.26472)x10.53937, direction TLT
.....\LTJY3/FandolSong-Regular(0)/bx/n/10.53937 试
....\penalty 10000
....\glue 0.0 plus 1.0fil
....\penalty 10000
....\hbox(6.91382+0.0)x16.33604, glue set 10.27591fil, direction TLT
.....\whatsit4=[]
.....\glue 0.0 plus 1.0fil minus 1.0fil
.....\TU/lmr/bx/n/10.53937 4
.....\kern-1.0
.....\kern1.0
....\penalty 10000
....\glue(\parfillskip) -16.33604
....\glue(\rightskip) 16.33604
...\penalty 301
...\glue -1.26472
...\glue 0.0 plus 1.0fil
...\glue 0.0
..\glue(\baselineskip) 18.27571
..\hbox(7.01923+0.0)x345.0, glue set 169.86516fil, direction TLT
...\whatsit4=[]
...\glue 0.0 plus 1.0fil
...\TU/lmr/m/n/10.53937 2
...\glue 0.0 plus 1.0fil
============================================================
29 changes: 29 additions & 0 deletions ctex/test/testfiles/github472-01.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
\input{regression-test}

\documentclass[fontset=fandol,openany]{ctexbook}
\usepackage{titletoc}

\begin{document}

\START

\AUTHOR{Xiangdong Zeng}

\OMIT
\mbox{文字ABC}
\clearpage
\TIMO

\loggingoutput

\TEST{\tableofcontents with titletoc}{
\tableofcontents
\clearpage
}

\OMIT

\chapter{测试}
\chapter{测试}

\end{document}
133 changes: 133 additions & 0 deletions ctex/test/testfiles/github472-01.pdftex.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Author: Xiangdong Zeng
============================================================
TEST 1: \tableofcontents with titletoc
============================================================
(github472-01.toc)
\tf@toc=\write...
Completed box being shipped out [2]
\vbox(627.36243+0.0)x434.0
.\glue 22.0
.\vbox(605.36243+0.0)x345.0, shifted 89.0
..\vbox(12.0+0.0)x345.0, glue set 12.0fil
...\glue 0.0 plus 1.0fil
...\hbox(0.0+0.0)x345.0
..\glue 18.06749
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0, glue set 361.58957fil
...\write-{}
...\write-{}
...\glue(\topskip) 10.0
...\rule(0.0+0.0)x*
...\penalty 10000
...\glue 50.0
...\glue 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 16.78278
...\hbox(17.66599+2.20825)x345.0, glue set 150.41751fil
....\glue(\leftskip) 0.0 plus 1.0fil
....\hbox(0.0+0.0)x0.0
....\C70/rm/bx/n/22.08249/76 �
....\kern -0.00002
....\kern 0.00002
....\glue 0.0 plus 2.75732
....\C70/rm/bx/n/22.08249/5f U
....\kern -0.00002
....\kern 0.00002
....\penalty 10000
....\glue(\parfillskip) 0.0
....\glue(\rightskip) 0.0 plus 1.0fil
...\mark{{\protect \MakeUppercase {目录}}{\protect \MakeUppercase {目录}\ETC.}
...\penalty 10000
...\glue 40.0
...\glue 10.53938 plus 1.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 5.80171
...\hbox(8.43149+1.05394)x345.0, glue set 267.06131fil
....\glue(\leftskip) 15.80907
....\hbox(0.0+0.0)x0.0
....\glue -15.80907
....\hbox(8.43149+1.05394)x40.52388, glue set 5.26968fil
.....\C70/rm/bx/n/10.53937/7b ,
.....\kern -0.00002
.....\kern 0.00002
.....\glue 0.0 plus 0.60931
.....\C70/rm/bx/n/10.53937/4e ^^@
.....\kern -0.00002
.....\kern 0.00002
.....\glue 0.0 plus 0.60931
.....\C70/rm/bx/n/10.53937/7a �
.....\kern -0.00002
.....\kern 0.00002
.....\glue 3.6361
.....\glue 0.0 plus 1.0fil
....\C70/rm/bx/n/10.53937/6d K
....\kern -0.00002
....\kern 0.00002
....\glue 0.0 plus 0.60931
....\C70/rm/bx/n/10.53937/8b �
....\kern -0.00002
....\kern 0.00002
....\penalty 10000
....\glue 0.0 plus 1.0fil
....\penalty 10000
....\hbox(6.79202+0.0)x16.33607, glue set 10.27599fil
.....\glue 0.0 plus 1.0fil minus 1.0fil
.....\OT1/cmr/bx/n/10.53937 3
.....\kern -1.0
.....\kern 1.0
....\penalty 10000
....\glue(\parfillskip) -16.33607
....\glue(\rightskip) 16.33607
...\penalty 301
...\penalty -301
...\glue 10.53938 plus 1.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 6.95602
...\hbox(8.43149+1.05394)x345.0, glue set 267.06131fil
....\glue(\leftskip) 15.80907
....\hbox(0.0+0.0)x0.0
....\glue -15.80907
....\hbox(8.43149+1.05394)x40.52388, glue set 5.26968fil
.....\C70/rm/bx/n/10.53937/7b ,
.....\kern -0.00002
.....\kern 0.00002
.....\glue 0.0 plus 0.60931
.....\C70/rm/bx/n/10.53937/4e �
.....\kern -0.00002
.....\kern 0.00002
.....\glue 0.0 plus 0.60931
.....\C70/rm/bx/n/10.53937/7a �
.....\kern -0.00002
.....\kern 0.00002
.....\glue 3.6361
.....\glue 0.0 plus 1.0fil
....\C70/rm/bx/n/10.53937/6d K
....\kern -0.00002
....\kern 0.00002
....\glue 0.0 plus 0.60931
....\C70/rm/bx/n/10.53937/8b �
....\kern -0.00002
....\kern 0.00002
....\penalty 10000
....\glue 0.0 plus 1.0fil
....\penalty 10000
....\hbox(6.79202+0.0)x16.33607, glue set 10.27599fil
.....\glue 0.0 plus 1.0fil minus 1.0fil
.....\OT1/cmr/bx/n/10.53937 4
.....\kern -1.0
.....\kern 1.0
....\penalty 10000
....\glue(\parfillskip) -16.33607
....\glue(\rightskip) 16.33607
...\penalty 301
...\glue -1.05394
...\glue 0.0 plus 1.0fil
...\glue 0.0
..\glue(\baselineskip) 18.50291
..\hbox(6.79202+0.0)x345.0, glue set 169.86516fil
...\glue 0.0 plus 1.0fil
...\OT1/cmr/m/n/10.53937 2
...\glue 0.0 plus 1.0fil
============================================================
Loading

0 comments on commit 6047a4c

Please sign in to comment.