texlive[54976] Master/texmf-dist: ctex (2may20)

commits+karl at tug.org commits+karl at tug.org
Sun May 3 00:24:14 CEST 2020


Revision: 54976
          http://tug.org/svn/texlive?view=revision&revision=54976
Author:   karl
Date:     2020-05-03 00:24:14 +0200 (Sun, 03 May 2020)
Log Message:
-----------
ctex (2may20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/ctex/README.md
    trunk/Master/texmf-dist/doc/latex/ctex/ctex.pdf
    trunk/Master/texmf-dist/source/latex/ctex/ctex.dtx
    trunk/Master/texmf-dist/source/latex/ctex/ctexpunct.spa
    trunk/Master/texmf-dist/tex/generic/ctex/ctexmakespa.tex
    trunk/Master/texmf-dist/tex/generic/ctex/ctexspamacro.tex
    trunk/Master/texmf-dist/tex/generic/ctex/ctxdocstrip.tex
    trunk/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex
    trunk/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex
    trunk/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex
    trunk/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex
    trunk/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex
    trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg
    trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg
    trunk/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg
    trunk/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo
    trunk/Master/texmf-dist/tex/latex/ctex/ctex.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexart.cls
    trunk/Master/texmf-dist/tex/latex/ctex/ctexbeamer.cls
    trunk/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
    trunk/Master/texmf-dist/tex/latex/ctex/ctexcap.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexheading.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexhook.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexpatch.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexrep.cls
    trunk/Master/texmf-dist/tex/latex/ctex/ctexsize.sty
    trunk/Master/texmf-dist/tex/latex/ctex/ctexspa.def
    trunk/Master/texmf-dist/tex/latex/ctex/ctxdoc.cls
    trunk/Master/texmf-dist/tex/latex/ctex/dictionary/translator-theorem-dictionary-ChineseGBK.dict
    trunk/Master/texmf-dist/tex/latex/ctex/dictionary/translator-theorem-dictionary-ChineseUTF8.dict
    trunk/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-aptex.def
    trunk/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def
    trunk/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def
    trunk/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-uptex.def
    trunk/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c19rm.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c19sf.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c19tt.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c70rm.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c70sf.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/c70tt.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jt2zhrm.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jt2zhsf.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jt2zhtt.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jy2zhrm.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jy2zhsf.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fd/jy2zhtt.fd
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-adobe.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-founder.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-macnew.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-macold.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-ubuntu.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-beamer.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-report.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-article.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-beamer.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-book.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-report.def
    trunk/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain.def

Added Paths:
-----------
    trunk/Master/texmf-dist/source/latex/ctex/ctex-zhconv-make.lua
    trunk/Master/texmf-dist/source/latex/ctex/ctex.ins
    trunk/Master/texmf-dist/tex/generic/ctex/zhmacfonts.tex
    trunk/Master/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg
    trunk/Master/texmf-dist/tex/latex/ctex/heading/
    trunk/Master/texmf-dist/tex/latex/ctex/heading/ctex-heading-article.def
    trunk/Master/texmf-dist/tex/latex/ctex/heading/ctex-heading-beamer.def
    trunk/Master/texmf-dist/tex/latex/ctex/heading/ctex-heading-book.def
    trunk/Master/texmf-dist/tex/latex/ctex/heading/ctex-heading-report.def
    trunk/Master/texmf-dist/tex/luatex/ctex/
    trunk/Master/texmf-dist/tex/luatex/ctex/ctex-zhconv-index.lua
    trunk/Master/texmf-dist/tex/luatex/ctex/ctex-zhconv.lua

Removed Paths:
-------------
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-article.def
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-beamer.def
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-book.def
    trunk/Master/texmf-dist/tex/latex/ctex/ctex-report.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def
    trunk/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsold.def

Modified: trunk/Master/texmf-dist/doc/latex/ctex/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ctex/README.md	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/doc/latex/ctex/README.md	2020-05-02 22:24:14 UTC (rev 54976)
@@ -15,6 +15,10 @@
 * Chen Zhichu <zhichu.chen at gmail.com>
 * Li Qing <sobenlee at gmail.com>
 * Liam Huang <liamhuang0205 at gmail.com>
+* Zeng Xiangdong <xdzeng96 at gmail.com>
+* Li Zeping <zepinglee at gmail.com>
+* Zhou Yukai <muzimuzhi at gmail.com>
+* Zhang Ruixi <ruixizhang42 at gmail.com>
 
 Contributing
 ------------
@@ -26,7 +30,7 @@
 Copyright and Licence
 ---------------------
 
-    Copyright (C) 2003--2019
+    Copyright (C) 2003--2020
     CTEX.ORG and any individual authors listed elsewhere in this file.
     ----------------------------------------------------------------------
 
@@ -40,11 +44,13 @@
     and version 1.3 or later is part of all distributions of
     LaTeX version 2005/12/01 or later.
 
-    This work has the LPPL maintenance status `maintained'.
+    This work has the LPPL maintenance status "maintained".
 
-    The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-
-    This package consists of the file  ctex.dtx,
+    This package consists of the files ctex.dtx,
+                                       ctxdoc.cls,
+                                       ctxdocstrip.tex,
+                                       ctex-zhconv.lua,
+                                       ctex-zhconv-make.lua,
                  and the derived files ctex.pdf,
                                        ctex.ins,
                                        ctex.sty,
@@ -54,16 +60,15 @@
                                        ctexbook.cls,
                                        ctexrep.cls,
                                        ctexbeamer.cls,
-                                       ctxdoc.cls,
                                        ctexcap.sty,
                                        ctexhook.sty,
                                        ctexpatch.sty,
                                        ctex-c5size.clo,
                                        ctex-cs4size.clo,
-                                       ctex-article.def,
-                                       ctex-book.def,
-                                       ctex-report.def,
-                                       ctex-beamer.def,
+                                       ctex-heading-article.def,
+                                       ctex-heading-book.def,
+                                       ctex-heading-report.def,
+                                       ctex-heading-beamer.def,
                                        ctex-scheme-plain.def,
                                        ctex-scheme-plain-article.def,
                                        ctex-scheme-plain-book.def,
@@ -78,6 +83,7 @@
                                        ctex-name-utf8.cfg,
                                        ctex.cfg,
                                        ctexopts.cfg,
+                                       ctexbackend.cfg,
                                        ctex-engine-pdftex.def,
                                        ctex-engine-xetex.def,
                                        ctex-engine-luatex.def,
@@ -95,26 +101,25 @@
                                        jt2zhrm.fd,
                                        jt2zhsf.fd,
                                        jt2zhtt.fd,
-                                       ctex-fontset-windows.def,
-                                       ctex-fontset-windowsnew.def,
-                                       ctex-fontset-windowsold.def,
                                        ctex-fontset-adobe.def,
                                        ctex-fontset-fandol.def,
+                                       ctex-fontset-founder.def,
                                        ctex-fontset-mac.def,
                                        ctex-fontset-macnew.def,
                                        ctex-fontset-macold.def,
-                                       ctex-fontset-founder.def,
                                        ctex-fontset-ubuntu.def,
+                                       ctex-fontset-windows.def,
                                        ctexspa.def,
                                        ctexpunct.spa,
                                        ctexmakespa.tex,
                                        ctexspamacro.tex,
-                                       ctxdocstrip.tex,
                                        zhadobefonts.tex,
                                        zhfandolfonts.tex,
                                        zhfounderfonts.tex,
+                                       zhmacfonts.tex,
                                        zhubuntufonts.tex,
                                        zhwindowsfonts.tex,
+                                       ctex-zhconv-index.lua,
                                        translator-theorem-dictionary-ChineseGBK.dict,
                                        translator-theorem-dictionary-ChineseUTF8.dict, and
                                        README.md (this file).

Modified: trunk/Master/texmf-dist/doc/latex/ctex/ctex.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/source/latex/ctex/ctex-zhconv-make.lua
===================================================================
--- trunk/Master/texmf-dist/source/latex/ctex/ctex-zhconv-make.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/ctex/ctex-zhconv-make.lua	2020-05-02 22:24:14 UTC (rev 54976)
@@ -0,0 +1,114 @@
+#!/usr/bin/env texlua
+--
+--  File ctex-zhconv-make.lua
+--
+--     Copyright (C) 2020 by Qing Lee <sobenlee at gmail.com>
+--------------------------------------------------------------------------
+--
+--     This work may be distributed and/or modified under the
+--     conditions of the LaTeX Project Public License, either
+--     version 1.3c of this license or (at your option) any later
+--     version. This version of this license is in
+--        http://www.latex-project.org/lppl/lppl-1-3c.txt
+--     and the latest version of this license is in
+--        http://www.latex-project.org/lppl.txt
+--     and version 1.3 or later is part of all distributions of
+--     LaTeX version 2005/12/01 or later.
+--
+--     This work has the LPPL maintenance status "maintained".
+--
+--     The Current Maintainer of this work is Qing Lee.
+--
+--     This work consists of the files ctex-zhconv.lua, ctex-zhconv-make.lua
+--               and the derived file  ctex-zhconv-index.lua.
+--
+--------------------------------------------------------------------------
+--
+
+local preamble = [[
+--
+--  File ctex-zhconv-index.lua
+--
+--     Copyright (C) 2020 by Qing Lee <sobenlee at gmail.com>
+--------------------------------------------------------------------------
+--
+--     This work may be distributed and/or modified under the
+--     conditions of the LaTeX Project Public License, either
+--     version 1.3c of this license or (at your option) any later
+--     version. This version of this license is in
+--        http://www.latex-project.org/lppl/lppl-1-3c.txt
+--     and the latest version of this license is in
+--        http://www.latex-project.org/lppl.txt
+--     and version 1.3 or later is part of all distributions of
+--     LaTeX version 2005/12/01 or later.
+--
+--     This work has the LPPL maintenance status "maintained".
+--
+--     The Current Maintainer of this work is Qing Lee.
+--
+--     This work consists of the files ctex-zhconv.lua, ctex-zhconv-make.lua
+--               and the derived file  ctex-zhconv-index.lua.
+--
+--------------------------------------------------------------------------
+--
+--  Do not edit this file!
+--  Generated from the WHATWG Encoding Standard:
+--
+--     https://encoding.spec.whatwg.org/index-big5.txt           (Date: %s)
+--     https://encoding.spec.whatwg.org/index-gb18030.txt        (Date: %s)
+--     https://encoding.spec.whatwg.org/index-gb18030-ranges.txt (Date: %s)
+--
+--
+]]
+
+local rep, format, dump = string.rep, string.format, string.dump
+local insert, unpack, concat = table.insert, table.unpack, table.concat
+local io_open, os_execute = io.open, os.execute
+
+local curlcmd = "curl --silent --output %s https://encoding.spec.whatwg.org/%s"
+local function prepare_index (file)
+  local file_path = file
+  local handle = io_open(file, "rb")
+  if handle then return handle end
+  local ret = os_execute(curlcmd:format(file, file))
+  assert(ret == 0, "the curl command failed with: ".. ret)
+  return assert(io_open(file, "rb"))
+end
+
+local index, date = { }, { }
+
+local indent = 2
+local begin_enc = "%s[%q] = {"
+local end_enc   = "%s} ,"
+local num_item = "%s[%s] = %s ,"
+local tab_item = "%s{ %6d , %s } ,"
+local tab = rep(" ", indent)
+local tabtab = tab .. tab
+
+insert(index, "return {")
+for i, v in ipairs { { "index-big5.txt",  "big5" },
+                     { "index-gb18030.txt", "gb18030" },
+                     { "index-gb18030-ranges.txt", "gb18030_ranges" } } do
+  local file, encode = unpack(v)
+  local handle = prepare_index(file)
+  insert(index, begin_enc:format(tab, encode))
+  for line in handle:lines() do
+    if not date[i] then
+      local s = line:match("Date: (.+)$")
+      if s then date[i] = s end
+    end
+    local pointer, code_point = line:match("^%s*(%d+)\t(0x%x+)")
+    if pointer and code_point then
+      insert(index, format(i == 3 and tab_item or num_item, tabtab, pointer, code_point))
+    end
+  end
+  insert(index, end_enc:format(tab))
+  handle:close()
+end
+insert(index, "}\n")
+
+local index = concat(index, "\n")
+
+local handle = io_open("ctex-zhconv-index.lua", "wb")
+handle:write(preamble:format(unpack(date)), index)
+handle:close()


Property changes on: trunk/Master/texmf-dist/source/latex/ctex/ctex-zhconv-make.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/source/latex/ctex/ctex.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/ctex/ctex.dtx	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/source/latex/ctex/ctex.dtx	2020-05-02 22:24:14 UTC (rev 54976)
@@ -2,7 +2,7 @@
 % !TeX program  = XeLaTeX
 % !TeX encoding = UTF-8
 %
-% Copyright (C) 2003--2019
+% Copyright (C) 2003--2020
 % CTEX.ORG and any individual authors listed elsewhere in this file.
 % --------------------------------------------------------------------------
 %
@@ -16,10 +16,8 @@
 % and version 1.3 or later is part of all distributions of
 % LaTeX version 2005/12/01 or later.
 %
-% This work has the LPPL maintenance status `maintained'.
+% This work has the LPPL maintenance status "maintained".
 %
-% The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%
 % --------------------------------------------------------------------------
 %
 %<*internal>
@@ -43,6 +41,10 @@
 * Chen Zhichu <zhichu.chen at gmail.com>
 * Li Qing <sobenlee at gmail.com>
 * Liam Huang <liamhuang0205 at gmail.com>
+* Zeng Xiangdong <xdzeng96 at gmail.com>
+* Li Zeping <zepinglee at gmail.com>
+* Zhou Yukai <muzimuzhi at gmail.com>
+* Zhang Ruixi <ruixizhang42 at gmail.com>
 
 Contributing
 ------------
@@ -54,7 +56,7 @@
 Copyright and Licence
 ---------------------
 
-    Copyright (C) 2003--2019
+    Copyright (C) 2003--2020
     CTEX.ORG and any individual authors listed elsewhere in this file.
     ----------------------------------------------------------------------
 
@@ -68,11 +70,13 @@
     and version 1.3 or later is part of all distributions of
     LaTeX version 2005/12/01 or later.
 
-    This work has the LPPL maintenance status `maintained'.
+    This work has the LPPL maintenance status "maintained".
 
-    The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-
-    This package consists of the file  ctex.dtx,
+    This package consists of the files ctex.dtx,
+                                       ctxdoc.cls,
+                                       ctxdocstrip.tex,
+                                       ctex-zhconv.lua,
+                                       ctex-zhconv-make.lua,
                  and the derived files ctex.pdf,
                                        ctex.ins,
                                        ctex.sty,
@@ -82,16 +86,15 @@
                                        ctexbook.cls,
                                        ctexrep.cls,
                                        ctexbeamer.cls,
-                                       ctxdoc.cls,
                                        ctexcap.sty,
                                        ctexhook.sty,
                                        ctexpatch.sty,
                                        ctex-c5size.clo,
                                        ctex-cs4size.clo,
-                                       ctex-article.def,
-                                       ctex-book.def,
-                                       ctex-report.def,
-                                       ctex-beamer.def,
+                                       ctex-heading-article.def,
+                                       ctex-heading-book.def,
+                                       ctex-heading-report.def,
+                                       ctex-heading-beamer.def,
                                        ctex-scheme-plain.def,
                                        ctex-scheme-plain-article.def,
                                        ctex-scheme-plain-book.def,
@@ -106,6 +109,7 @@
                                        ctex-name-utf8.cfg,
                                        ctex.cfg,
                                        ctexopts.cfg,
+                                       ctexbackend.cfg,
                                        ctex-engine-pdftex.def,
                                        ctex-engine-xetex.def,
                                        ctex-engine-luatex.def,
@@ -123,26 +127,25 @@
                                        jt2zhrm.fd,
                                        jt2zhsf.fd,
                                        jt2zhtt.fd,
-                                       ctex-fontset-windows.def,
-                                       ctex-fontset-windowsnew.def,
-                                       ctex-fontset-windowsold.def,
                                        ctex-fontset-adobe.def,
                                        ctex-fontset-fandol.def,
+                                       ctex-fontset-founder.def,
                                        ctex-fontset-mac.def,
                                        ctex-fontset-macnew.def,
                                        ctex-fontset-macold.def,
-                                       ctex-fontset-founder.def,
                                        ctex-fontset-ubuntu.def,
+                                       ctex-fontset-windows.def,
                                        ctexspa.def,
                                        ctexpunct.spa,
                                        ctexmakespa.tex,
                                        ctexspamacro.tex,
-                                       ctxdocstrip.tex,
                                        zhadobefonts.tex,
                                        zhfandolfonts.tex,
                                        zhfounderfonts.tex,
+                                       zhmacfonts.tex,
                                        zhubuntufonts.tex,
                                        zhwindowsfonts.tex,
+                                       ctex-zhconv-index.lua,
                                        translator-theorem-dictionary-ChineseGBK.dict,
                                        translator-theorem-dictionary-ChineseUTF8.dict, and
                                        README.md (this file).
@@ -160,9 +163,9 @@
 
 \preamble
 
-    Copyright (C) 2003--2019
+    Copyright (C) 2003--2020
     CTEX.ORG and any individual authors listed in the documentation.
-------------------------------------------------------------------------------
+---------------------------------------------------------------------
 
     This work may be distributed and/or modified under the
     conditions of the LaTeX Project Public License, either
@@ -174,16 +177,18 @@
     and version 1.3 or later is part of all distributions of
     LaTeX version 2005/12/01 or later.
 
-    This work has the LPPL maintenance status `maintained'.
+    This work has the LPPL maintenance status "maintained".
 
-    The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+---------------------------------------------------------------------
 
-------------------------------------------------------------------------------
-
 \endpreamble
 \postamble
 
-    This package consists of the file  ctex.dtx,
+    This package consists of the files ctex.dtx,
+                                       ctxdoc.cls,
+                                       ctxdocstrip.tex,
+                                       ctex-zhconv.lua,
+                                       ctex-zhconv-make.lua,
                  and the derived files ctex.pdf,
                                        ctex.ins,
                                        ctex.sty,
@@ -193,16 +198,15 @@
                                        ctexbook.cls,
                                        ctexrep.cls,
                                        ctexbeamer.cls,
-                                       ctxdoc.cls,
                                        ctexcap.sty,
                                        ctexhook.sty,
                                        ctexpatch.sty,
                                        ctex-c5size.clo,
                                        ctex-cs4size.clo,
-                                       ctex-article.def,
-                                       ctex-book.def,
-                                       ctex-report.def,
-                                       ctex-beamer.def,
+                                       ctex-heading-article.def,
+                                       ctex-heading-book.def,
+                                       ctex-heading-report.def,
+                                       ctex-heading-beamer.def,
                                        ctex-scheme-plain.def,
                                        ctex-scheme-plain-article.def,
                                        ctex-scheme-plain-book.def,
@@ -217,6 +221,7 @@
                                        ctex-name-utf8.cfg,
                                        ctex.cfg,
                                        ctexopts.cfg,
+                                       ctexbackend.cfg,
                                        ctex-engine-pdftex.def,
                                        ctex-engine-xetex.def,
                                        ctex-engine-luatex.def,
@@ -234,26 +239,25 @@
                                        jt2zhrm.fd,
                                        jt2zhsf.fd,
                                        jt2zhtt.fd,
-                                       ctex-fontset-windows.def,
-                                       ctex-fontset-windowsnew.def,
-                                       ctex-fontset-windowsold.def,
                                        ctex-fontset-adobe.def,
                                        ctex-fontset-fandol.def,
+                                       ctex-fontset-founder.def,
                                        ctex-fontset-mac.def,
                                        ctex-fontset-macnew.def,
                                        ctex-fontset-macold.def,
-                                       ctex-fontset-founder.def,
                                        ctex-fontset-ubuntu.def,
+                                       ctex-fontset-windows.def,
                                        ctexspa.def,
                                        ctexpunct.spa,
                                        ctexmakespa.tex,
                                        ctexspamacro.tex,
-                                       ctxdocstrip.tex,
                                        zhadobefonts.tex,
                                        zhfandolfonts.tex,
                                        zhfounderfonts.tex,
+                                       zhmacfonts.tex,
                                        zhubuntufonts.tex,
                                        zhwindowsfonts.tex,
+                                       ctex-zhconv-index.lua,
                                        translator-theorem-dictionary-ChineseGBK.dict,
                                        translator-theorem-dictionary-ChineseUTF8.dict, and
                                        README.md.
@@ -270,16 +274,15 @@
     \file{ctexrep.cls}                     {\from{\jobname.dtx}{class,report}}
     \file{ctexbeamer.cls}                  {\from{\jobname.dtx}{class,beamer}}
     \usepostamble\emptypostamble
-    \file{ctxdoc.cls}                      {\from{\jobname.dtx}{ctxdoc}}
     \file{ctexcap.sty}                     {\from{\jobname.dtx}{ctexcap}}
     \file{ctexhook.sty}                    {\from{\jobname.dtx}{ctexhook}}
     \file{ctexpatch.sty}                   {\from{\jobname.dtx}{ctexpatch}}
     \file{ctex-c5size.clo}                 {\from{\jobname.dtx}{c5size}}
     \file{ctex-cs4size.clo}                {\from{\jobname.dtx}{cs4size}}
-    \file{ctex-article.def}                {\from{\jobname.dtx}{heading,article}}
-    \file{ctex-book.def}                   {\from{\jobname.dtx}{heading,book}}
-    \file{ctex-report.def}                 {\from{\jobname.dtx}{heading,report}}
-    \file{ctex-beamer.def}                 {\from{\jobname.dtx}{heading,beamer}}
+    \file{ctex-heading-article.def}        {\from{\jobname.dtx}{heading,article}}
+    \file{ctex-heading-book.def}           {\from{\jobname.dtx}{heading,book}}
+    \file{ctex-heading-report.def}         {\from{\jobname.dtx}{heading,report}}
+    \file{ctex-heading-beamer.def}         {\from{\jobname.dtx}{heading,beamer}}
     \file{ctex-scheme-plain.def}           {\from{\jobname.dtx}{scheme,generic,plain}}
     \file{ctex-scheme-plain-article.def}   {\from{\jobname.dtx}{scheme,article,plain}}
     \file{ctex-scheme-plain-book.def}      {\from{\jobname.dtx}{scheme,book,plain}}
@@ -290,10 +293,11 @@
     \file{ctex-scheme-chinese-book.def}    {\from{\jobname.dtx}{scheme,book,chinese}}
     \file{ctex-scheme-chinese-report.def}  {\from{\jobname.dtx}{scheme,report,chinese}}
     \file{ctex-scheme-chinese-beamer.def}  {\from{\jobname.dtx}{scheme,beamer,chinese}}
-    \file{ctex-name-gbk.cfg}               {\from{\jobname.dtx}{name,GBK}}
+ \ctxfile{GBK}{ctex-name-gbk.cfg}          {\from{\jobname.dtx}{name,GBK}}
     \file{ctex-name-utf8.cfg}              {\from{\jobname.dtx}{name,UTF8}}
     \file{ctex.cfg}                        {\from{\jobname.dtx}{config}}
     \file{ctexopts.cfg}                    {\from{\jobname.dtx}{ctexopts}}
+    \file{ctexbackend.cfg}                 {\from{\jobname.dtx}{backend}}
     \file{ctex-engine-pdftex.def}          {\from{\jobname.dtx}{pdftex}}
     \file{ctex-engine-xetex.def}           {\from{\jobname.dtx}{xetex}}
     \file{ctex-engine-luatex.def}          {\from{\jobname.dtx}{luatex}}
@@ -311,25 +315,20 @@
     \file{jt2zhrm.fd}                      {\from{\jobname.dtx}{fd,rm,jt2}}
     \file{jt2zhsf.fd}                      {\from{\jobname.dtx}{fd,sf,jt2}}
     \file{jt2zhtt.fd}                      {\from{\jobname.dtx}{fd,tt,jt2}}
-    \file{ctex-fontset-windows.def}        {\from{\jobname.dtx}{fontset,windows}}
-    \file{ctex-fontset-windowsnew.def}     {\from{\jobname.dtx}{fontset,windowsnew}}
-    \file{ctex-fontset-windowsold.def}     {\from{\jobname.dtx}{fontset,windowsold}}
     \file{ctex-fontset-adobe.def}          {\from{\jobname.dtx}{fontset,adobe}}
     \file{ctex-fontset-fandol.def}         {\from{\jobname.dtx}{fontset,fandol}}
+    \file{ctex-fontset-founder.def}        {\from{\jobname.dtx}{fontset,founder}}
     \file{ctex-fontset-mac.def}            {\from{\jobname.dtx}{fontset,mac}}
+    \file{ctex-fontset-macnew.def}         {\from{\jobname.dtx}{fontset,macnew}}
     \file{ctex-fontset-macold.def}         {\from{\jobname.dtx}{fontset,macold}}
-    \file{ctex-fontset-macnew.def}         {\from{\jobname.dtx}{fontset,macnew}}
-    \file{ctex-fontset-founder.def}        {\from{\jobname.dtx}{fontset,founder}}
     \file{ctex-fontset-ubuntu.def}         {\from{\jobname.dtx}{fontset,ubuntu}}
-    \file{translator-theorem-dictionary-ChineseGBK.dict}
+    \file{ctex-fontset-windows.def}        {\from{\jobname.dtx}{fontset,windows}}
+ \ctxfile{GBK}{translator-theorem-dictionary-ChineseGBK.dict}
                                            {\from{\jobname.dtx}{dict,theorem,GBK}}
     \file{translator-theorem-dictionary-ChineseUTF8.dict}
                                            {\from{\jobname.dtx}{dict,theorem,UTF8}}
-    \file{ctexspa.def}
-      {
-        \from{\jobname.dtx}  {ctexspa}
-        \from{ctexpunct.spa} {}
-      }
+    \file{ctexspa.def}                     {\from{\jobname.dtx}{ctexspa}
+                                            \from{ctexpunct.spa}{}}
     \usedir{tex/generic/ctex}
     \file{ctexmakespa.tex}                 {\from{\jobname.dtx}{spa,make}}
     \file{ctexspamacro.tex}                {\from{\jobname.dtx}{spa,macro}}
@@ -336,9 +335,9 @@
     \file{zhadobefonts.tex}                {\from{\jobname.dtx}{zhmap,adobe}}
     \file{zhfandolfonts.tex}               {\from{\jobname.dtx}{zhmap,fandol}}
     \file{zhfounderfonts.tex}              {\from{\jobname.dtx}{zhmap,founder}}
+    \file{zhmacfonts.tex}                  {\from{\jobname.dtx}{zhmap,mac}}
     \file{zhubuntufonts.tex}               {\from{\jobname.dtx}{zhmap,ubuntu}}
     \file{zhwindowsfonts.tex}              {\from{\jobname.dtx}{zhmap,windows}}
-    \file{ctxdocstrip.tex}                 {\from{\jobname.dtx}{docstrip}}
 %</install>
 %<*internal>
     \usedir{source/latex/ctex}
@@ -366,16 +365,15 @@
 \Msg{*     ctexbook.cls                                          *}
 \Msg{*     ctexrep.cls                                           *}
 \Msg{*     ctexbeamer.cls                                        *}
-\Msg{*     ctxdoc.cls                                            *}
 \Msg{*     ctexcap.sty                                           *}
 \Msg{*     ctexhook.sty                                          *}
 \Msg{*     ctexpatch.sty                                         *}
 \Msg{*     ctex-c5size.clo                                       *}
 \Msg{*     ctex-cs4size.clo                                      *}
-\Msg{*     ctex-article.def                                      *}
-\Msg{*     ctex-book.def                                         *}
-\Msg{*     ctex-report.def                                       *}
-\Msg{*     ctex-beamer.def                                       *}
+\Msg{*     ctex-heading-article.def                              *}
+\Msg{*     ctex-heading-book.def                                 *}
+\Msg{*     ctex-heading-report.def                               *}
+\Msg{*     ctex-heading-beamer.def                               *}
 \Msg{*     ctex-scheme-plain.def                                 *}
 \Msg{*     ctex-scheme-plain-article.def                         *}
 \Msg{*     ctex-scheme-plain-book.def                            *}
@@ -390,6 +388,7 @@
 \Msg{*     ctex-name-utf8.cfg                                    *}
 \Msg{*     ctex.cfg                                              *}
 \Msg{*     ctexopts.cfg                                          *}
+\Msg{*     ctexbackend.cfg                                       *}
 \Msg{*     ctex-engine-pdftex.def                                *}
 \Msg{*     ctex-engine-xetex.def                                 *}
 \Msg{*     ctex-engine-luatex.def                                *}
@@ -407,23 +406,21 @@
 \Msg{*     jt2zhrm.fd                                            *}
 \Msg{*     jt2zhsf.fd                                            *}
 \Msg{*     jt2zhtt.fd                                            *}
-\Msg{*     ctex-fontset-windows.def                              *}
-\Msg{*     ctex-fontset-windowsnew.def                           *}
-\Msg{*     ctex-fontset-windowsold.def                           *}
 \Msg{*     ctex-fontset-adobe.def                                *}
 \Msg{*     ctex-fontset-fandol.def                               *}
+\Msg{*     ctex-fontset-founder.def                              *}
 \Msg{*     ctex-fontset-mac.def                                  *}
+\Msg{*     ctex-fontset-macnew.def                               *}
 \Msg{*     ctex-fontset-macold.def                               *}
-\Msg{*     ctex-fontset-macnew.def                               *}
-\Msg{*     ctex-fontset-founder.def                              *}
 \Msg{*     ctex-fontset-ubuntu.def                               *}
+\Msg{*     ctex-fontset-windows.def                              *}
 \Msg{*     ctexspa.def                                           *}
 \Msg{*     ctexmakespa.tex                                       *}
 \Msg{*     ctexspamacro.tex                                      *}
-\Msg{*     ctxdocstrip.tex                                       *}
 \Msg{*     zhadobefonts.tex                                      *}
 \Msg{*     zhfandolfonts.tex                                     *}
 \Msg{*     zhfounderfonts.tex                                    *}
+\Msg{*     zhmacfonts.tex                                        *}
 \Msg{*     zhubuntufonts.tex                                     *}
 \Msg{*     zhwindowsfonts.tex                                    *}
 \Msg{*     translator-theorem-dictionary-ChineseGBK.dict         *}
@@ -442,12 +439,11 @@
 \fi
 %</internal>
 %<*!(driver|readme|install|zhmap|spa|docstrip)>
-%<*!(fd|ctexspa|dict)>
-%<class|style|ctexcap|ctexhook|ctexpatch|ctxdoc>\NeedsTeXFormat{LaTeX2e}
-%<class|style|ctexcap|ctexhook|ctexpatch|ctxdoc>\RequirePackage{expl3}
-%<+!driver>\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-%<ctxdoc>  {ctex documentation (CTEX)}
-%<ctxdoc>\ProvidesExplClass{ctxdoc}
+%<*!(fd|ctexspa|dict|backend)>
+%<class|style|ctexcap|ctexhook|ctexpatch>\NeedsTeXFormat{LaTeX2e}
+%<class>\input{ctexbackend.cfg}
+%<class|style|ctexcap|ctexhook|ctexpatch>\RequirePackage{expl3}
+%<+!driver>\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
 %<ctex>  {Chinese adapter in LaTeX (CTEX)}
 %<ctex>\ProvidesExplPackage{\ExplFileName}
 %<ctexsize>  {Chinese font size definition (CTEX)}
@@ -502,7 +498,7 @@
 %<scheme&chinese&beamer>\ProvidesExplFile{ctex-scheme-chinese-beamer.def}
 %<name&GBK>  {Caption with encoding GBK (CTEX)}
 %<name&GBK>\ProvidesExplFile{ctex-name-gbk.cfg}
-%<name&UTF8>  {Caption with encoding UTF8 (CTEX)}
+%<name&UTF8>  {Caption with encoding UTF-8 (CTEX)}
 %<name&UTF8>\ProvidesExplFile{ctex-name-utf8.cfg}
 %<config>  {Configuration file (CTEX)}
 %<config>\ProvidesExplFile{\ExplFileName.cfg}
@@ -520,26 +516,22 @@
 %<uptex>\ProvidesExplFile{ctex-engine-uptex.def}
 %<windows>  {Windows fonts definition (CTEX)}
 %<windows>\ProvidesExplFile{ctex-fontset-windows.def}
-%<windowsnew>  {Windows fonts definition for Vista or later version (CTEX)}
-%<windowsnew>\ProvidesExplFile{ctex-fontset-windowsnew.def}
-%<windowsold>  {Windows fonts definition for XP or earlier version (CTEX)}
-%<windowsold>\ProvidesExplFile{ctex-fontset-windowsold.def}
 %<adobe>  {Adobe fonts definition (CTEX)}
 %<adobe>\ProvidesExplFile{ctex-fontset-adobe.def}
 %<fandol>  {Fandol fonts definition (CTEX)}
 %<fandol>\ProvidesExplFile{ctex-fontset-fandol.def}
-%<mac>  {Mac OS X fonts definition (CTEX)}
+%<mac>  {macOS fonts definition (CTEX)}
 %<mac>\ProvidesExplFile{ctex-fontset-mac.def}
-%<macnew>  {Mac OS X fonts definition for El Capitan or later version (CTEX)}
+%<macnew>  {macOS fonts definition for El Capitan or later version (CTEX)}
 %<macnew>\ProvidesExplFile{ctex-fontset-macnew.def}
-%<macold>  {Mac OS X fonts definition for Yosemite or earlier version (CTEX)}
+%<macold>  {macOS fonts definition for Yosemite or earlier version (CTEX)}
 %<macold>\ProvidesExplFile{ctex-fontset-macold.def}
 %<founder>  {Founder fonts definition (CTEX)}
 %<founder>\ProvidesExplFile{ctex-fontset-founder.def}
 %<ubuntu>  {Ubuntu fonts definition (CTEX)}
 %<ubuntu>\ProvidesExplFile{ctex-fontset-ubuntu.def}
-%<!driver>  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
-%</!(fd|ctexspa|dict)>
+%<!driver>  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
+%</!(fd|ctexspa|dict|backend)>
 %<c19&rm>\ProvidesFile{c19rm.fd}%
 %<c19&sf>\ProvidesFile{c19sf.fd}%
 %<c19&tt>\ProvidesFile{c19tt.fd}%
@@ -553,11 +545,13 @@
 %<jt2&sf>\ProvidesFile{jt2zhsf.fd}%
 %<jt2&tt>\ProvidesFile{jt2zhtt.fd}%
 %<ctexspa>\ProvidesFile{ctexspa.def}%
+%<backend>\ProvidesFile{ctexbackend.cfg}%
 %<dict&theorem&GBK>\ProvidesDictionary{translator-theorem-dictionary}{ChineseGBK}%
 %<dict&theorem&UTF8>\ProvidesDictionary{translator-theorem-dictionary}{ChineseUTF8}%
-%<fd>  [2019/05/29 v2.4.16 Chinese font definition (CTEX)]
-%<ctexspa>  [2019/05/29 v2.4.16 Space info for CJKpunct (CTEX)]
-%<dict&theorem>  [2019/05/29 v2.4.16 Chinese translation for theorem name (CTEX)]
+%<fd>  [2020/05/02 v2.5.1 Chinese font definition (CTEX)]
+%<ctexspa>  [2020/05/02 v2.5.1 Space info for CJKpunct (CTEX)]
+%<backend>  [2020/05/02 v2.5.1 Backend configuration file (CTEX)]
+%<dict&theorem>  [2020/05/02 v2.5.1 Chinese translation for theorem name (CTEX)]
 %</!(driver|readme|install|zhmap|spa|docstrip)>
 %<*driver>
 \documentclass{ctxdoc}
@@ -579,10 +573,10 @@
 % \changes{v2.4}{2015/02/19}{加强 \pkg{beamer} 宏包支持。}
 % \changes{v2.4.12}{2018/01/13}{同步 \LaTeXiii{} 2017/12/16。}
 % \changes{v2.4.15}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。}
+% \changes{v2.5.1}{2020/05/02}{\pkg{zhconv} 更名为 \pkg{ctex-zhconv}。}
 %
+% \CheckSum{6105}
 %
-% \CheckSum{5934}
-%
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
 %   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -599,7 +593,7 @@
 %   Grave accent  \`     Left brace    \{     Vertical bar  \|
 %   Right brace   \}     Tilde         \~}
 %
-% \GetFileId{ctex.sty}%
+% \GetFileId{ctex.sty}
 %
 % \title{\bfseries \CTeX{} 宏集手册}
 % \author{\href{http://www.ctex.org}{CTEX.ORG}}
@@ -612,13 +606,13 @@
 % 日期转换等支持功能,可适应论文、报告、书籍、幻灯片等不同类型的中文文档。
 %
 % \CTeX{} 宏集支持 \LaTeX、\pdfLaTeX、\XeLaTeX、\LuaLaTeX、\upLaTeX{} 等多种不同
-% 的编译方式,并为它们提供了统一的界面。主要功能由宏包 \pkg{ctex} 和中文文档类
+% 的编译方式,并为它们提供了统一的界面。主要功能由宏包 \pkg{ctex} 以及中文文档类
 % \cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和 \cls{ctexbeamer} 实现。
 % \end{abstract}
 %
 % \tableofcontents
 %
-% \clearpage
+% \bigskip
 % \setlength{\parskip}{0.8ex}
 %
 % \begin{documentation}
@@ -629,7 +623,7 @@
 %
 % \CTeX{} 宏集的源头有两个:一是王磊编写的 \cls{cjkbook} 文档类,二是吴凌云编写的
 % \file{GB.cap}。
-% 这些工作没有经过认真、系统的设计,也没有用户文档,不利于维护和改进。
+% 这些工作没有经过认真系统的设计,也没有用户文档,不利于维护和改进。
 %
 % 2003 年,吴凌云使用 \pkg{doc} 和 \pkg{DocStrip} 重构了整个工程,并增加了许多新的功能,
 % 称为 \pkg{ctex} 宏包。2007 年,oseen 和王越在 \pkg{ctex} 宏包的基础上,
@@ -636,7 +630,7 @@
 % 增加了对 UTF-8 编码的支持,开发出了 \pkg{ctexutf8} 宏包。
 %
 % 2009 年 5 月,我们在 Google Code 建立了 ctex-kit 项目^^A
-% \footnote{\nolinkurl{http://code.google.com/p/ctex-kit/}},
+% \footnote{\nolinkurl{http://code.google.com/p/ctex-kit/},该链接现已失效。},
 % 对 \pkg{ctex} 宏包及相关脚本进行了整合,并加入了对 \XeTeX{} 引擎的支持。
 % 在开发新版本时,考虑到合作开发和调试的方便,我们放弃了 \pkg{doc} 和 \pkg{DocStrip},
 % 采取了直接编写宏包代码的方式。
@@ -649,11 +643,11 @@
 % \href{https://github.com/CTeX-org/ctex-kit}{GitHub}^^A
 % \footnote{\url{https://github.com/CTeX-org/ctex-kit}}。
 %
-% 最初,Knuth 在设计开发 \TeX{} 的时候没有考虑到多国语言支持,特别是对多字节的中日韩
-% 语言的支持。这使得 \TeX{} 以至后来的 \LaTeX{} 对中文的支持一直不是很好。即使在
+% 最初,Knuth 在设计开发 \TeX{} 的时候没有考虑到多国文字支持,特别是对多字节的中日韩
+% 表意文字的支持。这使得 \TeX{} 以至后来的 \LaTeX{} 对中文的支持一直不是很好。即使在
 % \pkg{CJK} 宏包解决了中文字符处理的问题以后,中文用户使用 \LaTeX{} 仍然要面对许
 % 多困难。
-% 这些困难里,以章节标题的中文化为最。由于中文和西文语言习惯的差异,用户很难使用标准
+% 这些困难里,以章节标题的中文化为最。由于中文和西文书写习惯的差异,用户很难使用标准
 % 文档类中的代码结构来表达中文标题。于是,用户不得不对标准文档类做较大的修改。
 % 除此之外,日期格式、首行缩进、中文字号和字距等细节问题,也需要精细的调校。
 % 我们设计 \CTeX{} 宏集的目的之一就是解决这些 \LaTeX{} 文档的汉化难题。
@@ -661,14 +655,15 @@
 % 另一方面,随着 \TeX{} 引擎和 \LaTeX{} 宏包的不断发展,\LaTeX{} 的中文支持方式从早期的
 % 专用系统(如 \pkg{CCT})发展为适用于不同引擎的多种方式^^A
 % \footnote{比如:\pdfTeX{} 引擎下的 \pkg{CJK}、\pkg{zhmCJK}宏包,
-% \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏
-% 包}。这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等
+% \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏包。}。
+% 这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等
 % 客观情况又进一步带来了更多的细节差异。我们设计 \CTeX{} 宏集的另一个主要目的就是
 % 尽可能消除这些差异带来的影响,使用户能够以一个统一的接口来使用不同的中文支持方式,
 % 使得同一份文档能够在不同环境下交换使用。
 %
-% \CTeX{} 宏集的许多实现细节离不开热心朋友们在 \url{bbs.ctex.org} 论坛上的讨论,
-% 在此对参与讨论的朋友们表示感谢。
+% \CTeX{} 宏集的许多实现细节离不开热心朋友们在 \nolinkurl{bbs.ctex.org} 论坛^^A
+% \footnote{2018 年,\CTeX{} 论坛因故无限期关闭,此链接现已失效。}^^A
+% 上的讨论,在此对参与讨论的朋友们表示感谢。
 %
 % \subsection*{关于宏集名字的说明}
 %
@@ -675,9 +670,9 @@
 % \CTeX{} 之名是英文单词 China(中国)或 Chinese(中文)的首字母“C”与 “\TeX{}”
 % 结合而成的。在纯文本环境下,该名字应写作“CTeX”。
 %
-% \CTeX{} 宏集是由 \href{http://bbs.ctex.org}{\CTeX{} 社区} 发起并维护的
+% \CTeX{} 宏集是由 \href{https://github.com/CTeX-org}{\CTeX{} 社区}发起并维护的
 % \LaTeX{} \emph{宏包和文档类的集合}。
-% 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装}
+% 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装}^^A
 % 的 \TeX{} 发行版,与本文档所述的 \CTeX{} 宏集并非是同一事物。
 %
 % \pkg{ctex} 则是本宏集中的 \pkg{ctex.sty} 的名字。这一完全小写的名称,在过去
@@ -688,7 +683,7 @@
 %
 % \subsection{\CTeX{} 宏集的组成}
 %
-% 为了适应用户不同的需求,我们将 \CTeX{} 宏集的主要功能分散在四个中文文档类和
+% 为了适应用户不同的需求,我们将 \CTeX{} 宏集的主要功能设计安排在四个中文文档类和
 % 三个宏包当中,具体的组成见表~\ref{tab:ctex}。
 %
 % \begin{table}[htbp]
@@ -698,21 +693,21 @@
 % \toprule
 %   类别   & 文件 & 说明 \\
 % \midrule
-%   文档类 & \file{ctexart.cls}  & 标准文档类 \cls{article} 的汉化版本,一般适用于
-%                                  短篇幅的文章 \\
-%          & \file{ctexrep.cls}  & 标准文档类 \cls{report} 的汉化版本,一般适用于
-%                                  中篇幅的报告 \\
-%          & \file{ctexbook.cls} & 标准文档类 \cls{book} 的汉化版本,一般适用于
-%                                  长篇幅的书籍 \\
-%          & \file{ctexbeamer.cls} & 文档类 \cls{beamer} 的汉化版本,适用于
-%                                    幻灯片演示 \\
+%   文档类 & \file{ctexart.cls}    & 标准文档类 \cls{article} 的汉化版本,
+%                                    一般适用于短篇幅的文章 \\
+%          & \file{ctexrep.cls}    & 标准文档类 \cls{report} 的汉化版本,
+%                                    一般适用于中篇幅的报告 \\
+%          & \file{ctexbook.cls}   & 标准文档类 \cls{book} 的汉化版本,
+%                                    一般适用于长篇幅的书籍 \\
+%          & \file{ctexbeamer.cls} & 文档类 \cls{beamer} 的汉化版本,
+%                                    适用于幻灯片演示 \\
 % \midrule
-%   宏包   & \file{ctex.sty}     & 提供全部功能,但\emph{默认不开启章节标题设置功能},
-%                                  需要使用 \opt{heading} 选项来开启 \\
-%          & \file{ctexsize.sty} & 定义和调整中文字号,在 \pkg{ctex} 宏包
-%                                  或 \CTeX{} 中文文档类之外单独调用 \\
+%   宏包   & \file{ctex.sty}        & 提供全部功能,但\emph{默认不开启章节标题设置功能},
+%                                     需要使用 \opt{heading} 选项来开启 \\
+%          & \file{ctexsize.sty}    & 定义和调整中文字号,可以在 \pkg{ctex} 宏包
+%                                     或 \CTeX{} 中文文档类之外单独调用 \\
 %          & \file{ctexheading.sty} & 提供章节标题设置功能(见 \ref{sec:secstyle}
-%                                     节),在 \pkg{ctex} 宏包或 \CTeX{} 中文
+%                                     节),可以在 \pkg{ctex} 宏包或 \CTeX{} 中文
 %                                     文档类之外单独调用 \\
 % \bottomrule
 % \end{tabularx}
@@ -720,37 +715,42 @@
 %
 % \subsection{\CTeX{} 宏集的安装和更新}
 % \label{subsec:easy-ins}
+% 最常见的 \TeX{} 发行版(\TeXLive{} 和 \MiKTeX{})已收录 \CTeX{} 宏集及其依赖的宏包和宏集。
+% \footnote{\pkg{zhmCJK} 宏包是个例外。当用户显式指定选项 \opt{zhmap = zhmCJK} 时,^^A
+% \CTeX{} 宏集依赖它。由于,它没有被 \TeXLive{} 和 \MiKTeX{} 收录,用户可能需要遵照其说明文档
+% 自行安装。}如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完整版本,则可能需要通过这
+% 两个发行版提供的\emph{包管理器}来安装宏包。
 %
-% \CTeX{} 宏集依赖的宏包和宏集已被最常见的 \TeX{} 发行版 \TeXLive{} 和 \MiKTeX{}
-% 所收录。如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完全版本,就可能需要通过这
-% 两个发行版提供的\emph{宏包管理器}来安装宏包。
-%
-% \TeXLive{} 的宏包管理器是 tlmgr。用户可以在系统命令行中^^A
-% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键^^A
-% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}^^A
-% 执行
+% \TeXLive{} 的包管理器是 tlmgr(\TeXLive{} Manager)。用户可以在系统命令行中^^A
+% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键
+% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}执行
 % \begin{frameverb}
 %   tlmgr gui
 % \end{frameverb}
-% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的
-% TeX Live 2015 \ding{212} TeX Live Manager 打开)。
-% 连接上远程仓库之后,搜索 ctex 安装即可。
-% tlmgr 的图形界面使用 Perl 编写,容易造成系统假死。遇到这种问题的用户,
+% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的 TeX Live 20XX(年份)
+% \ding{212} TeX Live Manager 打开)。连接上远程仓库之后,搜索 |ctex| 即可安装。
+% tlmgr 的图形界面使用 Perl 编写,在实践中发现容易造成系统假死。遇到这种问题的用户,
 % 也可以直接在系统命令行执行
 % \begin{frameverb}
 %   tlmgr install ctex
 % \end{frameverb}
-% 来安装 \CTeX{} 宏集\footnote{*nix 用户可能需要超级用户权限才能正确安装宏集。}。
+% 来安装 \CTeX{} 宏集^^A
+% \footnote{*nix 用户可能需要超级用户权限(sudo)才能正确安装宏集。}。
 %
-% \MiKTeX{} 的宏包管理器是 mpm (\MiKTeX{} Package Manager)。用户可以在开始菜单
-% 找到 MiKTeX \ding{212} Maintenance (Admin) \ding{212} Package Manager (Admin),
-% 打开管理器,连接上远程仓库之后,搜索 ctex 安装即可。
+% \MiKTeX{} 通常会在缺失宏包时自动完成安装。如需手动安装,可以使用其管理维护
+% 工具 \MiKTeX{} Console。用户可以打开管理器,连接上远程仓库之后,在“Package”
+% 选项卡中搜索“ctex”并安装即可。
+% 也可以使用 mpm(\MiKTeX{} Package Manager),在命令行执行
+% \begin{frameverb}
+%   mpm --admin --install=ctex
+% \end{frameverb}
+% 来安装 \CTeX{} 宏集。
 %
-% 若希望了解 \CTeX{} 宏集具体的依赖情况和手工安装宏集的方法,
+% 若希望了解 \CTeX{} 宏集具体的依赖情况或手工安装宏集的方法,
 % 请参阅第 \ref{sec:dep-ins}~节。
 %
-% 当宏包发布新版本,并被发行版在远程仓库安装之后,在本地就可以通过宏包管理器来
-% 取得新版本。
+% 当我们将宏集的新版本发布于 CTAN,且为发行版的远程仓库更新后,用户就可以在本地
+% 通过包管理器获取新版本。
 %
 % 对于 \TeXLive{},可以在 tlmgr 的图形界面点击“更新全部已安装的”按钮或者在
 % 命令行执行
@@ -759,14 +759,17 @@
 % \end{frameverb}
 % 来完整更新已安装的宏包。
 %
-% 对于 \MiKTeX{},在开始菜单找到
-% MiKTeX \ding{212} Maintenance (Admin) \ding{212} Update (Admin),
-% 按照界面说明更新即可。
+% 对于 \MiKTeX{},在 \MiKTeX{} Console 中找到“Updates”选项卡,检查更新后即可
+% 选择升级宏包。也可以使用 mpm,在命令行执行
+% \begin{frameverb}
+%   mpm --admin --update
+% \end{frameverb}
+% 来进行更新。
 %
 % \subsection{使用 \CTeX{} 文档类}
 %
-% \emph{如果用户需要在标准文档类的基础上添加中文支持和中文版式支持,我们建议用户使用 \CTeX{}
-% 宏集提供的四个中文文档类。}
+% \emph{如果用户需要在三个标准文档类或 \cls{beamer} 的基础上添加中文及版式的支持,
+% 我们建议用户使用 \CTeX{} 宏集提供的四个中文文档类。}
 %
 % \CTeX{} 宏集提供了四个中文文档类:\cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和
 % \cls{ctexbeamer},分别对应 \LaTeX{} 的标准文档类 \cls{article}、\cls{report}、
@@ -775,18 +778,18 @@
 % \ref{subs:encoding}~节)}。
 %
 % \begin{ctexexam}
-%   \documentclass[UTF8]{ctexart}
+%   \documentclass{ctexart}
 %   \begin{document}
 %   中文文档类测试。你需要将所有源文件保存为 UTF-8 编码。
 %
 %   你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译,也可以使用 (pdf)LaTeX 编译。
-%   推荐使用 XeLaTeX 或 LuaLaTeX 编译。
+%   推荐使用 XeLaTeX 或 LuaLaTeX 编译。对高级用户,我们也推荐使用 upLaTeX 编译。
 %   \end{document}
 % \end{ctexexam}
 %
 % 以下是使用 \cls{ctexbeamer} 文档类编写中文演示文稿的一个示例。
 % \begin{ctexexam}
-%   \documentclass[UTF8]{ctexbeamer}
+%   \documentclass{ctexbeamer}
 %   \begin{document}
 %   \begin{frame}{中文演示文档}
 %   \begin{itemize}
@@ -794,6 +797,7 @@
 %     \item 你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译
 %     \item 也可以使用 (pdf)LaTeX 编译
 %     \item 推荐使用 XeLaTeX 或 LuaLaTeX 编译
+%     \item 对高级用户,我们也推荐使用 upLaTeX 编译
 %   \end{itemize}
 %   \end{frame}
 %   \end{document}
@@ -801,14 +805,14 @@
 %
 % \subsection{使用 \pkg{ctex} 宏包}
 %
-% \emph{用户在使用非标准文档类时,如果需要添加中文支持或中文版式支持,则可以使用 \pkg{ctex}
-% 宏包。}
+% \emph{用户在使用非标准文档类及 \cls{beamer} 时,如果需要添加中文及版式的支持,
+% 则可以使用 \pkg{ctex} 宏包。}
 %
-% 有些文档类是建立在 \LaTeX{} 标准文档类之上开发的。这时,给 \pkg{ctex} 宏包
+% 对于建立在 \LaTeX{} 标准文档类之上开发的文档类,在使用 \pkg{ctex} 宏包时
 % 加上 \opt{heading} 选项,可以将章节标题设置为中文风格。
 % \begin{ctexexam}
 %   \documentclass{ltxdoc}
-%   \usepackage[UTF8, heading = true]{ctex}
+%   \usepackage[heading = true]{ctex}
 %   \begin{document}
 %   \section{简介}
 %   章节标题中文化的 \LaTeX{} 手册。
@@ -820,16 +824,13 @@
 %
 % \CTeX{} 宏集已经尽可能就中文的行文和版式习惯做了调整和配置,通常而言,这些配置
 % 已经够用。因此,除非必要,我们不建议普通用户修改这些默认配置。如果你认为 \CTeX{} 宏集
-% 的默认配置还可以完善,可以在项目主页上%
+% 的默认配置还可以完善,可以在项目主页上^^A
 % \href{https://github.com/CTeX-org/ctex-kit/issues}{提交 issue},
 % 向我们反映,我们会酌情在后续版本中予以改进。
 %
 % 不过,\CTeX{} 宏集也提供了一系列选项。用户可以使用这些选项来控制 \CTeX{} 宏集的行为。
-% 具体来说,这些选项里,有的以传统的方式提供,
-% 也有的以 \meta{key}|=|\meta{value} 的形式提供。对于以键值对形式提供的选项,
-% 在下面的说明中使用\textbf{粗体}来表示 \CTeX{} 的默认设置。
-%
-% 另一方面,这些选项可以分为以下三类:
+% 按形式分类,这些选项有的以传统的方式提供,有的以 \meta{key}|=|\meta{value} 的形式提供。
+% 按指定位置分类,这些选项又可以分为以下三类:
 % \begin{itemize}
 % \item 名字后带有 \rexptarget\rexpstar{} 号的选项,只能作为宏包/文档类选项,需要
 %   在引入宏包/文档类的时候指定;
@@ -891,28 +892,24 @@
 % \end{table}
 %
 % 不同的编译方式和中文支持方式会在一定程度上影响 \CTeX{} 宏集的行为,比如宏包对
-% 编码的处理。
-% 在用户使用 \XeLaTeX、\LuaLaTeX{} 及 \upLaTeX{} 编译时,\CTeX{} 宏集使用(且仅
-% 能使用)UTF-8 编码;而因为历史原因,在用户使用 \LaTeX{} 及 \pdfLaTeX{} 编译
-% 时,宏包默认使用 GBK 编码。用户需要\emph{保证编译方式、
-% 源文件编码、宏包编码选项三者一致}。
-% 关于宏包编码选项,可以参考 \ref{subs:encoding}~节。
+% 文档编码、字体选择、空格、标点等的处理。具体细节将在本文档后续内容中进行阐述。
 %
-% 除去文档编码之外,选择不同的编译方式还可能影响 \CTeX{} 宏集对字体选择、空格处理、
-% 标点处理的处理。具体的影响将在本文档后续内容中进行阐述。
-%
 % \subsection{中文编码}
 % \label{subs:encoding}
 %
-% \begin{function}[rEXP]{GBK, UTF8}
-%   指明编写文档时使用的编码格式。\CTeX{} 宏集无法检测用户编写文档时使用的编码格式,因此
-%   需要用户自行指定编码。\emph{我们建议用户总是使用 UTF-8 编码,并显式指定 \opt{UTF8}
-%   选项,并使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译。}
+% \begin{function}[rEXP,updated=2019-11-10]{GBK, UTF8}
+%   指明编写文档时使用的编码。\CTeX{} 宏集无法检测文档源文件的实际编码格式,因此需要
+%   用户通过选项声明。如果没有显式指定,则默认采用 UTF-8 编码。
 %
-%   使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用 UTF-8
-%   编码,此时 \opt{GBK} 选项无效。
-%   使用 (pdf)\LaTeX{} 编译时,\CTeX{} 宏集默认启用 \opt{GBK} 选项;不过,用户也可以
-%   显式声明 \opt{UTF8} 选项,使 \CTeX{} 宏集工作在 UTF-8 编码下。
+%   使用 \XeLaTeX{}、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用
+%   UTF-8 编码,此时 \opt{GBK} 选项无效;使用 (pdf)\LaTeX{} 编译时,
+%   \CTeX{} 宏集默认使用 UTF-8 编码,但用户也可以显式声明 \opt{GBK} 选项,
+%   使 \CTeX{} 宏集按 GBK 编码处理文档。
+%
+%   用户需要\emph{保证编译方式、源文件编码、宏包编码选项三者一致}。
+%
+%   \emph{我们建议编写新文档时始终使用 UTF-8 编码,而仅把 GBK 编码留给
+%   历史遗留文档。}
 % \end{function}
 %
 % \subsection{中文字库}
@@ -920,9 +917,9 @@
 %
 % 以往,为 \LaTeX{} 文档配置中文支持是一件相当繁琐的事情。默认情况下,
 % \CTeX{} 宏集能自动检测用户使用的编译方式(参见 \ref{subs:compile}~节)和
-% 操作系统\footnote{\CTeX{} 宏集现在能够识别 Mac~OS~X 系统以及 Windows 系统。},
-% 选择合适的底层支持和字库,从而简化配置过程。自动配置的情况参见
-% 表~\ref{tab:default-font-select}。
+% 操作系统\footnote{\CTeX{} 宏集现在能够识别 macOS 及 Windows 系统,
+% 并将其他系统统一归为 Linux。},选择合适的底层支持和字库,从而简化配置过程。
+% 自动配置的情况参见表~\ref{tab:default-font-select}。
 %
 % \begin{table}[htbp]
 % \centering
@@ -931,42 +928,50 @@
 % \label{tab:default-font-select}
 % \begin{tabular}{*{5}{c}}
 %   \toprule
-%              & Mac OS X & Windows New\tnote{1} & Windows Old\tnote{2} &
-%               其他 \\
+%              & macOS Old\tnote{1}
+%              & macOS New\tnote{2}
+%              & Windows\tnote{3}
+%              & 其他 \\
 %   \midrule
-%   \XeLaTeX{} & \makecell{\pkg{xeCJK}\\华文字库} &
-%     \makecell{\pkg{xeCJK}\\中易字库 + 微软雅黑} & \makecell{\pkg{xeCJK}\\中易字库} &
-%     \makecell{\pkg{xeCJK}\\Fandol 字库\tnote{3}} \\
+%   \XeLaTeX   & \makecell{\pkg{xeCJK}\\华文字库}
+%              & \makecell{\pkg{xeCJK}\\华文字库 + 苹方}
+%              & \makecell{\pkg{xeCJK}\\中易字库 + 微软雅黑}
+%              & \makecell{\pkg{xeCJK}\\Fandol 字库\tnote{4}} \\
 %   \cmidrule(lr){1-5}
-%   \LuaLaTeX{}\tnote{4} & \makecell{\pkg{LuaTeX-ja}\\华文字库} &
-%     \makecell{\pkg{LuaTeX-ja}\\中易字库 + 微软雅黑} &
-%     \makecell{\pkg{LuaTeX-ja}\\中易字库} &
-%     \makecell{\pkg{LuaTeX-ja}\\Fandol 字库} \\
+%   \LuaLaTeX\tnote{5}
+%              & \makecell{\pkg{LuaTeX-ja}\\华文字库}
+%              & \makecell{\pkg{LuaTeX-ja}\\华文字库 + 苹方}
+%              & \makecell{\pkg{LuaTeX-ja}\\中易字库 + 微软雅黑}
+%              & \makecell{\pkg{LuaTeX-ja}\\Fandol 字库} \\
 %   \cmidrule(lr){1-5}
-%   \pdfLaTeX{} & 不可用\tnote{5} &
-%     \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑} &
-%     \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库} & 不可用\tnote{5} \\
+%   \pdfLaTeX
+%              & 不可用
+%              & 不可用
+%              & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}}
+%              & 不可用 \\
 %   \cmidrule(lr){1-5}
-%   \makecell{\LaTeX{} + \\\dvipdfmx{}} & 不可用\tnote{6} &
-%     \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑} &
-%     \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库} &
-%     \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\
+%   \makecell{\LaTeX{} + \\\dvipdfmx}
+%              & 不可用
+%              & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\华文字库 + 苹方}
+%              & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}}
+%              & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\
 %   \cmidrule(lr){1-5}
-%   \makecell{\upLaTeX{} + \\\dvipdfmx{}} & 不可用\tnote{6} &
-%     \makecell{\pkg{zhmetrics-uptex}\\中易字库 + 微软雅黑} &
-%     \makecell{\pkg{zhmetrics-uptex}\\中易字库} &
-%     \makecell{\pkg{zhmetrics-uptex}\\Fandol 字库} \\
+%   \makecell{\upLaTeX{} + \\\dvipdfmx}
+%              & 不可用
+%              & \makecell{\pkg{zhmetrics-uptex}\\华文字库 + 苹方}
+%              & \makecell{\pkg{zhmetrics-uptex}\\中易字库 + 微软雅黑}
+%              & \makecell{\pkg{zhmetrics-uptex}\\Fandol 字库} \\
 %   \bottomrule
 % \end{tabular}
 % \begin{tablenotes}
-%   \item [1] Windows Vista 及以后的 Windows 操作系统。
-%   \item [2] Windows XP 及以前的 Windows 操作系统。
-%   \item [3] 由马起园、苏杰、黄晨成等人开发的开源中文字体,
-%     参见:\url{https://github.com/clerkma/fandol-fonts}。
-%   \item [4] \LuaLaTeX{} 编译时使用 \pkg{LuaTeX-ja} 宏包。对此,
+%   \item [1] Yosemite (10.10) 及以前的 macOS 系统。
+%   \item [2] El Capitan (10.11) 及以后的 macOS 系统。
+%   \item [3] 仅支持 Windows Vista 及以后的 Windows 操作系统。
+%   \item [4] 由马起园、苏杰、黄晨成等人开发的开源中文字体,
+%     参见:\url{https://www.ctan.org/pkg/fandol}。
+%   \item [5] \LuaLaTeX{} 编译时使用 \pkg{LuaTeX-ja} 宏包。对此,
 %     第 \ref{sec:lualatex-chinese}~节有特别说明。
-%   \item [5] 受 \pdfTeX{} 的限制,无法嵌入 OpenType 字体。
-%   \item [6] 目前受 \dvipdfmx{} 的限制,Mac OS X 系统上的黑体和仿宋无法读取。
+%   \item [6] 微软雅黑字体并不总是有效,这和选项 \opt{zhmap} 的取值有关。
 % \end{tablenotes}
 % \end{threeparttable}
 % \end{table}
@@ -980,14 +985,20 @@
 %   \begin{syntax}
 %     zhmap = <\TTF|zhmCJK>
 %   \end{syntax}
-%   指定字体映射机制。本选项只在使用 \pdfLaTeX/\LaTeX{} 编译时有意义。
+%   指定字体映射机制。本选项只在使用 (pdf)\LaTeX{} 编译时有意义。
 % \end{function}
 % \begin{optdesc}
-%   \item[true] 使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special}
+%   \item[true] 这是该选项的默认值。^^A
+%   \footnote{对于以键值对形式提供的选项,文档以\textbf{粗体}来表示其默认值。^^A
+%   下同,不再额外解释。}使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special}
 %   命令映射到 \file{.ttf} 文件。
 %
 %   \item[false] 使用传统的 CJK 字库(Type 1)^^A
-%   \footnote{如果需要使用自定义的字体映射文件,或者希望使用 Type1 字库,请禁用本选项。}。
+%   \footnote{使用 (pdf)\LaTeX{} 编译时,如果需要使用自定义的字体映射文件(比如需要
+%     使用 \LaTeX{} + Dvips 编译),或者希望使用 Type1 字库,请禁用本选项。为此,你
+%     可能需要安装 CJK 字体。参考 \pkg{zhmetrics} 宏包提供的脚本
+%     \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua}
+%     {\file{CTeXFonts.lua}}。}。
 %
 %   \item[zhmCJK] 载入 \pkg{zhmCJK} 宏包^^A
 %   \footnote{\pkg{zhmCJK} 宏包基于 \pkg{zhmetrics} 和 \pkg{CJK} 宏包,提供与
@@ -997,8 +1008,7 @@
 %
 % \begin{function}[added=2014-03-08]{fontset}
 %   \begin{syntax}
-%     fontset =^^A
-% <none|adobe|fandol|founder|mac|macnew|macold|ubuntu|windows|windowsnew|windowsold|...>
+%     fontset = <adobe|fandol|founder|mac|macnew|macold|ubuntu|windows|none|...>
 %   \end{syntax}
 %   指定 \CTeX{} 宏集加载的字库。
 %
@@ -1012,24 +1022,18 @@
 %   \item[adobe] 使用 Adobe 公司的四款中文字体,\emph{不支持 \pdfLaTeX}。
 %   \item[fandol] 使用 Fandol 中文字体,\emph{不支持 \pdfLaTeX}。
 %   \item[founder] 使用方正公司的中文字体。
-%   \item[mac] 使用 Mac OS X 系统下的字体,\emph{不支持 (pdf)\LaTeX}。
-%   \item[macnew] 使用 El Capitan 或之后的多字重宋体、苹方黑体。
-%   \item[macold] 使用 Yosemite 或之前的华文字库。
-%   \item[ubuntu] 使用 Ubuntu 系统下的文泉驿和文鼎字体。
-%   \item[windows] 使用简体中文 Windows 系统下的中文字体,自动判断 Windows 系
-%   统版本,采用 |windowsnew| 或 |windowsold| 的设置。
-%   \item[windowsnew] 使用简体中文 Windows Vista 或之后系统下的中易字体和微软
-%   雅黑字体。
-%   \item[windowsold] 使用简体中文 Windows XP 或之前系统下的中易字体。
+%   \item[mac] 使用 macOS 系统下的字体,\emph{不支持 \pdfLaTeX},根据版本分为
+%     |macnew| 和 |macold| 两种。
+%   \item[macnew] 使用 El Capitan 或之后的多字重华文字体和苹方字体。
+%   \item[macold] 使用 Yosemite 或之前的华文字体。
+%   \item[ubuntu] 使用 Ubuntu 系统下的思源宋体、思源黑体和 \TeX{} 发行版自带的
+%     文鼎楷体,\emph{不支持 \pdfLaTeX}。
+%   \item[windows] 使用 Windows 系统下的中易字体和微软雅黑字体。
+%     当使用 (pdf)\LaTeX{} 编译时,微软雅黑仅在以下两种情形有效:
+%     安装有 \pkg{zhmCJK} 宏包且选项 \opt{zhmap=zhmCJK} 时,或者
+%     安装有微软雅黑的 Type1 字体且选项 \opt{zhmap=false} 时。
 % \end{optdesc}
 %
-% 注意:使用 (pdf)\LaTeX{} 编译的时候,若设置 \opt{zhmap = false}(比如需要
-% 使用 \LaTeX{} + Dvips 编译),则需要按照传统方式^^A
-% \footnote{可以使用 \pkg{zhmetrics} 宏包提供的脚本
-% \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua}
-% {\file{CTeXFonts.lua}}。}^^A
-% 在本地安装好 CJK 字体。
-%
 % 如果不想使用 \CTeX{} 预定义的中文字库,可以设置 \opt{fontset} 为下述值之一。
 %
 % \begin{optdesc}
@@ -1043,7 +1047,7 @@
 % \end{optdesc}
 %
 % 注意:\emph{如果希望使用 \tn{ctexset} 在导言区指定字库,则需要先在宏包/文档类选项中指定
-% \opt{fontset = none}}。例如:
+% \opt{fontset = none}}(这会禁用 \CTeX{} 宏集的操作系统检测功能和自动设定字库功能)。例如:
 % \begin{ctexexam}
 %   \documentclass[fontset = none]{ctexart}
 %   \ctexset{fontset = founder}
@@ -1054,8 +1058,7 @@
 % \end{ctexexam}
 %
 % \CTeX{} 宏集预定义的中文字库还定义了一些字体命令。除了在 \opt{ubuntu} 字库中没有
-% \tn{fangsong} 的定义外,所有字库都有以下四个字体命令。
-%
+% \tn{fangsong} 的定义外,所有字库都有以下四个字体命令:
 % \begin{optdesc}
 %   \item[\tn{songti}] 宋体,CJK 等价命令 |\CJKfamily{zhsong}|。
 %   \item[\tn{heiti}] 黑体,CJK 等价命令 |\CJKfamily{zhhei}|。
@@ -1062,19 +1065,18 @@
 %   \item[\tn{fangsong}] 仿宋,CJK 等价命令 |\CJKfamily{zhfs}|。
 %   \item[\tn{kaishu}] 楷书,CJK 等价命令 |\CJKfamily{zhkai}|。
 % \end{optdesc}
-%
-% 在 \opt{windows} 和 \opt{founder} 字库中,额外定义了 \tn{lishu} 和 \tn{youyuan}。
+% 在 \opt{windows}、\opt{founder} 和 \opt{macnew} 字库中,额外定义了 \tn{lishu}
+% 和 \tn{youyuan}:
 % \begin{optdesc}
 %   \item[\tn{lishu}] 隶书,CJK 等价命令 |\CJKfamily{zhli}|。
 %   \item[\tn{youyuan}] 圆体,CJK 等价命令 |\CJKfamily{zhyou}|。
 % \end{optdesc}
-% 在 \opt{windowsnew} 和 \opt{macnew} 字库中,还有 \tn{yahei}。
-% 其中在 \opt{macnew} 字库中,\tn{yahei} 实际调用苹方黑体。此举乃是为了更好的兼容性而设。
+% 在 \opt{windows} 字库中还定义了 \tn{yahei}。出于兼容性的考虑,\tn{yahei} 命令
+% 在 \opt{macnew} 字库中也有定义,但实际调用苹方黑体:
 % \begin{optdesc}
 %   \item[\tn{yahei}] 微软雅黑,CJK 等价命令 |\CJKfamily{zhyahei}|。
 % \end{optdesc}
-%
-% 在 \opt{macnew} 字库中,还定义了 \tn{pingfang}。
+% 在 \opt{macnew} 字库中,还定义了 \tn{pingfang}:
 % \begin{optdesc}
 %   \item[\tn{pingfang}] 苹方黑体,CJK 等价命令 |\CJKfamily{zhpf}|。
 % \end{optdesc}
@@ -1093,9 +1095,10 @@
 %   本选项可以用于四个 \CTeX{} 文档类和 \pkg{ctex} 宏包,
 %   也可以用于 \pkg{ctexsize} 宏包。
 %
-%   \opt{scheme = chinese} 时,对标准文档类默认值为 |5|,即设置
-%   \tn{normalsize} 为五号字;对 \cls{beamer} 则为 |false|,使用文档类原有的设
-%   置。
+%   该选项的默认值与 \opt{scheme} 的取值有关。
+%   当 \opt{scheme = chinese} 时,对标准文档类默认值为 |5|,即设置
+%   \tn{normalsize} 为五号字;对 \cls{beamer} 则为 |false|,使用文档类原有的设置。
+%   当 \opt{scheme = plain} 时,该选项不设默认值,沿用标准文档类或 \cls{beamer} 的原有设置。
 % \end{function}
 %
 % \begin{table}[htbp]
@@ -1150,8 +1153,7 @@
 %   本选项只能在调用 \pkg{ctex.sty} 时作为宏包选项使用。
 %
 %   \CTeX{} 宏集提供了一套用于修改文档章节标题格式的接口。该选项用于选择是否
-%   启用该功能。详细的设置方法请参见
-%   \ref{sec:secstyle}~节和 \ref{subs:pagestyle}~节。
+%   启用该功能。详细的设置方法请参见第 \ref{subs:pagestyle}~节和第 \ref{sec:secstyle}~节。
 % \end{function}
 %
 % \CTeX{} 宏集提供的四个文档类总是启用该功能。如果在 \pkg{ctex.sty} 下启用该选项,
@@ -1169,7 +1171,7 @@
 %   的格式。启用 \opt{sub4section} 会将 \tn{paragraph} 和 \tn{subparagraph} 的格式
 %   都修改为类似 \tn{section} 的格式。
 %
-%   启用该选项通常需要将计数器 |secnumdepth| 的值为设置为 4 或 5。
+%   启用该选项通常还需要将计数器 |secnumdepth| 的值为设置为 4 或 5。
 %
 %   具体格式可参考 \ref{sec:secstyle}~节中的 \opt{runin} 和 \opt{afterskip} 选项。
 %
@@ -1185,7 +1187,7 @@
 %   \begin{syntax}
 %     scheme = <(chinese)|plain>
 %   \end{syntax}
-%   选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。%
+%   选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。
 % \end{function}
 %   \begin{optdesc}[itemsep=\medskipamount]
 %     \item[chinese] 对 \cls{beamer} 以外的文档类,调整默认字号为五号字,并调
@@ -1224,14 +1226,14 @@
 %   \begin{syntax}
 %     space = <\TF|(auto)>
 %   \end{syntax}
-%   是否在生成的 PDF 中保留汉字后面的空格。
+%   是否在生成的 PDF 中保留汉字后面的空格。该选项仅在使用 \XeLaTeX{}/(pdf)\LaTeX{} 编译时有效。
 % \end{function}
 %
 % \begin{optdesc}
 %   \item[true] 总是保留汉字后的空格。此时,用户需要自行在行尾加上~|%|~处理换行产生
 %     的空格\footnote{\LaTeX{} 将单个换行视作一个空格。}。
-%   \item[false] 总是忽略掉汉字后面的空格,不论汉字后是什么(使用 (pdf)\LaTeX{}
-%     编译时);等同于 \opt{auto} 的效果(使用 \XeLaTeX{} 编译时)。不建议使用该选项。
+%   \item[false] 使用 (pdf)\LaTeX{} 编译时:总是忽略掉汉字后面的空格,不论汉字后是什么;
+%     使用 \XeLaTeX{} 编译时,等同于 \opt{auto} 的效果。不建议使用该选项。
 %   \item[auto] 根据空格后面的情况决定是否保留:如果空格后面是汉字,则忽略该
 %   空格,否则保留。
 % \end{optdesc}
@@ -1278,8 +1280,10 @@
 % \begin{optdesc}
 %   \item[\meta{数值或带单位的数值}] 用于设置段首缩进的长度。如果不带单位,则默认
 %   单位是单个汉字字宽 \tn{ccwd};如果带单位,则使用该单位。
+%   若要显式使用 \tn{ccwd} 为单位,则必须在导言区进行设置。
 %
-%   \item[true] 等价于设置 \opt{autoindent = 2}。
+%   \item[true] 等价于设置 \opt{autoindent = 2} 或
+%   在导言区设置 \opt{autoindent = 2\tn{ccwd}}。
 %
 %   \item[false] 禁用自动调整功能,可以设置固定长度的段首缩进。如设置每段缩进 40 点:
 %   \begin{ctexexam}
@@ -1315,7 +1319,7 @@
 % \subsection{日期汉化}
 %
 % \CTeX 宏包对显示当前日期的 \tn{today} 命令进行了汉化,使之以中文的方式显示今
-% 天的日期。如编译本文档的日期就是“\today”。
+% 天的日期。如本文档编译时的日期是“\today”。
 %
 % \begin{function}[EXP]{today}
 %   \begin{syntax}
@@ -1329,6 +1333,7 @@
 %     效果为“\today”。使用全汉字的日期格式。
 %   \item[old] \ctexset{today=old}
 %     效果为“\today”。使用文档原来的(英文)日期格式。
+%     \ctexset{today=small}  ^^A NOTE(Liam): 复原设定是好习惯。
 % \end{optdesc}
 % \end{function}
 %
@@ -1343,7 +1348,7 @@
 % \subsection{文档标题汉化}
 % \label{subs:capname}
 %
-% 这里主要介绍由宏包 \opt{scheme} 选项(\ref{subs:options-type-style}~节)控制
+% 这里主要介绍由 \opt{scheme} 选项(\ref{subs:options-type-style}~节)控制
 % 的文档标题汉化功能。
 %
 % 设置文档标题名的示例可见例~\ref{exam:capname}。下面的选项(如
@@ -1413,8 +1418,16 @@
 %   \begin{syntax}
 %     bibname = <名字>
 %   \end{syntax}
-% 设置参考文献标题名 \tn{refname}(对 \cls{article})或 \tn{bibname}(对
-% \cls{report}、\cls{book} 和 \cls{beamer})。中文默认为“\refname”。
+% 设置参考文献标题名。中文默认为“\refname”。
+%
+% 在标准文档类中 \cls{article} 的参考文献名使用宏 \tn{refname},而
+% \cls{book} 和 \cls{report} 使用宏 \tn{bibname}。本选项会根据标准文档类的不同,自动
+% 设定 \tn{refname} 或是 \tn{bibname}。因此,对于标准文档类及对应的 \CTeX{} 文档类
+% 可以统一地使用 \opt{bibname} 选项来控制参考文献标题名。
+%
+% 对于 \cls{beamer} 及对应的 \cls{ctexbeamer} 来说,它们同时具有宏 \tn{bibname} 和
+% 宏 \tn{refname}。本选项仅控制其中的 \tn{bibname};
+% \tn{refname} 则交由 \opt{refname} 选项控制。
 % \end{function}
 %
 % \begin{function}[EXP]{proofname}
@@ -1433,6 +1446,10 @@
 %     refname = <名字>
 %   \end{syntax}
 % 设置参考文献标题名 \tn{refname}。中文默认为“\refname”。
+%
+% 注意,三个标准文档类(及相应的 \CTeX{} 文档类)的参考文献标题名由 \opt{bibname} 选项
+% 统一设置,本选项仅适用于 \cls{beamer} 及其对应的 \cls{ctexbeamer}。
+% 在三个标准文档类(及相应的 \CTeX{} 文档类)中使用 \opt{refname} 选项会报错。
 % \end{function}
 %
 % \begin{function}[EXP]{algorithmname}
@@ -1455,8 +1472,10 @@
 % \subsection{页面格式设置与汉化}
 % \label{subs:pagestyle}
 %
-% 当使用了 \CTeX 的文档类或是用 \pkg{ctex} 宏包加载了 \opt{heading} 选项时,会
-% 设置整个文档的页面格式(page style)为 |headings|,即相当于设置了
+% 页面格式设置与汉化的功能(及章节标题样式设置功能,见第 \ref{sec:secstyle} 节)^^A
+% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A
+% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。
+% 此时,整个文档的页面格式(page style)被设定为 |headings|,即相当于设置了
 % \begin{frameverb}
 %   \pagestyle{headings}
 % \end{frameverb}
@@ -1481,7 +1500,7 @@
 % \tn{chaptermark}、\tn{sectionmark} 中调用 \tn{markright} 或 \tn{markboth} 生
 % 成的。
 % \end{itemize}
-% 有关 \LaTeX 页面标记的涵义与使用细节,已经超出了本文档讨论的范围。可以参考
+% 有关 \LaTeX 页面标记的含义与使用细节,已经超出了本文档讨论的范围。可以参考
 % \cite[Chapter~23]{knuthtex1986}、\cite[\S4.3, \S4.4]{mittelbach2004} 等书籍。
 %
 % 这里举一个例子,说明通过重定义 \tn{sectionmark},在 \cls{ctexart} 文档类中的
@@ -1548,41 +1567,50 @@
 % \smallskip\hrule
 % \end{trivlist}
 %
-% \section{章节标题格式设置}
+% \section{章节标题样式设置}
 % \label{sec:secstyle}
 %
-% \CTeX 宏包对 \LaTeX 的标准文档类(\cls{article}、\cls{report} 和
-% \cls{book})和 \cls{beamer} 进行了扩充。当以 \opt{heading} 选项调用 \CTeX
-% 宏包时(\ref{subs:options-heading}~节),则会启用章
-% 节标题的格式设置功能。本节就来介绍有关章节标题的格式选项,所有选项使用
-% \tn{ctexset} 命令设置。
+% \CTeX{} 宏集对 \LaTeX{} 的标准文档类(\cls{article}、\cls{report}、
+% \cls{book})和 \cls{beamer} 进行了章节标题样式设置功能的扩充。
+% 章节标题样式设置功能(及页面格式设置与汉化功能,见第 \ref{subs:pagestyle} 节)^^A
+% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A
+% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。
+% 其中,独立使用 \pkg{ctexheading} 宏包时,本节介绍各选项的默认值与指定
+% \opt{scheme = plain} 时相同。
 %
-% 第 \ref{subs:pagestyle} 节和本节介绍的功能已经被提取到 \pkg{ctexheading}
-% 宏包之中,可以在 \pkg{ctex} 宏包和 \cls{ctexart} 等文档类之外独立使用。
-% 各选项的默认值与 \opt{scheme = plain} 时的情形相同。
+% 本节涉及的所有选项均需使用 \tn{ctexset} 命令设置。
 %
 % \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。}
-% 章节标题的格式选项是分层设置的。顶层的选项是章节标题名称,次一级的选项是章节
-% 标题的格式。章节标题名包括 |part|, |chapter|, |section|, |subsection|,
-% |subsubsection|, |paragraph|, |subparagraph|;而可用的格式包括 \opt{numbering},
-% \opt{name}, \opt{number}, \opt{format}, \opt{nameformat}, \opt{numberformat},
-% \opt{aftername}, \opt{titleformat}, \opt{aftertitle}, \opt{runin},
-% \opt{afterindent}, \opt{beforeskip}, \opt{afterskip}, \opt{fixskip},
-% \opt{lotskip}, \opt{lofskip}, \opt{indent}, \opt{hang},
-% \opt{pagestyle}, \opt{break}, \opt{tocline} 等。
 %
+% 章节标题的样式选项是分层设置的。顶层的选项是章节标题名称(例如 |section|),
+% 次一层的选项是章节标题的样式(例如 \opt{nameformat})。章节标题名称包括
+% |part|, |chapter|, |section|, |subsection|, |subsubsection|, |paragraph|,
+% |subparagraph|。可用的样式选项包括:
+% \begin{itemize}
+%   \item 编号相关(\ref{subsec:sec-number}~小节):
+%     \opt{numbering}, \opt{name}, \opt{number}
+%   \item 格式相关(\ref{subsec:sec-format}~小节):
+%     \opt{format}, \opt{nameformat}, \opt{numberformat}, \opt{titleformat},
+%     \opt{aftername}, \opt{aftertitle}, \opt{pagestyle}
+%   \item 间距、缩进相关(\ref{subsec:sec-spacing}~小节):
+%     \opt{runin}, \opt{hang}, \opt{indent}, \opt{beforeskip}, \opt{afterskip},
+%     \opt{fixskip}, \opt{break}, \opt{afterindent}
+%   \item 目录、附录相关(\ref{subsec:sec-toc-appendix}~小节):
+%     \opt{tocline}, \opt{lofskip}, \opt{lotskip}, \opt{appendix/numbering},
+%     \opt{appendix/name}, \opt{appendix/number}
+% \end{itemize}
+%
 % 注意,对 \cls{article} 及其衍生的 \cls{ctexart} 等文档类,没有 |chapter|
-% 级别的标题。而对于 \cls{beamer} 文档类,这些选项控制的是由 \tn{partpage},
-% \tn{sectionpage} 和 \tn{subsectionpage} 产生的标题格式,此时只有 |part|,
+% 级别的标题;而对于 \cls{beamer} 文档类,这些选项控制的是由 \tn{partpage},
+% \tn{sectionpage} 和 \tn{subsectionpage} 产生的标题样式,此时只有 |part|,
 % |section| 和 |subsection| 这三层级别,并且 \opt{runin}, \opt{afterindent},
-% \opt{fixskip}, \opt{hang}, \opt{break} 和 \opt{tocline} 这六个格式无效。
+% \opt{fixskip}, \opt{hang}, \opt{break} 和 \opt{tocline} 这六个选项无效。
 %
-% 多级选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数
+% 多层选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数
 % 字前后的名称,而 \opt{section/number} 选项设置 \tn{section} 标题的数字类型。
-% 注意,斜线 |/| 前后不能有空格或者换行。
+% 注意,斜线 |/| 的前后不能有空格或者换行。
 %
-% 使用 \tn{ctexset} 设置多级选项时,可以在同一个上级选项下设置多个下级选项。
-%
+% 使用 \tn{ctexset} 设置多级选项时,还可以在同一个上级选项下设置多个下级选项。
 % 例如,同时设置 |part| 一级标题的 \opt{pagestyle} 选项,|chapter| 一级标题的
 % \opt{format} 与 \opt{pagestyle} 选项和 |section| 一级标题的 \opt{name} 与
 % \opt{number} 选项:
@@ -1600,6 +1628,9 @@
 %   }
 % \end{ctexexam}
 %
+% \subsection{编号相关}
+% \label{subsec:sec-number}
+%
 % \begin{function}[EXP,added=2015-06-21]{part/numbering, chapter/numbering,
 %   section/numbering, subsection/numbering, subsubsection/numbering,
 %   paragraph/numbering, subparagraph/numbering}
@@ -1606,26 +1637,46 @@
 %   \begin{syntax}
 %     numbering = \TTF
 %   \end{syntax}
-%   控制是否对章节标题编号。对各级标题的默认值均为 \opt{true}。
+%   控制是否对\emph{不带星号}的章节标题进行编号。
+%   各级标题的默认值均为 \opt{true}。
 %
-%   我们知道,\LaTeX{} 带星号的章节标题命令(如 \tn{section*})不会对标题编号,
-%   但也不会将该没编号的标题编入目录中。本选项控制的是不带星号的标题命令是否编号。
-%   设置本选项为 \opt{false},除了不对标题编号以外,功能与正常标题一致,
-%   比如可以编目录,正确的 \pkg{hyperref} 目录超链接位置和页眉标记。
+%   \LaTeX{} 标准的章节标题命令(如 \tn{section})大体上完成四项工作:
+%   输出标题内容、对标题编号(计数器增加 1)、将标题列入目录(若调用了
+%   \pkg{hyperref} 宏包还会添加 PDF 书签)、更新页眉页脚标记。带星号的
+%   章节标题命令(如 \tn{section*})只简单地输出章节标题内容,但不对标题编号,
+%   不将标题列入目录或 PDF 书签,也不写入页眉页脚标记。与之不同的是,
+%   本选项仅仅是否对\emph{不带星号}的章节标题进行编号。因此,当设置本选项为
+%   \opt{false} 时,除了不对标题编号以外,其余功能与正常标题一致:可以
+%   编入目录,并生成正确的 \pkg{hyperref} 目录超链接位置和页眉页脚标记。例如:
+%   \begin{ctexexam}
+%   \documentclass{ctexbook}
+%   \begin{document}
+%   \tableofcontents
+%   \chapter{A}
+%   \chapter*{B}
+%   \ctexset{chapter/numbering=false}
+%   \chapter{C}
+%   \end{document}
+%   \end{ctexexam}
+%   三章的标题分别为“第一章\quad A”、“B”和“C”,但在目录中则只出现
+%   “第一章\quad A”和“C”。
 %
-%   注意,章节标题的编号深度受 \LaTeX{} 计数器 |secnumdepth| 的控制。
-%   \opt{numbering} 选项在 |secnumdepth| 的控制下起作用。
+%   注意,章节标题是否编号还要受到 \LaTeX{} 计数器 |secnumdepth| 的控制。
+%   例如,对于 |section| 而言,其深度为 1。因此,|section| 会被编号,当且仅当
+%   |secnumdepth| 不小于 1,并且 \opt{section/numbering} 为 \opt{true},
+%   并且使用不带星号的章节标题命令(即 \tn{section})。
+%
+%   如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。
 % \end{function}
 %
-% 如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。
-%
 % \begin{function}[EXP,updated=2014-03-08]{.../name}
 %   \begin{syntax}
 %     name = \{<前名字>,<后名字>\}
 %     name = \Arg{前名字}
 %   \end{syntax}
-%   设置章节的名字。名字可以分为前后两部分,即章节编号前后的词语,两个词之间用
-%   一个半角逗号分开;也可以只有一部分,表示只有章节编号之前的名字。例如:
+%   设置章节的名字。所谓“章节的名字”,可以分为前后两部分,即章节编号前后的
+%   词语,两个词之间用一个半角逗号分开;也可以只有一部分,表示只有章节编号之前
+%   的名字。例如:
 %   \begin{ctexexam}
 %   \ctexset{
 %     chapter/name = {第,章},
@@ -1633,30 +1684,32 @@
 %   }
 %   \end{ctexexam}
 %   会使得 \tn{chapter} 标题使用形如“第一章”的名字,而 \tn{section} 标题则使
-%   用形如“\S1”的名字。
+%   用形如“\S1”的名字。该选项的默认设置见表~\ref{tab:name-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{name} 选项的默认设置}
-% \begin{tabular}{llll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\
-% \midrule
-% part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\
-% chapter & |{第,章}| & |{\chaptername\space}|
-%   & 原 \tn{chaptername} 为 Chapter \\
-% section (beamer) & |{}| & |{\sectionname\space}|
-%   & \BSTACK 原 \tn{sectionname} 为\\ |\translate{Section}| \ESTACK \\
-% section & 同右 & |{}| & \\
-% subsection (beamer) & |{}| & |{\subsectionname\space}|
-%   & \BSTACK 原 \tn{subsectionname} 为\\ |\translate{Subsection}| \ESTACK \\
-% subsection & 同右 & |{}| & \\
-% subsubsection & 同右 & |{}| & \\
-% paragraph & 同右 & |{}| & \\
-% subparagraph & 同右 & |{}| & \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
+%   \caption{\opt{name} 选项的默认设置}
+%   \label{tab:name-default}
+%   \begin{tabular}{llll}
+%   \toprule
+%   标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\
+%   \midrule
+%   part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\
+%   chapter & |{第,章}| & |{\chaptername\space}|
+%     & 原 \tn{chaptername} 为 Chapter \\
+%   section (beamer) & |{}| & |{\sectionname\space}|
+%     & \BSTACK 原 \tn{sectionname} 为\\ |\translate{Section}| \ESTACK \\
+%   section & 同右 & |{}| & \\
+%   subsection (beamer) & |{}| & |{\subsectionname\space}|
+%     & \BSTACK 原 \tn{subsectionname} 为\\ |\translate{Subsection}| \ESTACK \\
+%   subsection & 同右 & |{}| & \\
+%   subsubsection & 同右 & |{}| & \\
+%   paragraph & 同右 & |{}| & \\
+%   subparagraph & 同右 & |{}| & \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
 % \begin{function}[EXP]{.../number}
@@ -1664,80 +1717,78 @@
 %     number = \Arg{数字输出命令}
 %   \end{syntax}
 %   设置章节编号的数字输出格式。\meta{数字输出命令} 通常是对应章节编号计数器的
-%   输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。
+%   输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。例如:
 %   \begin{ctexexam}
 %   \ctexset{
 %     section/number = \Roman{section}
 %   }
 %   \end{ctexexam}
-% \end{function}
+%   将会使 \tn{section} 的编号变为大写罗马数字(如 I、II 等)。
 %
-%   \opt{number} 选项的定义同时将控制对章节计数器的交叉引用。在引用计数器时,
+%   \opt{number} 选项定义的同时将控制对章节计数器的交叉引用。在引用计数器时,
 %   记录在 \LaTeX{} 辅助文件中的是 \opt{number} 选项的定义。
 %
 %   但是,\opt{number} 选项不会影响计数器本身的输出。即设置 |section/number|
-%   不会影响 \tn{thesection} 的定义。(但该选项会影响 \tn{CTEXthesection} 的定
-%   义,见后。)
+%   不会影响 \tn{thesection} 的定义(但该选项会影响 \tn{CTEXthesection} 的定
+%   义,见后)。该选项的默认设置见表~\ref{tab:number-default}。
+% \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{number} 选项的默认设置}
-% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
-% \begin{tabular}{llll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain}
-%   & 原 |\the|\meta{标题} 等价定义 \\
-% \midrule
-% part (beamer) & |\chinese{part}| & |\insertromanpartnumber| & 意义为 |\Roman{part}| \\
-% part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\
-% chapter & |\chinese{chapter}| & |\thechapter| & |\arabic{chapter}| \\
-% section (beamer) & 同右 & |\insertsectionnumber| & 意义为 |\arabic{section}| \\
-% section & 同右 & |\thesection| & |\arabic{section}| \\
-% subsection (beamer)
-%   & \BSTACK |\arabic{section}.|\\ |\arabic{subsection}| \ESTACK
-%   & |\insertsubsectionnumber| & 意义为 |\arabic{subsection}| \\
-% subsection & 同右 & |\thesubsection| & |\thesection.\arabic{subsection}| \\
-% subsubsection & 同右 & |\thesubsubsection|
-%   & |\thesubsection.\arabic{subsubsection}| \\
-% paragraph & 同右 & |\theparagraph|
-%   & |\thesubsubsection.\arabic{paragraph}| \\
-% subparagraph & 同右 & |\thesubparagraph|
-%   & |\theparagraph.\arabic{subparagraph}| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{number} 选项的默认设置}
+%   \label{tab:number-default}
+%   \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
+%   \begin{tabular}{llll}
+%   \toprule
+%   标题名 & \opt{scheme = chinese} & \opt{scheme = plain}
+%     & 原 |\the|\meta{标题} 等价定义 \\
+%   \midrule
+%   part (beamer) & |\chinese{part}| & |\insertromanpartnumber| & 意义为 |\Roman{part}| \\
+%   part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\
+%   chapter & |\chinese{chapter}| & |\thechapter| & |\arabic{chapter}| \\
+%   section (beamer) & 同右 & |\insertsectionnumber| & 意义为 |\arabic{section}| \\
+%   section & 同右 & |\thesection| & |\arabic{section}| \\
+%   subsection (beamer)
+%     & \BSTACK |\arabic{section}.|\\ |\arabic{subsection}| \ESTACK
+%     & |\insertsubsectionnumber| & 意义为 |\arabic{subsection}| \\
+%   subsection & 同右 & |\thesubsection| & |\thesection.\arabic{subsection}| \\
+%   subsubsection & 同右 & |\thesubsubsection|
+%     & |\thesubsection.\arabic{subsubsection}| \\
+%   paragraph & 同右 & |\theparagraph|
+%     & |\thesubsubsection.\arabic{paragraph}| \\
+%   subparagraph & 同右 & |\thesubparagraph|
+%     & |\theparagraph.\arabic{subparagraph}| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
-% \begin{function}{\CTEXthepart, \CTEXthechapter, \CTEXthesection,
-%   \CTEXthesubsection, \CTEXthesubsubsection, \CTEXtheparagraph,
-%   \CTEXthesubparagraph}
-%   以 |\CTEXthe| 开头的这组宏给出结合了 \opt{name} 与 \opt{number} 选项的章节
-%   编号输出格式。例如在 \opt{scheme = chinese} 时,默认章编号输出格式就是
-%   \tn{CTEXthechapter},形如“第一章”。
+% \subsection{格式相关}
+% \label{subsec:sec-format}
 %
-%   这组宏在 \CTeX 文档类中将代替 \tn{thechapter} 等宏的作用,在章节中引用本章
-%   节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。
-% \end{function}
+% \CTeX{} 宏集提供了 \opt{numberformat}, \opt{nameformat}, \opt{titleformat},
+% \opt{format} 这几个选项用来控制章节标题的格式。
+% 它们的作用范围如图~\ref{fig:heading-format} 所示。具体用法见下文。
 %
-% \begin{function}[added=2016-09-18]{\CTEXifname}
-%   \begin{syntax}
-%     \tn{CTEXifname} \Arg{有名字时的格式命令} \Arg{无名字时的格式命令}
-%   \end{syntax}
-%   \tn{CTEXifname} 用于根据当前章节的名字的有无设置不同的格式。
+% \begin{figure}[htbp]
+%   \centering
+%   \[
+%     \underbrace{
+%       \overbrace{
+%         \text{\huge\bfseries 第}
+%         \mspace{-25mu}
+%         \underbrace{\text{\huge\bfseries 1}}_{\text{\small\opt{numberformat}}}
+%         \mspace{-25mu}
+%         \text{\huge\bfseries 章}
+%       }^{\text{\small\opt{nameformat}}} \quad
+%       \overbrace{\text{\huge\bfseries 熟悉 \LaTeX}}^{\text{\small\opt{titleformat}}}
+%     }_{\text{\small\opt{format}}}
+%   \]
+%   \caption{\opt{numberformat}, \opt{nameformat}, \opt{titleformat},
+%     \opt{format} 几个选项的作用范围示意}
+%   \label{fig:heading-format}
+% \end{figure}
 %
-%   它可用于 \opt{format}, \opt{titleformat}, \opt{aftertitle}, \opt{afterskip},
-%   \opt{indent} 这五个选项和 \tn{chapter} 标题 \opt{beforeskip} 选项的格式设置之中。
-%   也可用于帮助定义自定义的目录格式、页眉格式等。
-%
-%   例如,设置章的标题有名字时左对齐,无名字时居中对齐,并且在标题后画一条横线。
-%   \begin{ctexexam}
-%   \ctexset{
-%     chapter/format = \CTEXifname{\raggedright}{\centering},
-%     chapter/aftertitle = \par\CTEXifname{}{\hrule},
-%   }
-%   \end{ctexexam}
-% \end{function}
-%
-% \begin{function}[EXP,updated=2015-06-30]{.../format, .../format+}
+% \begin{function}[EXP,updated=2020-04-22]{.../format, .../format+}
 %   \begin{syntax}
 %     format = \Arg{格式命令}
 %     format+= \Arg{格式命令}
@@ -1744,38 +1795,54 @@
 %   \end{syntax}
 %   \opt{format} 选项用于控制章节标题的全局格式,作用域为章节名字和随后的标题
 %   内容。可以用于控制章节标题的对齐方式、整体字体字号等格式。
+%   带加号的 \opt{format+} 选项用于在已有的格式命令后附加内容。
 %
-%   带加号的 \opt{format+} 选项则用于在已有格式之后追加新的格式命令。
+%   \opt{format} 选项的最后一个格式命令可以带有一个参数。
+%   这一参数用于接受章节名字、编号和标题内容(以及由 \opt{nameformat}, \opt{numberformat},
+%   \opt{aftername},\opt{titleformat}, \opt{aftertitle}, \opt{indent}
+%   及 \opt{hang} 选项设定的,应用于这些内容之上的格式),以实现特殊效果。
 %
-%   例如,设置章格式为无衬线字体左对齐,为节格式增加无衬线字体设置:
+%   例如,设置章标题为无衬线字体左对齐、为节标题增加无衬线字体设置、
+%   为小节标题加框(\tn{fbox} 命令本身需带一个参数):
 %   \begin{ctexexam}
 %   \ctexset{
-%     chapter/format  = \sffamily\raggedright,
-%     section/format += \sffamily
+%     chapter/format     = \sffamily\raggedright,
+%     section/format    += \sffamily,
+%     subsection/format += \fbox,
 %   }
 %   \end{ctexexam}
+%
+%   \opt{format} 选项的默认设置见表~\ref{tab:format-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{format} 选项的默认设置}
-% \begin{tabular}{lll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
-% \midrule
-% part (article) & |\Large\bfseries\centering| & |\raggedright| \\
-% part (beamer) & 同右 & |\centering| \\
-% part & |\huge\bfseries\centering| & |\centering| \\
-% chapter & |\huge\bfseries\centering| & |\raggedright| \\
-% section (beamer) & 同右 & |\centering| \\
-% section & |\Large\bfseries\centering| & |\Large\bfseries| \\
-% subsection (beamer) & 同右 & |\centering| \\
-% subsection & 同右 & |\large\bfseries| \\
-% subsubsection & 同右 & |\normalsize\bfseries| \\
-% paragraph & 同右 & |\normalsize\bfseries| \\
-% subparagraph & 同右 & |\normalsize\bfseries| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \begin{threeparttable}
+%     \caption{\opt{format} 选项的默认设置}
+%     \label{tab:format-default}
+%     \begin{tabular}{lll}
+%     \toprule
+%     标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
+%     \midrule
+%     part (article) & |\Large\bfseries\centering| & |\raggedright|\tnote{*} \\
+%     part (beamer) & 同右 & |\centering| \\
+%     part & |\huge\bfseries\centering| & |\centering| \\
+%     chapter & |\huge\bfseries\centering| & |\raggedright| \\
+%     section (beamer) & 同右 & |\centering| \\
+%     section & |\Large\bfseries\centering| & |\Large\bfseries| \\
+%     subsection (beamer) & 同右 & |\centering| \\
+%     subsection & 同右 & |\large\bfseries| \\
+%     subsubsection & 同右 & |\normalsize\bfseries| \\
+%     paragraph & 同右 & |\normalsize\bfseries| \\
+%     subparagraph & 同右 & |\normalsize\bfseries| \\
+%     \bottomrule
+%     \end{tabular}
+%     \begin{tablenotes}
+%       \item[*] 为了与 \LaTeXe{} 的默认效果保持一致,在 \opt{scheme = plain}
+%           时,part 和 chapter 的 \opt{nameformat} 和 \opt{titleformat}
+%           并不一样,因此没有使用 \opt{format} 选项统一设置名字和标题的格式。
+%     \end{tablenotes}
+%   \end{threeparttable}
 % \end{table}
 %
 % \begin{function}[EXP,updated=2015-06-30]{.../nameformat, .../nameformat+}
@@ -1785,42 +1852,42 @@
 %   \end{syntax}
 %   \opt{nameformat} 用于控制章节名字的格式,作用域为章节名字,包括编号。它一
 %   般用于章节名(包括编号)与章节标题的字体、字号等设置不一致的情形。参见
-%   \opt{titleformat} 选项。
+%   下面的 \opt{titleformat} 选项。\opt{nameformat+} 用于在已有的章节名字
+%   格式命令后附加内容。
 %
-%   \opt{nameformat+} 用于在已有的章节名字格式后附加内容。
+%   \opt{nameformat} 选项的最后一个格式命令可以带有一个参数。
+%   这一参数用于接受章节名字和编号,以实现特殊效果(见例~\ref{exam:miscopt})。
 %
-%   \opt{nameformat} 选项的最后一个格式命令可以是一个有一个参数的命令。
-%   这个命令的参数用于接受章节名字和编号,实现特殊效果(见例~\ref{exam:miscopt})。
-%
-%   \opt{nameformat} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
+%   \opt{nameformat} 选项的默认设置见表~\ref{tab:nameformat-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{nameformat} 选项的默认设置}
-% \begin{tabular}{lll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
-% \midrule
-% part (article) & |{}| & |\Large\bfseries| \\
-% part (beamer) & 同右
-%   & \BSTACK |\usebeamerfont{part name}| \\
-%             |\usebeamercolor[fg]{part name}| \ESTACK \\
-% part & |{}| & |\huge\bfseries| \\
-% chapter & |{}| & |\huge\bfseries| \\
-% section (beamer) & 同右
-%   & \BSTACK |\usebeamerfont{section name}| \\
-%             |\usebeamercolor[fg]{section name}| \ESTACK \\
-% section & 同右 & |{}| \\
-% subsection (beamer) & 同右
-%   & \BSTACK |\usebeamerfont{subsection name}| \\
-%             |\usebeamercolor[fg]{subsection name}| \ESTACK \\
-% subsection & 同右 & |{}| \\
-% subsubsection & 同右 & |{}| \\
-% paragraph & 同右 & |{}| \\
-% subparagraph & 同右 & |{}| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{nameformat} 选项的默认设置}
+%   \label{tab:nameformat-default}
+%   \begin{tabular}{lll}
+%   \toprule
+%   标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
+%   \midrule
+%   part (article) & |{}| & |\Large\bfseries| \\
+%   part (beamer) & 同右
+%     & \BSTACK |\usebeamerfont{part name}| \\
+%               |\usebeamercolor[fg]{part name}| \ESTACK \\
+%   part & |{}| & |\huge\bfseries| \\
+%   chapter & |{}| & |\huge\bfseries| \\
+%   section (beamer) & 同右
+%     & \BSTACK |\usebeamerfont{section name}| \\
+%               |\usebeamercolor[fg]{section name}| \ESTACK \\
+%   section & 同右 & |{}| \\
+%   subsection (beamer) & 同右
+%     & \BSTACK |\usebeamerfont{subsection name}| \\
+%               |\usebeamercolor[fg]{subsection name}| \ESTACK \\
+%   subsection & 同右 & |{}| \\
+%   subsubsection & 同右 & |{}| \\
+%   paragraph & 同右 & |{}| \\
+%   subparagraph & 同右 & |{}| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
 % \begin{function}[EXP,updated=2015-06-19]{.../numberformat, .../numberformat+}
@@ -1829,60 +1896,26 @@
 %     numberformat+= \Arg{格式命令}
 %   \end{syntax}
 %   \opt{numberformat} 选项用于控制章节编号的格式,作用域仅为编号数字本身。对
-%   各级标题默认均为空,当你需要编号的格式和前后的章节名字不一样时可以使用。
+%   各级标题默认均为空,当需要编号的格式和前后的章节名字不一样时可以使用。
+%   \opt{numberformat+} 用于在已有的编号格式命令后附加内容。
 %
-%   \opt{numberformat+} 选项用于在原有编号格式后面附加格式命令。
-%
-%   \opt{numberformat} 选项的最后一个格式命令可以是一个有一个参数的命令。
-%   这个命令的参数用于接受编号数字。
-% \end{function}
-%
-%   例如,我们可以使用 \opt{numberformat} 特别强调章标题中的数字:
+%   \opt{numberformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受
+%   编号数字。例如,我们可以使用 \opt{numberformat} 特别强调章标题中的数字:
 %   \begin{ctexexam}
 %   \ctexset{
 %     chapter/number = \arabic{chapter},
-%     chapter/numberformat = \color{blue}\zihao{0}\itshape,
+%     chapter/numberformat = \color{blue}\zihao{0}\emph,
 %   }
 %   \end{ctexexam}
 %   上面的代码在 \opt{scheme = chinese} 时可以做出类似这样的章标题效果:
 %   \begin{center}
-%   \huge\bfseries 第 \textit{\color{blue}\zihao{0}4} 章
+%     \huge\bfseries 第 \emph{\color{blue}\zihao{0}4} 章
 %   \end{center}
 %
-% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+}
-%   \begin{syntax}
-%   aftername = \Arg{代码}
-%   aftername+= \Arg{代码}
-%   \end{syntax}
-%   \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之
-%   间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题
-%   是否另起一行。
-%
-%   \opt{aftername+} 选项用于在原有代码后面附加代码。
+%   \opt{numberformat} 选项默认均设置为空,故章节编号默认与章节名字使用
+%   相同的格式。
 % \end{function}
 %
-% \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{aftername} 选项的默认设置}
-% \begin{tabular}{lll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
-% \midrule
-% part (article) & |\quad| & |\par\nobreak| \\
-% part (beamer) & 同右 & |\vskip 1em \par| \\
-% part & 同右 & |\par\vskip 20pt| \\
-% chapter & |\quad| & |\par\nobreak\vskip 20pt| \\
-% section (beamer) & 同右 & |\vskip 1em \par| \\
-% section & 同右 & |\quad| \\
-% subsection (beamer) & 同右 & |\vskip 1em \par| \\
-% subsection & 同右 & |\quad| \\
-% subsubsection & 同右 & |\quad| \\
-% paragraph & 同右 & |\quad| \\
-% subparagraph & 同右 & |\quad| \\
-% \bottomrule
-% \end{tabular}
-% \end{table}
-%
 % \begin{function}[EXP,updated=2015-06-30]{.../titleformat, .../titleformat+}
 %   \begin{syntax}
 %     titleformat = \Arg{格式命令}
@@ -1889,14 +1922,11 @@
 %     titleformat+= \Arg{格式命令}
 %   \end{syntax}
 %   \opt{titleformat} 选项用于控制标题内容的格式,作用域为章节标题内容。
+%   \opt{titleformat+} 选项用于在已有的标题格式命令后附加内容。
 %
-%   \opt{titleformat+} 选项用于在原有标题格式后面附加格式命令。
-%
-%   需要注意的是,\opt{titleformat} 选项的最后一个格式命令可以是一个有一个
-%   参数的命令。这个命令的参数接受标题内容,用于实现特殊效果。
-%   例如,实现多行标题的居中悬挂对齐:
-% \end{function}
-% \begin{ctexexam}
+%   \opt{titleformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受
+%   标题内容。例如,实现多行标题的居中悬挂对齐:
+%   \begin{ctexexam}
 %   \usepackage{varwidth} %% 提供 varwidth 环境
 %   \ctexset{
 %     chapter/name = {第,回},
@@ -1906,38 +1936,53 @@
 %     \begin{varwidth}[t]{.7\linewidth}#1\end{varwidth}}
 %   ......
 %   \chapter{情中情因情感妹妹\\错里错以错劝哥哥}
-% \end{ctexexam}
-% 上面的代码可以做出类似这样的章标题效果:
-% \begin{center}\Large\bfseries
-% 第三十四回\quad
-% \begin{tabular}[t]{l}
-%   情中情因情感妹妹\\
-%   错里错以错劝哥哥
-% \end{tabular}
-% \end{center}
+%   \end{ctexexam}
+%   上面的代码可以做出类似这样的章标题效果:
+%   \begin{center}\Large\bfseries
+%   第三十四回\quad
+%   \begin{tabular}[t]{l}
+%     情中情因情感妹妹\\
+%     错里错以错劝哥哥
+%   \end{tabular}
+%   \end{center}
 %
+%   \opt{titleformat} 选项的默认设置见表~\ref{tab:titleformat-default}。
+% \end{function}
+%
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{titleformat} 选项的默认设置}
-% \begin{tabular}{lll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
-% \midrule
-% part (article) & |{}| & |\huge\bfseries| \\
-% part (beamer) & 同右 & |\usebeamerfont{part title}| \\
-% part & |{}| & |\Huge\bfseries| \\
-% chapter & |{}| & |\Huge\bfseries| \\
-% section (beamer) & 同右 & |\usebeamerfont{section title}| \\
-% section & 同右 & |{}| \\
-% subsection (beamer) & 同右 & |\usebeamerfont{subsection title}| \\
-% subsection & 同右 & |{}| \\
-% subsubsection & 同右 & |{}| \\
-% paragraph & 同右 & |{}| \\
-% subparagraph & 同右 & |{}| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{titleformat} 选项的默认设置}
+%   \label{tab:titleformat-default}
+%   \begin{tabular}{lll}
+%   \toprule
+%   标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
+%   \midrule
+%   part (article) & |{}| & |\huge\bfseries| \\
+%   part (beamer) & 同右 & |\usebeamerfont{part title}| \\
+%   part & |{}| & |\Huge\bfseries| \\
+%   chapter & |{}| & |\Huge\bfseries| \\
+%   section (beamer) & 同右 & |\usebeamerfont{section title}| \\
+%   section & 同右 & |{}| \\
+%   subsection (beamer) & 同右 & |\usebeamerfont{subsection title}| \\
+%   subsection & 同右 & |{}| \\
+%   subsubsection & 同右 & |{}| \\
+%   paragraph & 同右 & |{}| \\
+%   subparagraph & 同右 & |{}| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
+% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+}
+%   \begin{syntax}
+%   aftername = \Arg{代码}
+%   aftername+= \Arg{代码}
+%   \end{syntax}
+%   \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之
+%   间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题
+%   是否另起一行。\opt{aftername+} 用于在已有的代码后附加内容。该选项的默认设置
+%   见表~\ref{tab:aftername-default}。
+% \end{function}
+%
 % \begin{function}[EXP,added=2015-06-19]{.../aftertitle, .../aftertitle+}
 %   \begin{syntax}
 %   aftertitle = \Arg{代码}
@@ -1944,104 +1989,212 @@
 %   aftertitle+= \Arg{代码}
 %   \end{syntax}
 %   \opt{aftertitle} 选项的参数 \meta{代码} 将被插入到章节标题内容之后。
+%   \opt{aftertitle+} 用于在已有的代码后附加内容。该选项的默认设置
+%   见表~\ref{tab:aftertitle-default}。需注意,\opt{sub3section} 或
+%   \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)会影响
+%   \opt{aftertitle} 选项的默认值。
+% \end{function}
 %
-%   \opt{aftertitle+} 选项用于在原有代码后面附加代码。
+% \begin{table}[htbp]
+%   \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
+%   \begin{minipage}[t]{.75\linewidth}
+%     \small\centering
+%     \caption{\opt{aftername} 选项的默认设置}
+%     \label{tab:aftername-default}
+%     \begin{tabular}{lll}
+%     \toprule
+%     标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
+%     \midrule
+%     part (article) & |\quad| & |\par\nobreak| \\
+%     part (beamer) & 同右 & |\vskip 1em \par| \\
+%     part & 同右 & |\par\vskip 20pt| \\
+%     chapter & |\quad| & |\par\nobreak\vskip 20pt| \\
+%     section (beamer) & 同右 & |\vskip 1em \par| \\
+%     section & 同右 & |\quad| \\
+%     subsection (beamer) & 同右 & |\vskip 1em \par| \\
+%     subsection & 同右 & |\quad| \\
+%     subsubsection & 同右 & |\quad| \\
+%     paragraph & 同右 & |\quad| \\
+%     subparagraph & 同右 & |\quad| \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}\nobreak\quad
+%   \begin{minipage}[t]{.42\linewidth}
+%     \small\centering
+%     \caption{\opt{aftertitle} 选项的默认设置}
+%     \label{tab:aftertitle-default}
+%     \begin{tabular}{p{\dimexpr .58\linewidth - 2\tabcolsep\relax}p{\dimexpr .4\linewidth - 2\tabcolsep\relax}}
+%     \toprule
+%     标题名 & 默认值 \\
+%     \midrule
+%     part & |\par| \\
+%     chapter & |\par| \\
+%     section & |\@@par| \\
+%     subsection & |\@@par| \\
+%     subsubsection & |\@@par| \\
+%     paragraph & |{}| \\
+%     \qquad(sub3section) & |\@@par| \\
+%     \qquad(sub4section) & 同上 \\
+%     subparagraph & |{}| \\
+%     \qquad(sub4section) & |\@@par| \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}
+% \end{table}
 %
-%   \opt{aftertitle} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
-%
-%   \opt{sub3section} 或 \opt{sub4section} 宏包选项(见
-%   \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。
+% \begin{function}[EXP,added=2014-03-21]{part/pagestyle, chapter/pagestyle}
+%   \begin{syntax}
+%     pagestyle = \Arg{页面格式}
+%   \end{syntax}
+%   设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类
+%   中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。
+%   该选项的默认设置见表~\ref{tab:pagestyle-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \begin{minipage}[t]{.5\linewidth}
-% \small\centering
-% \caption{\opt{aftertitle} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part & |\par| \\
-% chapter & |\par| \\
-% section & |\@@par| \\
-% subsection & |\@@par| \\
-% subsubsection & |\@@par| \\
-% paragraph & |{}| \\
-% \qquad(sub3section) & |\@@par| \\
-% \qquad(sub4section) & 同上 \\
-% subparagraph & |{}| \\
-% \qquad(sub4section) & |\@@par| \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}%
-% \begin{minipage}[t]{.5\linewidth}
-% \small\centering
-% \caption{\opt{runin} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part & 无效 \\
-% chapter & 无效 \\
-% section & |false| \\
-% subsection & |false| \\
-% subsubsection & |false| \\
-% paragraph & |true| \\
-% \qquad(sub3section) & |false| \\
-% \qquad(sub4section) & 同上 \\
-% subparagraph & |true| \\
-% \qquad(sub4section) & |false| \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}
+%   \small\centering
+%   \caption{\opt{pagestyle} 选项的默认设置}
+%   \label{tab:pagestyle-default}
+%   \begin{tabular}{ll}
+%   \toprule
+%   标题名 & 默认值 \\
+%   \midrule
+%   part (article) & 无效 \\
+%   part & |plain| \\
+%   chapter & |plain| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
+% \subsection{间距、缩进相关}
+% \label{subsec:sec-spacing}
+%
 % \begin{function}[EXP,added=2015-06-27]{section/runin, subsection/runin,
 %   subsubsection/runin, paragraph/runin, subparagraph/runin}
 %   \begin{syntax}
 %   runin = \TF
 %   \end{syntax}
-%   \opt{runin} 选项只对 \tn{section} 级以下标题有意义。
-%   用于确定标题与随后的正文是否排在同一段之上。
+%   \opt{runin} 选项只对 \tn{section} 级以下标题有意义,用于确定标题与随后的
+%   正文是否排在同一段之上。该选项的默认设置见表~\ref{tab:runin-default}。
 %
-%   \opt{runin} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
-%
 %   默认情况下,\tn{paragraph}、\tn{subparagraph} 两级标题是与后面正文排在同一
 %   段的,\opt{runin} 选项为 \opt{true};但使用 \opt{sub3section} 或
-%   \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后,
-%   将对这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。
+%   \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后,将对
+%   这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。
 % \end{function}
 %
-% \begin{function}[EXP,added=2015-06-27]{.../afterindent}
+% \begin{table}[htbp]
+%   \small\centering
+%   \caption{\opt{runin} 选项的默认设置}
+%   \label{tab:runin-default}
+%   \begin{tabular}{ll}
+%   \toprule
+%   标题名 & 默认值 \\
+%   \midrule
+%   part & 无效 \\
+%   chapter & 无效 \\
+%   section & |false| \\
+%   subsection & |false| \\
+%   subsubsection & |false| \\
+%   paragraph & |true| \\
+%   \qquad(sub3section) & |false| \\
+%   \qquad(sub4section) & 同上 \\
+%   subparagraph & |true| \\
+%   \qquad(sub4section) & |false| \\
+%   \bottomrule
+%   \end{tabular}
+% \end{table}
+%
+% \begin{function}[EXP,updated=2020-04-23]{.../hang}
 %   \begin{syntax}
-%   afterindent = \TF
+%   hang = \TF
 %   \end{syntax}
-%   \opt{afterindent} 选项用于设置章节标题后首段的缩进。
+%   \opt{hang} 选项用于设置是否对章节标题实施悬挂缩进(缩进的宽度为名字宽度
+%   和 \opt{indent} 选项设置的宽度之和)。
 %
-%   \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上,
-%   \opt{afterindent} 选项没有意义。
+%   注意,当 \opt{hang = true} 时,不恰当地设置选项 \opt{aftername} 的值,可能会引发
+%   错误。这是因为当 \opt{hang = true} 时,\LaTeX{} 内部会构造一个 \tn{hbox} 而
+%   进入受限水平模式(restricted horizontal mode)。若在 \opt{aftername} 中加入
+%   包含 \tn{vskip} 等会导致从受限水平模式切出的垂直命令(vertical command)时,就会报错。
+%   特别地,\opt{aftername} 的默认值也可能导致这种情形(见表~\ref{tab:aftername-default})。
+%   因此,当设置 \opt{hang = true} 时,用户必须恰当地设置选项 \opt{aftername} 的值。
 %
+%   本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。
 %   对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true},
-%   即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。
+%   即标题与随后正文排在同一段,\opt{hang} 选项没有意义。
+%   该选项的默认设置见表~\ref{tab:hang-default}。
 % \end{function}
 %
+% \begin{function}[EXP,updated=2020-04-23]{.../indent}
+%   \begin{syntax}
+%   indent = \Arg{缩进间距}
+%   \end{syntax}
+%   \opt{indent} 选项用于设置章节标题本身的首行缩进。
+%   该选项的默认设置见表~\ref{tab:indent-default}。
+%
+%   如果 \opt{indent} 的值是以 \texttt{em}、\texttt{ex} 或 \cs{ccwd} 为单位,
+%   那么缩进间距的大小是相对于 \opt{format} 中指定的字号大小。
+%   例如,设置 \tn{part} 标题缩进三个字、\tn{section} 标题缩进 \SI{20}{pt}:
+%   \begin{ctexexam}
+%   \ctexset{
+%     part = {
+%       format += \raggedright,
+%       indent  = 3\ccwd,
+%     },
+%     section = {
+%       format  = \Large\bfseries,
+%       indent  = 20pt,
+%     }
+%   }
+%   \part{首行缩进的标题}
+%   \noindent 无缩进的正文。
+%   \section{首行缩进的标题}
+%   \noindent 无缩进的正文。
+%   \end{ctexexam}
+% \end{function}
+%
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{afterindent} 选项的默认设置}
-% \begin{tabular}{lll}
-% \toprule
-% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
-% \midrule
-% part (article) & |true| & |false| \\
-% part & 无效 & 无效 \\
-% chapter & |true| & |false| \\
-% section & |true| & |false| \\
-% subsection & |true| & |false| \\
-% subsubsection & |true| & |false| \\
-% paragraph & |true| & |false| \\
-% subparagraph & |true| & |false| \\
-% \bottomrule
-% \end{tabular}
+%   \begin{minipage}[t]{.5\linewidth}
+%     \small\centering
+%     \caption{\opt{hang} 选项的默认设置}
+%     \label{tab:hang-default}
+%     \begin{tabular}{ll}
+%     \toprule
+%     标题名 & 默认值 \\
+%     \midrule
+%     part & |false| \\
+%     chapter & |false| \\
+%     section & |true| \\
+%     subsection & |true| \\
+%     subsubsection & |true| \\
+%     paragraph & 无意义 \\
+%     \qquad(sub3section) & |true| \\
+%     \qquad(sub4section) & |true| \\
+%     subparagraph & 无意义 \\
+%     \qquad(sub4section) & |true| \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}
+%   \begin{minipage}[t]{.5\linewidth}
+%     \small\centering
+%     \caption{\opt{indent} 选项的默认设置}
+%     \label{tab:indent-default}
+%     \begin{tabular}{ll}
+%     \toprule
+%     标题名 & 默认值 \\
+%     \midrule
+%     part & |0pt| \\
+%     chapter & |0pt| \\
+%     section & |0pt| \\
+%     subsection & |0pt| \\
+%     subsubsection & |0pt| \\
+%     paragraph & |0pt| \\
+%     subparagraph & |\parindent| \\
+%     \qquad(sub3section) & |0pt| \\
+%     \qquad(sub4section) & 同上 \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}
 % \end{table}
 %
 % \begin{function}[EXP,updated=2016-05-10]{.../beforeskip}
@@ -2049,59 +2202,9 @@
 %   beforeskip = \Arg{弹性间距}
 %   \end{syntax}
 %   \opt{beforeskip} 选项用于设置章节标题前的垂直间距。
-%
-%   \opt{beforeskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
+%   该选项的默认设置见表~\ref{tab:beforeskip-default}。
 % \end{function}
 %
-% \begin{table}[htbp]
-% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
-% \begin{minipage}[t]{.6\linewidth}
-% \small\centering
-% \caption{\opt{beforeskip} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part (article) & |4ex| \\
-% part (beamer) & |0pt| \\
-% part & |0pt plus 1fil| \\
-% chapter & |50pt| \\
-% section (beamer) & |0pt| \\
-% section & |3.5ex plus 1ex minus .2ex| \\
-% subsection (beamer) & |0pt| \\
-% subsection & |3.25ex plus 1ex minus .2ex| \\
-% subsubsection & |3.25ex plus 1ex minus .2ex| \\
-% paragraph & |3.25ex plus 1ex minus .2ex| \\
-% subparagraph & |3.25ex plus 1ex minus .2ex| \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}%
-% \begin{minipage}[t]{.5\linewidth}
-% \small\centering
-% \caption{\opt{afterskip} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part (article) & |3ex| \\
-% part (beamer) & |0pt| \\
-% part & |0pt plus 1fil| \\
-% chapter & |40pt| \\
-% section (beamer) & |0pt| \\
-% section & |2.3ex plus .2ex| \\
-% subsection (beamer) & |0pt| \\
-% subsection & |1.5ex plus .2ex| \\
-% subsubsection & |1.5ex plus .2ex| \\
-% paragraph & |1em| \\
-% \qquad(sub3section) & |1ex plus .2ex| \\
-% \qquad(sub4section) & 同上 \\
-% subparagraph & |1em| \\
-% \qquad(sub4section) & |1ex plus .2ex| \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}
-% \end{table}
-%
 % \begin{function}[EXP,updated=2015-06-27]{.../afterskip}
 %   \begin{syntax}
 %   afterskip = \Arg{弹性间距}
@@ -2112,222 +2215,207 @@
 %   若 \opt{runin} 为 \opt{true},标题与随后正文排在同一段,\meta{弹性间距} 给出水平间距。
 %   否则,正文另起一段,\meta{弹性间距} 给出的是垂直间距。
 %
-%   \opt{afterskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
-%
-%   \opt{sub3section} 或 \opt{sub4section} 宏包选项(见
+%   该选项的默认设置见表~\ref{tab:afterskip-default}。
+%   注意 \opt{sub3section} 或 \opt{sub4section} 宏包选项(见
 %   \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。
 % \end{function}
 %
+% \begin{table}[htbp]
+%   \setlength\leftskip{0pt plus 1 fil minus \marginparwidth}
+%   \begin{minipage}[t]{.6\linewidth}
+%     \small\centering
+%     \caption{\opt{beforeskip} 选项的默认设置}
+%     \label{tab:beforeskip-default}
+%     \begin{tabular}{ll}
+%     \toprule
+%     标题名 & 默认值 \\
+%     \midrule
+%     part (article) & |4ex| \\
+%     part (beamer) & |0pt| \\
+%     part & |0pt plus 1fil| \\
+%     chapter & |50pt| \\
+%     section (beamer) & |0pt| \\
+%     section & |3.5ex plus 1ex minus .2ex| \\
+%     subsection (beamer) & |0pt| \\
+%     subsection & |3.25ex plus 1ex minus .2ex| \\
+%     subsubsection & |3.25ex plus 1ex minus .2ex| \\
+%     paragraph & |3.25ex plus 1ex minus .2ex| \\
+%     subparagraph & |3.25ex plus 1ex minus .2ex| \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}\nobreak\quad
+%   \begin{minipage}[t]{.5\linewidth}
+%     \small\centering
+%     \caption{\opt{afterskip} 选项的默认设置}
+%     \label{tab:afterskip-default}
+%     \begin{tabular}{ll}
+%     \toprule
+%     标题名 & 默认值 \\
+%     \midrule
+%     part (article) & |3ex| \\
+%     part (beamer) & |0pt| \\
+%     part & |0pt plus 1fil| \\
+%     chapter & |40pt| \\
+%     section (beamer) & |0pt| \\
+%     section & |2.3ex plus .2ex| \\
+%     subsection (beamer) & |0pt| \\
+%     subsection & |1.5ex plus .2ex| \\
+%     subsubsection & |1.5ex plus .2ex| \\
+%     paragraph & |1em| \\
+%     \qquad(sub3section) & |1ex plus .2ex| \\
+%     \qquad(sub4section) & 同上 \\
+%     subparagraph & |1em| \\
+%     \qquad(sub4section) & |1ex plus .2ex| \\
+%     \bottomrule
+%     \end{tabular}
+%   \end{minipage}
+% \end{table}
+%
 % \begin{function}[EXP,added=2016-06-03]{.../fixskip}
 %   \begin{syntax}
 %   fixskip = \TFF
 %   \end{syntax}
-%   默认情况下,\cls{article}、\cls{book} 和 \cls{report} 类的标题与正文的距离除了由
-%   \opt{beforeskip} 和 \opt{afterskip} 选项设置的垂直间距外,还会有一些多余的间距。
-%   \opt{fixskip} 选项用于抑制这些多余间距。
+%   默认情况下,\cls{article}、\cls{book} 和 \cls{report} 类的标题与正文的距离
+%   除了由 \opt{beforeskip} 和 \opt{afterskip} 选项设置的垂直间距外,还会有
+%   一些多余的间距。\opt{fixskip} 选项用于抑制这些多余间距。该选项默认不开启。
 % \end{function}
 %
-% \begin{function}[EXP,added=2016-10-01]{chapter/lofskip, chapter/lotskip}
+% \begin{function}[EXP,added=2016-09-19]{.../break, .../break+}
 %   \begin{syntax}
-%   lofskip = \Arg{弹性间距}
-%   lotskip = \Arg{弹性间距}
+%     break = \Arg{格式命令}
+%     break+= \Arg{格式命令}
 %   \end{syntax}
-%   \opt{lofskip} 选项控制插图目录(\file{.lof})中,章之间的插图标题的距离。
+%   \opt{break} 选项用于控制章节标题与\emph{之前}正文的分隔关系。
+%   一般用于设置是否在标题之前分页或者设置行间罚点。
+%   \opt{break+} 用于在已有的格式命令后附加内容。
 %
-%   同样,\opt{lotskip} 选项控制表格目录(\file{.lot})中,章之间的表格标题的距离。
+%   例如,若当前页剩余高度小于正文高度的一半时,则另起一页输出
+%   \tn{section} 标题:
+%   \begin{ctexexam}
+%   \usepackage{needspace}
+%   \ctexset{section/break = \Needspace{.5\textheight}}
+%   \end{ctexexam}
 %
-%   目前,这两个选项只在 \opt{chapter} 标题下有定义。
-%   他们的默认值,在 \opt{scheme} 选项的不同取值下都为 \SI{10}{pt}。
+%   该选项的默认设置见表~\ref{tab:break-default}。
 % \end{function}
 %
-% \begin{function}[EXP,updated=2015-06-27]{.../indent}
-%   \begin{syntax}
-%   indent = \Arg{缩进间距}
-%   \end{syntax}
-%   \opt{indent} 选项用于设置章节标题本身的首行缩进。
-%
-%   \opt{indent} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
-%
-%   如果 \opt{indent} 的值是以 \texttt{em}、\texttt{ex} 或 \cs{ccwd} 为单位,
-%   那么缩进间距的大小是相对于 \opt{format} 中指定的字号大小。
-%
-%   例如,设置 \tn{part} 标题缩进三个字、\tn{section} 标题缩进 \SI{20}{pt}:
-% \end{function}
-% \begin{ctexexam}
-%   \ctexset{
-%     part={
-%       format+=\raggedright,
-%       indent=3\ccwd,
-%     },
-%     section={
-%       format=\Large\bfseries,
-%       indent=20pt,
-%     }
-%   }
-%   \part{首行缩进的标题}
-%   \noindent 无缩进的正文。
-%   \section{首行缩进的标题}
-%   \noindent 无缩进的正文。
-% \end{ctexexam}
-%
 % \begin{table}[htbp]
-% \begin{minipage}[t]{.5\linewidth}
-% \small\centering
-% \caption{\opt{indent} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part & |0pt| \\
-% chapter & |0pt| \\
-% section & |0pt| \\
-% subsection & |0pt| \\
-% subsubsection & |0pt| \\
-% paragraph & |0pt| \\
-% subparagraph & |\parindent| \\
-% \qquad(sub3section) & |0pt| \\
-% \qquad(sub4section) & 同上 \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}%
-% \begin{minipage}[t]{.5\linewidth}
-% \small\centering
-% \caption{\opt{hang} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part & |false| \\
-% chapter & |false| \\
-% section & |true| \\
-% subsection & |true| \\
-% subsubsection & |true| \\
-% paragraph & 无意义 \\
-% \qquad(sub3section) & |true| \\
-% \qquad(sub4section) & |true| \\
-% subparagraph & 无意义 \\
-% \qquad(sub4section) & |true| \\
-% \bottomrule
-% \end{tabular}
-% \end{minipage}%
+%   \small\centering
+%   \caption{\opt{break} 选项的默认设置}
+%   \label{tab:break-default}
+%   \begin{tabular}{ll}
+%   \toprule
+%   标题名 & 默认值 \\
+%   \midrule
+%   part (article) & |{}| \\
+%   part & |\if at openright\cleardoublepage\else\clearpage\fi| \\
+%   chapter & 同上 \\
+%   section & |\addpenalty{\@secpenalty}| \\
+%   subsection & 同上 \\
+%   subsubsection & 同上 \\
+%   paragraph & 同上 \\
+%   subparagraph & 同上 \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
-% \begin{function}[EXP,updated=2019-03-31]{part/hang, chapter/hang, section/hang,
-%   subsection/hang, subsubsection/hang, paragraph/hang, subparagraph/hang}
+% \begin{function}[EXP,added=2015-06-27]{.../afterindent}
 %   \begin{syntax}
-%   hang = \TF
+%   afterindent = \TF
 %   \end{syntax}
-%   \opt{hang} 选项用于设置是否对章节标题实施悬挂缩进(缩进的宽度为名字宽度和 \opt{indent} 选项
-%   设置的宽度之和)。
+%   \opt{afterindent} 选项用于设置章节标题后首段的缩进。
 %
-%   本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。
+%   \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上,
+%   \opt{afterindent} 选项没有意义。
 %   对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true},
-%   即标题与随后正文排在同一段,\opt{hang} 选项没有意义。
-% \end{function}
+%   即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。
 %
-% \begin{function}[EXP,added=2014-03-21]{part/pagestyle, chapter/pagestyle}
-%   \begin{syntax}
-%     pagestyle = \Arg{页面格式}
-%   \end{syntax}
-%   设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类
-%   中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。
+%   该选项的默认设置见表~\ref{tab:afterindent-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{pagestyle} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part (article) & 无效 \\
-% part & |plain| \\
-% chapter & |plain| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{afterindent} 选项的默认设置}
+%   \label{tab:afterindent-default}
+%   \begin{tabular}{lll}
+%   \toprule
+%   标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\
+%   \midrule
+%   part (article) & |true| & |false| \\
+%   part & 无效 & 无效 \\
+%   chapter & |true| & |false| \\
+%   section & |true| & |false| \\
+%   subsection & |true| & |false| \\
+%   subsubsection & |true| & |false| \\
+%   paragraph & |true| & |false| \\
+%   subparagraph & |true| & |false| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
-% \begin{function}[EXP,added=2016-09-19]{.../break, .../break+}
+% \subsection{目录、附录相关}
+% \label{subsec:sec-toc-appendix}
+%
+% \begin{function}[EXP,added=2016-10-25]{.../tocline}
 %   \begin{syntax}
-%     break = \Arg{格式命令}
-%     break+= \Arg{格式命令}
+%     tocline = \Arg{格式定义}
 %   \end{syntax}
-%   \opt{break} 选项用于控制章节标题与之前正文的分隔关系。一般用于设置是否在标题之前分页或者设置行间罚点。
-%
-%   带加号的 \opt{break+} 选项则用于在已有格式之后追加新的格式命令。
-%
-%   \opt{break} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。
-%
-%   例如,若当前页剩余高度小于正文高度的一半时,则另起一页输出 \tn{section} 标题:
-%   \begin{ctexexam}
-%   \usepackage{needspace}
-%   \ctexset{section/break = \Needspace{.5\textheight}}
-%   \end{ctexexam}
+%   \opt{tocline} 选项用于定义章节标题在目录文件(\file{.toc})中的格式。
+%   \meta{格式定义}有两个参数:参数 |#1| 是 |part|、|chapter| 等名字,
+%   参数 |#2| 是标题内容。该选项的默认设置见表~\ref{tab:tocline-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{break} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part (article) & |{}| \\
-% part & |\if at openright\cleardoublepage\else\clearpage\fi| \\
-% chapter & 同上 \\
-% section & |\addpenalty{\@secpenalty}| \\
-% subsection & 同上 \\
-% subsubsection & 同上 \\
-% paragraph & 同上 \\
-% subparagraph & 同上 \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{tocline} 选项的默认设置}
+%   \label{tab:tocline-default}
+%   \begin{tabular}{ll}
+%   \toprule
+%   标题名 & 默认值 \\
+%   \midrule
+%   part & |\CTEXifname{\CTEXthepart\hspace{1em}}{}#2| \\
+%   chapter (\opt{chinese})
+%     & |\CTEXifname{\protect\numberline{\CTEXthechapter\hspace{.3em}}}{}#2| \\
+%   chapter (\opt{plain})
+%     & |\CTEXnumberline{#1}#2| \\
+%   section & |\CTEXnumberline{#1}#2| \\
+%   subsection & 同上 \\
+%   subsubsection & 同上 \\
+%   paragraph & 同上 \\
+%   subparagraph & 同上 \\
+%   \bottomrule
+%   \end{tabular}
+%
+%   \medskip
+%   \raggedright
+%   这里 \tn{CTEXnumberline} 的意义是,若标题 |#1| 没有名字,则不输出
+%   |\numberline{\CTEXthe#1}| 等编号:
+%   \begin{verbatim}
+%     \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{}
+%   \end{verbatim}
+%   其中,\tn{CTEXifname} 的定义见 \ref{subsec:sec-commands}~小节。
 % \end{table}
 %
-% \begin{function}[EXP,added=2016-10-25]{.../tocline}
+% \begin{function}[EXP,added=2016-10-01]{chapter/lofskip, chapter/lotskip}
 %   \begin{syntax}
-%     tocline = \Arg{格式定义}
+%   lofskip = \Arg{弹性间距}
+%   lotskip = \Arg{弹性间距}
 %   \end{syntax}
-%   \opt{tocline} 选项用于定义章节标题在目录文件(\file{.toc})中的格式。\meta{格式定义}有两个参数:
-%   参数 |#1| 是 |part|、|chapter| 等名字,参数 |#2| 是标题内容。
+%   \opt{lofskip} 选项控制插图目录(\file{.lof})中,章之间的插图标题的距离。
+%   同样,\opt{lotskip} 选项控制表格目录(\file{.lot})中,章之间的表格标题
+%   的距离。
+%
+%   目前,这两个选项只在 \opt{chapter} 标题下有定义。
+%   它们的默认值,在 \opt{scheme} 选项的不同取值下都为 \SI{10}{pt}。
 % \end{function}
 %
-% \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{tocline} 选项的默认设置}
-% \begin{tabular}{ll}
-% \toprule
-% 标题名 & 默认值 \\
-% \midrule
-% part & |\CTEXifname{\CTEXthepart\hspace{1em}}{}#2| \\
-% chapter (\opt{chinese})
-%   & |\CTEXifname{\protect\numberline{\CTEXthechapter\hspace{.3em}}}{}#2| \\
-% chapter (\opt{plain})
-%   & |\CTEXnumberline{#1}#2| \\
-% section & |\CTEXnumberline{#1}#2| \\
-% subsection & 同上 \\
-% subsubsection & 同上 \\
-% paragraph & 同上 \\
-% subparagraph & 同上 \\
-% \bottomrule
-% \end{tabular}
-%
-% \medskip
-% 其中 \tn{CTEXnumberline} 的意义是若标题 |#1| 没有名字,则不输出 |\numberline{\CTEXthe#1}|
-% 等编号:
-% \begin{verbatim}
-%   \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{}
-% \end{verbatim}
-% \end{table}
-%
 % \begin{function}[EXP,added=2015-06-21]{appendix/numbering}
 %   \begin{syntax}
 %     numbering = \TTF
 %   \end{syntax}
-%   控制是否对附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})
-%   进行编号。
-%
-%   用法与普通章节 \opt{numbering} 选项类似。
+%   控制是否对附录章(对应 \cls{book} 与 \cls{report})或附录节
+%   (对应 \cls{article})进行编号,用法与普通章节对应的 \opt{numbering}
+%   选项相同。该选项默认值为 \opt{true}。
 % \end{function}
 %
 % \begin{function}[EXP,updated=2014-03-08]{appendix/name}
@@ -2335,30 +2423,31 @@
 %     name = \{<前名字>,<后名字>\}
 %     name = \Arg{前名字}
 %   \end{syntax}
-%   设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})的
-%   名字。
+%   设置附录章(对应 \cls{book} 与 \cls{report})或附录节(对应 \cls{article})
+%   的名字,用法与普通章节对应的 \opt{name} 选项相同。
 %
-%   用法与普通章节 \opt{name} 选项类似。
+%   注意该选项与 \opt{appendixname} 选项(\ref{subs:capname}~节)在意义上有
+%   些重叠,但不完全相同。\opt{appendixname} 选项只用来重定义
+%   \tn{appendixname},而不管 \tn{appendixname} 如何使用;该选项则决定在章节
+%   标题中输出的名字,可以调用 \tn{appendixname} 设置。
 %
-%   注意该选项与 \opt{appendixname} 选项(\ref{subs:capname}~节)在意义上有
-%   些重叠,但意义不同。\opt{appendixname} 选项只用来重定义
-%   \tn{appendixname},而不管 \tn{appendixname} 如何使用;该选项则决定在章节标
-%   题中输出的名字,可以调用 \tn{appendixname} 设置。
+%   该选项的默认设置见表~\ref{tab:appendix-name-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{appendix/name} 选项的默认设置}
-% \begin{tabular}{llllll}
-% \toprule
-% 文档类 & 影响命令 & \opt{scheme = chinese} & 实际定义
-%   & \opt{scheme = plain} & 实际定义 \\
-% \midrule
-% article & \tn{section} & |{}| & & |{}| & \\
-% book, report & \tn{chapter} & |\appendixname\space| & \verb*|附录 |
-%                             & |\appendixname\space| & \verb*|Appendix | \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{appendix/name} 选项的默认设置}
+%   \label{tab:appendix-name-default}
+%   \begin{tabular}{llllll}
+%   \toprule
+%   文档类 & 影响命令 & \opt{scheme = chinese} & 实际定义
+%     & \opt{scheme = plain} & 实际定义 \\
+%   \midrule
+%   article & \tn{section} & |{}| & & |{}| & \\
+%   book, report & \tn{chapter} & |\appendixname\space| & \verb*|附录 |
+%                               & |\appendixname\space| & \verb*|Appendix | \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
 % \begin{function}[EXP]{appendix/number}
@@ -2365,30 +2454,72 @@
 %   \begin{syntax}
 %     number = \Arg{数字输出命令}
 %   \end{syntax}
-%   设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})编
-%   号的数字输出格式。
+%   设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})
+%   编号的数字输出格式,用法与普通章节对应的 \opt{number} 选项相同。
 %
-%   用法与普通章节的 \opt{number} 选项类似。
-%
-%   该选项也同时控制附录章节计数器的交叉引用。
-%
+%   \opt{appendix/number} 选项同时也会控制附录章节计数器的交叉引用。
 %   与普通章节的 \opt{number} 选项类似,同样需要注意,该选项不会影响计数器本身
 %   的输出,即不影响 \tn{thesection} 或 \tn{thechapter} 的定义。
+%
+%   该选项的默认设置见表~\ref{tab:appendix-number-default}。
 % \end{function}
 %
 % \begin{table}[htbp]
-% \small\centering
-% \caption{\opt{appendix/number} 选项的默认设置}
-% \begin{tabular}{llllll}
-% \toprule
-% 文档类 & 影响命令 & 默认值 \\
-% \midrule
-% article & \tn{section} & |\Alph{section}| \\
-% book, report & \tn{chapter} & |\Alph{chapter}| \\
-% \bottomrule
-% \end{tabular}
+%   \small\centering
+%   \caption{\opt{appendix/number} 选项的默认设置}
+%   \label{tab:appendix-number-default}
+%   \begin{tabular}{llllll}
+%   \toprule
+%   文档类 & 影响命令 & 默认值 \\
+%   \midrule
+%   article & \tn{section} & |\Alph{section}| \\
+%   book, report & \tn{chapter} & |\Alph{chapter}| \\
+%   \bottomrule
+%   \end{tabular}
 % \end{table}
 %
+% \subsection{有关命令}
+% \label{subsec:sec-commands}
+%
+% \CTeX{} 宏集还提供了一些命令(宏),用于存储章节标题格式,或进行一些条件判断。
+%
+% \begin{function}{\CTEXthepart, \CTEXthechapter, \CTEXthesection,
+%   \CTEXthesubsection, \CTEXthesubsubsection, \CTEXtheparagraph,
+%   \CTEXthesubparagraph}
+%   以 |\CTEXthe| 开头的这组宏给出结合了 \opt{name} 与 \opt{number} 选项的章节
+%   编号输出格式。例如在 \opt{scheme = chinese} 时,默认章编号输出格式就是
+%   \tn{CTEXthechapter},形如“第一章”。
+%
+%   这组宏在 \CTeX 文档类中将代替 \tn{thechapter} 等宏的作用,在章节中引用本章
+%   节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。
+% \end{function}
+%
+% \begin{function}[added=2016-09-18]{\CTEXifname}
+%   \begin{syntax}
+%     \tn{CTEXifname} \Arg{有名字时的内容} \Arg{无名字时的内容}
+%   \end{syntax}
+%   \tn{CTEXifname} 会根据当前章节有无名字展开得到不同内容(通常是格式命令)。
+%   由于章节名字总是与编号一起出现,章节有无名字通常也表达为“章节是否编号”。
+%   在 \LaTeX{} 中,后者取决于以下几个方面:章节深度是否不大于计数器
+%   |secnumdepth| 的值,章节标题是否使用不带星号的命令。在 \CTeX{} 宏集中,
+%   后者还取决于 \opt{.../numbering} 是否为 \opt{true}。
+%
+%   \tn{CTEXifname} 可用于 \opt{format}, \opt{titleformat}, \opt{aftertitle},
+%   \opt{afterskip}, \opt{indent} 这五个选项和 \tn{chapter} 标题
+%   \opt{beforeskip} 选项的格式设置之中。也可用于帮助定义自定义的目录格式、
+%   页眉格式等。
+%
+%   例如,设置章的标题有名字时左对齐,无名字时居中对齐,并且在标题后画一条横线。
+%   \begin{ctexexam}
+%   \ctexset{
+%     chapter/format     = \CTEXifname{\raggedright}{\centering},
+%     chapter/aftertitle = \par\CTEXifname{}{\hrule},
+%   }
+%   \end{ctexexam}
+% \end{function}
+%
+% \subsection{示例}
+%
 % 我们最后举一个稍微复杂的例子,来看看上述选项的综合应用。
 %
 % \begin{ctexexam}[labelref=exam:miscopt]
@@ -2548,18 +2679,18 @@
 %
 % \subsection{\LuaLaTeX{} 下替代字体的设置}
 %
-% \begin{function}[added=2014-04-14]{AlternateFont}
+% \begin{function}[updated=2020-04-30]{AlternateFont}
 %   \begin{syntax}
-%     \tn{setCJKfamilyfont} \Arg{family}
+%     \tn{setCJKfamilyfont} \Arg{family} \Arg{base font name}
 %     \  [
+%     \    <base font features> ,
 %     \    AlternateFont =
 %     \      \{
-%     \        \Arg{character range_1} \oarg{alternate font features_1} \Arg{alternate font name_1} ||
-%     \        \Arg{character range_2} \oarg{alternate font features_2} \Arg{alternate font name_2} ||
+%     \        \Arg{character range_1} \Arg{alternate font name_1} ,
+%     \        \Arg{character range_2} \Arg{alternate font name_2} \Arg{alternate font features_2} ,
 %     \        ......
-%     \      \} ,
-%     \    <base font features>
-%     \  ] \Arg{base font name}
+%     \      \}
+%     \  ]
 %   \end{syntax}
 %   在设置字体族 \meta{family} 的时候,同时设置该字体族在字符范围
 %   \meta{character range_n} 内,对应字形的替代字体。
@@ -2567,11 +2698,11 @@
 %
 % \begin{function}[added=2014-04-14]{CharRange}
 %   \begin{syntax}
-%     \tn{setCJKfamilyfont} \Arg{family}
+%     \tn{setCJKfamilyfont} \Arg{family} \Arg{alternate font name}
 %     \  [
 %     \    CharRange = \Arg{character range} ,
 %     \    <alternate font features>
-%     \  ] \Arg{alternate font name}
+%     \  ]
 %   \end{syntax}
 %   只设置字体族 \meta{family} 在字符范围 \meta{character range} 内,对应字形的
 %   替代字体。
@@ -2586,7 +2717,7 @@
 %   \setCJKmainfont[CharRange={"6800->"9FFF}, ...]{...}
 % \end{ctexexam}
 %
-% \begin{function}[EXP,added=2014-04-14]{declarecharrange}
+% \begin{function}[EXP,added=2020-04-30]{declarecharrange}
 %   \begin{syntax}
 %     \tn{ctexset}
 %     \  \{
@@ -2605,9 +2736,10 @@
 %
 % 在声明字符范围 \meta{name} 的同时,还为 \tn{setCJKmainfont} 等字体设置命令定义
 % 了选项 \meta{name},用于设置对应字符的替代字体:
-% \begin{quote}\linespread{1}\small\ttfamily
-%   \meta{name} = \oarg{alternate font features} \Arg{alternate font name}
-% \end{quote}
+% \begin{syntax}
+%   \meta{name} = \Arg{alternate font name}
+%   \meta{name} = \Arg{alternate font name} \Arg{alternate font features}
+% \end{syntax}
 % \meta{name} 选项可以与 \opt{AlternateFont} 共同使用,但不能与 \opt{CharRange}
 % 一起使用。如果没有给 \meta{name} 设置值,则等价于设置 \opt{CharRange=\meta{name}},
 % 即只设置 \meta{name} 对应的字符范围的替代字体。
@@ -2652,7 +2784,7 @@
 % 例如对于 \TeX{} Live,系统自带的配置文件就在 \TeX{} Live 安装目录下的
 % \path{texmf-dist/tex/latex/ctex/config/} 子目录下,可以修改它的副本,保存在
 % 本地 TDS 树的 \path{texmf-local/tex/latex/ctex/} 目录下,或者用户 TDS 树的
-% \path{~/.texlive2015/texmf-var/tex/latex/ctex/} 目录下,作为本地/用户专有的
+% \path{~/texmf/tex/latex/ctex/} 目录下,作为本地/用户专有的
 % 配置文件。复制配置文件后需要运行 |texhash| 命令使本地配置文件生效。
 %
 % \MiKTeX{} 的配置文件也保存在类似的目录结构中,\MiKTeX{} 管理的
@@ -2668,13 +2800,12 @@
 % 注释就可以生效。
 %
 % \begin{ctexexam}
-%   % 系统自带 ctexopts.cfg 注释中的示例语句,固定默认字体集为 windowsnew。
+%   % 系统自带 ctexopts.cfg 注释中的示例语句,固定默认字体集为 windows。
 %   % 该设置可以用在安装了 Windows 字体的非 Windows 系统中。
-%   \keys_set:nn { ctex / option } { fontset = windowsnew }
+%   \ctex_set:nn { option } { fontset = windows }
 % \end{ctexexam}
-% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{keys_set:nn} 命令完成键值设置,
-% 第一个参数是固定的子模块 |ctex/option|,第二个参数中是用户定义的新的默认宏包
-% 选项。
+% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{ctex_set:nn} 命令完成键值设置,
+% 第一个参数是固定的子模块 |option|,第二个参数中是用户定义的新的默认宏包选项。
 %
 % \file{ctexopts.cfg} 中的设置将在 \CTeX{} 宏集的开始处,定义过宏包选项之后,
 % \tn{ProcessKeysOptions} 命令之前生效。最好只使用此配置文件修改宏包默认选项。
@@ -2820,20 +2951,22 @@
 %
 % \begin{function}{fntef}
 % 旧版本的 \opt{fntef} 选项用于统一 \pkg{CCTfntef} 与 \pkg{CJKfntef} 的界面,
-% 新版本 \CTeX{} 宏集不再支持 \pkg{CCT},而是直接载入 \pkg{CJKfntef} 或
-% \pkg{xeCJKfntef} 宏包并禁用其彩色设置。该选项是过时选项。
+% 新版本 \CTeX{} 宏集不再支持 \pkg{CCT},也不再自动载入 \pkg{CJKfntef} 或
+% \pkg{xeCJKfntef} 宏包,而仅在其末尾做适当格式调整。
+%
+% \opt{fntef} 选项过时,因兼容性保留,功能是根据引擎载入 \pkg{CJKfntef}
+% (\pdfTeX{}) 或 \pkg{xeCJKfntef} (\XeTeX{}) 宏包。
 % \end{function}
 %
 % \begin{function}{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline,
-%   \CTEXunderwave, \CTEXsout, \CTEXxout, \CTEXfilltwosides}
+%   \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides}
 % 在调用 \opt{fntef} 宏包选项的同时,旧版本 \CTeX{} 宏包由于需要支持 \pkg{CCT}
 % 系统,会将以 |\CJK| 开头的 \tn{CJKunderline} 等宏换名为以 |\CTEX| 开头的
-% \tn{CTEXunderline} 等宏。此功能在新版本的 \CTeX{} 宏集中已失去意义。
+% \tn{CTEXunderline} 等宏。此功能在新版本的 \CTeX{} 宏集中已失去意义。此外,
+% 在 \pdfTeX{} 引擎下,用于设置格式的 \tn{CJKunderdotbasesep} 等宏也被更名为
+% \tn{CTEXunderdotbasesep} 等宏。
 %
-% 此外,在 \pdfTeX{} 引擎下,用于设置格式的 \tn{CJKunderdotbasesep} 等宏也被换
-% 名为 \tn{CTEXunderdotbasesep} 等宏。
-%
-% 在新版本中,上述由 \opt{fntef} 衍生的相关宏都成为过时命令。
+% 在新版本中,上述由 \opt{fntef} 衍生的相关命令和环境均被移除。
 % \end{function}
 %
 % \begin{function}{\CTEXsetfont}
@@ -2927,11 +3060,53 @@
 %   这两个选项已经被删除,相应功能由新的选项 \opt{fixskip} 提供。
 % \end{function}
 %
+% \subsection{\CTeX\ 2.5 之前的版本}
+%
+% \CTeX\ 2.5 有一些比较大的变动。
+%
+% \begin{function}[label =]{UTF8, GBK}
+%   (pdf)\LaTeX{} 格式下,文档编码初始值统一设置成 UTF-8。因此,仍旧使用 GBK
+%   编码的文档,需要在文档类或宏包选项中显式指定 \opt{GBK}。
+% \end{function}
+%
+% \begin{function}[label =]{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline,
+%   \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides}
+%   不再默认载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包,同步移除有关命令
+%   和环境。若需使用相关宏包,建议用户使用 \tn{usepackage} 命令主动载入。
+% \end{function}
+%
+% \begin{function}[label =]{fntef}
+%   作为兼容性保留,会视编译引擎载入相应宏包。
+% \end{function}
+%
+% \begin{function}{windows}
+%   不再支持 Windows XP 系统,默认要求 Windows 系统有微软雅黑字体。
+%   建议 Windows XP 系统的用户及时更新操作系统。若一定要在 Windows XP 中使用,
+%   请使用 2.5 以前的版本。
+% \end{function}
+%
+% \begin{function}{windowsold, windowsnew}
+%   过时字库选项,作为兼容性保留,功能是载入 \opt{windows} 字库。
+% \end{function}
+%
+% \begin{function}{ubuntu}
+%   改用思源(Noto CJK)和文鼎字库。该字库不再支持 \pdfLaTeX 编译。
+% \end{function}
+%
+% \begin{function}[label =]{AlternateFont}
+%   不再支持将替代字体的可选项放在字体名之前的方括号中,
+%   新的语法是将可选项放在字体名之后的花括号之内。
+% \end{function}
+%
+% 除了以上列出的选项以外,当用户使用 \CTeX{} 系列文档类,且使用 \LaTeX 或
+% \upLaTeX 编译时,若用户没有在文档类选项中显式指定 |dvips|/|dvipdfmx|/|dvisvgm|
+% 等驱动选项,则文档类指定默认驱动为 \dvipdfmx。
+%
 % \section{宏集依赖情况与手工安装方法}
 % \label{sec:dep-ins}
 %
 % 本节介绍 \CTeX{} 宏集的依赖情况,并介绍手工编译安装的具体方法。
-% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的宏包管理器安装
+% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的包管理器安装
 % 本宏集。
 %
 % \CTeX{} 宏集有两个源文件:\file{ctex.dtx}、\file{ctexpunct.spa}。
@@ -2943,7 +3118,6 @@
 %   和 \pkg{l3packages} 宏集。
 %   \item \pkg{indentfirst} 宏包,属于 \pkg{tools} 宏集。
 %   \item \pkg{everysel} 宏包,属于 \pkg{ms} 宏集。
-%   \item \pkg{ulem} 宏包。
 %   \item \pkg{zhnumber} 宏包。
 %   \item[\ding{229}] 以上是各种编译方式都必需的依赖项。
 %   \item \pkg{CJK} 宏集。
@@ -2950,7 +3124,14 @@
 %   \item \pkg{CJKpunct} 宏包。
 %   \item \pkg{xCJK2uni} 宏包。
 %   \item \pkg{zhmetrics} 宏包。
-%   \item \pkg{zhmCJK} 宏包,它还依赖 \pkg{oberdiek} 宏集。
+%   \item \pkg{zhmCJK} 宏包,它还依赖
+%   \begin{itemize}
+%     \item \pkg{iftex} 宏包。
+%     \item \pkg{ltxcmds} 宏包。
+%     \item \pkg{kvoptions} 宏包。
+%     \item \pkg{kvsetkeys} 宏包。
+%     \item \pkg{keyval} 宏包,\pkg{graphics} 宏集。
+%   \end{itemize}
 %   \item[\ding{229}] 以上是使用 \pdfLaTeX{} 或 \LaTeX{} + \dvipdfmx{} 的编译方式所需要
 %   的依赖项,其中 \pkg{zhmCJK} 是可选的。
 %   \item \pkg{xeCJK} 宏集,它还依赖
@@ -2958,17 +3139,19 @@
 %     \item \pkg{xtemplate} 宏包,它属于 \pkg{l3packages} 宏集。
 %     \item \pkg{fontspec} 宏包。
 %   \end{itemize}
-%   \item \pkg{environ} 宏包,它还依赖 \pkg{trimspaces} 宏包。
 %   \item[\ding{229}] 以上是使用 \XeLaTeX{} 编译时的依赖项。
 %   \item \pkg{luatexja} 宏包,它还依赖
 %   \begin{itemize}
 %     \item \pkg{adobemapping} 宏包。
-%     \item \pkg{lualibs} 宏包。
-%     \item \pkg{luaotfload} 宏包。
+%     \item \pkg{luaotfload} 宏包,它还依赖 \pkg{lualibs} 宏包。
 %     \item \pkg{luatexbase} 宏包,它还依赖 \pkg{ctablestack} 宏包。
-%     \item \pkg{oberdiek} 宏集。
+%     \item \pkg{atbegshi} 宏包。
+%     \item \pkg{etoolbox} 宏包。
+%     \item \pkg{iftex} 宏包。
+%     \item \pkg{infwarerr} 宏包。
+%     \item \pkg{ltxcmds} 宏包。
+%     \item \pkg{pdftexcmds} 宏包。
 %     \item \pkg{xkeyval} 宏包。
-%     \item \pkg{etoolbox} 宏包。
 %   \end{itemize}
 %   \item \pkg{fontspec} 宏包。
 %   \item \pkg{xunicode-addon} 宏包,属于 \pkg{xeCJK} 宏集,它还依赖
@@ -2978,6 +3161,7 @@
 %       \item \pkg{graphics} 宏集。
 %       \item \pkg{graphics-cfg} 宏包。
 %       \item \pkg{graphics-def} 宏包。
+%       \item \pkg{tipa} 宏包。
 %     \end{itemize}
 %   \end{itemize}
 %   \item[\ding{229}] 以上是使用 \LuaLaTeX{} 编译时的依赖项。
@@ -3001,7 +3185,7 @@
 % 中第 3 节的指导。
 %
 % \emph{\CTeX{} 宏集已被 \TeXLive{} 和 \MiKTeX{} 收录,若无特别理由,
-% 我们强烈建议用户使用宏包管理器安装本宏集。}
+% 我们强烈建议用户使用包管理器安装本宏集。}
 %
 % 若要手工安装,请遵循如下步骤:
 % \begin{enumerate}
@@ -3023,9 +3207,12 @@
 % \item 陈之初 (\email{zhichu.chen at gmail.com})
 % \item 李清 (\email{sobenlee at gmail.com})
 % \item 黄晨成 (\email{liamhuang0205 at gmail.com})
+% \item 曾祥东 (\email{xdzeng96 at gmail.com})
+% \item 李泽平 (\email{zepinglee at gmail.com})
+% \item 周宇恺 (\email{muzimuzhi at gmail.com})
+% \item 张瑞熹 (\email{ruixizhang42 at gmail.com})
 % \end{itemize}
 %
-% 目前比较活跃的开发维护人员是刘海洋、李清和黄晨成。
 %
 %
 % \begin{thebibliography}{9}
@@ -3105,11 +3292,11 @@
 \msg_new:nnnn { ctex } { l3-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~bundles\\\\
+    Please~update~an~up-to-date~version~of~the~bundles\\\\
     `l3kernel'~and~`l3packages'\\\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
-\@ifpackagelater { expl3 } { 2019/03/05 } { }
+\@ifpackagelater { expl3 } { 2020/04/06 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
 %<*class>
 \@ifpackagelater { l3keys2e } { 2015/12/20 } { }
@@ -3138,13 +3325,20 @@
 %</class|ctex>
 %    \end{macrocode}
 %
+% \changes{v2.5}{2020/04/19}
+%   {处理 \cs{ctex_file_input:n} 在 \pkg{ctexsize} 中未定义的错误。}
+% \changes{v2.5}{2020/04/21}{在 \pkg{ctexsize} 也载入 \pkg{fix-cm}。}
+%
 %    \begin{macrocode}
-%<*class|ctex|ctexheading>
+%<*class|ctex|ctexheading|ctexsize>
 %    \end{macrocode}
 %
+% \pkg{ctexsize} 也要载入 \pkg{fix-cm} 包解决传统 cm 字体字号缺失的问题。
 %    \begin{macrocode}
-\RequirePackage { ctexhook , ctexpatch }
-%<!ctexheading>\RequirePackage { fix-cm , everysel }
+%<!ctexsize>\RequirePackage { ctexhook , ctexpatch }
+%<!ctexheading>\RequirePackage { fix-cm }
+%<*!ctexsize>
+%<!ctexheading>\RequirePackage { everysel }
 %    \end{macrocode}
 %
 % \subsection{内部函数与变量}
@@ -3159,10 +3353,28 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{macro}[int]{\ctex_define_option:n,
+% \ctex_define:n,\ctex_set:n,\ctex_set:nn}
+% 在宏包内部使用的键值选项定义、设置命令。
+%    \begin{macrocode}
+%</!ctexsize>
+\cs_new_protected:Npn \ctex_define_option:n
+  { \keys_define:nn { ctex / option } }
+%<*!ctexsize>
+\cs_new_protected:Npn \ctex_define:n
+  { \keys_define:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:n
+  { \keys_set:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:nn #1
+  { \keys_set:nn { ctex / #1 } }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[int]{\ctex_file_wrapper:nnn}
 % 设置文件操作的 \tn{catcode} 环境,参数 |#1| 是设置,|#2| 是文件操作,|#3| 是恢复。
 % 默认关闭 \LaTeXiii{} 语法环境,并设置 |@| 的 \tn{catcode} 为 $11$。
 %    \begin{macrocode}
+%</!ctexsize>
 \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3
   {
     \use:x
@@ -3184,8 +3396,9 @@
 % \begin{macro}[int]{\ctex_file_input:n}
 % 输入文件。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_file_input:n #1
+\cs_new_protected:Npn \ctex_file_input:n #1
   { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
+%<*!ctexsize>
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3192,7 +3405,7 @@
 % \begin{macro}[int]{\ctex_scheme_input:n}
 % 输入 \opt{scheme} 文件。先查找当前文档类下的 \meta{scheme},找不到再查找一般的文件。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
+\cs_new_protected:Npn \ctex_scheme_input:n #1
   {
     \ctex_file_wrapper:nnn
       { }
@@ -3222,7 +3435,8 @@
 % \end{variable}
 %
 %    \begin{macrocode}
-%</class|ctex|ctexheading>
+%</!ctexsize>
+%</class|ctex|ctexheading|ctexsize>
 %<*class|ctex>
 %    \end{macrocode}
 %
@@ -3231,7 +3445,7 @@
 \msg_new:nnnn { ctex } { package-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~package~`#1'\\
+    Please~update~an~up-to-date~version~of~the~package~`#1'\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
 %    \end{macrocode}
@@ -3278,12 +3492,10 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{variable}{\l_@@_encoding_tl}
-% (pdf)\LaTeX{} 初始化编码为 GBK,其它则是 UTF8。
+% \begin{variable}{\g_@@_encoding_tl}
+% 所有引擎下默认编码均设为 UTF-8,初始值为空,\tn{ProcessKeysOptions} 再判断。
 %    \begin{macrocode}
-\tl_new:N \l_@@_encoding_tl
-\tl_set:Nx \l_@@_encoding_tl
-  { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
+\tl_new:N \g_@@_encoding_tl
 %    \end{macrocode}
 % \end{variable}
 %
@@ -3318,8 +3530,8 @@
 % \begin{macro}[int]{\ctex_at_end:n}
 % 区分 \tn{AtEndOfClass} 和 \tn{AtEndOfPackage},虽然它们的意思都是一样的。
 %    \begin{macrocode}
-%<class>\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfClass }
-%<ctex>\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfPackage }
+%<class>\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass }
+%<ctex>\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfPackage }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3340,15 +3552,28 @@
   { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
 %    \end{macrocode}
 %
+% \begin{macro}[int]{\ctex_deprecated_option:nn,
+% \ctex_set_deprecated_option:n,\ctex_deprecated_command:Nn}
 % 对过时选项或命令给出警告。
 %    \begin{macrocode}
+\cs_new_protected:Npn \ctex_deprecated_option:n
+  { \msg_warning:nnn { ctex } { deprecated-option } }
+\cs_new_protected:Npn \ctex_set_deprecated_option:n #1
+  {
+    \ctex_deprecated_option:n { Option~`#1'~is~set. }
+    \ctex_set:nn { option } {#1}
+  }
+\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
+  {
+    \msg_warning:nnxx { ctex } { deprecated-command }
+      { \token_to_str:N #1 } { \exp_not:n {#2} }
+  }
 \msg_new:nnn { ctex } { deprecated-option }
-  { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 }
+  { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
 \msg_new:nnn { ctex } { deprecated-command }
-  { Command~ #1 is~ deprecated.\\ #2 }
-\msg_new:nnn { ctex } { deprecated-environment }
-  { Environment~ `#1'~ is~ deprecated.\\ #2 }
+  { Command~`#1'~is~deprecated.\\ #2 }
 %    \end{macrocode}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</class|ctex>
@@ -3360,7 +3585,7 @@
 %    \begin{macrocode}
 %<*class|ctex|ctexsize>
 \int_new:N \g_@@_font_size_int
-\int_set:Nn \g_@@_font_size_int { -1 }
+\int_gset:Nn \g_@@_font_size_int { -1 }
 %</class|ctex|ctexsize>
 %    \end{macrocode}
 % \end{variable}
@@ -3372,7 +3597,7 @@
 %
 %   \begin{macrocode}
 %<*class|style>
-\keys_define:nn { ctex / option }
+\ctex_define_option:n
   {
 %</class|style>
 %    \end{macrocode}
@@ -3392,18 +3617,8 @@
 %<ctexsize>  }
 %</class|ctex|ctexsize>
 %<*class|ctex>
-    c5size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=5'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = 5 }
-      } ,
-    cs4size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=-4'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = -4 }
-      } ,
+    c5size  .code:n = { \ctex_set_deprecated_option:n { zihao =  5 } } ,
+    cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
     c5size  .value_forbidden:n = true ,
     cs4size .value_forbidden:n = true ,
 %    \end{macrocode}
@@ -3451,21 +3666,19 @@
 %    \begin{macrocode}
     indent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.~
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     indent .value_forbidden:n = true ,
     noindent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     noindent .value_forbidden:n = true ,
@@ -3472,10 +3685,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v2.5}{2019/11/10}{所有引擎下默认编码均设为 UTF-8。}
+%
 % \begin{macro}{GBK,UTF8}
+% 文档编码,默认为 UTF-8。
 %   \begin{macrocode}
-    GBK  .code:n = { \tl_set:Nn \l_@@_encoding_tl { GBK } } ,
-    UTF8 .code:n = { \tl_set:Nn \l_@@_encoding_tl { UTF8 } } ,
+    GBK  .code:n =
+      {
+        \sys_if_engine_pdftex:TF
+          { \tl_gset:Nn \g_@@_encoding_tl { GBK } }
+          {
+            \msg_warning:nn { ctex } { invalid-option }
+            \tl_gset:Nn \g_@@_encoding_tl { UTF8 }
+          }
+      } ,
+    UTF8 .code:n = { \tl_gset:Nn \g_@@_encoding_tl { UTF8 } } ,
     GBK  .value_forbidden:n = true ,
     UTF8 .value_forbidden:n = true ,
 %    \end{macrocode}
@@ -3487,36 +3711,12 @@
 %
 % \begin{macro}{fontset}
 % 初始值为空。若用户未指定,则根据操作系统载入对应字体配置,可以区分 Windows、
-% Mac~OS~X 和其它。
+% macOS 和其他。
 %   \begin{macrocode}
     fontset    .tl_gset:N = \g_@@_fontset_tl ,
-    nofonts    .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = none }
-      } ,
-    adobefonts .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = adobe }
-      } ,
-    winfonts   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = windows }
-      } ,
+    nofonts    .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
+    adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
+    winfonts   .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
     nofonts    .value_forbidden:n = true ,
     winfonts   .value_forbidden:n = true ,
     adobefonts .value_forbidden:n = true ,
@@ -3546,11 +3746,7 @@
         \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
       } ,
     nozhmap   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zhmap=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { zhmap = false }
-      } ,
+      { \ctex_set_deprecated_option:n { zhmap = false } } ,
     nozhmap   .value_forbidden:n = true ,
 %    \end{macrocode}
 % \end{macro}
@@ -3564,12 +3760,7 @@
     punct   .tl_set:N = \l_@@_punct_tl ,
     punct  .default:n = { quanjiao } ,
     punct  .initial:n = { quanjiao } ,
-    nopunct   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `punct=plain'~ is~ set.  }
-        \keys_set:nn { ctex / option } { punct = plain }
-      } ,
+    nopunct   .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
     nopunct   .value_forbidden:n = true ,
 %    \end{macrocode}
 % \end{macro}
@@ -3581,15 +3772,10 @@
       { true , auto , false }
       {
         \exp_args:Nx \ctex_at_end:n
-          { \keys_set:nn { ctex } { space = \l_keys_choice_tl } }
+          { \ctex_set:n { space = \l_keys_choice_tl } }
       } ,
     space  .default:n = { true } ,
-    nospace   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `space=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { space = false }
-      } ,
+    nospace   .code:n = { \ctex_deprecated_option:nn { space = false } } ,
     nospace   .value_forbidden:n = true ,
 %    \end{macrocode}
 % \end{macro}
@@ -3622,6 +3808,7 @@
 %
 % \changes{v2.0}{2015/04/15}{新增 \opt{scheme} 选项,并将 \opt{cap} 和 \opt{nocap}
 % 列为过时选项。}
+%
 % \begin{macro}{scheme}
 %    \begin{macrocode}
     scheme .tl_set:N  = \l_@@_scheme_tl ,
@@ -3635,6 +3822,7 @@
     scheme .initial:n = { chinese } ,
 %</!ctexheading>
 %    \end{macrocode}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</class|ctex|ctexheading>
@@ -3641,19 +3829,11 @@
 %<*class|ctex>
 %    \end{macrocode}
 %
+% \begin{macro}{cap,nocap}
+% \opt{cap} 和 \opt{nocap} 是过时选项。
 % \begin{macrocode}
-    cap    .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = chinese' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = chinese }
-      } ,
-    nocap  .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = plain' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = plain }
-      } ,
+    cap    .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
+    nocap  .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
     cap    .value_forbidden:n = true ,
     nocap  .value_forbidden:n = true ,
 %    \end{macrocode}
@@ -3662,25 +3842,51 @@
 % \changes{v2.0}{2015/04/20}{\opt{hyperref} 成为过时选项,原选项功能总是打开。}
 % \changes{v2.0}{2015/04/20}{\opt{fancyhdr} 成为过时选项,原选项功能总是打开。}
 % \changes{v2.0}{2015/04/20}{\opt{fntef} 成为过时选项,原选项功能总是打开。}
-% \begin{macro}{fntef,fancyhdr,hyperref}
-% \changes{v2.1}{2015/06/03}{补充定义 \tn{hypersetup}。}
-% 这些都是过时的宏包兼容选项,原选项功能总是打开的。
+%
+% 以下三项都是过时的兼容选项,它们会载入有关宏包。
+%
+% \begin{macro}{fntef}
+% \changes{v2.5}{2019/11/10}{仅在该选项启用时会载入 \pkg{CJKfntef} 或
+% \pkg{xeCJKfntef} 宏包。}
 %   \begin{macrocode}
-    fntef    .code:n =
+    fntef .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `(xe)CJKfntef'~ package~ is~ always~ loaded. }
+        \sys_if_engine_xetex:TF
+          {
+            \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
+            \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
+          }
+          {
+            \sys_if_engine_pdftex:TF
+              {
+                \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
+                \ctex_at_end:n { \RequirePackage { CJKfntef } }
+              }
+              {
+                \ctex_deprecated_option:n
+                  { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
+              }
+          }
       } ,
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{fancyhdr}
+%   \begin{macrocode}
     fancyhdr .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `fancyhdr'~ package~ is~ loaded. }
-        \RequirePackage { fancyhdr }
+        \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
+        \ctex_at_end:n { \RequirePackage { fancyhdr } }
       } ,
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{hyperref}
+% \changes{v2.1}{2015/06/03}{补充定义 \tn{hypersetup}。}
+%   \begin{macrocode}
     hyperref .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `hyperref'~ package~ will~ be~ loaded. }
+        \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
         \ctex_at_end:n
           {
             \cs_if_exist:NF \hypersetup
@@ -3726,7 +3932,7 @@
         #1 .value_forbidden:n = true ,
       }
   }
-\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l_@@_tmp_tl } } }
+\exp_args:No \ctex_define_option:n { \l_@@_tmp_tl }
 \tl_clear:N \l_@@_tmp_tl
 %    \end{macrocode}
 % \end{macro}
@@ -3734,7 +3940,7 @@
 % 将未知选项传给标准文档类。
 %    \begin{macrocode}
 %<*class>
-\keys_define:nn { ctex / option }
+\ctex_define_option:n
   {
     unknown .code:n =
       { \clist_gput_right:No \g_@@_std_options_clist { \CurrentOption } }
@@ -3742,11 +3948,13 @@
 %</class>
 %    \end{macrocode}
 %
+% 载入选项配置文件。
 %    \begin{macrocode}
 %<!ctexsize>\ctex_file_input:n { ctexopts.cfg }
 %</class|ctex|ctexsize>
 %    \end{macrocode}
 %
+% 处理宏包选项。
 %    \begin{macrocode}
 %<*class|style>
 \ProcessKeysOptions { ctex / option }
@@ -3753,17 +3961,31 @@
 %</class|style>
 %    \end{macrocode}
 %
+% \pdfLaTeX{} 下,如果没有显式指定编码为 |UTF8|,则给出警告信息。
 %    \begin{macrocode}
+%<*class|ctex>
+\msg_new:nnn { ctex } { pdftex-utf8 }
+  { UTF8~will~be~used~as~the~default~encoding. }
+\tl_if_empty:NT \g_@@_encoding_tl
+  {
+    \sys_if_engine_pdftex:T
+      { \msg_warning:nn { ctex } { pdftex-utf8 } }
+    \tl_gset:Nn \g_@@_encoding_tl { UTF8 }
+  }
+%</class|ctex>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 %<*class>
 %    \end{macrocode}
 %
 % 五号字使用标准文档类的 |10pt| 字体大小设置,小四号字则使用 |12pt|。
 %    \begin{macrocode}
-\if_case:w \g_@@_font_size_int
-  \clist_gput_right:Nn \g_@@_std_options_clist { 10pt }
-\or:
-  \clist_gput_right:Nn \g_@@_std_options_clist { 12pt }
-\fi:
+\int_case:nn { \g_@@_font_size_int }
+  {
+    { 0 } { \clist_gput_right:Nn \g_@@_std_options_clist { 10pt } }
+    { 1 } { \clist_gput_right:Nn \g_@@_std_options_clist { 12pt } }
+  }
 %    \end{macrocode}
 %
 % 使用 \tn{PassOptionsToClass} 是为了预防可能存在的选项冲突。
@@ -3796,19 +4018,71 @@
 %
 % \subsection{特定引擎支持与设置}
 %
+% \changes{v2.5}{2020/04/22}{给 \LaTeX 和 \upLaTeX 下的文档类指定驱动为 \dvipdfmx。}
+%
+% \subsubsection{\pkg{ctexbackend.cfg}}
+%
+% 对于 \XeLaTeX{}/\pdfLaTeX{}/\LuaLaTeX{} 等默认直接输出 PDF 的编译方式,用户
+% 无需为涉及驱动的宏包指定驱动选项。对于 \LaTeX 和 \upLaTeX{} 等默认不直接输出 PDF 的编译方式,
+% 用户则需要指定驱动选项。
+%
+% 由于历史遗留问题,在使用 \LaTeX{} 或 \upLaTeX{} 等编译时,
+% 大多数涉及驱动的宏包选定的默认输出驱动都是 Dvips。
+% 考虑当前实际使用频率,以及考虑到 \CTeX{} 宏集对中文支持的默认方式,
+% 我们在用户使用 \CTeX{} 系列文档类时,将默认的输出驱动改为 \dvipdfmx。
+%
+% 具体来说,如果 |dvips|,|dvipdfmx|,|dvisvgm| 等驱动没有在文档类的全局选项中被明确指定,
+% 我们就在 \tn{@classoptionslist} 开头加入 |dvipdfmx|。
+%
+% 本段代码只在 \cls{ctexart} 等文档类开头载入,不在 \pkg{ctex} 中使用。
+% 并且需要放在 \pkg{expl3} 之前载入,保证它载入正确的 backend 文件。
+%    \begin{macrocode}
+%<*backend>
+\begingroup
+\expandafter\ifx\csname Umathchardef\endcsname\relax
+\else\expandafter\endgroup\expandafter\endinput\fi
+  \ifodd
+    \expandafter\ifx\csname      pdfoutput\endcsname\relax
+    \expandafter\ifx\csname enablecjktoken\endcsname\relax 0\else 1\fi
+                                   \else\ifnum\pdfoutput>0 0\else 1\fi\fi\space
+    \def\x#1{%
+      \if\relax\detokenize{#1}\relax
+        \gdef\@classoptionslist{dvipdfmx}%
+      \else
+        \let\CTEX at add\@ne
+        \@tfor\x:={dvips}{dvipdfmx}{dvisvgm}\do{%
+          \expandafter\in@\expandafter{\expandafter,\x,}{,#1,}%
+          \ifin@ \let\CTEX at add\tw@ \@break at tfor \fi}%
+        \ifodd\CTEX at add \gdef\@classoptionslist{dvipdfmx,#1}\fi
+      \fi}
+    \expandafter\x\expandafter{\@classoptionslist}
+  \fi
+\endgroup
+%</backend>
+%    \end{macrocode}
+%
 % \subsubsection{\pkg{ctex-engine-pdftex.def}}
 %
 % \begin{macro}[int]{\ctex_set_zhmap:n}
 % 设置 \upTeX{} 字体映射,同时作用于 \tn{AtBeginDvi} 与
 % \tn{AtBeginShipoutFirst}。该宏对 \pdfTeX{} 和 \upTeX{} 均有用。
+% \tn{AtBeginDvi} 直接将 \tn{special} 保存到盒子中,
+% \tn{AtBeginShipoutFirst} 是保存到到宏中,并且不展开参数。
 %     \begin{macrocode}
 %<*pdftex|uptex|aptex>
-\cs_new_protected_nopar:Npn \ctex_set_zhmap:n #1
+\cs_new_protected:Npn \ctex_set_zhmap:n
+  { \tl_gput_right:Nx \g_@@_zhmap_tl }
+\cs_new_protected:Npn \ctex_use_zhmap:
+  { \tl_use:N \g_@@_zhmap_tl }
+\cs_new_protected:Npn \ctex_add_dvi_zhmap:
+  { \AtBeginDvi { \ctex_use_zhmap: } }
+\ctex_after_end_preamble:n { \ctex_add_dvi_zhmap: }
+\ctex_at_end_package:nn { atbegshi }
   {
-    \AtBeginDvi {#1}
-    \ctex_at_end_package:nn { atbegshi }
-      { \AtBeginShipoutFirst {#1} }
+    \AtBeginShipoutFirst { \ctex_use_zhmap: }
+    \cs_gset_eq:NN \ctex_add_dvi_zhmap: \prg_do_nothing:
   }
+\tl_new:N \g_@@_zhmap_tl
 \@onlypreamble \ctex_set_zhmap:n
 %</pdftex|uptex|aptex>
 %    \end{macrocode}
@@ -3818,7 +4092,7 @@
 %<*pdftex>
 %    \end{macrocode}
 %
-% \changes{v2.1}{2015/05/18}{给 \pdfLaTeX{} 下的非 UTF8 编码 CJK 字体族加上 CMap。}
+% \changes{v2.1}{2015/05/18}{给 \pdfLaTeX{} 下的非 UTF-8 编码 CJK 字体族加上 CMap。}
 %
 % \begin{variable}{\c_@@_cmap_encoding_seq}
 % 需要加上 CMap 的 CJK 字体编码。
@@ -3831,7 +4105,7 @@
 % \begin{macro}[int]{\ctex_family_cmap:nn}
 % 在 \tn{DeclareFontFamily} 的 \meta{loading-settings} 中给 CJK 字体族加上 CMap。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_family_cmap:nn #1#2
+\cs_new_protected:Npn \ctex_family_cmap:nn #1#2
   {
     \cs_if_free:cF { #1 + #2 }
       {
@@ -3847,22 +4121,22 @@
 % \begin{macro}[int]{\ctex_add_cmap:n}
 % 给 |#1| 编码的 CJK 字体加上 CMap。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_add_cmap:n #1
+\cs_new_protected:Npn \ctex_add_cmap:n #1
   {
     \cs_if_free:NF \CJK at plane
       { \ctex_add_cmap:cn { @@_add_cmap_ #1 \CJK at plane : } {#1} }
   }
-\cs_new_protected_nopar:Npn \ctex_add_cmap:Nn #1#2
+\cs_new_protected:Npn \ctex_add_cmap:Nn #1#2
   {
     \cs_if_exist:NF #1 { \@@_save_cmap:Nn #1 {#2} }
     #1
   }
 \cs_generate_variant:Nn \ctex_add_cmap:Nn { c }
-\cs_new_protected_nopar:Npn \@@_save_cmap:Nn #1#2
+\cs_new_protected:Npn \@@_save_cmap:Nn #1#2
   {
-    \tl_set:Nx \l_@@_tmp_tl { \str_lower_case:n {#2} \CJK at plane }
+    \tl_set:Nx \l_@@_tmp_tl { \str_lowercase:n {#2} \CJK at plane }
     \tex_immediate:D \tex_pdfobj:D stream ~ file { \l_@@_tmp_tl .cmap }
-    \cs_new_protected_nopar:Npx #1
+    \cs_new_protected:Npx #1
       {
         \exp_not:N \tex_pdffontattr:D \exp_not:N \tex_font:D
           { /ToUnicode ~ \int_use:N \tex_pdflastobj:D \c_space_tl 0 ~ R }
@@ -3894,13 +4168,13 @@
 % 首先检查选项,决定是否载入 \pkg{zhmCJK} 宏包。
 %    \begin{macrocode}
 \if_bool:N \g_@@_zhmCJK_bool
-  \PassOptionsToPackage { encoding = \l_@@_encoding_tl } { zhmCJK }
+  \PassOptionsToPackage { encoding = \g_@@_encoding_tl } { zhmCJK }
   \RequirePackage { zhmCJK }
 %    \end{macrocode}
 % 不载入 \pkg{zhmCJK} 宏包时直接调用 \pkg{CJK} 及相关宏包。
 %    \begin{macrocode}
 \else:
-  \str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
+  \str_if_eq:onTF { \g_@@_encoding_tl } { GBK }
     { \RequirePackage { CJK } }
     { \RequirePackage { CJKutf8 } }
   \RequirePackage { CJKpunct , CJKspace }
@@ -3909,7 +4183,7 @@
 % \begin{macro}[int]{\ctex_load_zhmap:nnnn}
 % 载入 \pkg{zhmetrics} 的字体映射文件,同时设置 \tn{CJKrmdefault} 等。
 %    \begin{macrocode}
-  \cs_new_protected_nopar:Npn \ctex_load_zhmap:nnnn #1#2#3#4
+  \cs_new_protected:Npn \ctex_load_zhmap:nnnn #1#2#3#4
     {
       \tl_set:Nn \CJKrmdefault {#1}
       \tl_set:Nn \CJKsfdefault {#2}
@@ -3924,7 +4198,7 @@
 % \begin{macro}[int]{\ctex_zhmap_input:n}
 % 载入字体映射文件时,确认 |%| 和 |\| 的 \tn{catcode}。
 %    \begin{macrocode}
-  \cs_new_protected_nopar:Npn \ctex_zhmap_input:n #1
+  \cs_new_protected:Npn \ctex_zhmap_input:n #1
     {
       \ctex_file_wrapper:nnn
         {
@@ -3946,22 +4220,10 @@
   \tl_if_exist:NF \CJKrmdefault { \tl_new:N \CJKrmdefault }
   \tl_if_exist:NF \CJKsfdefault { \tl_new:N \CJKsfdefault }
   \tl_if_exist:NF \CJKttdefault { \tl_new:N \CJKttdefault }
-  \ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff }
-    { \CJKfamily { \CJKrmdefault } }
-    { }
-    { \ctex_patch_failure:N \rmfamily }
-  \ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff }
-    { \CJKfamily { \CJKsfdefault } }
-    { }
-    { \ctex_patch_failure:N \sffamily }
-  \ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff }
-    { \CJKfamily { \CJKttdefault } }
-    { }
-    { \ctex_patch_failure:N \ttfamily }
-  \ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff }
-    { \CJKfamily { \CJKfamilydefault } }
-    { \cs_set_eq:NN \reset at font \normalfont }
-    { \ctex_patch_failure:N \normalfont }
+  \g at addto@macro \@rmfamilyhook      { \CJKfamily { \CJKrmdefault } }
+  \g at addto@macro \@sffamilyhook      { \CJKfamily { \CJKsfdefault } }
+  \g at addto@macro \@ttfamilyhook      { \CJKfamily { \CJKttdefault } }
+  \g at addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } }
 %    \end{macrocode}
 %
 % \pkg{zhmCJK} 判断结束。
@@ -3975,7 +4237,7 @@
 % \tn{CJK at loadEncoding})。因此需要确保载入 \file{.enc} 和 \file{.bdg} 文件时,
 % |^| 的 \tn{catcode} 为 $7$。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_CJK_input:n #1
+\cs_new_protected:Npn \ctex_CJK_input:n #1
   {
     \ctex_file_wrapper:nnn
       {
@@ -4002,7 +4264,7 @@
 % 我们在这里给出 \tn{CJK at surr} 的一个不依赖 \tn{uppercase} 的实现。
 %    \begin{macrocode}
 \if_cs_exist:N \CJK at surr
-  \cs_new_protected_nopar:Npn \ctex_plane_to_utfxvibe:Nn #1#2
+  \cs_new_protected:Npn \ctex_plane_to_utfxvibe:Nn #1#2
     {
       \tl_set:Nx \l_@@_tmp_tl {#2}
       \int_set:Nn \l_@@_tmp_int
@@ -4039,14 +4301,14 @@
 \ctex_at_end_preamble:n { \ctex_update_default_family: }
 %    \end{macrocode}
 %
-% 启用中文字符功能。\texttt{GBK} 编码时,将汉字的首字节设置为活动字符,并对这些
-% 字符初始化;\texttt{UTF8} 编码时,上游宏包已经处理好。
+% 启用中文字符功能。\opt{GBK} 编码时,将汉字的首字节设置为活动字符,并对这些
+% 字符初始化;\opt{UTF8} 编码时,上游宏包已经处理好。
 % \tn{CJK at makeActive} 应该先于 \file{ctex-name-gbk.cfg} 等文件的载入。
 % 注意 \tn{CJK at loadBinding} 需要调用补丁后的 \tn{CJK at input}。使用
 % \pkg{zhmCJK} 时,此功能已经被启用。
 %    \begin{macrocode}
 \reverse_if:N \if_bool:N \g_@@_zhmCJK_bool
-  \str_if_eq:onF { \l_@@_encoding_tl } { UTF8 }
+  \str_if_eq:onF { \g_@@_encoding_tl } { UTF8 }
     {
       \CJK at makeActive
       \CJK at loadBinding { standard }
@@ -4087,7 +4349,7 @@
   \exp_args:Nx \ctex_at_end_preamble:n
     {
       \exp_not:N \CJK at envStart
-        { } { \l_@@_encoding_tl } { \exp_not:N \CJKfamilydefault }
+        { } { \g_@@_encoding_tl } { \exp_not:N \CJKfamilydefault }
       \exp_not:N \CJKtilde
     }
 %    \end{macrocode}
@@ -4098,15 +4360,10 @@
 %    \end{macrocode}
 %
 % \begin{macro}[int]{\ctex_auto_ignorespaces:}
-% 关闭名字空间,保存 \tn{CJK@@ignorespaces} 的定义,方便使用。
+% 保存 \tn{CJK@@ignorespaces} 的定义,方便使用。
 %    \begin{macrocode}
-%<@@=>
-\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@ignorespaces
+\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@@@ignorespaces
 %    \end{macrocode}
-% 恢复名字空间,要把它放在一个 \env{macrocode} 环境中,\cls{l3doc} 才能正确工作。
-%    \begin{macrocode}
-%<@@=ctex>
-%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}[int]{\ctex_ignorespaces_case:N,\ctex_set_ignorespaces:}
@@ -4113,13 +4370,13 @@
 % 设置忽略空格的的方式。根据 \opt{space} 选项的值重定义 \tn{CJK at ignorespaces},
 % 并保存起来供 \tn{CJKhook} 备用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ignorespaces_case:N #1
+\cs_new_protected:Npn \ctex_ignorespaces_case:N #1
   {
-    \cs_set_protected_nopar:Npn \ctex_set_ignorespaces:
+    \cs_set_protected:Npn \ctex_set_ignorespaces:
       { \cs_set_eq:NN \CJK at ignorespaces #1 }
     \ctex_set_ignorespaces:
   }
-\cs_new_protected_nopar:Npn \ctex_set_ignorespaces:
+\cs_new_protected:Npn \ctex_set_ignorespaces:
   { \cs_set_eq:NN \CJK at ignorespaces \ctex_auto_ignorespaces: }
 %    \end{macrocode}
 % \end{macro}
@@ -4136,7 +4393,7 @@
 % \begin{macro}[int]{\ctex_punct_set:n}
 % 设置 CJK 族对应到实际的字体。|#1| 是 \opt{fontset} 的名字。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_punct_set:n #1
+\cs_new_protected:Npn \ctex_punct_set:n #1
   {
     \clist_map_inline:Nn \c_@@_punct_family_clist
       {
@@ -4159,7 +4416,7 @@
 % \begin{macro}[int]{\ctex_punct_map_family:nn}
 % CJK 族 |#1| 使用族 |#2| 的边界信息。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_punct_map_family:nn #1#2
+\cs_new_protected:Npn \ctex_punct_map_family:nn #1#2
   {
     \cs_if_free:cF { CJKpunct@ #2 @spaces }
       { \cs_set_eq:cc { CJKpunct@ #1 @spaces } { CJKpunct@ #2 @spaces } }
@@ -4170,7 +4427,7 @@
 % \begin{macro}[int]{\ctex_punct_map_bfseries:nn}
 % CJK 族 |#1| 的 \tn{bfseries} 使用族 |#2| 的边界信息。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_punct_map_bfseries:nn #1#2
+\cs_new_protected:Npn \ctex_punct_map_bfseries:nn #1#2
   {
     \clist_map_inline:nn {#1}
       {
@@ -4178,7 +4435,7 @@
         \ctex_punct_map_series:nnn { ##1 } { bx } {#2}
       }
   }
-\cs_new_protected_nopar:Npn \ctex_punct_map_series:nnn #1#2#3
+\cs_new_protected:Npn \ctex_punct_map_series:nnn #1#2#3
   {
     \CJKpunctmapfamily { C19 } {#1} {#2} { m }  {#3}
     \CJKpunctmapfamily { C19 } {#1} {#2} { it } {#3}
@@ -4193,7 +4450,7 @@
 % \begin{macro}[int]{\ctex_punct_map_itshape:nn}
 % CJK 族 |#1| 的 \tn{itshape} 使用族 |#2| 的边界信息。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_punct_map_itshape:nn #1#2
+\cs_new_protected:Npn \ctex_punct_map_itshape:nn #1#2
   {
     \CJKpunctmapfamily { C19 } {#1} { m }  { it } {#2}
     \CJKpunctmapfamily { C19 } {#1} { b }  { it } {#2}
@@ -4208,7 +4465,7 @@
 % \begin{macro}[int]{\ctex_punct_space:nn,\ctexspadef}
 % 定义标点的边界信息。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_punct_space:nn #1#2
+\cs_new_protected:Npn \ctex_punct_space:nn #1#2
   { \tl_const:cn { c_@@_ #1 _punct_spaces_tl } {#2} }
 \cs_new_eq:NN \ctexspadef \ctex_punct_space:nn
 %    \end{macrocode}
@@ -4259,6 +4516,7 @@
 %
 % \changes{v2.0}{2014/03/08}{通过 \pkg{LuaTeX-ja} 宏包支持 \LuaLaTeX。}
 % \changes{v2.3}{2015/09/25}{更新 \pkg{LuaTeX-ja} 支持(20150922.0)。}
+% \changes{v2.5}{2020/04/18}{更新 \pkg{LuaTeX-ja} 支持(20200412.0)。}
 %
 % \pkg{LuaTeX-ja} 为了兼容 p\LaTeX 的使用习惯,对 \LaTeXe 的 \pkg{NFSS} 作了不少
 % 修改和扩充,这对于简体中文用户来说不是必要的。我们在这里禁用它。
@@ -4275,13 +4533,13 @@
 %
 %    \begin{macrocode}
 \RequirePackage { luatexja }
-\@ifpackagelater { luatexja } { 2015/09/21 } { }
+\@ifpackagelater { luatexja } { 2020/04/12 } { }
   { \msg_error:nnn { ctex } { package-too-old } { luatexja } }
 %    \end{macrocode}
 %
 %    \begin{macrocode}
 \RequirePackage { fontspec }
-\@ifpackagelater { fontspec } { 2014/05/25 } { }
+\@ifpackagelater { fontspec } { 2020/02/21 } { }
   { \msg_error:nnn { ctex } { package-too-old } { fontspec } }
 %    \end{macrocode}
 %
@@ -4300,19 +4558,20 @@
 \ltjdefcharrange{1}{"80-"36F, "1E00-"1EFF}
 \ltjdefcharrange{2}{"370-"4FF, "1F00-"1FFF}
 \ltjdefcharrange{3}{%
-  "2000-"206F, "2070-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF,
-  "2B00-"2BFF}
+  "2000-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, "2B00-"2BFF}
 \ltjdefcharrange{4}{%
    "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF,
-  "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F,
-  "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese
+  "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF,
+  "FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF,
+  "1F300-"1FFFF, "2000-"206F}
 \ltjdefcharrange{5}{"D800-"DFFF, "E0000-"E00FF, "E01F0-"10FFFF}
 \ltjdefcharrange{6}{%
   "2E80-"2EFF, "3000-"30FF, "3190-"319F, "31F0-"4DBF,
-  "4E00-"9FFF, "F900-"FAFF, "FE10-"FE6F, "20000-"2FFFF, "E0100-"E01EF}
+  "4E00-"9FFF, "F900-"FAFF, "FE10-"FE1F, "FE30-"FE6F, "FF00-"FFEF,
+  "1B000-"1B16F, "1F100-"1F2FF, "20000-"3FFFF, "E0100-"E01EF}
 \ltjdefcharrange{7}{%
-  "1100-"11FF, "2F00-"2FFF, "3100-"31EF, "A000-"A4CF,
-  "A830-"A83F, "AC00-"D7FF}
+  "1100-"11FF, "2F00-"2FFF, "3100-"318F, "31A0-"31EF, "A000-"A4CF,
+  "A960-"A97F, "AC00-"D7FF}
 \ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7}
 %    \end{macrocode}
 % 将引号、破折号等中西文公用的标点符号归入字符范围 9,将他们设置为 JAchar。
@@ -4358,47 +4617,192 @@
 % 字符是 ALchar 类。我们这里用 \pkg{xunicode-addon} 来处理 \pkg{xunicode}。
 %    \begin{macrocode}
 \RequirePackage { xunicode-addon }
-\AtBeginUTFCommand
+\AtBeginUTFCommand { \CTEX at beginallalchar }
+\AtEndUTFCommand   { \CTEX at endallalchar }
+\cs_new_protected:Npn \CTEX at beginallalchar
   {
     \group_begin:
-    \lua_now:e { tex.globaldefs = 0 }
-    \ltj at allalchar
+      \ctex_ltj_zero_globaldefs:
+      \ltj at allalchar
   }
-\AtEndUTFCommand { \group_end: }
+\cs_new_protected:Npn \CTEX at endallalchar
+  { \group_end: }
 %    \end{macrocode}
 %
 % \changes{v2.4.2}{2016/05/15}{恢复 \pkg{luatexja} 对 \tn{emshape} 和
 % \tn{eminnershape} 的重定义。}
 % \changes{v2.4.3}{2016/08/26}{简化 \pkg{fontspec} 补丁。}
-% \begin{macro}[int]{\fontspec_visible_space:}
-% 我们不使用 \pkg{luatexja} 对 \pkg{fontspec} 的补丁,直接处理。
+% \changes{v2.5}{2020/04/18}{删除 \pkg{fontspec} 补丁。}
+%
+% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。
 %    \begin{macrocode}
-\cs_set_protected:Npn \fontspec_visible_space:
+\ctex_at_end_package:nn { listings }
+  { \RequirePackage { lltjp-listings } }
+%    \end{macrocode}
+%
+% \paragraph{\pkg{Lua} 函数}
+%
+% 直接用 |token.set_lua| 定义,不是传统意义上的 \TeX \ 宏。
+%    \begin{macrocode}
+\group_begin:
+\char_set_catcode_space:n { 32 }
+\lua_now:e
   {
-    \tex_iffontchar:D \tex_font:D "2423 \exp_stop_f:
-      \ltjalchar "2423 \exp_stop_f:
-    \else:
-      \fontspec_visible_space_fallback:
-    \fi:
-  }
+    local func = lua.get_functions_table()
+    local ltjfont = luatexja.jfont
+    local getattribute = tex.getattribute
+    local set_lua = token.set_lua
+    local scan_int, scan_arg = token.scan_int, token.scan_argument
+    local new_luafunction = luatexbase.new_luafunction
 %    \end{macrocode}
+% \begin{macro}{\ctex_ltj_add_kyenc:n}
+% 保存 jfont 的编码,用于判断。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = ltjfont.add_kyenc_list
+    set_lua("ctex_ltj_add_kyenc:n", id, "global", "protected")
+%    \end{macrocode}
 % \end{macro}
-%
-% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。\pkg{LuaTeX-ja} 的补丁会将
-% 代码目录标题改为日文,我们不需要。
+% \begin{macro}{\ctex_ltj_is_kenc:n}
+% 判断编码是否属于 jfont。
 %    \begin{macrocode}
-\ctex_at_end_package:nn { listings }
-  {
-    \use:x
-      {
-        \exp_not:N \RequirePackage { lltjp-listings }
-        \tl_set:Nn \exp_not:N \lstlistingname
-          { \exp_not:o { \lstlistingname } }
-        \tl_set:Nn \exp_not:N \lstlistlistingname
-          { \exp_not:o { \lstlistlistingname } }
-      }
+    local id = new_luafunction("ctex")
+    func[id] = ltjfont.is_kenc
+    set_lua("ctex_ltj_is_kenc:n", id, "global")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_patch_external_font:n}
+% 若对字体的定义完全相同,则它们有相同的 \texttt{font.id}。因此如果字形是由
+% \textsf{NFSS} 的替换机制定义的,它们就有相同的 \texttt{font.id}。
+% |print_aftl_address| 函数的定义是
+% \begin{verbatim}
+%   function luatexja.jfont.print_aftl_address()
+%     return ';ltjaltfont' .. tostring(aftl_base):sub(8)
+%   end
+% \end{verbatim}
+% 主要目的是,如果当前字形有替代字体,则往字形的定义中加入一些标志,确保
+% \texttt{font.id} 唯一。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      local s = scan_arg()
+      local is_braced, is_quoted
+      if s:sub(1,1) == '{' and s:sub(-1)=='}' then
+        is_braced = true; s = s:sub(2,-2)
+      end
+      if s:sub(1,1) == '"' and s:sub(-1) == '"' then
+        is_quoted = true; s = s:sub(2,-2)
+      end
+      s = s .. ltjfont.print_aftl_address()
+      if     is_braced then s = '{'..s..'}'
+      elseif is_quoted then s = '"'..s..'"'
+      end
+      tex.sprint(-2, s)
+    end
+    set_lua("ctex_ltj_patch_external_font:n", id, "global")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_use_jfont:}
+% 使用 jfont,确保当前的 \tn{font} 是 jfont。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      font.current(getattribute("ltj at curjfnt"))
+    end
+    set_lua("ctex_ltj_use_jfont:", id, "global", "protected")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_set_alt_font:nnnn}
+% |#1| 和 |#2| 分别是字符区间的首末,|#3| 是基础字体,|#4| 是替代字体。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      local b = tonumber(scan_arg())
+      local e = tonumber(scan_arg())
+      local alt  = scan_arg()
+      local base = scan_arg()
+      ltjfont.set_alt_font_latex(b, e, alt, base)
+    end
+    set_lua("ctex_ltj_set_alt_font:nnnn", id, "global", "protected")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_clear_alt_font:n}
+% 清除 |#1| 的替代字体。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      local base = scan_arg()
+      ltjfont.clear_alt_font_latex(base)
+    end
+    set_lua("ctex_ltj_clear_alt_font:n", id, "global", "protected")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_pickup_alt_font:nn}
+% 定义 |#1| 的替代字体,|#2| 是字体大小。\\
+% 会在内部执行 \tn{ltj at pickup@altfont at auxy} 和 \tn{ltj at pickup@altfont at copy}。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      local base = scan_arg()
+      local size = scan_arg()
+      ltjfont.output_alt_font_cmd("y", base)
+      ltjfont.pickup_alt_font_a(size)
+    end
+    set_lua("ctex_ltj_pickup_alt_font:nn", id, "global", "protected")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_pickup_alt_font:Nn}
+% |#1| 是 \texttt{font.id},|#2| 是字体名称。
+% 在 \tn{ltj at pickup@altfont at copy} 之中使用。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      local num  = scan_int()
+      local base = scan_arg()
+      ltjfont.pickup_alt_font_b(num, base)
+    end
+    set_lua("@@_pickup_alt_font:Nn", id, "global", "protected")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_if_alt_set:nT}
+% 判断是否存在替代字体。会设置变量 |aftl_base| 和返回 \tn{@firstofone} 或 \tn{@gobble}。
+% \begin{verbatim}
+%   function luatexja.jfont.does_alt_set(bbase)
+%     aftl_base = alt_font_table_latex[bbase]
+%     tex.sprint(cat_lp, aftl_base and '\\@firstofone' or '\\@gobble')
+%   end
+% \end{verbatim}
+% \pkg{luatexja} 20200412.0 以后的定义为:
+% \begin{verbatim}
+%   function luatexja.jfont.does_alt_set()
+%     aftl_base = alt_font_table_latex[scan_arg()]
+%     tex.sprint(cat_lp, aftl_base and '\\@firstofone' or '\\@gobble')
+%   end
+% \end{verbatim}
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = \LuaTeXjaversion > 20200412.0
+      and ltjfont.does_alt_set
+      or  function ()
+            local base = scan_arg()
+            ltjfont.does_alt_set(base)
+          end
+    set_lua("@@_if_alt_set:nT", id, "global")
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ctex_ltj_zero_globaldefs:}
+% 设置 \tn{globaldefs} 为 $0$,避免全局设置,应当在分组中使用。
+% 这里通过 Lua 设置,可以不受外部 \TeX\ 环境中的 \tn{globaldefs} 的影响。
+%    \begin{macrocode}
+    local id = new_luafunction("ctex")
+    func[id] = function ()
+      tex.set("globaldefs", 0)
+    end
+    set_lua("ctex_ltj_zero_globaldefs:", id, "global", "protected")
   }
+\group_end:
 %    \end{macrocode}
+% \end{macro}
 %
 % \paragraph{字体切换方式}
 %
@@ -4405,9 +4809,10 @@
 % \begin{macro}[int]{\ctex_ltj_select_font:,\CJK at family}
 % \tn{CJK at family} 保存的是当前 CJK 实际的字体族名,如果为空表示没有设置过字体。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_select_font:
+\cs_new_protected:Npn \ctex_ltj_select_font:
   {
-    \cs_if_exist_use:cF { \l_@@_current_font_tl }
+    \group_begin: \exp_args:NNc \group_end:
+    \cs_if_exist_use:NF { \l_@@_current_font_tl }
       { \tl_if_empty:NF \CJK at family { \@@_select_font_aux: } }
   }
 \tl_new:N \CJK at family
@@ -4421,7 +4826,7 @@
 % 使用 \tn{pickup at font} 取得字体名称前,总需要先设置 \tn{font at name}。在这里将
 % \tn{f at family} 换成 CJK 字体族,并确保编码正确。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_select_font_aux:
+\cs_new_protected:Npn \@@_select_font_aux:
   {
     \group_begin:
       \tl_set_eq:NN \f at encoding \CJK at encoding
@@ -4440,13 +4845,17 @@
     \cs_if_exist:cF { \l_@@_current_font_tl }
       { \@@_select_font_aux: }
   }
-\cs_new_protected_nopar:Npn \@@_push_fontname:n #1
+\cs_new_protected:Npn \@@_push_fontname:n #1
   {
-    \cs_gset_eq:NN \@@_save_fontname:w \font at name
+    \seq_gpush:No \g_@@_fontname_seq { \font at name }
     \cs_gset_nopar:Npx \font at name {#1}
   }
-\cs_new_protected_nopar:Npn \@@_pop_fontname:
-  { \cs_gset_eq:NN \font at name \@@_save_fontname:w }
+\cs_new_protected:Npn \@@_pop_fontname:
+  {
+    \seq_gpop:NNT \g_@@_fontname_seq \l_@@_tmp_tl
+      { \cs_gset_eq:NN \font at name \l_@@_tmp_tl }
+  }
+\seq_new:N \g_@@_fontname_seq
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4453,7 +4862,7 @@
 % \begin{macro}[int]{\ctex_ltj_pickup_font:}
 % 替换 \tn{define at newfont} 内部调用的 \tn{extract at font} 和 \tn{do at subst@correction}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_pickup_font:
+\cs_new_protected:Npn \ctex_ltj_pickup_font:
   {
     \exp_after:wN \cs_if_exist:NF \font at name
       {
@@ -4474,11 +4883,18 @@
 %   %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
 %   \protected\def\jfont#1{%
 %     \afterassignment\ltj@@jfont
-%     \directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
+%     \directlua{luatexja.jfont.jfontdefX
+%       (false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
 %   \protected\def\globaljfont#1{%
 %     \afterassignment\ltj@@jfont
-%     \directlua{luatexja.jfont.jfontdefX(true,  'yoko','\luatexluaescapestring{\noexpand#1}')}}
-%   \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
+%     \directlua{luatexja.jfont.jfontdefX
+%       (true,  'yoko','\luatexluaescapestring{\noexpand#1}')}}
+%   \newluafunction\ltj@@jfont at inner
+%   \directlua{
+%     local t = lua.get_functions_table()
+%     t[\the\ltj@@jfont at inner] = luatexja.jfont.jfontdefY
+%   }
+%   \def\ltj@@jfont{\luafunction\ltj@@jfont at inner}
 % \end{verbatim}
 % \texttt{jfontdefX} 函数的作用是把 \tn{CS} 定义为其后的字体,\texttt{jfontdefY}
 % 的作用是更新 \texttt{JFM} 和记录相关字体信息。最后的工作是:
@@ -4505,7 +4921,7 @@
 % 赋值总是全局的,不会受到分组的影响。
 %    \begin{macrocode}
     \font at name
-    \lua_now:e { font.current(tex.getattribute('ltj at curjfnt')) }
+    \ctex_ltj_use_jfont:
     \use:c { \f at encoding + \f at family }
     \use:c { \curr at fontshape }
   }
@@ -4557,26 +4973,16 @@
 %    \begin{macrocode}
 \prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF }
   {
-    \lua_now:e { luatexja.jfont.does_alt_set ('\lua_escape:e {#1}') }
-      \prg_return_true: \else: \prg_return_false: \fi:
+    \@@_if_alt_set:nT {#1} { \prg_return_true: \use_none:n }
+    \prg_return_false:
   }
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\@@_patch_external_font:w}
-% 若对字体的定义完全相同,则它们有相同的 \texttt{font.id}。因此如果字形是由
-% \textsf{NFSS} 的替换机制定义的,它们就有相同的 \texttt{font.id}。
-% |print_aftl_address| 函数的定义是
-% \begin{verbatim}
-%   function print_aftl_address()
-%     tex.sprint(cat_lp, ';ltjaltfont' .. tostring(aftl_base):sub(8))
-%   end
-% \end{verbatim}
-% 主要目的是,如果当前字形有替代字体,则往字形的定义中加入一些标志,确保
-% \texttt{font.id} 唯一。
 %    \begin{macrocode}
-\cs_new_nopar:Npn \@@_patch_external_font:w #1 ~ at
-  { #1 \lua_now:e { luatexja.jfont.print_aftl_address() } ~ at }
+\cs_new:Npn \@@_patch_external_font:w #1 ~ at
+  { \ctex_ltj_patch_external_font:n {#1} ~ at }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4583,16 +4989,12 @@
 % \begin{macro}[int]{\ctex_ltj_select_alternate_font:}
 % 在 \tn{selectfont} 中更新替代字体。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_select_alternate_font:
+\cs_new_protected:Npn \ctex_ltj_select_alternate_font:
   {
     \ctex_ltj_if_alternate_shape_exist:nT { \l_@@_current_shape_tl }
       {
-        \lua_now:e
-          {
-            luatexja.jfont.output_alt_font_cmd
-              ('y', '\lua_escape:e { \l_@@_current_shape_tl }')
-          }
-        \lua_now:e { luatexja.jfont.pickup_alt_font_a ('\f at size') }
+        \ctex_ltj_pickup_alt_font:nn
+          { \l_@@_current_shape_tl } { \f at size }
       }
   }
 \tl_new:N \l_@@_current_shape_tl
@@ -4604,12 +5006,12 @@
 % \begin{macro}[int]{\ltj at pickup@altfont at auxy}
 % 被用在函数 |output_alt_font_cmd| 中,作用是定义替代字体。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ltj at pickup@altfont at auxy #1
+\cs_new_protected:Npn \ltj at pickup@altfont at auxy #1
   {
     \cs_if_exist:cF { #1/\f at size }
       {
         \group_begin:
-          \use:x { \exp_not:N \split at name #1 / \f at size } \@nil
+          \use:e { \exp_not:N \split at name #1 / \f at size } \@nil
           \@@_push_fontname:n { \use:c { \curr at fontshape / \f at size } }
           \ctex_ltj_pickup_font:
         \group_end:
@@ -4619,22 +5021,14 @@
 %    \end{macrocode}
 % \end{macro}
 %
-%    \begin{macrocode}
-%<@@=>
-%    \end{macrocode}
-%
 % \begin{macro}[int]{\ltj at pickup@altfont at copy}
 % 被用在函数 |pickup_alt_font_a| 中。\tn{ltj@@getjfontnumber} 的作用是将字体命令
 % |#1| 对应的 \texttt{font.id} 保存到 \tn{ltj at tempcntc} 中。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ltj at pickup@altfont at copy #1#2
+\cs_new_protected:Npn \ltj at pickup@altfont at copy #1#2
   {
-    \ltj@@getjfontnumber #1
-    \lua_now:e
-      {
-        luatexja.jfont.pickup_alt_font_b
-          ( \int_use:N \ltj at tempcntc, '\lua_escape:e {#2}' )
-      }
+    \ltj@@@@getjfontnumber #1
+    \@@_pickup_alt_font:Nn \ltj at tempcntc {#2}
   }
 %    \end{macrocode}
 % \end{macro}
@@ -4641,10 +5035,6 @@
 %
 % \paragraph{数学字体族}
 %
-%    \begin{macrocode}
-%<@@=ctex_ltj>
-%    \end{macrocode}
-%
 % 以下内容来自 \file{lltjfont.sty},目的是让汉字可以在数学环境中直接使用。
 %
 % \begin{macro}[int]{\ctex_ltj_if_jfont:nTF}
@@ -4657,10 +5047,11 @@
 %    \begin{macrocode}
 \cs_new:Npn \ctex_ltj_if_jfont:nTF #1
   {
-    \lua_now:e
-      { luatexja.jfont.is_kenc( string.match('\lua_escape:e {#1}', '[^/]+') ) }
+    \ctex_ltj_is_kenc:n { \@@_ltj_if_jfont:w #1 / \q_stop }
     \ifin@ \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi:
   }
+\cs_new:Npn \@@_ltj_if_jfont:w #1 / #2 \q_stop
+  {#1}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4678,17 +5069,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-%    \begin{macrocode}
-%<@@=>
-%    \end{macrocode}
-%
 % \begin{macro}[int]{\getanddefine at fonts,\ctex_ltj_get_and_define_fonts:nN}
 % 在使用的场合,\tn{escapechar} 已经被设置成 $-1$,使用 \cs{token_to_str:N} 就
 % 可以得到名字,不必使用 \cs{cs_to_str:N}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts:nN #1#2
+\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts:nN #1#2
   {
-    \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 }
+    \exp_args:No \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 }
       { \ctex_ltj_get_and_define_fonts_ja:nN }
       { \ctex_ltj_get_and_define_fonts_al:nN }
       {#1} #2
@@ -4695,7 +5082,7 @@
   }
 \cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine at fonts
 \cs_set_eq:NN \getanddefine at fonts \ctex_ltj_get_and_define_fonts:nN
-\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2
+\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2
   {
     \tl_gset:Nx \font at name { \use:c { \token_to_str:N #2 / \tf at size } }
     \ctex_ltj_pickup_font: \tl_set_eq:NN \textfont at name \font at name
@@ -4706,22 +5093,18 @@
     \tl_put_right:Nx \math at fonts
       {
         \ltj at setpar@global
-        \ltj@@set at stackfont #1 , \textfont at name   \c_colon_str { MJT }
-        \ltj@@set at stackfont #1 , \scriptfont at name \c_colon_str { MJS }
-        \ltj@@set at stackfont #1 , \font at name       \c_colon_str { MJSS }
+        \ltj@@@@set at stackfont #1 , \textfont at name   \c_colon_str { MJT }
+        \ltj@@@@set at stackfont #1 , \scriptfont at name \c_colon_str { MJS }
+        \ltj@@@@set at stackfont #1 , \font at name       \c_colon_str { MJSS }
       }
   }
 %    \end{macrocode}
 % \end{macro}
 %
-%    \begin{macrocode}
-%<@@=ctex_ltj>
-%    \end{macrocode}
-%
 % \begin{macro}[int]{\use at mathgroup,\ctex_ltj_use_math_group:Nn}
 % 在使用 \pkg{unicode-math} 宏包时,\cs{ctex_ltj_math_group_hook:} 将被重定义。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_use_math_group:Nn #1#2
+\cs_new_protected:Npn \ctex_ltj_use_math_group:Nn #1#2
   {
     \mode_if_math:T
       {
@@ -4762,7 +5145,7 @@
       }
       {
         \cs_set_eq:NN \use at mathgroup \ctex_ltj_use_math_group:Nn
-        \cs_set_protected_nopar:Npn \ctex_ltj_math_group_hook:
+        \cs_set_protected:Npn \ctex_ltj_math_group_hook:
           { \__um_switchto_literal: }
         \ctex_ltj_set_math_letter:NN
           \__um_sym:nnn
@@ -4777,7 +5160,7 @@
 % \begin{variable}{\l_@@_jfm_tl}
 % \pkg{LuaTeX-ja} 中与标点格式 \opt{plain} 对应的 \texttt{JFM} 是 \opt{mono}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_mono_jfm:n #1
+\cs_new_protected:Npn \ctex_mono_jfm:n #1
   {
     \str_if_eq:nnTF {#1} { plain }
       { \tl_set:Nn \l_@@_jfm_tl { mono } }
@@ -4791,7 +5174,6 @@
 % \end{macro}
 %
 % \begin{macro}[int]{\CJK at encoding}
-% \begin{macro}{\@@_change_encoding:}
 % 在 \LaTeX 下,\pkg{LuaTeX-ja} 依赖字体编码来实现特殊设置。例如上述的
 % \cs{ctex_ltj_if_jfont:nTF} 就是通过判断编码来实现的,它在设置数学字体时会用到。所以
 % 不应该与西文共用 \texttt{EU2}。定义字体族 song 为 \tn{CJK at encoding} 的默认替换
@@ -4799,29 +5181,26 @@
 %    \begin{macrocode}
 \tl_const:Nn \CJK at encoding { LTJY3 }
 \DeclareFontEncoding { \CJK at encoding } { } { }
-\use:x
+\use:e
   {
     \exp_not:N \DeclareFontSubstitution
-      { \CJK at encoding } { song } { \mddefault } { \updefault }
+      { \CJK at encoding } { song } { \mddefault } { \shapedefault }
   }
-\lua_now:e { luatexja.jfont.add_kyenc_list('\CJK at encoding') }
-\cs_new_protected_nopar:Npn \@@_change_encoding:
-  { \tl_set_eq:NN \g_fontspec_encoding_tl \CJK at encoding }
+\ctex_ltj_add_kyenc:n { \CJK at encoding }
 \DeclareFontFamily { \CJK at encoding } { song } { }
-\DeclareFontShape { \CJK at encoding } { song } { \mddefault } { \updefault }
+\DeclareFontShape { \CJK at encoding } { song } { \mddefault } { \shapedefault }
   { <-> psft:SimSun:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { }
-\DeclareFontShape { \CJK at encoding } { song } { \bfdefault } { \updefault }
+\DeclareFontShape { \CJK at encoding } { song } { \bfdefault } { \shapedefault }
   { <-> psft:SimHei:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { }
 \tl_const:Nn \c_@@_math_tl { CJKmath }
 \DeclareSymbolFont { \c_@@_math_tl }
-  { \CJK at encoding } { song } { \mddefault } { \updefault }
+  { \CJK at encoding } { song } { \mddefault } { \shapedefault }
 \SetSymbolFont { \c_@@_math_tl } { bold }
-  { \CJK at encoding } { song } { \bfdefault } { \updefault }
+  { \CJK at encoding } { song } { \bfdefault } { \shapedefault }
 \int_const:Nn \c_@@_math_fam_int { \use:c { sym \c_@@_math_tl } }
 \jfam \c_@@_math_fam_int
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 % 这是 \pkg{luatexja-fontspec} 中新增的一些字体选项。
 %    \begin{macrocode}
@@ -4847,7 +5226,7 @@
   {
     \group_begin:
     \clist_clear:N \l_@@_char_range_clist
-    \seq_clear:N \l_@@_alternate_seq
+    \prop_clear:N \l_@@_alternate_prop
     \tl_set:Nn \l_@@_base_CJKfamily_tl {#1}
     \keys_set_known:nnN { ctex_ltj / fontspec } {#2} \l_@@_tmp_tl
     \clist_set:No \l_@@_font_options_clist { \l_@@_tmp_tl }
@@ -4864,10 +5243,17 @@
   }
 \tl_new:N \l_@@_base_CJKfamily_tl
 \clist_new:N \l_@@_font_options_clist
-\cs_new_protected_nopar:Npn \@@_use_global_options:N #1
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_use_global_options:N}
+% 应用默认字体选项,并总是设置 \opt{JFM} 和 \opt{NFSSEncoding} 。
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_use_global_options:N #1
   {
     \clist_concat:NNN #1 \g_@@_default_features_clist #1
-    \clist_put_left:Nx #1 { JFM = \l_@@_jfm_tl }
+    \clist_put_left:Nx #1
+      { NFSSEncoding = \CJK at encoding , JFM = \l_@@_jfm_tl }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -4885,7 +5271,7 @@
 % \begin{macro}{\@@_check_family:n}
 % 删除重复的定义,清除替代字体的先前设置。
 %   \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_check_family:n #1
+\cs_new_protected:Npn \@@_check_family:n #1
   {
     \prop_gpop:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl
       {
@@ -4911,20 +5297,16 @@
 % 在设置字体时,实际上并不是马上就定义。而是只保存相关参数,在通过 \tn{CJKfamily}
 % 第一次使用时才定义。需要注意将编码改为 \tn{CJK at encoding}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_gset_family_cs:nn #1#2
+\cs_new_protected:Npn \@@_gset_family_cs:nn #1#2
   {
-    \cs_gset_protected_nopar:cpx { \@@_family_csname:n {#1} }
+    \cs_gset_protected:cpx { \@@_family_csname:n {#1} }
       {
         \group_begin:
-        \@@_change_encoding:
         \exp_not:n { \cs_set_eq:NN \CJKfamily \use_none:n }
-        \exp_not:n { \cs_set_eq:NN \CTEX at fontfamily \use_none:n }
-        \exp_not:n { \fontspec_set_family:Nnn \g_@@_fontspec_family_tl }
+        \exp_not:n { \fontspec_gset_family:Nnn \g_@@_fontspec_family_tl }
           { \exp_not:o { \l_@@_font_options_clist } } {#2}
         \prop_gput:Nno \exp_not:N \g_@@_family_name_prop {#1}
           { \exp_not:N \g_@@_fontspec_family_tl }
-        \tl_gset_eq:NN \exp_not:N \g_@@_fontspec_family_tl
-          \exp_not:N \g_@@_fontspec_family_tl
         \@@_set_alternate_family:n {#1}
         \group_end:
       }
@@ -4931,8 +5313,8 @@
   }
 \tl_new:N \l_@@_base_family_tl
 \tl_new:N \g_@@_fontspec_family_tl
-\cs_new_nopar:Npn \@@_family_csname:n #1 { ctex_ltj/family/#1 }
-\cs_new_protected_nopar:Npn \@@_set_alternate_family:n #1
+\cs_new:Npn \@@_family_csname:n #1 { ctex_ltj/family/#1 }
+\cs_new_protected:Npn \@@_set_alternate_family:n #1
   {
     \tl_set:Nn \l_@@_base_CJKfamily_tl {#1}
     \tl_set_eq:NN \l_@@_base_family_tl \g_@@_fontspec_family_tl
@@ -4948,7 +5330,7 @@
 %    \begin{macrocode}
 \NewDocumentCommand \CJKfamily { m }
   { \ctex_ltj_switch_family:x {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ltj_switch_family:n #1
+\cs_new_protected:Npn \ctex_ltj_switch_family:n #1
   {
     \ctex_ltj_family_if_exist:nNTF {#1} \CJK at family
       {
@@ -4984,7 +5366,7 @@
 %
 % \begin{macro}{\@@_family_unknown_warning:n}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_family_unknown_warning:n #1
+\cs_new_protected:Npn \@@_family_unknown_warning:n #1
   {
     \prop_if_empty:NF \g_@@_family_font_name_prop
       {
@@ -5001,7 +5383,7 @@
     Unknown~CJK~family~`\@@_msg_family_map:n {#1}'~is~being~ignored.\\
     Try~to~use~`\@@_msg_def_family_map:n {#1}'~to~define~it.
   }
-\cs_new_nopar:Npn \@@_msg_def_family_map:n #1
+\cs_new:Npn \@@_msg_def_family_map:n #1
   {
     \str_case_e:nnF {#1}
       {
@@ -5012,7 +5394,7 @@
       { \token_to_str:N \setCJKfamilyfont \{ #1 \} }
     [...]\{...\}
   }
-\cs_new_nopar:Npn \@@_msg_family_map:n #1
+\cs_new:Npn \@@_msg_family_map:n #1
   {
     \str_case_e:nnF {#1}
       {
@@ -5027,7 +5409,7 @@
 %
 % \begin{macro}[int]{\ctex_ltj_fontspec:nn}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:nn #1#2
+\cs_new_protected:Npn \ctex_ltj_fontspec:nn #1#2
   {
     \prop_get:NnNTF \g_@@_fontspec_prop
       { CJKfontspec/#1/#2/id } \l_ctex_ltj_family_tl
@@ -5034,14 +5416,14 @@
       { \ctex_ltj_switch_family:x { \l_ctex_ltj_family_tl } }
       {
         \int_gincr:N \g_@@_family_int
-        \@@_fontspec:xnn
+        \@@_fontspec:enn
           { CJKfontspec ( \int_use:N \g_@@_family_int ) }
           {#1} {#2}
       }
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:xx #1#2
-  { \use:x { \ctex_ltj_fontspec:nn {#1} {#2} } }
-\cs_new_protected_nopar:Npn \@@_fontspec:nnn #1#2#3
+\cs_new_protected:Npn \ctex_ltj_fontspec:ee #1#2
+  { \use:e { \ctex_ltj_fontspec:nn {#1} {#2} } }
+\cs_new_protected:Npn \@@_fontspec:nnn #1#2#3
   {
     \bool_if:NT \l_@@_add_alternate_bool
       {
@@ -5061,7 +5443,7 @@
     \ctex_ltj_set_family:nnn {#1} {#2} {#3}
     \ctex_ltj_switch_family:n {#1}
   }
-\cs_generate_variant:Nn \@@_fontspec:nnn { x }
+\cs_generate_variant:Nn \@@_fontspec:nnn { e }
 \prop_new:N \g_@@_fontspec_prop
 %    \end{macrocode}
 % \end{macro}
@@ -5069,9 +5451,9 @@
 % \begin{macro}[int]
 % {\ctex_ltj_add_font_features:n,\ctex_ltj_add_font_features:nn}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:n #1
+\cs_new_protected:Npn \ctex_ltj_add_font_features:n #1
   { \ctex_ltj_add_font_features:xn { \l_ctex_ltj_family_tl } {#1} }
-\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:nn #1#2
+\cs_new_protected:Npn \ctex_ltj_add_font_features:nn #1#2
   {
     \prop_get:NnNTF \g_@@_family_font_name_prop
       {#1} \l_@@_tmp_tl
@@ -5080,7 +5462,7 @@
           {#1} \l_@@_font_options_clist
         \clist_put_right:Nn \l_@@_font_options_clist {#2}
         \bool_set_true:N \l_@@_add_alternate_bool
-        \ctex_ltj_fontspec:xx
+        \ctex_ltj_fontspec:ee
           { \exp_not:o { \l_@@_font_options_clist } }
           { \exp_not:o { \l_@@_tmp_tl } }
       }
@@ -5102,16 +5484,16 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_pass_args:nnnn #1#2#3#4
   {
-    \IfNoValueTF {#2}
+    \tl_if_novalue:nTF {#2}
       { \@@_post_arg:w {#1} {#3} {#4} }
       {
-        \use:x { #1 {#2} {#3} }
+        \use:e { #1 {#2} {#3} }
         #4
       }
   }
 \NewDocumentCommand \@@_post_arg:w { m m m O { } }
   {
-    \use:x { #1 {#4} {#2} }
+    \use:e { #1 {#4} {#2} }
     #3
   }
 %    \end{macrocode}
@@ -5131,8 +5513,8 @@
 \NewDocumentCommand \newCJKfontfamily { o m o m }
   {
     \tl_set:Nx \l_@@_tmp_tl
-      { \IfNoValueTF {#1} { \cs_to_str:N #2 } {#1} }
-    \cs_new_protected_nopar:Npx #2
+      { \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} }
+    \cs_new_protected:Npx #2
       { \ctex_ltj_switch_family:n { \l_@@_tmp_tl } }
     \@@_pass_args:nnnn
       { \ctex_ltj_set_family:nnn { \l_@@_tmp_tl } } {#3} {#4}
@@ -5202,36 +5584,15 @@
 \tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } }
 %    \end{macrocode}
 %
-% \begin{macro}[int]{\fontfamily}
-% \begin{macro}[int]{\CTEX at fontfamily}
 % \changes{v2.4.8}{2017/02/23}
 %   {解决与 \pkg{fontspec} 2017/01/24 v2.5d 的字体族匹配兼容问题。}
-% 修改 \tn{fontfamily},使主要 |CJK| 字体族能随西文主要字体更新。
+% 使用 \LaTeXe \ 提供的钩子,使主要 |CJK| 字体族能随西文主要字体更新。
 %    \begin{macrocode}
-\RenewDocumentCommand \fontfamily { m }
-  {
-    \tl_set:Nx \f at family {#1}
-    \CTEX at fontfamily {#1}
-  }
-\cs_new_protected_nopar:Npn \CTEX at fontfamily #1
-  {
-    \str_if_eq:nnTF {#1} { \familydefault }
-      { \CJKfamily { \CJKfamilydefault } }
-      { \@@_update_family_aux: }
-  }
-\cs_new_protected_nopar:Npn \@@_update_family_aux:
-  {
-    \str_case_e:nn { \f at family }
-      {
-        { \rmdefault }     { \CJKfamily { \CJKrmdefault } }
-        { \sfdefault }     { \CJKfamily { \CJKsfdefault } }
-        { \ttdefault }     { \CJKfamily { \CJKttdefault } }
-        { \familydefault } { \CJKfamily { \CJKfamilydefault } }
-      }
-  }
+\g at addto@macro \@rmfamilyhook      { \CJKfamily { \CJKrmdefault } }
+\g at addto@macro \@sffamilyhook      { \CJKfamily { \CJKsfdefault } }
+\g at addto@macro \@ttfamilyhook      { \CJKfamily { \CJKttdefault } }
+\g at addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } }
 %    \end{macrocode}
-% \end{macro}
-% \end{macro}
 %
 % 在导言区末尾更新 \tn{CJKfamilydefault}。
 %    \begin{macrocode}
@@ -5241,7 +5602,7 @@
 % \begin{macro}[int]{\ctex_ltj_ensure_default_family:}
 % 在导言区结束确认 \tn{CJKfamilydefault} 确实存在。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_ensure_default_family:
+\cs_new_protected:Npn \ctex_ltj_ensure_default_family:
   {
     \prop_if_empty:NF \g_@@_family_font_name_prop
       {
@@ -5272,7 +5633,7 @@
 % \begin{macro}[int]{\ctex_ltj_update_mathfont:}
 % 更新数学字体为实际的字体。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont:
+\cs_new_protected:Npn \ctex_ltj_update_mathfont:
   {
     \ctex_ltj_family_if_exist:xNTF { \c_@@_math_tl } \l_@@_tmp_tl
       { \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } }
@@ -5281,20 +5642,20 @@
           { \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont:n #1
+\cs_new_protected:Npn \ctex_ltj_update_mathfont:n #1
   {
     \tl_const:Nx \c_@@_math_family_tl {#1}
     \DeclareSymbolFont { \c_@@_math_tl } { \CJK at encoding }
-      { \c_@@_math_family_tl } { \mddefault } { \updefault }
+      { \c_@@_math_family_tl } { \mddefault } { \shapedefault }
     \cs_if_free:cTF
-      { \CJK at encoding/\c_@@_math_family_tl/\bfdefault/\updefault }
+      { \CJK at encoding/\c_@@_math_family_tl/\bfdefault/\shapedefault }
       {
         \SetSymbolFont { \c_@@_math_tl } { bold } { \CJK at encoding }
-          { \c_@@_math_family_tl } { \mddefault } { \updefault }
+          { \c_@@_math_family_tl } { \mddefault } { \shapedefault }
       }
       {
         \SetSymbolFont { \c_@@_math_tl } { bold } { \CJK at encoding }
-          { \c_@@_math_family_tl } { \bfdefault } { \updefault }
+          { \c_@@_math_family_tl } { \bfdefault } { \shapedefault }
       }
   }
 %    \end{macrocode}
@@ -5302,12 +5663,14 @@
 %
 % \paragraph{替代字体的设置}
 %
+% \changes{v2.5}{2020/04/30}{重构字体选项 \opt{AlternateFont}。}
+%
 % \begin{macro}{AlternateFont,CharRange}
 % 设置替代字体的选项。
 %    \begin{macrocode}
 \keys_define:nn { ctex_ltj / fontspec }
   {
-    AlternateFont  .code:n = \ctex_ltj_set_alternate_seq:n {#1} ,
+    AlternateFont  .code:n = \ctex_ltj_set_alternate_prop:n {#1} ,
     AlternateFont  .value_required:n = true ,
     CharRange .clist_set:N = \l_@@_char_range_clist ,
     CharRange .value_required:n = true
@@ -5315,33 +5678,25 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]{\ctex_ltj_set_alternate_seq:n}
-% 我们使用 \verb=||= 作为替代字体序列的分隔标志。它可能被设置为活动字符,为此
-% 需要先“消毒”,同时过滤掉空元素。
+% \begin{macro}[int]{\ctex_ltj_set_alternate_prop:n}
+% 保存替代字体序列。
 %    \begin{macrocode}
-\group_begin:
-  \char_set_catcode_other:N \|
-  \cs_set:Npn \@@_tmp:w #1
-    {
-      \cs_new_protected:Npn \ctex_ltj_set_alternate_seq:n ##1
-        {
-          \clist_if_empty:NT \l_@@_char_range_clist
-            {
-              \tl_set:Nn \l_@@_tmp_tl { ##1 }
-              \tl_replace_all:Nnn \l_@@_tmp_tl {#1} { || }
-              \seq_set_split:NnV \l_@@_tmp_seq { || } \l_@@_tmp_tl
-              \seq_set_filter:NNn \l_@@_tmp_seq \l_@@_tmp_seq
-                { ! \tl_if_blank_p:n { ####1 } }
-              \seq_concat:NNN \l_@@_alternate_seq
-                \l_@@_alternate_seq \l_@@_tmp_seq
-            }
-        }
-    }
-  \char_set_catcode_active:N \|
-  \@@_tmp:w { || }
-\group_end:
-\seq_new:N \l_@@_tmp_seq
-\seq_new:N \l_@@_alternate_seq
+\cs_new_protected:Npn \ctex_ltj_set_alternate_prop:n #1
+  { \clist_map_function:nN {#1} \@@_push_alternate_prop:n }
+\cs_new_protected:Npn \@@_push_alternate_prop:n #1
+  {
+    \clist_set:Nx \l_@@_tmp_clist { \tl_head:n {#1} }
+    \tl_remove_all:Nn \l_@@_tmp_clist { ~ }
+    \exp_args:No \@@_push_alternate_prop:nn
+      { \l_@@_tmp_clist } {#1}
+  }
+\cs_new_protected:Npn \@@_push_alternate_prop:nn #1
+  {
+    \prop_remove:Nn \l_@@_alternate_prop {#1}
+    \prop_put:Nnn \l_@@_alternate_prop {#1}
+  }
+\clist_new:N \l_@@_tmp_clist
+\prop_new:N \l_@@_alternate_prop
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5348,45 +5703,52 @@
 % \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnF}
 % 如果在字体的选项中设置了 \opt{CharRange},则只设置替代字体。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnF #1#2#3
+\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnF
   {
     \clist_if_empty:NTF \l_@@_char_range_clist
-      {
-        \@@_check_family:n {#1}
-        \seq_if_empty:NF \l_@@_alternate_seq
-          { \ctex_ltj_save_alternate_seq:cn { \@@_alternate_cs:n {#1} } {#2} }
-        #3
-      }
-      { \ctex_ltj_set_alternate_family:nn {#1} {#2} }
+      { \@@_set_family_aux:nnn }
+      { \@@_set_alternate_family_aux:nnn }
   }
+\cs_new_protected:Npn \@@_set_family_aux:nnn #1#2#3
+  {
+    \@@_check_family:n {#1}
+    \prop_if_empty:NF \l_@@_alternate_prop
+      { \ctex_ltj_save_alternate_seq:cn { \@@_alternate_cs:n {#1} } {#2} }
+    #3
+  }
+\cs_new_protected:Npn \@@_set_alternate_family_aux:nnn #1#2#3
+  { \ctex_ltj_set_alternate_family:nn {#1} {#2} }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]
-% {\ctex_ltj_save_alternate_seq:Nn,\ctex_ltj_save_alternate_seq:Nnnwn}
+% \begin{macro}[int]{\ctex_ltj_save_alternate_seq:Nn}
 % 保存由 \opt{AlternateFont} 设置的替代字体序列。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_seq:Nn #1#2
+\cs_new_protected:Npn \ctex_ltj_save_alternate_seq:Nn #1#2
   {
-    \seq_map_inline:Nn \l_@@_alternate_seq
-      { \ctex_ltj_save_alternate_seq:Nnnwnw #1 {#2} ##1 { } \q_stop }
+    \prop_map_inline:Nn \l_@@_alternate_prop
+      { \@@_save_alternate_auxi:w ##2 { } \q_mark #1 {#2} }
   }
-\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c }
-\NewDocumentCommand \ctex_ltj_save_alternate_seq:Nnnwnw
-  { m m m +O{ } m u{ \q_stop } }
+\cs_new_protected:Npn \@@_save_alternate_auxi:w #1#2#
   {
-    \clist_set:Nn \l_@@_char_range_clist {#3}
-    \clist_set:Nn \l_@@_alternate_options_clist {#4}
+    \tl_if_blank:nTF {#2}
+      { \@@_save_alternate_auxii:w {#1} }
+      { \@@_save_alternate_auxii:w {#1} {#2} }
+  }
+\cs_new_protected:Npn \@@_save_alternate_auxii:w #1#2#3 #4 \q_mark #5#6
+  {
+    \clist_set:Nn \l_@@_char_range_clist {#1}
+    \clist_set:Nn \l_@@_alternate_options_clist {#3}
     \@@_use_global_options:N \l_@@_alternate_options_clist
-    \tl_if_blank:nTF {#5}
-      { \tl_set:Nn \l_@@_tmp_tl {#2} }
+    \tl_if_blank:nTF {#2}
+      { \tl_set:Nn \l_@@_tmp_tl {#6} }
       {
-        \tl_set:Nn \l_@@_tmp_tl {#5}
-        \tl_replace_all:Nnn \l_@@_tmp_tl { * } {#2}
+        \tl_set:Nx \l_@@_tmp_tl { \tl_trim_spaces:n {#2} }
+        \tl_replace_all:Nnn \l_@@_tmp_tl { * } {#6}
       }
-    \use:x
+    \use:e
       {
-        \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #1
+        \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #5
           { \exp_not:o { \l_@@_char_range_clist } }
           { \exp_not:o { \l_@@_alternate_options_clist } }
           { \exp_not:o { \l_@@_tmp_tl } }
@@ -5393,6 +5755,7 @@
       }
   }
 \clist_new:N \l_@@_alternate_options_clist
+\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5400,7 +5763,7 @@
 % 设置选项 \opt{CharRange} 范围内的替代字体。如果已经定义了主字体,我们也马上
 % 定义替代字体,否则只保存起来备用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nn #1#2
+\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nn #1#2
   {
     \@@_update_family_uid:N \l_@@_font_options_clist
     \@@_use_global_options:N \l_@@_font_options_clist
@@ -5409,7 +5772,7 @@
       { \l_@@_char_range_clist }
       { \l_@@_font_options_clist } {#2} {#1}
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5
+\cs_new_protected:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5
   {
     \prop_get:NnNT \g_@@_family_name_prop {#5} \l_@@_base_family_tl
       { \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} }
@@ -5422,10 +5785,10 @@
 % \begin{macro}[int]{\ctex_ltj_save_alternate_family:Nnnn}
 % 保存替代字体序列的定义,以备定义主字体时使用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4
   {
     \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: }
-    \cs_gset_protected_nopar:Npx #1
+    \cs_gset_protected:Npx #1
       { \exp_not:o { #1 \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } }
   }
 %    \end{macrocode}
@@ -5434,10 +5797,9 @@
 % \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnn}
 % 实际定义替代字体族。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3
+\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3
   {
     \group_begin:
-    \@@_change_encoding:
     \cs_set_eq:NN \CJKfamily \use_none:n
     \ctex_ltj_swap_cs:NN
       \DeclareFontShape@ \ctex_ltj_declare_alternate_shape:nnnnnn
@@ -5469,7 +5831,7 @@
 % \pkg{fontspec} 对 CJK 字体族总是定义新字体。
 %    \begin{macrocode}
 \keys_define:nn { fontspec } { LTJFONTUID .code:n = }
-\cs_new_protected_nopar:Npn \@@_update_family_uid:N #1
+\cs_new_protected:Npn \@@_update_family_uid:N #1
   {
     \int_gincr:N \g_@@_family_int
     \clist_put_right:Nx #1 { LTJFONTUID = \int_use:N \g_@@_family_int }
@@ -5488,8 +5850,7 @@
   {
     \ctex_ltj_declare_alternate_shape:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6}
     \ctex_ltj_set_alternate_shape:Nnnnnnn \l_@@_char_range_clist
-      { \l_@@_base_family_tl } {#3} {#4}
-      { \l_fontspec_family_tl } {#3} {#4}
+      { \l_@@_base_family_tl } {#3} {#4} {#2} {#3} {#4}
   }
 %    \end{macrocode}
 % \end{macro}
@@ -5498,7 +5859,7 @@
 % 与 \pkg{LuaTeX-ja} 的 \tn{DeclareAlternateKanjiFont} 的功能类似,区别是固定编码
 % 为 \tn{CJK at encoding}。这个设置总是全局的。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7
+\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7
   {
     \clist_map_inline:Nn #1
       {
@@ -5509,10 +5870,9 @@
           }
           { \ctex_ltj_set_alternate_shape:nnn { #2/#3/#4 } { #5/#6/#7 } { ##1 } }
       }
-    \@@_save_alternate_shape:cnn
+    \@@_save_alternate_shape:cn
       { \@@_alternate_cs:n { clear / \l_@@_base_CJKfamily_tl } }
-      { luatexja.jfont.clear_alt_font_latex }
-      { '\lua_escape:e { \CJK at encoding/#2/#3/#4 }' }
+      { \ctex_ltj_clear_alt_font:n { \CJK at encoding/#2/#3/#4 } }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -5526,27 +5886,23 @@
 \NewDocumentCommand \ctex_ltj_set_alternate_shape:nnn
   { m m > { \SplitArgument { 1 } { -> } } m }
   { \ctex_ltj_set_alternate_shape:nnnn {#1} {#2} #3 }
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4
   {
-    \ctex_ltj_set_alternate_shape:n
+    \ctex_ltj_set_alternate_shape:e
       {
-        \IfNoValueTF {#4}
-          { \int_eval:n {#3} , \int_eval:n {#3} , }
-          {
-            \int_eval:n { \tl_if_blank:nTF {#3} { "80 } {#3} } ,
-            \int_eval:n { \tl_if_blank:nTF {#4} { "10FFFF } {#4} } ,
-          }
-        '\lua_escape:e { \CJK at encoding/#2 }' ,
-        '\lua_escape:e { \CJK at encoding/#1 }'
+        \@@_range_normalization:nn {#3} {#4}
+        { \CJK at encoding / \exp_not:n {#2} }
+        { \CJK at encoding / \exp_not:n {#1} }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:n #1
+\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:n #1
   {
-    \lua_now:e { luatexja.jfont.set_alt_font_latex ( #1 ) }
-    \@@_save_alternate_shape:cnn
+    \ctex_ltj_set_alt_font:nnnn #1
+    \@@_save_alternate_shape:cn
       { \@@_alternate_cs:n { reset / \l_@@_base_CJKfamily_tl } }
-      { luatexja.jfont.set_alt_font_latex } {#1}
+      { \ctex_ltj_set_alt_font:nnnn #1 }
   }
+\cs_generate_variant:Nn \ctex_ltj_set_alternate_shape:n { e }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5553,15 +5909,15 @@
 % \begin{macro}[int]{\ctex_ltj_set_alternate_shape:nnN}
 % 若字符范围预先由 \texttt{declarecharrange} 声明,则可以直接使用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3
+\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3
   {
     \tl_map_inline:Nn #3
       {
         \ctex_ltj_set_alternate_shape:n
           {
-            ##1 ,
-            '\lua_escape:e { \CJK at encoding/#2 }' ,
-            '\lua_escape:e { \CJK at encoding/#1 }'
+            ##1
+            { \CJK at encoding/#2 }
+            { \CJK at encoding/#1 }
           }
       }
   }
@@ -5568,22 +5924,20 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_save_alternate_shape:Nnn}
+% \begin{macro}{\@@_save_alternate_shape:Nn}
 % 将实际设置的替换字形保存起来用于清除或恢复。
 % 暂时令 \cs{l_@@_base_family_tl} 为 \cs{scan_stop:} 是让它不被展开,使得替换
 % 字体的设置可以在 \tn{addCJKfontfeature} 中直接使用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_save_alternate_shape:Nnn #1#2#3
+\cs_new_protected:Npn \@@_save_alternate_shape:Nn #1#2
   {
     \group_begin:
-    \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: }
-    \cs_set_eq:NN \l_@@_base_family_tl \scan_stop:
-    \cs_set_eq:NN \lua_escape:e \scan_stop:
-    \cs_gset_protected_nopar:Npx #1
-      { \exp_not:o {#1} \exp_not:N \lua_now:e { #2 ( #3 ) } }
+      \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: }
+      \cs_set_eq:NN \l_@@_base_family_tl \scan_stop:
+      \cs_gset_protected:Npx #1 { \exp_not:o {#1} #2 }
     \group_end:
   }
-\cs_generate_variant:Nn \@@_save_alternate_shape:Nnn { c }
+\cs_generate_variant:Nn \@@_save_alternate_shape:Nn { c }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5590,21 +5944,22 @@
 % \begin{macro}{clearalternatefont,resetalternatefont}
 % 清除和重置操作总是全局的。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     clearalternatefont    .code:n =
-      { \clist_map_function:xN {#1} \ctex_ltj_clear_alternate_font:n } ,
+      { \clist_map_function:eN {#1} \ctex_ltj_clear_alternate_font:n } ,
     resetalternatefont    .code:n =
-      { \clist_map_function:xN {#1} \ctex_ltj_reset_alternate_font:n } ,
+      { \clist_map_function:eN {#1} \ctex_ltj_reset_alternate_font:n } ,
     clearalternatefont .default:n = \l_ctex_ltj_family_tl ,
     resetalternatefont .default:n = \l_ctex_ltj_family_tl
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_clear_alternate_font:n #1
+\cs_new_protected:Npn \ctex_ltj_clear_alternate_font:n #1
   {
     \group_begin:
       \ctex_ltj_family_if_exist:xNTF {#1} \l_@@_base_family_tl
         {
-          \cs_if_exist_use:cT { \@@_alternate_cs:n { clear / #1 } }
+          \cs_if_exist_use:cT
+            { \@@_alternate_cs:n { clear / #1 } }
             {
               \prop_gput:Nno \g_@@_reset_alternate_prop
                 {#1} { \l_@@_base_family_tl }
@@ -5615,7 +5970,7 @@
         { \@@_family_unknown_warning:n {#1} }
     \group_end:
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_reset_alternate_font:n #1
+\cs_new_protected:Npn \ctex_ltj_reset_alternate_font:n #1
   {
     \group_begin:
       \prop_gpop:NnNT \g_@@_reset_alternate_prop {#1} \CJK at family
@@ -5627,7 +5982,7 @@
     \group_end:
   }
 \prop_new:N \g_@@_reset_alternate_prop
-\cs_generate_variant:Nn \clist_map_function:nN { x }
+\cs_generate_variant:Nn \clist_map_function:nN { e }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5634,16 +5989,16 @@
 % \begin{macro}{declarecharrange}
 % 预先声明字符范围。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
-    declarecharrange .code:n = \ctex_ltj_declare_char_range:x {#1} ,
+    declarecharrange .code:n = \ctex_ltj_declare_char_range:e {#1} ,
     declarecharrange .value_required:n = true
   }
-\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:n #1
+\cs_new_protected:Npn \ctex_ltj_declare_char_range:n #1
   { \clist_map_inline:nn {#1} { \@@_declare_char_range:nn ##1 } }
-\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { x }
-\cs_new_protected_nopar:Npn \@@_declare_char_range:nn #1#2
-  { \use:x { \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } } {#2} }
+\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { e }
+\cs_new_protected:Npn \@@_declare_char_range:nn #1
+  { \exp_args:Ne \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5651,7 +6006,7 @@
 % \begin{variable}{\g_@@_char_range_prop}
 % |#1| 是名字,|#2| 是范围。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:nn #1#2
+\cs_new_protected:Npn \ctex_ltj_declare_char_range:nn #1#2
   {
     \tl_clear:N \l_@@_char_range_tl
     \clist_map_function:nN {#2} \ctex_ltj_save_char_range:n
@@ -5671,18 +6026,25 @@
 \NewDocumentCommand \ctex_ltj_save_char_range:n
   { > { \SplitArgument { 1 } { -> } } m }
   { \ctex_ltj_save_char_range:nn #1 }
-\cs_new_protected_nopar:Npn \ctex_ltj_save_char_range:nn #1#2
+\cs_new_protected:Npn \ctex_ltj_save_char_range:nn #1#2
   {
     \tl_put_right:Nx \l_@@_char_range_tl
-      { {
-          \IfNoValueTF {#2}
-            { \int_eval:n {#1} , \int_eval:n {#1} }
-            {
-              \int_eval:n { \tl_if_blank:nTF {#1} { "80 } {#1} } ,
-              \int_eval:n { \tl_if_blank:nTF {#2} { "10FFFF } {#2} }
-            }
-      } }
+      { { \@@_range_normalization:nn {#1} {#2} } }
   }
+\cs_new:Npn \@@_range_normalization:nn #1#2
+  {
+    \tl_if_novalue:nTF {#2}
+      {
+        { \int_eval:n {#1} }
+        { \int_eval:n {#1} }
+      }
+      {
+        { \int_eval:n { \tl_if_blank:nTF {#1} { \c_@@_range_min_int } {#1} } }
+        { \int_eval:n { \tl_if_blank:nTF {#2} { \c_@@_range_max_int } {#2} } }
+      }
+  }
+\int_const:Nn \c_@@_range_min_int { "80 }
+\int_const:Nn \c_@@_range_max_int { \c_max_char_int }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5689,7 +6051,7 @@
 % \begin{macro}[int]{\ctex_ltj_def_char_range_key:n}
 % 在字体设置选项中定义字符范围键。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_def_char_range_key:n #1
+\cs_new_protected:Npn \ctex_ltj_def_char_range_key:n #1
   {
     \keys_if_exist:nnF { ctex_ltj / fontspec } {#1}
       {
@@ -5706,43 +6068,14 @@
 \cs_new_protected:Npn \ctex_ltj_char_range_key:nn #1#2
   {
     \tl_if_blank:nTF {#2}
-      { \tl_set:Nn \l_@@_char_range_clist {#1} }
-      {
-        \clist_if_empty:NT \l_@@_char_range_clist
-          {
-            \tl_set:Nn \l_@@_tmp_tl { {#1} }
-            \@@_char_range_parse_feature:w #2 \q_stop
-          }
-      }
+      { \clist_set:Nn \l_@@_char_range_clist {#1} }
+      { \@@_push_alternate_prop:nn {#1} { {#1} #2 } }
   }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_char_range_parse_feature:w}
-% 可以使用加方括号的方式,通过文件名来调用字体。这容易与字体选项混淆。例如,需要
-% 将 |[simsun.ttc]| 设置为 \opt{range} 的主字体,就需要使用
-% |range={{[simsun.ttc]}}| 或者 |[]{[simsun.ttc]}|。下面的目的是,支持直接使用
-% |[simsun.ttc]| 和 |[...][simsun.ttc]|。
-%    \begin{macrocode}
-\NewDocumentCommand \@@_char_range_parse_feature:w
-  { +o o u { \q_stop } }
-  {
-    \exp_args:NNf \tl_put_right:Nn \l_@@_tmp_tl
-      {
-        \IfNoValueTF {#1} { {#3} }
-          {
-            \IfNoValueTF {#2}
-              { \tl_if_blank:nTF {#3} { { [#1] } } { [ {#1} ] {#3} } }
-              { [ {#1} ] { [#2] } }
-          }
-      }
-    \seq_put_right:No \l_@@_alternate_seq { \l_@@_tmp_tl }
-  }
-%    \end{macrocode}
-% \end{macro}
+% \paragraph{其他设置}
 %
-% \paragraph{其它设置}
-%
 % 在抄录环境中禁用 \opt{autospacing} 和 \opt{autoxspacing}。然而,\pkg{LuaTeX-ja}
 % 还是会使 JAchar 自动折行。没有看到有简单的禁用折行的办法,可能需要设置所有的
 % JAchar 的 \opt{prebreakpenalty} 或 \opt{postbreakpenalty} 为 \texttt{10000}:
@@ -5768,16 +6101,14 @@
       { }
       { \ctex_patch_failure:N \verbatim at font }
   }
-\cs_new_protected_nopar:Npn \CTEX at verbatim@font at hook
+\cs_new_protected:Npn \CTEX at verbatim@font at hook
   { \ltjsetparameter { autospacing = false , autoxspacing = false } }
 %    \end{macrocode}
 %
-% \begin{macro}{\@@italiccorr}
+% \begin{macro}{\@@@@italiccorr}
 % \LaTeX{} 的倾斜校正也要重新定义。
 %    \begin{macrocode}
-%<@@=>
-\cs_set_eq:NN \@@italiccorr \/
-%<@@=ctex>
+\cs_set_eq:NN \@@@@italiccorr \/
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5787,14 +6118,15 @@
 % \tn{ltjsetkanjiskip} 和 \tn{ltjsetxkanjiskip} 是相应的 \tn{ltjsetparameter}
 % 的快捷方式,在使用他们时,要注意先使用 \tn{ltj at setpar@global}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_ltj_set_kanjiskip:N
+\cs_new_protected:Npn \ctex_ltj_set_kanjiskip:N
   { \ltj at setpar@global \ltjsetkanjiskip }
-\cs_new_protected_nopar:Npn \ctex_ltj_set_xkanjiskip:N
+\cs_new_protected:Npn \ctex_ltj_set_xkanjiskip:N
   { \ltj at setpar@global \ltjsetxkanjiskip }
 %    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
+%<@@=ctex>
 %</luatex>
 %    \end{macrocode}
 %
@@ -5809,37 +6141,17 @@
 %
 % 按 \pkg{CJK} 的命名习惯模拟部分命令,并设置默认字体。
 %    \begin{macrocode}
-\tl_set:Nn \CJKrmdefault { zhrm }
-\tl_set:Nn \CJKsfdefault { zhsf }
-\tl_set:Nn \CJKttdefault { zhtt }
-\tl_set:Nn \CJKfamilydefault { \CJKrmdefault }
+\tl_if_exist:NF \CJKfamilydefault
+  { \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } }
+\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } }
+\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } }
+\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } }
 \tl_set:Nn \kanjifamilydefault { \CJKfamilydefault }
-\RenewDocumentCommand \rmfamily { }
-  {
-    \not at math@alphabet \rmfamily \mathrm
-    \romanfamily \rmdefault
-    \kanjifamily \CJKrmdefault
-    \selectfont
-  }
-\RenewDocumentCommand \sffamily { }
-  {
-    \not at math@alphabet \sffamily \mathsf
-    \romanfamily \sfdefault
-    \kanjifamily \CJKsfdefault
-    \selectfont
-  }
-\RenewDocumentCommand \ttfamily { }
-  {
-    \not at math@alphabet \ttfamily \mathtt
-    \romanfamily \ttdefault
-    \kanjifamily \CJKttdefault
-    \selectfont
-  }
+\g at addto@macro \@rmfamilyhook { \kanjifamily { \CJKrmdefault } }
+\g at addto@macro \@sffamilyhook { \kanjifamily { \CJKsfdefault } }
+\g at addto@macro \@ttfamilyhook { \kanjifamily { \CJKttdefault } }
 \NewDocumentCommand \CJKfamily { m }
-  {
-    \kanjifamily {#1}
-    \selectfont
-  }
+  { \kanjifamily {#1} \selectfont }
 %    \end{macrocode}
 %
 % \changes{v2.4.15}{2019/04/05}{将 \upLaTeX 的默认字体由 \texttt{mc} 改为
@@ -5847,9 +6159,9 @@
 %
 % 将 \upLaTeX 的默认字体由 |mc| 改为 |zhrm|,并启用 \tn{jfam}。
 %    \begin{macrocode}
-\DeclareErrorKanjiFont{JY2}{zhrm}{m}{n}{10}
-\DeclareKanjiSubstitution{JY2}{zhrm}{m}{n}
-\DeclareKanjiSubstitution{JT2}{zhrm}{m}{n}
+\DeclareErrorKanjiFont    {JY2}{zhrm}{m}{n}{10}
+\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n}
+\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n}
 \DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n}
 \SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n}
 \jfam \symmincho
@@ -5892,19 +6204,20 @@
 % 形如 |upzhserif|,不包括表示方向的后缀 |-h| 与 |-v|。粗体字体名为空时不设置该
 % 字形。本命令不设置字体映射,需要复用已有的字体映射或另行设置。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_set_upfamily:nnn #1 #2 #3
+\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3
   {
     \DeclareKanjiFamily{JY2}{#1}{}
     \DeclareKanjiFamily{JT2}{#1}{}
     \DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{}
     \DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{}
-    \tl_if_empty:nF { #3 }
+    \tl_if_empty:nF {#3}
       {
+        \DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{}
+        \DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{}
         \DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{}
         \DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{}
       }
   }
-\@onlypreamble \ctex_set_upfamily:nnn
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5913,38 +6226,63 @@
 % 的后缀 |b| 与表示排版方向的后缀 |-h| 与 |-v|。|#2| 与 |#3| 是普通与粗体的实际
 % 字体名。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_set_upmap:nnn #1 #2 #3
+\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3
   {
     \ctex_set_zhmap:n
       {
-        \special{ pdf:mapline~ #1-h~   UniGB-UTF16-H~ #2 }
-        \special{ pdf:mapline~ #1-v~   UniGB-UTF16-V~ #2 }
-        \tl_if_empty:nF { #3 }
+        \special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 }
+        \special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 }
+        \tl_if_empty:nF {#3}
           {
-            \special{ pdf:mapline~ #1b-h~  UniGB-UTF16-H~ #3 }
-            \special{ pdf:mapline~ #1b-v~  UniGB-UTF16-V~ #3 }
+            \special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 }
+            \special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 }
           }
       }
   }
-\@onlypreamble \ctex_set_upmap:nnn
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[int]{\ctex_set_upmap_unicode:nnn}
+% 设置 \upTeX{} 字体映射,使用 |unicode| CMap。参数同上。
+%    \begin{macrocode}
+\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3
+  {
+    \ctex_set_zhmap:n
+      {
+        \special { pdf:mapline~#1-h~unicode~#2 }
+        \special { pdf:mapline~#1-v~unicode~#2 }
+        \tl_if_empty:nF {#3}
+          {
+            \special { pdf:mapline~#1b-h~unicode~#3 }
+            \special { pdf:mapline~#1b-v~unicode~#3 }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[int]{\ctex_set_upfonts:nnnnnn}
 % 设置 \upTeX{} 基本字体映射,按 \pkg{zhmetrics-uptex} 的定义,依次设置衬线体
 % 正、粗、意大利,无衬线体正、粗,等宽体正——共 6 种字体,并分横排及直排。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_set_upfonts:nnnnnn #1 #2 #3 #4 #5 #6
+\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6
   {
-    \ctex_set_upmap:nnn { upserif } { #1 } { #2 }
-    \ctex_set_upmap:nnn { upserifit } { #3 } {}
-    \ctex_set_upmap:nnn { upsans } { #4 } { #5 }
-    \ctex_set_upmap:nnn { upmono } { #6 } {}
+    \ctex_set_upmap:nnn { upserif   } {#1} {#2}
+    \ctex_set_upmap:nnn { upserifit } {#3} {}
+    \ctex_set_upmap:nnn { upsans    } {#4} {#5}
+    \ctex_set_upmap:nnn { upmono    } {#6} {}
   }
-\@onlypreamble \ctex_set_upfonts:nnnnnn
 %    \end{macrocode}
 % \end{macro}
 %
+% 以下命令只能在导言区使用。
+%    \begin{macrocode}
+\@onlypreamble \ctex_set_upfamily:nnn
+\@onlypreamble \ctex_set_upmap:nnn
+\@onlypreamble \ctex_set_upmap_unicode:nnn
+\@onlypreamble \ctex_set_upfonts:nnnnnn
+%    \end{macrocode}
+%
 % \changes{v2.4.7}{2016/12/27}{依赖 \pkg{pxeverysel} 宏包。}
 %
 % \pkg{everysel} 宏包(2011/10/28)未考虑 \upLaTeX{} 对 \tn{selectfont} 的修
@@ -5967,7 +6305,7 @@
 % 更新 \tn{CJKfamilydefault}。\pkg{xeCJK} 已经有这个功能,不需要再调整。
 %    \begin{macrocode}
 %<*pdftex|luatex|uptex|aptex>
-\cs_new_protected_nopar:Npn \ctex_update_default_family:
+\cs_new_protected:Npn \ctex_update_default_family:
   {
     \tl_if_eq:NNT \CJKfamilydefault \l_@@_family_default_init_tl
       {
@@ -6012,91 +6350,10 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \subsubsection{操作系统的判断}
-%
 % \changes{v2.0}{2014/04/16}{自动检测操作系统,载入对应的字体配置。}
+% \changes{v2.5}{2019/10/25}{操作系统检测移动至载入中文字库处,且不再需要
+%   依赖特定引擎。}
 %
-% \begin{macro}[int]{\ctex_detected_platform:}
-% 在 \LuaTeX{} 下直接用调用 |os.name| 来判断。
-%    \begin{macrocode}
-%<*luatex>
-\cs_new_protected_nopar:Npn \ctex_detected_platform:
-  {
-    \tl_gset:Nx \g_@@_fontset_tl
-      {
-        \lua_now:e
-          {
-            if ~ os.name == 'windows' then ~
-              tex.sprint ( 'windows' )
-            elseif ~ os.name == 'macosx' then ~
-              tex.sprint ( 'mac' )
-            else ~
-              tex.sprint ( 'fandol' )
-            end
-          }
-      }
-  }
-%</luatex>
-%    \end{macrocode}
-%
-% \ApTeX{} 可以使用 \tn{ngostype} 来判断。
-%    \begin{macrocode}
-%<*aptex>
-\cs_new_protected_nopar:Npn \ctex_detected_platform:
-  {
-    \tl_gset:Nx \g_@@_fontset_tl
-      {
-        \str_case:onF { \ngostype }
-          {
-            { Win32 }  { windows }
-            { Win64 }  { windows }
-            { Darwin } { mac }
-          }
-          { fandol }
-      }
-  }
-%</aptex>
-%    \end{macrocode}
-%
-% \pdfTeX{} 和 \XeTeX{} 下则依据 \file{/dev/null} 和 \file{nul:} 的存在性以及
-% 文件系统的大小写敏感性来判断。Mac~OS~X 的大小写敏感性在安装时是可选的。为了
-% 保险起见,这里的判断很繁琐,最多要进行 4 次文件操作!
-%    \begin{macrocode}
-%<*xetex|pdftex|uptex>
-\cs_new_protected_nopar:Npn \ctex_detected_platform:
-  {
-    \file_if_exist:nTF { /dev/null }
-      {
-        \file_if_exist:nTF { nul: }
-          {
-            \file_if_exist:nTF { \c_@@_upper_case_file_str }
-              { \ctex_if_macosx:TF { mac } { windows } }
-              { \ctex_if_macosx:TF { mac } { fandol } }
-          }
-          { \ctex_if_macosx:TF { mac } { fandol } }
-      }
-      { \tl_gset:Nn \g_@@_fontset_tl { windows } }
-  }
-\str_const:Nx \c_@@_upper_case_file_str
-  { \exp_args:No \str_upper_case:n { \g_file_curr_name_str } }
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}[int]{\ctex_if_macosx:TF}
-% \changes{v2.1}{2015/06/17}{改用 \file{/Library/Fonts/Songti.ttc} 为特征文件。}
-% 以 \file{/Library/Fonts/Songti.ttc} 为特征文件判断 Mac~OS~X。
-%    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2
-  {
-    \file_if_exist:nTF { \c_@@_macosx_file_str }
-      { \tl_gset:Nn \g_@@_fontset_tl {#1} }
-      { \tl_gset:Nn \g_@@_fontset_tl {#2} }
-  }
-\str_const:Nn \c_@@_macosx_file_str { /Library/Fonts/Songti.ttc }
-%</xetex|pdftex|uptex>
-%    \end{macrocode}
-% \end{macro}
-%
 % \subsubsection{\pkg{hyperref} 兼容性处理}
 %
 % \changes{v2.1}{2015/06/16}{不再设置 \pkg{hyperref} 宏包的 \opt{colorlinks} 选项。}
@@ -6113,11 +6370,11 @@
 %<*class|ctex>
 \@ifpackageloaded { hyperref }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \hypersetup {#1} }
   }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \PassOptionsToPackage {#1} { hyperref } }
   }
 %</class|ctex>
@@ -6125,7 +6382,7 @@
 % \end{macro}
 %
 % 在 \pdfTeX{} 下使用 \texttt{GBK} 编码,\dvipdfmx{} 驱动可以直接用它的
-% \tn{special} 命令,其它模式用 \pkg{xCJK2uni} 宏包处理。使用 \texttt{UTF-8} 编
+% \tn{special} 命令,其他模式用 \pkg{xCJK2uni} 宏包处理。使用 \texttt{UTF-8} 编
 % 码时,\pkg{CJKutf8} 已经处理了书签问题,但仍需要设置 \opt{pdfencoding} 为
 % \opt{unicode},目的是在书签的开头写入 BOM (|\376\377|),提示这是
 % \texttt{UTF-16BE} 字节流。
@@ -6132,7 +6389,7 @@
 %    \begin{macrocode}
 %<*pdftex>
 \ctex_hypersetup:n { driverfallback = dvipdfmx }
-\str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
+\str_if_eq:onTF { \g_@@_encoding_tl } { GBK }
   {
     \ctex_hypersetup:n { CJKbookmarks = true }
     \sys_if_output_pdf:TF
@@ -6205,7 +6462,7 @@
 %<*uptex|aptex>
 \ctex_hypersetup:n { driverfallback = dvipdfmx }
 \ctex_at_end_package:nn { hyperref }
-  { \AtBeginShipoutFirst { \special { pdf:tounicode~ UTF8-UTF16 } } }
+  { \AtBeginShipoutFirst { \special { pdf:tounicode~UTF8-UTF16 } } }
 %</uptex|aptex>
 %    \end{macrocode}
 %
@@ -6215,83 +6472,46 @@
 %
 % \subsubsection{\pkg{CJKfntef}、\pkg{xeCJKfntef} 相关设置}
 %
-% \CTeX{} 宏集对 \pdfTeX{} 与 \XeTeX{} 引擎,分别载入 \pkg{CJKfntef} 或
-% \pkg{xeCJKfntef} 宏包,并关闭宏包默认的彩色等多余格式。
-%
 % \changes{v2.0}{2015/03/25}{默认关闭 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 的彩
 % 色设置。}
-% \changes{v2.0}{2015/03/25}{\tn{CTEXunderdot}, \tn{CTEXunderline},
-% \tn{CTEXunderdblline}, \tn{CTEXunderwave}, \tn{CTEXsout}, \tn{CTEXxout} 是过
+% \changes{v2.0}{2015/03/25}{\tn{CTEXunderdot}、\tn{CTEXunderline}、
+% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout} 是过
 % 时命令;\env{CTEXfilltwosides} 是过时环境。}
+% \changes{v2.5}{2019/11/10}{不再自动载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包。}
+% \changes{v2.5}{2019/11/10}{移除 \tn{CTEXunderdot}、\tn{CTEXunderline}、
+% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout}、
+% \env{CTEXfilltwosides} 等命令和环境。}
 %
-% 载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 并做适当格式设置。有关 |\CTEX| 开头
-% 的宏定义是过时命令,仅做兼容性保留。
+% 对 \pdfTeX{} 与 \XeTeX{} 引擎,分别在 \pkg{CJKfntef}、\pkg{xeCJKfntef} 宏包
+% 的末尾关闭彩色显式等多余格式。
 %
 %    \begin{macrocode}
 %<*pdftex>
-\RequirePackage { CJKfntef }
-\normalem
-\cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1
-  { \tl_clear:c { CJK#1color } }
+\ctex_at_end_package:nn { CJKfntef }
+  {
+    \normalem
+    \cs_new_protected:Npn \@@_clear_fntef_color:n #1
+      { \tl_clear:c { CJK#1color } }
 %</pdftex>
 %<*xetex>
-\RequirePackage { xeCJKfntef }
-\@ifpackagelater { xeCJKfntef } { 2014/11/04 }
+\ctex_at_end_package:nn { xeCJKfntef }
   {
-    \cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1
-      { \xeCJKsetup { #1 / format = { } } }
-  }
-  {
-    \cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1
-      { \tl_clear:c { CJK#1color } }
-  }
+    \@ifpackagelater { xeCJKfntef } { 2014/11/04 }
+      {
+        \cs_new_protected:Npn \@@_clear_fntef_color:n #1
+          { \xeCJKsetup { #1 / format = { } } }
+      }
+      {
+        \cs_new_protected:Npn \@@_clear_fntef_color:n #1
+          { \tl_clear:c { CJK#1color } }
+      }
 %</xetex>
-%<*luatex|uptex|aptex>
-\msg_new:nnn { ctex } { fntef-not-available }
-%<luatex>  { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ LuaLaTeX. }
-%<uptex>  { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ upLaTeX. }
-%<aptex>  { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ ApLaTeX. }
-\msg_warning:nn { ctex } { fntef-not-available }
-%</luatex|uptex|aptex>
-\clist_map_inline:nn
-  { underdot , underline , underdblline , underwave , sout , xout }
 %<*pdftex|xetex>
-  {
-    \@@_clear_fntef_color:n {#1}
-    \cs_new_protected_nopar:cpx { CTEX#1 }
-      {
-        \msg_warning:nnnn { ctex } { deprecated-command } { \exp_not:c { CTEX#1 } }
-          { You~ can~ use~ the~ command~ with~ prefix~ \exp_not:N \CJK~ instead. }
-        \exp_not:c { CJK#1 }
-      }
+    \clist_map_inline:nn
+      { underdot , underline , underdblline , underwave , sout , xout }
+      { \@@_clear_fntef_color:n {#1} }
   }
-\cs_new_protected_nopar:Npn { \CTEXfilltwosides }
-  {
-    \msg_warning:nnnn { ctex } { deprecated-environment } { CTEXfilltwosides }
-      { You~ can~ use~ `CJKfilltwosides'~ environment~ instead. }
-    \CJKfilltwosides
-  }
-\cs_new_protected_nopar:Npn { \endCTEXfilltwosides } { \endCJKfilltwosides }
 %</pdftex|xetex>
-%<*luatex|uptex|aptex>
-  { \cs_new_eq:cN { CTEX#1 } \use:n }
-\cs_new_eq:NN \CTEXfilltwosides \use_none:n
-\cs_new_eq:NN \endCTEXfilltwosides \prg_do_nothing:
-%</luatex|uptex|aptex>
-%<*pdftex>
-\clist_map_inline:nn
-  {
-    underdotbasesep ,   underdotsep ,     underlinebasesep ,
-    underlinesep ,      underdbllinesep , underdbllinebasesep ,
-    underwavebasesep ,  underwavesep ,    southeight ,
-    underdotcolor ,     underwavecolor ,  underlinecolor ,
-    underdbllinecolor , soutcolor ,       xoutcolor
-  }
-  {
-    \cs_new_eq:cc { CTEX#1 } { CJK#1 }
-    \cs_set_nopar:cpx { CJK#1 } { \exp_not:c { CTEX#1 } }
-  }
-%</pdftex>
 %    \end{macrocode}
 %
 % \subsubsection{\tn{ccwd} 的更新}
@@ -6299,7 +6519,7 @@
 % \begin{macro}[int]{\ctex_update_ccwd:,\ccwd}
 % \changes{v2.4.1}{2016/04/29}{正确设置 \upTeX{} 下的 \tn{ccwd}。}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_ccwd:
+\cs_new_protected:Npn \ctex_update_ccwd:
 %<*pdftex|xetex>
   {
     \hbox_set:Nn \l_@@_tmp_box { \CJKglue }
@@ -6319,10 +6539,10 @@
 % \begin{macro}[int]{\ctex_update_ccglue:}
 % 更新字间距。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_ccglue:
+\cs_new_protected:Npn \ctex_update_ccglue:
 %<*pdftex|xetex>
   {
-    \cs_set_protected_nopar:Npn \CJKglue
+    \cs_set_protected:Npn \CJKglue
       { \skip_horizontal:N \l_@@_ccglue_skip }
   }
 %</pdftex|xetex>
@@ -6354,14 +6574,8 @@
       { \prg_return_false: } { \prg_return_true: }
 %</uptex|aptex>
   }
+%<pdftex|xetex>\ctex_at_end:n { \cs_new_eq:NN \@@_ccglue: \CJKglue }
 %    \end{macrocode}
-% 注意下面的标记不能用 \verb"%<pdftex|xetex>",它会导致旧版本的 \pkg{l3docstrip}
-% 不能替换 \texttt{@@}。
-%    \begin{macrocode}
-%<*pdftex|xetex>
-\ctex_at_end:n { \cs_new_eq:NN \@@_ccglue: \CJKglue }
-%</pdftex|xetex>
-%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}[int]{\ctex_update_em_unit:}
@@ -6374,7 +6588,7 @@
 % 意义。在 \LuaTeX{} 下,\pkg{LuaTeX-ja} 总是按照 JFM 中的设置输出汉字的宽度,可以
 % 直接用 \tn{zw} 作为汉字宽度。\upTeX{} 可以直接使用原生的长度单位 |zw|。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_em_unit:
+\cs_new_protected:Npn \ctex_update_em_unit:
 %<pdftex|xetex>  { \dim_set:Nn \ccwd { \f at size \p@ } }
 %<luatex>  { \dim_set:Nn \ccwd { \zw } }
 %<uptex|aptex>  { \dim_set:Nn \ccwd { 1zw } }
@@ -6381,20 +6595,22 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsubsection{其它}
+% \subsubsection{其他}
 %
+% \begin{macro}[int]{\ctex_add_to_selectfont:n,\CTEX at selectfont@hook}
 % \changes{v2.4.13}{2018/03/23}{修正导言区 \tn{selectfont} 钩子位置。}
+% \changes{v2.5}{2020/04/19}{兼容 \pkg{KOMA-Script} 的 \tn{selectfont} 补丁。}
 %
-% \begin{macro}[int]{\ctex_add_to_selectfont:n,\CTEX at selectfont@hook}
 % \tn{EverySelectfont} 直到文档开始时才有效。为了 \tn{ccwd} 和 \pkg{LuaTeX-ja} 的
 % 字体设置在导言区也可用,我们还需要在这里手工修改 \tn{selectfont}。\pkg{everysel}
 % 宏包会用 \tn{CheckCommand} 来检查 \tn{selectfont} 是否为标准定义。我们修改了
 % \tn{selectfont},所以会给出一个警告。为了消除这个警告,在它检查之前,还原本来
 % 定义。\pkg{pxeverysel} 宏包取消了检查,但也需要恢复定义,避免重复使用钩子。
+% \pkg{KOMA-Script} 宏包也会进行检查,我们需要小心处理。
 %    \begin{macrocode}
 \cs_new_protected:Npn \ctex_add_to_selectfont:n #1
   {
-    \cs_set_protected_nopar:Npx \CTEX at selectfont@hook
+    \cs_set_protected:Npx \CTEX at selectfont@hook
       { \exp_not:o { \CTEX at selectfont@hook #1 } }
   }
 \cs_new_eq:NN \CTEX at selectfont@hook \prg_do_nothing:
@@ -6404,10 +6620,32 @@
       {
         \tl_set:Nn \l_@@_tmp_tl {#1}
         \cs_new_eq:NN \CTEX at selectfont@save #1
-        \cs_new_protected_nopar:Npn \@@_restore_selectfont:
+        \cs_new_protected:Npn \@@_restore_selectfont:
           {
+            \cs_if_free:NF \scr at new@selectfont
+              {
+%    \end{macrocode}
+% \pkg{CJK} 直接修改 \tn{selectfont} 和 \pkg{pxeverysel} 的补丁,
+% 会使 \pkg{KOMA-Script} 的 \tn{par at update} 失效。
+%    \begin{macrocode}
+%<*pdftex|uptex|aptex>
+                \cs_if_free:NF \par at update
+%<*uptex|aptex>
+                  {
+                    \tl_put_right:Nn \@EverySelectfont at Init
+                      { \tl_put_right:Nn #1 { \par at update } }
+                  }
+%</uptex|aptex>
+%<*pdftex>
+                  { \tl_put_right:Nn #1 { \par at update } }
+                \cs_set_eq:NN \scr at selectfont \CTEX at selectfont@save
+%</pdftex>
+%</pdftex|uptex|aptex>
+                \cs_set_eq:NN \scr at new@selectfont #1
+%<!pdftex>                \cs_set_eq:NN \CTEX at selectfont@save \scr at selectfont
+              }
             \tl_put_left:Nn \@EverySelectfont at Init
-              { \let #1 \CTEX at selectfont@save }
+              { \cs_set_eq:NN #1 \CTEX at selectfont@save }
             \cs_undefine:N \@@_restore_selectfont:
           }
       }
@@ -6458,7 +6696,7 @@
 % 全段。
 %    \begin{macrocode}
 %<*luatex|uptex|aptex>
-\cs_new_protected_nopar:Npn \ctex_update_xkanjiskip:
+\cs_new_protected:Npn \ctex_update_xkanjiskip:
   {
     \skip_if_eq:nnT
 %<luatex>      { \ltjgetparameter { xkanjiskip } } { \l_@@_xkanjiskip_skip }
@@ -6488,7 +6726,7 @@
 %
 % \changes{v2.4.10}{2017/07/23}{定义 \tn{cht},\tn{cdp} 和 \tn{cwd}。}
 %
-% \begin{macro}[int]{\cht,\cdp,\cwd}
+% \begin{macro}[int]{\cht,\cdp,\cwd,\ctex_update_kanjisize:}
 % 分别从 \file{.jfm} 中读取字符高度、深度和宽度,目前仅考虑横排的情况。
 %    \begin{macrocode}
 %<*luatex>
@@ -6495,28 +6733,27 @@
 \dim_new:N \cht
 \dim_new:N \cdp
 \dim_new:N \cwd
-\newluafunction \g_@@_kanjisize_func
 \group_begin:
 \char_set_catcode_space:n { 32 }
 \lua_now:e
   {
     local nulltable = { }
-    local t = lua.get_functions_table()
     local fmt = luatexja.jfont.font_metric_table
     local getattribute = tex.getattribute
     local setdimen = tex.setdimen
-    t[\int_use:N \g_@@_kanjisize_func] = function ()
-      local ft = fmt[getattribute('ltj at curjfnt')] or nulltable
+    local func = lua.get_functions_table()
+    local id = luatexbase.new_luafunction("ctex")
+    func[id] = function ()
+      local ft = fmt[getattribute("ltj at curjfnt")] or nulltable
       local ft = ft and ft.char_type or nulltable
       local fk = ft and ft[0] or nulltable
-      setdimen('cht', fk.height or 0)
-      setdimen('cdp', fk.depth or 0)
-      setdimen('cwd', fk.width or ft.zw or 0)
+      setdimen("cht", fk.height or 0)
+      setdimen("cdp", fk.depth or 0)
+      setdimen("cwd", fk.width or ft.zw or 0)
     end
+    token.set_lua("ctex_update_kanjisize:", id, "global", "protected")
   }
 \group_end:
-\cs_new_protected_nopar:Npn \ctex_update_kanjisize:
- { \tex_luafunction:D \g_@@_kanjisize_func }
 \ctex_add_to_selectfont:n { \ctex_update_kanjisize: }
 %</luatex>
 %    \end{macrocode}
@@ -6527,7 +6764,7 @@
 % \pdfTeX{} 和 \XeTeX{} 下初始设置为 \opt{auto},\LuaTeX{}、\upTeX{} 下是无效
 % 选项。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
 %<*pdftex|xetex>
     space .choice: ,
@@ -6555,11 +6792,11 @@
 % 在导言区或正文中设置标点符号输出格式。\pkg{LuaTeX-ja} 设置的是字体的默认 \texttt{JFM},
 % 只会影响到之后设置的字体。\upTeX{} 暂时无效。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     punct .code:n =
       {
-        \tl_set:Nx \l_@@_punct_tl { #1 }
+        \tl_set:Nx \l_@@_punct_tl {#1}
 %<pdftex>        \punctstyle { \l_@@_punct_tl }
 %<xetex>        \xeCJKsetup { PunctStyle = \l_@@_punct_tl }
 %<luatex>        \ctex_mono_jfm:o { \l_@@_punct_tl }
@@ -6570,14 +6807,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \XeLaTeX{}、\LuaLaTeX{} 和 \upLaTeX{} 总是使用 \texttt{UTF8} 编码。
 %    \begin{macrocode}
-%<*xetex|luatex|uptex|aptex>
-\tl_set:Nn \l_@@_encoding_tl { UTF8 }
-%</xetex|luatex|uptex|aptex>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
 %</pdftex|xetex|luatex|uptex|aptex>
 %    \end{macrocode}
 %
@@ -6597,7 +6827,7 @@
 % \begin{macro}{\ctexset}
 %    \begin{macrocode}
 %<*class|ctex|ctexheading>
-\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
+\NewDocumentCommand \ctexset { } { \ctex_set:n }
 %</class|ctex|ctexheading>
 %    \end{macrocode}
 % \end{macro}
@@ -6604,20 +6834,28 @@
 %
 % \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。}
 % \begin{macro}{\CTEXsetup,\CTEXoptions}
-% 过时命令。出于历史原因,\tn{CTEXoptions} 需要在 \pkg{pxeverysel} 宏包之后定义。
+% 过时命令。
 %    \begin{macrocode}
 %<*class|ctex>
-\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
+\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
-      { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXsetup { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXsetup
+          { \ctexset {~#2~=~{~#1~}~}~is~set. }
+        \ctex_set:nn {#2} {#1}
+      }
   }
-\NewDocumentCommand \CTEXoptions { +o }
+\NewDocumentCommand \CTEXoptions { +O { } }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions }
-      { \ctexset~ {~ #1~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXoptions { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXoptions
+          { \ctexset {~#1~}~is~set. }
+        \ctex_set:n {#1}
+      }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -6627,7 +6865,7 @@
 % \begin{macro}{autoindent}
 % \opt{autoindent} 也是可以用在正文中的选项,意义与宏包选项 |option/autoindent| 相同。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     autoindent .choice: ,
     autoindent .default:n = { true } ,
@@ -6651,7 +6889,7 @@
 % 无论字体大小是否变化都更新相关信息。
 %    \begin{macrocode}
 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
-\cs_new_protected_nopar:Npn \ctex_select_size:
+\cs_new_protected:Npn \ctex_select_size:
   { \cs_if_free:NTF \size at update { \ctex_update_size: } { \selectfont } }
 %    \end{macrocode}
 % \end{macro}
@@ -6659,7 +6897,7 @@
 % \begin{macro}[int]{\ctex_update_size:}
 % 在字号变化时更新 \tn{ccwd}、\tn{parindent} 和汉字间距。字距为零则恢复正常设置。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_size:
+\cs_new_protected:Npn \ctex_update_size:
   {
     \tl_if_eq:NNTF \l_@@_ziju_tl \c_@@_zero_tl
       {
@@ -6687,7 +6925,7 @@
 % 额外伸展量。初始化为一个汉字的宽度。若设置为 \tn{maxdimen},则禁用此功能。
 % 参数的默认单位是汉字的宽度 \tn{ccwd}。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     linestretch .code:n =
       {
@@ -6710,7 +6948,7 @@
 % \tn{ccwd},否则设置伸展量为 $0.08$ 倍 \tn{baselineskip}。注意 \pkg{everysel} 的
 % 钩子位于 \tn{size at update} 之前,\tn{baselineskip} 还未更新,不能直接使用它。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_stretch:
+\cs_new_protected:Npn \ctex_update_stretch:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l_@@_tmp_dim { \l_@@_line_stretch_tl }
@@ -6751,7 +6989,7 @@
 % \begin{macro}[int]{\ctex_update_parindent:}
 % 更新段落首行缩进。此函数在字号变化时调用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_parindent:
+\cs_new_protected:Npn \ctex_update_parindent:
   {
     \tl_if_empty:NF \l_@@_autoindent_tl
       {
@@ -6767,7 +7005,7 @@
 %    \begin{macrocode}
 \NewDocumentCommand \ziju { m }
   { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ziju:n #1
+\cs_new_protected:Npn \ctex_ziju:n #1
   {
     \tl_set:Nx \l_@@_ziju_tl { \fp_eval:n {#1} }
     \ctex_select_size:
@@ -6779,7 +7017,7 @@
 % 更新字距。若字距不大于 $-1$,即 \tn{ccwd} 为非正值,则不计算伸缩值。
 % 否则,首先假定汉字的宽度为正常宽度加上字距,看一行上能正常放下多少个汉字。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_update_ziju:
+\cs_new_protected:Npn \ctex_update_ziju:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l_@@_ziju_dim { \l_@@_ziju_tl \ccwd }
@@ -6832,14 +7070,15 @@
 %    \begin{macrocode}
 \NewDocumentCommand \CTEXindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent }
-      { \parindent is~ set~ to~ 2\ccwd. }
-    \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd }
+    \ctex_deprecated_command:Nn \CTEXindent
+      { \parindent is~set~to~2\ccwd. }
+    \ctex_update_ccwd:
+    \dim_set:Nn \parindent { 2 \ccwd }
   }
 \NewDocumentCommand \CTEXnoindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent }
-      { \parindent is~ set~ to~ 0pt. }
+    \ctex_deprecated_command:Nn \CTEXnoindent
+      { \parindent is~set~to~0pt. }
     \dim_zero:N \parindent
   }
 %    \end{macrocode}
@@ -6848,7 +7087,7 @@
 % \subsection{中文数字与日期}
 %
 %    \begin{macrocode}
-\PassOptionsToPackage { encoding = \l_@@_encoding_tl } { zhnumber }
+\PassOptionsToPackage { encoding = \g_@@_encoding_tl } { zhnumber }
 \RequirePackage { zhnumber }
 %    \end{macrocode}
 %
@@ -6855,7 +7094,7 @@
 % \begin{macro}{\chinese}
 % \changes{v2.4.1}{2016/05/01}{支持 \tn{pagenumbering}。}
 %    \begin{macrocode}
-\cs_new_nopar:Npn \chinese { \zhnum_counter:n }
+\cs_new:Npn \chinese { \zhnum_counter:n }
 \cs_new_eq:NN \@chinese \@zhnum
 \cs_new_eq:NN \Chinese \chinese
 \cs_new_eq:NN \CTEXcounter \use_none:n
@@ -6890,7 +7129,7 @@
 % \begin{macro}{today}
 %    \begin{macrocode}
 \cs_set_eq:NN \CTEX at todayold \today
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     today .choice: ,
     today / old     .code:n =
@@ -6914,7 +7153,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsection{其它中文标题定义}
+% \subsection{其他中文标题定义}
 %
 % \changes{v2.0}{2014/03/08}{将标题汉化功能加入 \pkg{ctex.sty}。}
 % \changes{v2.4.3}{2016/08/18}{确保 \tn{proofname} 非空。}
@@ -6931,7 +7170,7 @@
 % \end{macro}
 %
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     contentsname   .tl_set:N = \contentsname ,
     listfigurename .tl_set:N = \listfigurename ,
@@ -6962,7 +7201,7 @@
   }
 \tl_if_exist:NTF \insertcontinuationtext
   {
-    \keys_define:nn { ctex }
+    \ctex_define:n
       {
         algorithmname .tl_set:N = \algorithmname ,
         bibname       .tl_set:N = \bibname ,
@@ -6972,13 +7211,13 @@
   }
   {
     \tl_if_exist:NTF \bibname
-      { \keys_define:nn { ctex } { bibname .tl_set:N = \bibname } }
+      { \ctex_define:n { bibname .tl_set:N = \bibname } }
       {
         \tl_if_exist:NTF \refname
-          { \keys_define:nn { ctex } { bibname .tl_set:N = \refname } }
+          { \ctex_define:n { bibname .tl_set:N = \refname } }
           {
             \msg_warning:nn { ctex } { ctexbibname }
-            \keys_define:nn { ctex } { bibname .tl_set:N = \ctexbibname }
+            \ctex_define:n { bibname .tl_set:N = \ctexbibname }
           }
       }
   }
@@ -7028,7 +7267,7 @@
 %
 % \begin{macro}{\@@_initial_heading:n}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_initial_heading:n #1
+\cs_new_protected:Npn \@@_initial_heading:n #1
   {
     \tl_new:c { CTEX at pre#1 }
     \tl_new:c { CTEX at post#1 }
@@ -7078,7 +7317,7 @@
 %
 % \begin{macro}{\@@_def_heading_keys:n}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_def_heading_keys:n #1
+\cs_new_protected:Npn \@@_def_heading_keys:n #1
   {
     \tl_put_right:Nx \l_@@_tmp_tl
       {
@@ -7103,11 +7342,8 @@
         #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
         #1 / hang         .initial:n = true ,
         #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
+        #1 / tocline      .cs_set:Np = \exp_not:c { CTEX@#1 at tocline}
+                                       \exp_not:n { ##1##2 } ,
         \@@_plus_key_aux:nn {#1} { break } ,
 %</article|book|report>
         \@@_plus_key_aux:nn {#1} { format } ,
@@ -7118,7 +7354,7 @@
         \@@_plus_key_aux:nn {#1} { aftertitle } ,
       }
   }
-\cs_new_nopar:Npn \@@_plus_key_aux:nn #1#2
+\cs_new:Npn \@@_plus_key_aux:nn #1#2
   {
     #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
     #1 / #2 +   .code:n =
@@ -7143,7 +7379,7 @@
 \cs_new_protected:Npn \@@_assign_heading_name:nnn #1#2#3
   {
     \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
+    \tl_if_novalue:nTF {#3}
       { \tl_clear:c { CTEX at post#1 } }
       { \tl_set:cn { CTEX at post#1 } {#3} }
   }
@@ -7189,24 +7425,54 @@
     \@@_initial_heading:n {#1}
     \@@_def_heading_keys:n {#1}
   }
-\use:x
+\exp_args:NNo \group_end: \ctex_define:n { \l_@@_tmp_tl }
+%    \end{macrocode}
+%
+% \changes{v2.5}{2020/04/23}{重构标题选项 \opt{indent} 和 \opt{hang}。}
+%
+% \begin{macro}[int]{\CTEX at heading@format at initial}
+% 标题格式的一些初始设置,包括恢复默认字体,并禁用自动调整首行缩进,禁止在标题中分页。
+% 同时用 \tn{noindent} 抑制首行缩进并进入水平模式。
+% 统一在各级标题的 \opt{format} 选项之前使用。
+%    \begin{macrocode}
+\cs_new_protected:Npn \CTEX at heading@format at initial
   {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l_@@_tmp_tl } }
+    \normalfont
+    \tl_clear:N \l_@@_autoindent_tl
+    \int_set:Nn \tex_interlinepenalty:D { 10 000 }
+    \tex_noindent:D
   }
 %    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}[int]{\ctex_indent_box:n}
+% 设置 \tn{parindent},并插入用于产生缩进的盒子,如果缩进为 |0|,就不插入。
 %    \begin{macrocode}
-%<*article|book|report>
+\cs_new_protected:Npn \ctex_indent_box:n #1
+  {
+    \dim_set:Nn \tex_parindent:D {#1}
+    \@@_insert_indent:
+  }
+\cs_new_protected:Npn \@@_insert_indent:
+  {
+    \dim_compare:nNnF \tex_parindent:D = \c_zero_dim
+      { \tex_indent:D }
+  }
+\cs_new_eq:NN \CTEX at indentbox \ctex_indent_box:n
 %    \end{macrocode}
+% \end{macro}
 %
 % \subsubsection{标准标题命令的修改}
 %
+%    \begin{macrocode}
+%<*article|book|report>
+%    \end{macrocode}
+%
 % \begin{macro}[int]{\CTEX at fixtopskip}
 % 修正 \cls{book} 和 \cls{report} 类的 \tn{part} 和 \tn{chapter} 标题之前的多余空行。
 %    \begin{macrocode}
 %<*book|report>
-\cs_new_protected_nopar:Npn \CTEX at fixtopskip
+\cs_new_protected:Npn \CTEX at fixtopskip
   {
     \CTEX at fixheadingskip
     \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim
@@ -7222,7 +7488,7 @@
 % \TeX{} 就不会加上 \tn{parskip}。这时候就需要用户把 \tn{parskip} 加到 \opt{beforeskip}
 % 或者 \opt{afterskip} 作为修正。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
+\cs_new_protected:Npn \CTEX at fixheadingskip
   {
     \par
     \dim_set:Nn \tex_prevdepth:D { -1000pt }
@@ -7229,7 +7495,7 @@
     \skip_sub:Nn \l_@@_heading_skip { \tex_parskip:D }
   }
 \skip_new:N \l_@@_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
+\cs_new_protected:Npn \CTEX at setheadingskip
   { \skip_set:Nn \l_@@_heading_skip }
 \cs_new_eq:NN \CTEX at headingskip \l_@@_heading_skip
 %    \end{macrocode}
@@ -7251,9 +7517,9 @@
 % 用于判断当前标题是否有编号。
 %    \begin{macrocode}
 \cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
+\cs_new_protected:Npn \CTEX at ifnametrue
   { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
+\cs_new_protected:Npn \CTEX at ifnamefalse
   { \cs_set_eq:NN \CTEXifname \use_ii:nn }
 %    \end{macrocode}
 % \end{macro}
@@ -7263,7 +7529,7 @@
 % 往插图和表格目录中加入额外间距。如果间距为零,则不加入。
 %    \begin{macrocode}
 %<*book|report>
-\cs_new_protected_nopar:Npn \CTEX at addloflotskip #1
+\cs_new_protected:Npn \CTEX at addloflotskip #1
   {
     \skip_set:Nn \l_@@_heading_skip { \use:c { CTEX@#1 at lofskip } }
     \skip_if_eq:nnF { \l_@@_heading_skip } { \c_zero_skip }
@@ -7289,14 +7555,6 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]{\CTEX at disableautoindent}
-% 禁用自动调整首行缩进。
-%    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l_@@_autoindent_tl }
-%    \end{macrocode}
-% \end{macro}
-%
 % \changes{v2.2}{2015/06/27}{\opt{beforeskip}、\opt{afterskip} 和 \opt{indent}
 %   选项支持表达式。}
 % \changes{v2.4.15}{2019/03/31}{修正 \opt{part/indent} 和 \opt{chapter/indent} 的实现方法。}
@@ -7304,12 +7562,10 @@
 % \changes{v2.4.16}{2019/05/11}{修正 \opt{part/indent} 和 \opt{chapter/indent}
 %   的实现方法,在其标题内部禁用 \opt{autoindent}。}
 %
+% \changes{v2.5}{2020/04/22}{标题选项 \opt{format} 也可以接受参数。}
+%
 % \paragraph{part 的标题}
 %
-%    \begin{macrocode}
-%<@@=>
-%    \end{macrocode}
-%
 % \changes{v2.2}{2015/06/27}{非 \cls{ctexart} 类的 \opt{part/beforeskip} 和
 %   \opt{part/afterskip} 选项有意义。}
 %
@@ -7317,19 +7573,19 @@
 %    \begin{macrocode}
 %<*article>
 \renewcommand\part{%
-   \if at noskipsec \leavevmode \fi
-   \par
-   \CTEX at part@break
-%  \addvspace{4ex}%
-   \CTEX at setheadingskip \CTEX at part@beforeskip
-   \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-   \addvspace \CTEX at headingskip
-   \ifodd \CTEX at part@afterindent
-     \@afterindenttrue
-   \else
-     \@afterindentfalse
-   \fi
-   \secdef\@part\@spart}
+  \if at noskipsec \leavevmode \fi
+  \par
+  \CTEX at part@break
+% \addvspace{4ex}%
+  \CTEX at setheadingskip \CTEX at part@beforeskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \addvspace \CTEX at headingskip
+  \ifodd \CTEX at part@afterindent
+   \@afterindenttrue
+  \else
+   \@afterindentfalse
+  \fi
+  \secdef\@part\@spart}
 %</article>
 %<*book|report>
 \renewcommand\part{%
@@ -7377,20 +7633,21 @@
   \fi
   \CTEX at gettitle{#1}%
   \CTEX at addtocline{part}{#1}%
-  {\interlinepenalty \@M
-%  \normalfont \parindent \z@ \raggedright
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-%  \ifnum \c at secnumdepth >\m at ne
-%    \Large\bfseries\partname\nobreakspace\thepart\par\nobreak
-%  \fi
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-%  \huge\bfseries #2%
-   \CTEX at part@titleformat{#2}%
-%  \markboth{}{}%
-   \partmark{#1}%
-   \CTEX at part@aftertitle}%
+  \partmark{#1}%
+  \begingroup
+%   \parindent \z@ \raggedright \interlinepenalty \@M \normalfont
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+%   \ifnum \c at secnumdepth >\m at ne
+%     \Large\bfseries\partname\nobreakspace\thepart\par\nobreak
+%   \fi
+      \CTEX at headinghang{part}%
+        {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
+%   \huge\bfseries #2%
+        \CTEX at part@titleformat{#2}%
+%   \markboth{}{}\par
+        \CTEX at part@aftertitle}\par
+  \endgroup
   \nobreak
 % \vskip 3ex
   \CTEX at setheadingskip \CTEX at part@afterskip
@@ -7418,19 +7675,20 @@
   \CTEX at gettitle{#1}%
   \CTEX at addtocline{part}{#1}%
 %  \markboth{}{}%
-   \partmark{#1}%
-  {\interlinepenalty \@M
-%  \normalfont \centering
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-%  \ifnum \c at secnumdepth >-2\relax
-%    \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@
-%  \fi
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-%  \Huge\bfseries #2\par}%
-   \CTEX at part@titleformat{#2}%
-   \CTEX at part@aftertitle}%
+  \partmark{#1}%
+  \begingroup
+%   \centering \interlinepenalty \@M \normalfont
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+%   \ifnum \c at secnumdepth >-2\relax
+%     \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@
+%   \fi
+      \CTEX at headinghang{part}%
+        {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
+%   \Huge\bfseries #2\par
+      \CTEX at part@titleformat{#2}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
   \@endpart}
 %</book|report>
 %    \end{macrocode}
@@ -7440,38 +7698,40 @@
 %    \begin{macrocode}
 %<*article>
 \def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-%    \normalfont \parindent \z@ \raggedright
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-%    \huge \bfseries #1\par}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-     \nobreak
-%    \vskip 3ex
-     \CTEX at setheadingskip \CTEX at part@afterskip
-     \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-     \vskip \CTEX at headingskip
-     \@afterheading}
+  \CTEX at ifnamefalse
+  \CTEX at makeanchor@spart{part*}%
+  \CTEX at gettitle{#1}%
+  \begingroup
+%   \parindent \z@ \raggedright \interlinepenalty \@M \normalfont
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}{}%
+%   \huge \bfseries #1\par
+      \CTEX at part@titleformat{#1}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
+  \nobreak
+% \vskip 3ex
+  \CTEX at setheadingskip \CTEX at part@afterskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip
+  \@afterheading}
 %</article>
 %<*book|report>
 \def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-%    \normalfont \centering
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-%    \Huge \bfseries #1\par}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-    \@endpart}
+  \CTEX at ifnamefalse
+  \CTEX at makeanchor@spart{part*}%
+  \CTEX at gettitle{#1}%
+  \begingroup
+%   \centering \interlinepenalty \@M \normalfont
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}{}%
+%    \Huge \bfseries #1\par%
+      \CTEX at part@titleformat{#1}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
+  \@endpart}
 %</book|report>
 %    \end{macrocode}
 % \end{macro}
@@ -7480,21 +7740,21 @@
 %    \begin{macrocode}
 %<*book|report>
 \def\@endpart{%
-%             \vfil
-              \CTEX at setheadingskip \CTEX at part@afterskip
-              \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-              \vskip \CTEX at headingskip
-              \newpage
-              \if at twoside
-               \if at openright
-                \null
-                \thispagestyle{empty}%
-                \newpage
-               \fi
-              \fi
-              \if at tempswa
-                \twocolumn
-              \fi}
+% \vfil
+  \CTEX at setheadingskip \CTEX at part@afterskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip
+  \newpage
+  \if at twoside
+    \if at openright
+      \null
+      \thispagestyle{empty}%
+      \newpage
+    \fi
+  \fi
+  \if at tempswa
+    \twocolumn
+  \fi}
 %</book|report>
 %    \end{macrocode}
 % \end{macro}
@@ -7508,18 +7768,18 @@
 % \begin{macro}[int]{\chapter}
 %    \begin{macrocode}
 \renewcommand\chapter{%
-%                   \if at openright\cleardoublepage\else\clearpage\fi
-%                   \thispagestyle{plain}%
-                    \CTEX at chapter@break
-                    \thispagestyle{\CTEX at chapter@pagestyle}%
-                    \global\@topnum\z@
-%                   \@afterindentfalse
-                    \ifodd \CTEX at chapter@afterindent
-                      \@afterindenttrue
-                    \else
-                      \@afterindentfalse
-                    \fi
-                    \secdef\@chapter\@schapter}
+% \if at openright\cleardoublepage\else\clearpage\fi
+% \thispagestyle{plain}%
+  \CTEX at chapter@break
+  \thispagestyle{\CTEX at chapter@pagestyle}%
+  \global\@topnum\z@
+% \@afterindentfalse
+  \ifodd \CTEX at chapter@afterindent
+    \@afterindenttrue
+  \else
+    \@afterindentfalse
+  \fi
+  \secdef\@chapter\@schapter}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -7591,26 +7851,26 @@
   \CTEX at setheadingskip \CTEX at chapter@beforeskip
   \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
   \vspace*{\CTEX at headingskip}%
-% {\normalfont \parindent \z@ \raggedright
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-%  \ifnum \c at secnumdepth >\m at ne
-%    \if at mainmatter
-%      \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@
-%    \fi
-%  \fi
-   \CTEX at hangindent{chapter}%
-     {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
-%  \Huge \bfseries #1\par\nobreak
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
+  \begingroup
+%   \parindent \z@ \raggedright \normalfont
+    \CTEX at heading@format at initial
+    \CTEX at chapter@format{%
+%   \ifnum \c at secnumdepth >\m at ne
+%     \if at mainmatter
+%       \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@
+%     \fi
+%   \fi
+      \CTEX at headinghang{chapter}%
+        {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
+%   \Huge \bfseries #1\par\nobreak
+      \CTEX at chapter@titleformat{#1}%
+      \CTEX at chapter@aftertitle}\par
+  \endgroup
+  \nobreak
 %  \vskip 40\p@
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
+  \CTEX at setheadingskip \CTEX at chapter@afterskip
+  \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -7621,20 +7881,20 @@
   \CTEX at setheadingskip \CTEX at chapter@beforeskip
   \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
   \vspace*{\CTEX at headingskip}%
-% {\normalfont \parindent \z@ \raggedright
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}{}%
-%  \Huge \bfseries  #1\par\nobreak
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-%  \vskip 40\p@
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
+  \begingroup
+% \parindent \z@ \raggedright \normalfont \interlinepenalty\@M
+    \CTEX at heading@format at initial
+    \CTEX at chapter@format{%
+      \CTEX at headinghang{chapter}{}%
+%     \Huge \bfseries  #1\par\nobreak
+      \CTEX at chapter@titleformat{#1}%
+      \CTEX at chapter@aftertitle}\par
+  \endgroup
+  \nobreak
+% \vskip 40\p@
+  \CTEX at setheadingskip \CTEX at chapter@afterskip
+  \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -7645,6 +7905,11 @@
 % \paragraph{section 类的标题}
 %
 % \begin{macro}[int]{\@startsection}
+% \LaTeX 的标准参数是:
+% \begin{quote}\small
+%   \Arg{name}\Arg{level}\Arg{indent}\Arg{beforeskip}\Arg{afterskip}^^A
+%   \Arg{style}|*|\oarg{altheading}\Arg{heading}
+% \end{quote}
 %    \begin{macrocode}
 \def\@startsection#1#2#3#4#5#6{%
   \if at noskipsec \leavevmode \fi
@@ -7707,12 +7972,13 @@
 % \ifdim \@tempskipa>\z@
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-%       \interlinepenalty \@M #8\@@par}%
-        \interlinepenalty \@M
+%       \@hangfrom{\hskip #3\relax\@svsec}%
+%       \interlinepenalty \@M #8\@@@@par
+        \CTEX at sectionhang{#3}{\@svsec}%
         \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
+        \csname CTEX@#1 at aftertitle\endcsname}\par
     \endgroup
     \csname #1mark\endcsname{#7}%
 %   \addcontentsline{toc}{#1}{%
@@ -7723,18 +7989,18 @@
     \CTEX at addtocline{#1}{#7}%
   \else
     \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-%     \@svsec #8}%
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-%   \addcontentsline{toc}{#1}{%
-%     \ifnum #2>\c at secnumdepth \else
-%       \protect\numberline{\csname the#1\endcsname}%
-%     \fi
-%     #7}%
-    \CTEX at addtocline{#1}{#7}}%
+      #6{%
+%       \hskip #3\relax \@svsec #8
+        {\CTEX at indentbox{#3}}\@svsec
+        \csname CTEX@#1 at titleformat\endcsname{#8}%
+        \csname CTEX@#1 at aftertitle\endcsname}%
+      \csname #1mark\endcsname{#7}%
+%     \addcontentsline{toc}{#1}{%
+%       \ifnum #2>\c at secnumdepth \else
+%         \protect\numberline{\csname the#1\endcsname}%
+%       \fi
+%       #7}%
+      \CTEX at addtocline{#1}{#7}}%
   \fi
   \@xsect{#5}}
 %    \end{macrocode}
@@ -7749,17 +8015,18 @@
 % \ifdim \@tempskipa>\z@
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-%         \interlinepenalty \@M #5\@@par}%
-          \interlinepenalty \@M
+%       \@hangfrom{\hskip #1}%
+%       \interlinepenalty \@M #5\@@par
+        \CTEX at sectionhang{#1}{}%
           \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
+          \CTEX at aftertitle}\par
     \endgroup
   \else
-%   \def\@svsechd{#4{\hskip\glueexpr #1\relax #5}}%
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
+%   \def\@svsechd{#4{\hskip #1\relax #5}}%
+    \def\@svsechd{#4{{\CTEX at indentbox{#1}}%
+      \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
   \fi
   \@xsect{#3}}
 %    \end{macrocode}
@@ -7789,7 +8056,7 @@
         \unskip
 %       \@tempskipa #1\relax
 %       \hskip -\@tempskipa
-        \hskip\glueexpr #1\relax
+        \CTEX at heading@glue{#1}%
       \else
         \clubpenalty \@clubpenalty
         \everypar{}%
@@ -7799,37 +8066,55 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[int]{\CTEX at headinghang,\CTEX at sectionhang}
+% 分别用于用于实现 \tn{part}/\tn{chapter} 和 \tn{section} 类标题的
+% \opt{indent} 和 \opt{hang} 选项。
 %    \begin{macrocode}
-%<@@=ctex>
+\cs_new_protected:Npn \CTEX at headinghang #1
+  {
+    \ctex_heading_hang:cnn
+      { CTEX@#1 at hang }
+      { \use:c { CTEX@#1 at indent } }
+  }
+\cs_new_protected:Npn \CTEX at sectionhang
+  { \ctex_heading_hang:Nnn \CTEX at hang }
 %    \end{macrocode}
+% \end{macro}
 %
-% \begin{macro}[int]{\CTEX at hangindent}
-% 用于实现 \tn{part} 和 \tn{chapter} 标题的 \opt{indent} 和 \opt{hang} 选项。
+% \begin{macro}[int]{\ctex_heading_hang:Nnn,\ctex_hang_from:n}
+% \opt{hang} 选项控制是否采用悬挂缩进,同时设置 \tn{parindent}。
 %    \begin{macrocode}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
+\cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3
   {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \@@_indent_aux: #2 } }
-      {#2}
+    \dim_set:Nn \tex_parindent:D {#2}
+    \bool_if:NTF #1
+      { \ctex_hang_from:n }
+      { \use:n }
+      { \@@_insert_indent: #3 }
   }
-\cs_new_protected_nopar:Npn \@@_indent_aux:
+\cs_new_protected:Npn \ctex_hang_from:n #1
   {
-    \dim_compare:nNnF \parindent = \c_zero_dim
-      { \skip_horizontal:n { \parindent } }
+    \tex_noindent:D
+    \hbox_set:Nn \l_@@_tmp_box {#1}
+    \tex_hangindent:D = \box_wd:N \l_@@_tmp_box
+    \box_use_drop:N \l_@@_tmp_box
   }
+\cs_generate_variant:Nn \ctex_heading_hang:Nnn { c }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]{\CTEX at hangfrom}
-% \opt{hang} 选项控制是否采用悬挂缩进。
+% \begin{macro}[int]{\ctex_heading_glue:n,\CTEX at heading@glue}
+% 如果缩进 |#1| 长度为零,就不插入水平间距。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at hangfrom
+\cs_new_protected:Npn \ctex_heading_glue:n #1
   {
-    \bool_if:NTF \CTEX at hang
-      { \@hangfrom }
-      { \noindent \use:n }
+    \group_begin:
+      \skip_set:Nn \l_@@_heading_skip {#1}
+      \dim_compare:nNnF \l_@@_heading_skip = \c_zero_dim
+        { \skip_horizontal:N \l_@@_heading_skip }
+    \group_end:
   }
+\cs_new_eq:NN \CTEX at heading@glue \ctex_heading_glue:n
 %    \end{macrocode}
 % \end{macro}
 %
@@ -7836,7 +8121,7 @@
 % \begin{macro}[int]{\CTEX at update@sectionformat at n}
 % 在 \tn{@startsection} 中设置 \tn{CTEX at titleformat@n} 等为相应函数。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at update@sectionformat at n #1
+\cs_new_protected:Npn \CTEX at update@sectionformat at n #1
   {
     \cs_set_eq:Nc \CTEX at titleformat@n { CTEX@#1 at titleformat }
     \cs_set_eq:Nc \CTEX at aftertitle    { CTEX@#1 at aftertitle }
@@ -7877,7 +8162,7 @@
 %
 % \begin{macro}[int]{\CTEXnumberline}
 %    \begin{macrocode}
-\cs_new_nopar:Npn \CTEXnumberline #1
+\cs_new:Npn \CTEXnumberline #1
   {
     \CTEXifname
       { \protect \numberline { \use:c { CTEXthe #1 } } }
@@ -7891,7 +8176,7 @@
 \seq_map_inline:Nn \c_@@_section_headings_seq
   {
     \int_incr:N \l_@@_tmp_int
-    \cs_gset_protected_nopar:cpx  {#1}
+    \cs_gset_protected:cpx  {#1}
       {
         \exp_not:N \@startsection {#1}
           { \int_use:N \l_@@_tmp_int }
@@ -7909,7 +8194,7 @@
 %
 % \begin{macro}[int]{appendix/name,appendix/number,appendix/numbering}
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     appendix                .meta:nn = { ctex / appendix } {#1} ,
     appendix / name          .code:n =
@@ -7926,7 +8211,7 @@
 % \begin{macro}[int]{\appendix}
 %    \begin{macrocode}
 \cs_new_eq:NN \CTEX at save@appendix \appendix
-\cs_gset_protected_nopar:Npn \appendix
+\cs_gset_protected:Npn \appendix
   {
     \CTEX at save@appendix
 %<*article>
@@ -7952,7 +8237,7 @@
 % \begin{macro}[int]{\CTEX at makeanchor}
 % 设置超链接跳转锚点,在 \pkg{hyperref} 载入后才有意义。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at makeanchor #1
+\cs_new_protected:Npn \CTEX at makeanchor #1
   { }
 %    \end{macrocode}
 % \end{macro}
@@ -7976,7 +8261,7 @@
 % \opt{implicit} 选项的控制)。我们在上面对标题命令的修改已经包含这一功能,如果这些标题命令在
 % \pkg{hyperref} 载入之前没有被修改过,则恢复 \CTeX{} 的定义。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at hyperheadinghook
+\cs_new_protected:Npn \CTEX at hyperheadinghook
   {
     \group_begin:
       \ifHy at implicit
@@ -8001,7 +8286,7 @@
 %    \begin{macrocode}
 \ctex_at_end_package:nn { hyperref }
   {
-    \cs_gset_protected_nopar:Npn \CTEX at makeanchor #1
+    \cs_gset_protected:Npn \CTEX at makeanchor #1
       {
         \Hy at MakeCurrentHrefAuto {#1}
         \Hy at raisedlink
@@ -8025,7 +8310,7 @@
   { }
 \ctex_at_end_package:nn { nameref }
   {
-    \cs_gset_protected_nopar:Npn \CTEX at gettitle { \NR at gettitle }
+    \cs_gset_protected:Npn \CTEX at gettitle { \NR at gettitle }
     \seq_map_inline:Nn \c_@@_headings_cs_seq
       {
         \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
@@ -8062,7 +8347,7 @@
 % 如果使用了 \pkg{titlesec} 的 \opt{indentafter} 等选项,也不需要调整
 % |\ttls@|\meta{section}。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_titlesec_hook:
+\cs_new_protected:Npn \ctex_titlesec_hook:
   {
     \@ifpackagewith { titlesec } { explicit }
       {
@@ -8082,17 +8367,17 @@
       }
     \seq_map_function:NN \c_@@_section_headings_seq \@@_titlesec_hook:n
   }
-\cs_new_protected_nopar:Npn \@@_titlesec_hook:n #1
+\cs_new_protected:Npn \@@_titlesec_hook:n #1
   {
     \@@_titlesec_format:n {#1}
     \exp_args:Nc \@@_titlesec_spacing:Nn { ttls@#1 } {#1}
   }
-\cs_new_protected_nopar:Npn \@@_titlesec_format:n #1
+\cs_new_protected:Npn \@@_titlesec_format:n #1
   {
     \cs_if_free:cF { ttlf@#1 }
       { \exp_args:Nc \@@_titlesec_format:Nn { ttlf@#1 } {#1} }
   }
-\cs_new_protected_nopar:Npn \@@_titlesec_format:Nn #1#2
+\cs_new_protected:Npn \@@_titlesec_format:Nn #1#2
   {
     \tl_set:Nx #1
       {
@@ -8102,7 +8387,7 @@
         \tl_tail:N #1
       }
   }
-\cs_new_protected_nopar:Npn \@@_titlesec_format_explicit:Nn #1#2
+\cs_new_protected:Npn \@@_titlesec_format_explicit:Nn #1#2
   {
     \cs_set_nopar:Npx #1 ##1
       {
@@ -8112,7 +8397,7 @@
         \exp_args:No \tl_tail:n { #1 { } }
       }
   }
-\cs_new_protected_nopar:Npn \@@_titlesec_spacing:Nn #1#2
+\cs_new_protected:Npn \@@_titlesec_spacing:Nn #1#2
   { \tl_set:Nx #1 { \exp_after:wN \@@_titlesec_spacing:nnnnnn #1 {#2} } }
 \cs_new:Npn \@@_titlesec_spacing:nnnnnn #1#2#3#4#5#6
   {
@@ -8145,7 +8430,7 @@
 %</book|report>
     \cs_if_free:NF \ttl at tocpart
       {
-        \cs_set_protected_nopar:Npn \ttl at tocpart
+        \cs_set_protected:Npn \ttl at tocpart
           { \tl_set:Nn \ttl at a { \CTEXthepart \hspace { 1em } } }
       }
     \seq_map_inline:Nn \c_@@_headings_seq
@@ -8152,7 +8437,7 @@
       {
         \cs_if_exist:cF { ttl at toc #1 }
           {
-            \cs_new_protected_nopar:cpx { ttl at toc #1 }
+            \cs_new_protected:cpx { ttl at toc #1 }
               {
                 \tl_set:Nn \exp_not:N \ttl at a
                   {
@@ -8178,7 +8463,7 @@
 %    \begin{macrocode}
 \group_begin:
 \char_set_catcode_other:N \#
-\cs_new_protected_nopar:Npn \ctex_titleps_hook:
+\cs_new_protected:Npn \ctex_titleps_hook:
   {
     \ctex_patch_cmd:Nnn \ttl at settopmark
       { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
@@ -8207,12 +8492,12 @@
 % 这两个函数要在随后被 \tn{xdef} 展开来获得 |\CTEXtheXXX| 的内容,不应该用
 % \tn{protected} 来定义。
 %    \begin{macrocode}
-\cs_new_nopar:Npn \CTEX at titlepslabel@set #1
+\cs_new:Npn \CTEX at titlepslabel@set #1
   {
     \cs_if_free:cF { CTEXthe#1 }
       { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
   }
-\cs_new_nopar:Npn \CTEX at titlepslabel@clear #1
+\cs_new:Npn \CTEX at titlepslabel@clear #1
   {
     \cs_if_free:cF { CTEXthe#1 }
       { \protect \@namedef { CTEXthe#1 } { } }
@@ -8240,9 +8525,9 @@
 %    \begin{macrocode}
 \ctex_at_end_package:nn { titleps }
   {
-    \cs_set_protected_nopar:Npn \ttl at setifthe #1
+    \cs_set_protected:Npn \ttl at setifthe #1
       {
-        \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 }
+        \exp_args:Nco \cs_set:Npn { ifthe #1 }
           {
             \CTEXifname
               { \protect \@firstoftwo }
@@ -8257,7 +8542,7 @@
 %
 % \subsubsection{目录标签的宽度}
 %
-% \begin{macro}[int]{\numberline}
+% \begin{macro}{\CTEX at toc@width at n}
 %   \begin{macrocode}
 \cs_new_protected:Npn \CTEX at toc@width at n #1
   {
@@ -8268,6 +8553,17 @@
           { \box_wd:N \l_@@_tmp_box + \f at size \p@ / 2 }
       }
   }
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v2.5}{2020/01/11}{兼容 \pkg{titletoc} 宏包。}
+%
+% \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
@@ -8277,19 +8573,24 @@
       { \CTEX at toc@width at 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 at toc@width at 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 at toc@width at n {#1} }
+                  { }
+                  { \ctex_patch_failure:N \numberline }
+              }
           }
       }
   }
+\@@_patch_toc_width:n { tocloft  }
+\@@_patch_toc_width:n { titletoc }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -8385,24 +8686,23 @@
 %    \begin{macrocode}
 \defbeamertemplate*{part page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
 %    \centering
 %    {\usebeamerfont{part name}%
 %     \usebeamercolor[fg]{part name}\partname~\insertromanpartnumber}
 %    \vskip1em\par
     \par \addvspace{\glueexpr\CTEX at part@beforeskip\relax}%
-    \CTEX at part@format
-    \parindent \dimexpr \CTEX at part@indent \relax
-    \ifodd \CTEX at part@numbering
-      \CTEX at partname \CTEX at part@aftername
-    \fi
-    \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
-%      \usebeamerfont{part title}\insertpart\par
-      \CTEX at part@titleformat \insertpart \CTEX at part@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at indentbox{\CTEX at part@indent}%
+      \ifodd \CTEX at part@numbering
+        \CTEX at partname \CTEX at part@aftername
+      \fi
+      \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
+%       \usebeamerfont{part title}\insertpart\par
+        \CTEX at part@titleformat \insertpart \CTEX at part@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at part@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 %    \end{macrocode}
 %
 % 对应 \tn{sectionpage}。
@@ -8409,24 +8709,23 @@
 %    \begin{macrocode}
 \defbeamertemplate*{section page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
 %    \centering
 %    {\usebeamerfont{section name}%
 %     \usebeamercolor[fg]{section name}\sectionname~\insertsectionnumber}
 %    \vskip1em\par
     \par \addvspace{\glueexpr\CTEX at section@beforeskip\relax}%
-    \CTEX at section@format
-    \parindent \dimexpr \CTEX at section@indent \relax
-    \ifodd \CTEX at section@numbering
-      \CTEX at sectionname \CTEX at section@aftername
-    \fi
-    \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
-%      \usebeamerfont{section title}\insertsection\par
-      \CTEX at section@titleformat \insertsection \CTEX at section@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at section@format{%
+      \CTEX at indentbox{\CTEX at section@indent}%
+      \ifodd \CTEX at section@numbering
+        \CTEX at sectionname \CTEX at section@aftername
+      \fi
+      \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
+%       \usebeamerfont{section title}\insertsection\par
+        \CTEX at section@titleformat \insertsection \CTEX at section@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at section@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 %    \end{macrocode}
 %
 % 对应 \tn{subsectionpage}。
@@ -8433,24 +8732,23 @@
 %    \begin{macrocode}
 \defbeamertemplate*{subsection page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
 %    \centering
 %    {\usebeamerfont{subsection name}%
 %     \usebeamercolor[fg]{subsection name}\subsectionname~\insertsubsectionnumber}
 %    \vskip1em\par
     \par \addvspace{\glueexpr\CTEX at subsection@beforeskip\relax}%
-    \CTEX at subsection@format
-    \parindent \dimexpr \CTEX at subsection@indent \relax
-    \ifodd \CTEX at subsection@numbering
-      \CTEX at subsectionname \CTEX at subsection@aftername
-    \fi
-    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
-%      \usebeamerfont{subsection title}\insertsubsection\par
-      \CTEX at subsection@titleformat \insertsubsection \CTEX at subsection@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at subsection@format{%
+      \CTEX at indentbox{\CTEX at subsection@indent}%
+      \ifodd \CTEX at subsection@numbering
+        \CTEX at subsectionname \CTEX at subsection@aftername
+      \fi
+      \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
+%       \usebeamerfont{subsection title}\insertsubsection\par
+        \CTEX at subsection@titleformat \insertsubsection \CTEX at subsection@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at subsection@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 %    \end{macrocode}
 %
 % 将 \cls{beamer} 的默认模板重定向为 \texttt{CTEX} 模板。
@@ -8473,7 +8771,7 @@
 % \begin{macro}[int]{\refstepcounter}
 % 对标题进行引用时,设置标签为通过 \opt{number} 选项设置的形式。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
+\cs_new_protected:Npn \CTEX at setcurrentlabel@n #1
   {
     \protected at edef \@currentlabel
       {
@@ -8490,8 +8788,9 @@
 % \pkg{hyperref} 宏包都会保存之前的定义,并且它们都要求尽可能晚的被载入,所以
 % 对我们上述的修改影响不大。需要注意的是 \pkg{varioref} 宏包,如果它在
 % \CTeX{} 之后被载入,我们之前的修改将会被覆盖。
+% 较新版 \LaTeX \ 内核已经包含 \tn{labelformat},可以直接使用。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
+\cs_new_protected:Npn \ctex_varioref_hook:
   {
     \seq_map_inline:Nn \c_@@_headings_seq
       { \ctex_fix_varioref_label:n { ##1 } }
@@ -8510,17 +8809,19 @@
 % \end{verbatim}
 % 它的第二个参数必须放在花括号内,否则将会被作为宏的定界符号。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
+\cs_new_protected:Npn \ctex_fix_varioref_label:n #1
   {
     \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
+      { \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX at the#1 } } }
   }
 %    \end{macrocode}
 % \end{macro}
 %
+% \changes{v2.5}{2020/04/19}{应用新内核中的 \tn{labelformat}。}
+%
 % 如果 \pkg{varioref} 已经被载入,则使用它来设置。
 %    \begin{macrocode}
-\@ifpackageloaded { varioref }
+\cs_if_exist:NTF \labelformat
   { \ctex_varioref_hook: }
   {
     \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
@@ -8558,7 +8859,7 @@
 % 标题的 \opt{nameformat} 和 \opt{titleformat} 选项的初值合并到 \opt{format} 中。}
 %
 %    \begin{macrocode}
-\keys_set:nn { ctex / part }
+\ctex_set:nn { part }
   {
     aftertitle  = \par ,
 %<*article|book|report>
@@ -8619,7 +8920,7 @@
 %
 %    \begin{macrocode}
 %<*book|report>
-\keys_set:nn { ctex / chapter }
+\ctex_set:nn { chapter }
   {
     pagestyle   = plain ,
     aftertitle  = \par ,
@@ -8650,16 +8951,12 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-%<@@=>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-\keys_set:nn { ctex / section }
+\ctex_set:nn { section }
   {
 %<*article|book|report>
     number      = \thesection ,
     aftername   = \quad ,
-    aftertitle  = \@@par ,
+    aftertitle  = \@@@@par ,
     beforeskip  = 3.5ex \@plus 1ex \@minus .2ex ,
     afterskip   = 2.3ex \@plus .2ex ,
     runin       = false ,
@@ -8689,13 +8986,13 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_set:nn { ctex / subsection }
+\ctex_set:nn { subsection }
   {
 %<*article|book|report>
     number      = \thesubsection ,
     format      = \large \bfseries ,
     aftername   = \quad ,
-    aftertitle  = \@@par ,
+    aftertitle  = \@@@@par ,
     beforeskip  = 3.25ex \@plus 1ex \@minus .2ex ,
     afterskip   = 1.5ex  \@plus .2ex ,
     runin       = false ,
@@ -8730,12 +9027,12 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_set:nn { ctex / subsubsection }
+\ctex_set:nn { subsubsection }
   {
     number      = \thesubsubsection ,
     format      = \normalsize \bfseries ,
     aftername   = \quad ,
-    aftertitle  = \@@par ,
+    aftertitle  = \@@@@par ,
     beforeskip  = 3.25ex \@plus 1ex \@minus .2ex ,
     afterskip   = 1.5ex \@plus .2ex ,
     runin       = false ,
@@ -8750,7 +9047,7 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_set:nn { ctex / paragraph }
+\ctex_set:nn { paragraph }
   {
     number      = \theparagraph ,
     format      = \normalsize \bfseries ,
@@ -8767,7 +9064,7 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\keys_set:nn { ctex / subparagraph }
+\ctex_set:nn { subparagraph }
   {
     number      = \thesubparagraph ,
     format      = \normalsize \bfseries ,
@@ -8787,15 +9084,15 @@
 %    \begin{macrocode}
 \int_compare:nNnTF \g__ctex_section_depth_int > 2
   {
-    \keys_set:nn { ctex / paragraph }
+    \ctex_set:nn { paragraph }
       {
-        aftertitle  = \@@par ,
+        aftertitle  = \@@@@par ,
         afterskip   = 1ex \@plus .2ex ,
         runin       = false
       }
   }
   {
-    \keys_set:nn { ctex / paragraph }
+    \ctex_set:nn { paragraph }
       {
         afterskip   = 1em ,
         runin       = true
@@ -8803,15 +9100,15 @@
   }
 \int_compare:nNnTF \g__ctex_section_depth_int > 3
   {
-    \keys_set:nn { ctex / subparagraph }
+    \ctex_set:nn { subparagraph }
       {
-        aftertitle  = \@@par ,
+        aftertitle  = \@@@@par ,
         afterskip   = 1ex \@plus .2ex ,
         runin       = false
       }
   }
   {
-    \keys_set:nn { ctex / subparagraph }
+    \ctex_set:nn { subparagraph }
       {
         afterskip   = 1em ,
         runin       = true
@@ -8818,17 +9115,13 @@
       }
   }
 \int_compare:nNnTF \g__ctex_section_depth_int > 2
-  { \keys_set:nn { ctex / subparagraph } { indent = \c_zero_dim } }
-  { \keys_set:nn { ctex / subparagraph } { indent = \parindent } }
+  { \ctex_set:nn { subparagraph } { indent = \c_zero_dim } }
+  { \ctex_set:nn { subparagraph } { indent = \parindent } }
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-%<@@=ctex>
-%    \end{macrocode}
-%
 % 处理附录的格式。
 %    \begin{macrocode}
-\keys_set:nn { ctex / appendix }
+\ctex_set:nn { appendix }
 %<*article>
   { number      = \@Alph \c at section }
 %</article>
@@ -8890,7 +9183,7 @@
           { \tl_const:Nn \c_@@_class_tl { article } }
         \msg_warning:nnx { ctex } { not-standard-class } { \c_@@_class_tl }
       }
-    \ctex_file_input:n { ctex- \c_@@_class_tl .def }
+    \ctex_file_input:n { ctex-heading- \c_@@_class_tl .def }
   }
 %<ctex>  { \ctex_scheme_input:o { \l_@@_scheme_tl } }
 %    \end{macrocode}
@@ -8943,19 +9236,19 @@
 %
 % 日期格式。
 %    \begin{macrocode}
-\keys_set:nn { ctex } { today = small }
+\ctex_set:n { today = small }
 %    \end{macrocode}
 %
 % 若用户未设置宏包选项 \opt{autoindent},则自动调整首行缩进。
 %    \begin{macrocode}
 \ctex_if_autoindent_touched:F
-  { \keys_set:nn { ctex } { autoindent = true } }
+  { \ctex_set:n { autoindent = true } }
 %    \end{macrocode}
 %
 % 使用标题定义时的设置。首先是命题名字汉化。\cls{beamer} 需要汉化定理名称。
 %    \begin{macrocode}
 %<*!generic>
-\str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
+\str_if_eq:onTF { \g_@@_encoding_tl } { GBK }
 %<*beamer>
   {
     \uselanguage { ChineseGBK }
@@ -8989,19 +9282,19 @@
 % 对 \cls{beamer} 以外的文档类,若用户未设置宏包选项 \opt{linespread},则设置行
 % 距初始值为 $1.3\times 1.2=1.56$ 倍字体大小。\cls{beamer} 不调整行距。
 %    \begin{macrocode}
-\fp_compare:nNnT { \l_@@_line_spread_fp } ? { \c_zero_fp }
+\fp_if_nan:nT { \l_@@_line_spread_fp }
   { \fp_set:Nn \l_@@_line_spread_fp { 1.3 } }
 %</!beamer>
 %</!generic>
 %    \end{macrocode}
 %
-% 不使用标题定义时的通用设置。
+% 不使用标题定义时的通用设置,注意此处 \cs{c_@@_std_class_tl} 可能没有定义。
 %    \begin{macrocode}
 %<*generic>
 \tl_set:Nn \l_@@_tmp_tl { beamer }
 \tl_if_eq:NNTF \c_@@_std_class_tl \l_@@_tmp_tl
   {
-    \str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
+    \str_if_eq:onTF { \g_@@_encoding_tl } { GBK }
       {
         \uselanguage { ChineseGBK }
         \languagealias { chinese } { ChineseGBK }
@@ -9015,12 +9308,12 @@
     \clist_put_left:Nn \trans at languagepath { chinese }
   }
   {
-    \str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
+    \str_if_eq:onTF { \g_@@_encoding_tl } { GBK }
       { \ctex_file_input:n { ctex-name-gbk.cfg } }
       { \ctex_file_input:n { ctex-name-utf8.cfg } }
     \int_compare:nNnF \g_@@_font_size_int > { -1 }
       { \int_gset:Nn \g_@@_font_size_int { 0 } }
-    \fp_compare:nNnT { \l_@@_line_spread_fp } ? { \c_zero_fp }
+    \fp_if_nan:nT { \l_@@_line_spread_fp }
       { \fp_set:Nn \l_@@_line_spread_fp { 1.3 } }
 %    \end{macrocode}
 % \changes{v2.0.2}{2015/05/16}{修复加载 \pkg{ctex} 宏包后章节标题后第一段
@@ -9055,7 +9348,7 @@
 %
 % \begin{macro}[int]{\ctex_zihao:n}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_zihao:n #1
+\cs_new_protected:Npn \ctex_zihao:n #1
   {
     \prop_get:NnNTF \c_@@_font_size_prop {#1} \l_@@_font_size_tl
       { \exp_after:wN \fontsize \l_@@_font_size_tl \selectfont }
@@ -9083,7 +9376,7 @@
 %    \begin{macrocode}
 \prop_new:N \c_@@_font_size_prop
 \seq_new:N \c_@@_font_size_seq
-\cs_new_protected_nopar:Npn \@@_save_font_size:nn #1#2
+\cs_new_protected:Npn \@@_save_font_size:nn #1#2
   {
     \use:x
       {
@@ -9121,7 +9414,7 @@
 %
 % \begin{macro}[int]{\ctex_declare_math_sizes:nnnn}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
   {
     \@@_get_font_sizes:Nn \l_@@_font_size_tl { {#1} {#2} {#3} {#4} }
     \exp_after:wN \DeclareMathSizes \l_@@_font_size_tl
@@ -9131,7 +9424,7 @@
 %
 % \begin{macro}{\@@_get_font_sizes:Nn}
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_get_font_sizes:Nn #1#2
+\cs_new_protected:Npn \@@_get_font_sizes:Nn #1#2
   {
     \tl_clear:N #1
     \tl_map_inline:nn {#2}
@@ -9178,16 +9471,16 @@
       { \msg_error:nnn { ctex } { fontsize } {#2} }
   }
 \cs_new_protected:Npn \@@_set_font_size:nnNn #1#2#3#4
-  { \cs_set_protected_nopar:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
+  { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
 %    \end{macrocode}
 % \end{macro}
 %
 %    \begin{macrocode}
-\if_case:w \g_@@_font_size_int
-  \ctex_file_input:n { ctex-c5size.clo }
-\or:
-  \ctex_file_input:n { ctex-cs4size.clo }
-\fi:
+\int_case:nn { \g_@@_font_size_int }
+  {
+    { 0 } { \ctex_file_input:n { ctex-c5size.clo } }
+    { 1 } { \ctex_file_input:n { ctex-cs4size.clo } }
+  }
 %    \end{macrocode}
 %
 %    \begin{macrocode}
@@ -9287,7 +9580,7 @@
 %
 % \cs{l_@@_line_spread_fp} 被设置了才有必要更新行距和 \tn{footnotesep}。
 %    \begin{macrocode}
-\fp_compare:nNnF { \l_@@_line_spread_fp } ? { \c_zero_fp }
+\fp_if_nan:nF { \l_@@_line_spread_fp }
   {
     \exp_args:Nx \linespread { \fp_use:N \l_@@_line_spread_fp }
 %    \end{macrocode}
@@ -9310,7 +9603,7 @@
 \normalsize
 %    \end{macrocode}
 %
-% \subsection{其它功能}
+% \subsection{其他功能}
 %
 % \begin{macro}{\CTeX}
 % \changes{v2.4.12}{2017/12/05}{不依赖 \tn{ifincsname}。}
@@ -9332,11 +9625,11 @@
 % \begin{macro}{captiondelimiter}
 % 过时选项。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     captiondelimiter .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           { You~can~load~the~package~`caption'~to~get~its~functionality. }
       }
   }
@@ -9368,12 +9661,12 @@
 % {解决 \pkg{etoolbox} 与 \pkg{breqn} 关于 \tn{end} 的冲突。}
 % \changes{v2.2}{2015/06/23}{删去 \pkg{etoolbox} 与 \pkg{breqn} 的兼容补丁。}
 %
-% \subsection{载入中文字体}
+% \subsection{载入中文字库}
 %
 % \begin{macro}[int]{\ctex_fontset_error:n}
 % 字库不可用时给出紧急错误信息,停止读取定义文件。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_fontset_error:n #1
+\cs_new_protected:Npn \ctex_fontset_error:n #1
   { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} }
 \msg_new:nnn { ctex } { fontset-unavailable }
   { CTeX~fontset~`#1'~is~unavailable~in~current~mode. }
@@ -9380,37 +9673,94 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\ctex_fontset_case:nnn}
+% $3$ 个参数依次为 \pdfTeX、\upTeX\ 和 \XeTeX/\LuaTeX。
+%    \begin{macrocode}
+\cs_new:Npx \ctex_fontset_case:nnn #1#2#3
+  {
+    \sys_if_engine_pdftex:TF
+      {#1}
+      { \sys_if_engine_uptex:TF {#2} {#3} }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ctex_fontset_case:nnnn}
+% $4$ 个参数依次为 \pdfTeX(生成 PDF)、\pdfTeX(生成 DVI)、\upTeX 和
+% \XeTeX/\LuaTeX。
+%    \begin{macrocode}
+\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4
+  {
+    \sys_if_engine_pdftex:TF
+      { \sys_if_output_pdf:TF   {#1} {#2} }
+      { \sys_if_engine_uptex:TF {#3} {#4} }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[int]{\ctex_detect_platform:}
+% 根据操作系统判断默认字体配置。
+%    \begin{macrocode}
+\cs_new_protected:Npn \ctex_detect_platform:
+  {
+    \sys_if_platform_windows:TF
+      { \tl_gset:Nn \g_@@_fontset_tl { windows } }
+      {
+        \ctex_if_platform_macos:TF
+          { \tl_gset:Nn \g_@@_fontset_tl { mac    } }
+          { \tl_gset:Nn \g_@@_fontset_tl { fandol } }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[int]{\ctex_if_platform_macos:TF}
+% \changes{v2.1}{2015/06/17}{改用 \file{/Library/Fonts/Songti.ttc} 为特征文件。}
+% \changes{v2.5}{2019/10/25}{改用 \file{/System/Library/Fonts/Menlo.ttc}
+%   为特征文件。}
+% 以特定字体判断 macOS 系统。
+%    \begin{macrocode}
+\cs_new_protected:Npn \ctex_if_platform_macos:TF
+  { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[int]{\ctex_load_fontset:}
 % 如果用户没有指定字体,则探测操作系统,载入相应的字体配置。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_load_fontset:
+\cs_new_protected:Npn \ctex_load_fontset:
   {
     \tl_if_empty:NTF \g_@@_fontset_tl
+      { \ctex_detect_platform: }
       {
-        \ctex_detected_platform:
-        \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def }
-      }
-      {
-        \file_if_exist:nTF { ctex-fontset- \g_@@_fontset_tl .def }
-          { \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } }
+        \bool_lazy_or:nnTF
+          { \str_if_eq_p:on { \g_@@_fontset_tl } { windowsnew } }
+          { \str_if_eq_p:on { \g_@@_fontset_tl } { windowsold } }
           {
-            \use:x
+            \msg_warning:nnxx { ctex } { deprecated-fontset }
+              { \g_@@_fontset_tl } { windows }
+            \tl_gset:Nn \g_@@_fontset_tl { windows }
+          }
+          {
+            \file_if_exist:nF { ctex-fontset- \g_@@_fontset_tl .def }
               {
-                \ctex_detected_platform:
-                \msg_error:nnxx { ctex } { fontset-not-found }
-                  { \g_@@_fontset_tl } { \exp_not:N \g_@@_fontset_tl }
+                \use:x
+                  {
+                    \ctex_detect_platform:
+                    \msg_error:nnxx { ctex } { fontset-not-found }
+                      { \g_@@_fontset_tl } { \exp_not:N \g_@@_fontset_tl }
+                  }
               }
-            \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def }
           }
       }
+    \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def }
   }
-\@onlypreamble \ctex_load_fontset:
+\msg_new:nnn { ctex } { deprecated-fontset }
+  { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. }
 \msg_new:nnnn { ctex } { fontset-not-found }
-  {
-    CTeX~fontset~`#1'~could~not~be~found.\\
-    Fontset~`#2'~will~be~used~instead.
-  }
+  { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. }
   { You~may~run~`mktexlsr'~firstly. }
+\@onlypreamble \ctex_load_fontset:
 %    \end{macrocode}
 % \end{macro}
 %
@@ -9417,7 +9767,7 @@
 % \begin{macro}{fontset}
 % 在导言区通过 \tn{ctexset} 载入中文字库的选项。
 %    \begin{macrocode}
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     fontset .code:n =
       {
@@ -9447,9 +9797,7 @@
   }
   { Only~one~fontset~can~be~loaded~in~the~preamble. }
 \msg_new:nnn { ctex } { fontset-only-preamble }
-  {
-    The~ `fontset'~ option~ can~ be~ used~ only~ in~ preamble.
-  }
+  { The~`fontset'~option~can~be~used~only~in~preamble. }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -9479,11 +9827,11 @@
 %
 % \subsubsection{\pkg{ctexopts.cfg}}
 %
-% 这里仅为配置文件示例:使用 Windows Vista 或以后版本的字体设置。
+% 这里仅为配置文件示例:使用 Windows 下的字体设置。
 %    \begin{macrocode}
 %<*ctexopts>
 %%
-%% \keys_set:nn { ctex / option } { fontset = windowsnew }
+%% \ctex_set:nn { option } { fontset = windows }
 %</ctexopts>
 %    \end{macrocode}
 %
@@ -9555,11 +9903,13 @@
 %<*jy2>
 \DeclareFontShape{JY2}{zhrm}{m}{n}{<-> upzhserif-h}{}
 \DeclareFontShape{JY2}{zhrm}{m}{it}{<-> upzhserifit-h}{}
+\DeclareFontShape{JY2}{zhrm}{b}{n}{<-> upzhserifb-h}{}
 \DeclareFontShape{JY2}{zhrm}{bx}{n}{<-> upzhserifb-h}{}
 %</jy2>
 %<*jt2>
 \DeclareFontShape{JT2}{zhrm}{m}{n}{<-> upzhserif-v}{}
 \DeclareFontShape{JT2}{zhrm}{m}{it}{<-> upzhserifit-v}{}
+\DeclareFontShape{JT2}{zhrm}{b}{n}{<-> upzhserifb-v}{}
 \DeclareFontShape{JT2}{zhrm}{bx}{n}{<-> upzhserifb-v}{}
 %</jt2>
 %</rm>
@@ -9591,10 +9941,12 @@
 %</c70>
 %<*jy2>
 \DeclareFontShape{JY2}{zhsf}{m}{n}{<-> upzhsans-h}{}
+\DeclareFontShape{JY2}{zhsf}{b}{n}{<-> upzhsansb-h}{}
 \DeclareFontShape{JY2}{zhsf}{bx}{n}{<-> upzhsansb-h}{}
 %</jy2>
 %<*jt2>
 \DeclareFontShape{JT2}{zhsf}{m}{n}{<-> upzhsans-v}{}
+\DeclareFontShape{JT2}{zhsf}{b}{n}{<-> upzhsansb-v}{}
 \DeclareFontShape{JT2}{zhsf}{bx}{n}{<-> upzhsansb-v}{}
 %</jt2>
 %</sf>
@@ -9633,307 +9985,238 @@
 %</tt>
 %    \end{macrocode}
 %
+% \subsubsection{预定义字库}
+%
 %    \begin{macrocode}
 %<*fontset>
 %    \end{macrocode}
 %
-% \subsubsection{\pkg{ctex-fontset-windows.def} 等}
+% \paragraph{\opt{adobe}}
 %
-% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免
-% 权限问题。}
-% \pkg{ctex} 包利用 |C:\bootfont.bin| 文件的存在性来判断是否使用 Windows XP 版
-% 本,分别载入新旧字体设置。(注:\pkg{ctex} 包不支持 Windows 2000 以前使用
-% \file{simsun.ttf} 的旧宋体文件名。)
+% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下
+% 就没有定义。\opt{fandol} 的情况类似。
 %    \begin{macrocode}
-%<*windows>
-\file_if_exist:nTF { C:/bootfont.bin }
-  { \ctex_file_input:n { ctex-fontset-windowsold.def } }
-  { \ctex_file_input:n { ctex-fontset-windowsnew.def } }
-%</windows>
-%    \end{macrocode}
-%
-% 旧的 Windows 字体设置使用黑体作为无衬线体,楷体和仿宋是 GB2312 编码;新的
-% Windows 字体设置使用微软雅黑作为无衬线体,楷体和仿宋是大字库。
-% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要
-% 加以区分。
-%    \begin{macrocode}
-%<*windowsnew>
-\tl_new:N \l_@@_msyh_suffix_tl
-\tl_set:Nn \l_@@_msyh_suffix_tl { .ttc }
-\file_if_exist:nF { C:/Windows/Fonts/msyh.ttc }
+%<*adobe>
+\ctex_fontset_case:nnnn
+  { \ctex_fontset_error:n { adobe } }
   {
-    \file_if_exist:nF { msyh.ttc }
-      { \tl_set:Nn \l_@@_msyh_suffix_tl { .ttf } }
-  }
-%</windowsnew>
-%<*windowsnew|windowsold>
-\sys_if_engine_pdftex:TF
-  {
     \ctex_zhmap_case:nnn
       {
-        \ctex_punct_set:n { windows }
-        \setCJKmainfont
-          [ BoldFont = simhei.ttf , ItalicFont = simkai.ttf ] { simsun.ttc }
-%<*windowsold>
-        \setCJKsansfont { simhei.ttf }
-        \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
-%</windowsold>
-%<*windowsnew>
-        \setCJKsansfont
-          [ BoldFont = msyhbd\l_@@_msyh_suffix_tl ] { msyh\l_@@_msyh_suffix_tl }
-        \setCJKfamilyfont { zhyahei }
-          [ BoldFont = msyhbd\l_@@_msyh_suffix_tl ] { msyh\l_@@_msyh_suffix_tl }
-        \ctex_punct_map_family:nn { \CJKsfdefault } { zhyahei }
-        \ctex_punct_map_bfseries:nn { \CJKsfdefault , zhyahei } { zhyaheib }
-%</windowsnew>
-        \setCJKmonofont { simfang.ttf }
-        \setCJKfamilyfont { zhkai }  { simkai.ttf }
-        \setCJKfamilyfont { zhfs }   { simfang.ttf }
-        \setCJKfamilyfont { zhsong } { simsun.ttc }
-        \setCJKfamilyfont { zhhei }  { simhei.ttf }
-        \setCJKfamilyfont { zhli }   { simli.ttf }
-        \setCJKfamilyfont { zhyou }  { simyou.ttf }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
+        \setCJKmainfont  { AdobeSongStd-Light.otf }
+          [
+            cmap       = UniGB-UTF16-H,
+            BoldFont   = AdobeHeitiStd-Regular.otf,
+            ItalicFont = AdobeKaitiStd-Regular.otf
+          ]
+        \setCJKsansfont { AdobeHeitiStd-Regular.otf }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKmonofont { AdobeFangsongStd-Regular.otf }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhsong } { AdobeSongStd-Light.otf       }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhhei  } { AdobeHeitiStd-Regular.otf    }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhkai  } { AdobeKaitiStd-Regular.otf    }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhfs   } { AdobeFangsongStd-Regular.otf }
+          [ cmap = UniGB-UTF16-H ]
+        \ctex_punct_set:n { adobe }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_family:nn   { \CJKsfdefault } { zhhei  }
+        \ctex_punct_map_family:nn   { \CJKttdefault } { zhfs   }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
       {
-        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhwindowsfonts }
-        \ctex_punct_set:n { windows }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhadobefonts }
+        \ctex_punct_set:n { adobe }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
-      {
-        \tl_set:Nn \CJKrmdefault { rm }
-        \tl_set:Nn \CJKsfdefault { sf }
-        \tl_set:Nn \CJKttdefault { tt }
-      }
+      { \ctex_fontset_error:n { adobe } }
   }
   {
-    \sys_if_engine_uptex:TF
-      {
-        \ctex_set_upfonts:nnnnnn
-          {simsun.ttc} {simhei.ttf} {simkai.ttf}
-%<windowsnew>          {msyh\l_@@_msyh_suffix_tl} {msyhbd\l_@@_msyh_suffix_tl}
-%<windowsold>          {simhei.ttf} {simhei.ttf}
-          {simfang.ttf}
-        \ctex_set_upfamily:nnn { zhsong } { upzhserif } {}
-        \ctex_set_upfamily:nnn { zhhei } { upzhserifb } {}
-        \ctex_set_upfamily:nnn { zhfs } { upzhmono} {}
-        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
-%<windowsnew>        \ctex_set_upfamily:nnn { zhyahei } { upzhsans } { upzhsansb }
-        \ctex_set_upfamily:nnn { zhli } { upschrm } {}
-        \ctex_set_upmap:nnn { upstsl } { simli.ttf } {}
-        \ctex_set_upfamily:nnn { zhyou } { upschgt } {}
-        \ctex_set_upmap:nnn { upstht } { simyou.ttf } {}
-      }
-      {
-%<*windowsold>
-        \setCJKmainfont
-          [ BoldFont = SimHei , ItalicFont = KaiTi_GB2312 ] { SimSun }
-        \setCJKsansfont { SimHei }
-        \setCJKmonofont { FangSong_GB2312 }
-        \setCJKfamilyfont { zhkai } { KaiTi_GB2312 }
-        \setCJKfamilyfont { zhfs }  { FangSong_GB2312 }
-%</windowsold>
-%<*windowsnew>
-        \setCJKmainfont
-          [ BoldFont = SimHei , ItalicFont = KaiTi ] { SimSun }
-        \setCJKsansfont
-          [ BoldFont = { *~Bold } ] { Microsoft~YaHei }
-        \setCJKmonofont { FangSong }
-        \setCJKfamilyfont { zhkai } { KaiTi }
-        \setCJKfamilyfont { zhfs }  { FangSong }
-%</windowsnew>
-        \setCJKfamilyfont { zhsong }  { SimSun }
-        \setCJKfamilyfont { zhhei }   { SimHei }
-        \setCJKfamilyfont { zhli }    { LiSu }
-        \setCJKfamilyfont { zhyou }   { YouYuan }
-%<*windowsnew>
-        \setCJKfamilyfont { zhyahei }
-          [ BoldFont = { *~Bold } ] { Microsoft~YaHei }
-%</windowsnew>
-      }
+    \ctex_set_upfonts:nnnnnn
+      { AdobeSongStd-Light.otf       }
+      { AdobeHeitiStd-Regular.otf    }
+      { AdobeKaitiStd-Regular.otf    }
+      { AdobeHeitiStd-Regular.otf    }
+      { AdobeHeitiStd-Regular.otf    }
+      { AdobeFangsongStd-Regular.otf }
+    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } {}
+    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } {}
+    \ctex_set_upfamily:nnn { zhfs   } { upzhmono    } {}
+    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } {}
   }
-%</windowsnew|windowsold>
+  {
+    \setCJKmainfont { AdobeSongStd-Light       }
+      [ BoldFont = AdobeHeitiStd-Regular, ItalicFont = AdobeKaitiStd-Regular ]
+    \setCJKsansfont { AdobeHeitiStd-Regular    }
+    \setCJKmonofont { AdobeFangsongStd-Regular }
+    \setCJKfamilyfont { zhsong } { AdobeSongStd-Light       }
+    \setCJKfamilyfont { zhhei  } { AdobeHeitiStd-Regular    }
+    \setCJKfamilyfont { zhfs   } { AdobeFangsongStd-Regular }
+    \setCJKfamilyfont { zhkai  } { AdobeKaitiStd-Regular    }
+  }
+%</adobe>
 %    \end{macrocode}
 %
-% \subsubsection{\pkg{ctex-fontset-adobe.def}}
+% \paragraph{\opt{fandol}}
 %
 %    \begin{macrocode}
-%<*adobe>
-%    \end{macrocode}
-%
-% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下
-% 就没有定义。\opt{fandol} 的情况类似。
-%    \begin{macrocode}
-\sys_if_engine_pdftex:TF
+%<*fandol>
+\ctex_fontset_case:nnnn
+  { \ctex_fontset_error:n { fandol } }
   {
-    \sys_if_output_pdf:TF
-      { \ctex_fontset_error:n { adobe } }
+    \ctex_zhmap_case:nnn
       {
-        \ctex_zhmap_case:nnn
-          {
-            \setCJKmainfont
-              [
-                      cmap = UniGB-UTF16-H ,
-                  BoldFont = AdobeHeitiStd-Regular.otf ,
-                ItalicFont = AdobeKaitiStd-Regular.otf
-              ] { AdobeSongStd-Light.otf }
-            \setCJKsansfont [ cmap = UniGB-UTF16-H ] { AdobeHeitiStd-Regular.otf }
-            \setCJKmonofont [ cmap = UniGB-UTF16-H ] { AdobeFangsongStd-Regular.otf }
-            \setCJKfamilyfont { zhsong }
-              [ cmap = UniGB-UTF16-H ] { AdobeSongStd-Light.otf }
-            \setCJKfamilyfont { zhhei }
-              [ cmap = UniGB-UTF16-H ] { AdobeHeitiStd-Regular.otf }
-            \setCJKfamilyfont { zhkai }
-              [ cmap = UniGB-UTF16-H ] { AdobeKaitiStd-Regular.otf }
-            \setCJKfamilyfont { zhfs }
-              [ cmap = UniGB-UTF16-H ] { AdobeFangsongStd-Regular.otf }
-            \ctex_punct_set:n { adobe }
-            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-            \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
-            \ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
-            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-            \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-          }
-          {
-            \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhadobefonts }
-            \ctex_punct_set:n { adobe }
-            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-            \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-          }
-          { \ctex_fontset_error:n { adobe } }
+        \setCJKmainfont { FandolSong-Regular.otf }
+          [
+            cmap       = UniGB-UTF16-H,
+            BoldFont   = FandolSong-Bold.otf,
+            ItalicFont = FandolKai-Regular.otf
+          ]
+        \setCJKsansfont { FandolHei-Regular.otf }
+          [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ]
+        \setCJKmonofont { FandolFang-Regular.otf }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhsong } { FandolSong-Regular.otf }
+          [ cmap = UniGB-UTF16-H, BoldFont = FandolSong-Bold.otf ]
+        \setCJKfamilyfont { zhhei  } { FandolHei-Regular.otf  }
+          [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf  ]
+        \setCJKfamilyfont { zhfs   } { FandolFang-Regular.otf }
+          [ cmap = UniGB-UTF16-H ]
+        \setCJKfamilyfont { zhkai  } { FandolKai-Regular.otf  }
+          [ cmap = UniGB-UTF16-H ]
+        \ctex_punct_set:n { fandol }
+        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
+        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhhei   }
+        \ctex_punct_map_family:nn   { \CJKttdefault         } { zhfs    }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
+        \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei  } { zhheib  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
       }
-  }
-  {
-    \sys_if_engine_uptex:TF
       {
-        \ctex_set_upfonts:nnnnnn
-          {AdobeSongStd-Light.otf} {AdobeHeitiStd-Regular.otf} {AdobeKaitiStd-Regular.otf}
-          {AdobeHeitiStd-Regular.otf} {AdobeHeitiStd-Regular.otf}
-          {AdobeFangsongStd-Regular.otf}
-        \ctex_set_upfamily:nnn { zhsong } { upzhserif } {}
-        \ctex_set_upfamily:nnn { zhhei } { upzhsans } {}
-        \ctex_set_upfamily:nnn { zhfs } { upzhmono} {}
-        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfandolfonts }
+        \ctex_punct_set:n { fandol }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
-      {
-        \setCJKmainfont
-          [
-              BoldFont = AdobeHeitiStd-Regular ,
-            ItalicFont = AdobeKaitiStd-Regular
-          ] { AdobeSongStd-Light }
-        \setCJKsansfont { AdobeHeitiStd-Regular}
-        \setCJKmonofont { AdobeFangsongStd-Regular}
-        \setCJKfamilyfont { zhsong } { AdobeSongStd-Light }
-        \setCJKfamilyfont { zhhei }  { AdobeHeitiStd-Regular }
-        \setCJKfamilyfont { zhfs }   { AdobeFangsongStd-Regular }
-        \setCJKfamilyfont { zhkai }  { AdobeKaitiStd-Regular }
-      }
+      { \ctex_fontset_error:n { fandol } }
   }
+  {
+    \ctex_set_upfonts:nnnnnn
+      { FandolSong-Regular.otf }
+      { FandolSong-Bold.otf    }
+      { FandolKai-Regular.otf  }
+      { FandolHei-Regular.otf  }
+      { FandolHei-Bold.otf     }
+      { FandolFang-Regular.otf }
+    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } { upzhserifb }
+    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } { upzhsansb  }
+    \ctex_set_upfamily:nnn { zhfs   } { upzhmono    } {}
+    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } {}
+  }
+  {
+    \setCJKmainfont { FandolSong-Regular }
+      [
+        Extension  = .otf,
+        BoldFont   = FandolSong-Bold,
+        ItalicFont = FandolKai-Regular
+      ]
+    \setCJKsansfont { FandolHei-Regular  }
+      [ Extension = .otf, BoldFont = FandolHei-Bold ]
+    \setCJKmonofont { FandolFang-Regular }
+      [ Extension = .otf ]
+    \setCJKfamilyfont { zhsong } { FandolSong-Regular }
+      [ Extension = .otf, BoldFont = FandolSong-Bold ]
+    \setCJKfamilyfont { zhhei  } { FandolHei-Regular  }
+      [ Extension = .otf, BoldFont = FandolHei-Bold  ]
+    \setCJKfamilyfont { zhfs   } { FandolFang-Regular }
+      [ Extension = .otf ]
+    \setCJKfamilyfont { zhkai  } { FandolKai-Regular  }
+      [ Extension = .otf ]
+  }
+%</fandol>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-%</adobe>
-%<*fandol>
-%    \end{macrocode}
+% \paragraph{\opt{founder}}
 %
-% \subsubsection{\pkg{ctex-fontset-fandol.def}}
+% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。}
 %
 %    \begin{macrocode}
-\sys_if_engine_pdftex:TF
+%<*founder>
+\ctex_fontset_case:nnn
   {
-    \sys_if_output_pdf:TF
-      { \ctex_fontset_error:n { fandol } }
+    \ctex_zhmap_case:nnn
       {
-        \ctex_zhmap_case:nnn
-          {
-            \setCJKmainfont
-              [
-                      cmap = UniGB-UTF16-H ,
-                  BoldFont = FandolSong-Bold.otf ,
-                ItalicFont = FandolKai-Regular.otf
-              ] { FandolSong-Regular.otf }
-            \setCJKsansfont
-              [
-                    cmap = UniGB-UTF16-H ,
-                BoldFont = FandolHei-Bold.otf
-              ] { FandolHei-Regular.otf }
-            \setCJKmonofont [ cmap = UniGB-UTF16-H ] { FandolFang-Regular.otf }
-            \setCJKfamilyfont { zhsong }
-              [
-                    cmap = UniGB-UTF16-H ,
-                BoldFont = FandolSong-Bold.otf
-              ] { FandolSong-Regular.otf }
-            \setCJKfamilyfont { zhhei }
-              [
-                    cmap = UniGB-UTF16-H ,
-                BoldFont = FandolHei-Bold.otf
-              ] { FandolHei-Regular.otf }
-            \setCJKfamilyfont { zhfs }
-              [ cmap = UniGB-UTF16-H ] { FandolFang-Regular.otf }
-            \setCJKfamilyfont { zhkai }
-              [ cmap = UniGB-UTF16-H ] { FandolKai-Regular.otf }
-            \ctex_punct_set:n { fandol }
-            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-            \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
-            \ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
-            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-            \ctex_punct_map_bfseries:nn { \CJKrmdefault , zhsong } { zhsongb }
-            \ctex_punct_map_bfseries:nn { \CJKsfdefault , zhhei } { zhheib }
-          }
-          {
-            \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfandolfonts }
-            \ctex_punct_set:n { fandol }
-            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-            \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-          }
-          { \ctex_fontset_error:n { fandol } }
+        \setCJKmainfont { FZSSK.TTF }
+          [ BoldFont = FZXBSK.TTF, ItalicFont = FZKTK.TTF ]
+        \setCJKsansfont { FZXH1K.TTF } [ BoldFont = FZHTK.TTF ]
+        \setCJKmonofont { FZFSK.TTF }
+        \setCJKfamilyfont { zhsong } { FZSSK.TTF } [ BoldFont = FZXBSK.TTF ]
+        \setCJKfamilyfont { zhhei  } { FZHTK.TTF }
+        \setCJKfamilyfont { zhkai  } { FZKTK.TTF }
+        \setCJKfamilyfont { zhfs   } { FZFSK.TTF }
+        \setCJKfamilyfont { zhli   } { FZLSK.TTF }
+        \setCJKfamilyfont { zhyou  } { FZY1K.TTF } [ BoldFont = FZY3K.TTF ]
+        \ctex_punct_set:n { founder }
+        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
+        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhheil  }
+        \ctex_punct_map_family:nn   { \CJKttdefault         } { zhfs    }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
+        \ctex_punct_map_bfseries:nn { \CJKsfdefault         } { zhhei   }
+        \ctex_punct_map_bfseries:nn { zhyou                 } { zhyoub  }
       }
-  }
-  {
-    \sys_if_engine_uptex:TF
       {
-        \ctex_set_upfonts:nnnnnn
-          {FandolSong-Regular.otf} {FandolSong-Bold.otf} {FandolKai-Regular.otf}
-          {FandolHei-Regular.otf} {FandolHei-Bold.otf}
-          {FandolFang-Regular.otf}
-        \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
-        \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
-        \ctex_set_upfamily:nnn { zhfs } { upzhmono} {}
-        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfounderfonts }
+        \ctex_punct_set:n { founder }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
-      {
-        \setCJKmainfont
-          [
-            Extension = .otf ,
-            BoldFont = FandolSong-Bold , ItalicFont = FandolKai-Regular
-          ]
-          { FandolSong-Regular }
-        \setCJKsansfont
-          [ Extension = .otf , BoldFont = FandolHei-Bold ] { FandolHei-Regular }
-        \setCJKmonofont [ Extension = .otf ] { FandolFang-Regular }
-        \setCJKfamilyfont { zhsong }
-          [ Extension = .otf , BoldFont = FandolSong-Bold ] { FandolSong-Regular }
-        \setCJKfamilyfont { zhhei }
-          [ Extension = .otf , BoldFont = FandolHei-Bold ] { FandolHei-Regular }
-        \setCJKfamilyfont { zhfs }  [ Extension = .otf ] { FandolFang-Regular }
-        \setCJKfamilyfont { zhkai } [ Extension = .otf ] { FandolKai-Regular }
-      }
+      { \ctex_fontset_error:n { founder } }
   }
+  {
+    \ctex_set_upfonts:nnnnnn
+      { FZSSK.TTF  }
+      { FZXBSK.TTF }
+      { FZKTK.TTF  }
+      { FZXH1K.TTF }
+      { FZHTK.TTF  }
+      { FZFSK.TTF  }
+    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } { upzhserifb }
+    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } { upzhsansb  }
+    \ctex_set_upfamily:nnn { zhfs   } { upzhmono    } {}
+    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } {}
+    \ctex_set_upfamily:nnn { zhli   } { upschrm     } {}
+    \ctex_set_upfamily:nnn { zhyou  } { upschgt     } {}
+    \ctex_set_upmap:nnn    { upstsl } { FZLSK.TTF } {}
+    \ctex_set_upmap:nnn    { upstht } { FZY1K.TTF } {}
+  }
+  {
+    \setCJKmainfont { FZShuSong-Z01 }
+      [ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ]
+    \setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ]
+    \setCJKmonofont { FZFangSong-Z02 }
+    \setCJKfamilyfont { zhsong } { FZShuSong-Z01  }
+      [ BoldFont = FZXiaoBiaoSong-B05 ]
+    \setCJKfamilyfont { zhhei  } { FZHei-B01      }
+    \setCJKfamilyfont { zhkai  } { FZKai-Z03      }
+    \setCJKfamilyfont { zhfs   } { FZFangSong-Z02 }
+    \setCJKfamilyfont { zhli   } { FZLiShu-S01    }
+    \setCJKfamilyfont { zhyou  } { FZXiYuan-M01   }
+      [ BoldFont = FZZhunYuan-M02 ]
+  }
+%</founder>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-%</fandol>
-%    \end{macrocode}
+% \paragraph{\opt{mac} 相关}
 %
-% \subsubsection{\pkg{ctex-fontset-mac.def} 等}
-% \changes{v2.4.14}{2018/05/01}{区分 \texttt{macold} 及 \texttt{macnew}。}
+% \changes{v2.4.14}{2018/05/01}{区分 \opt{macold} 及 \opt{macnew}。}
 %
 % 按 \href{https://github.com/CTeX-org/ctex-kit/issues/351}{Issue 351}
 % 的讨论,以 El Capitan 为分界,分别设置 |macold|(El Capitan 之前)
@@ -9948,261 +10231,304 @@
 %</mac>
 %    \end{macrocode}
 %
-% |macold| 的设置参考了 ^^A
-% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-\%E9\%A2\%84\%E8\%A3\%85\%E7\%9A\%84\%E4\%B8\%BB\%E8\%A6\%81\%E7\%AE\%80\%E4\%BD\%93\%E4\%B8\%AD\%E6\%96\%87\%E5\%AD\%97\%E4\%BD\%93}^^A
+% \changes{v2.4.14}{2018/05/01}{配置 \opt{macnew} 的默认字体设置。}
+% \changes{v2.5}{2019/11/05}{为 \opt{macnew} 增加粗楷体、隶书和圆体的定义。}
+% \changes{v2.5}{2019/11/07}{允许 \opt{macnew} 在 \LaTeX{} 和 \upLaTeX{} 下使用。}
+%
+% |macold| 的设置参考了
+% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-预装的主要简体中文字体}^^A
 % {OS X Mavericks (10.9) 预装的主要简体中文字体列表}。
 %
-% 在 \dvipdfmx{} 下,可以通过下述方式使用华文宋体和华文楷体:
-% \begin{verbatim}
-%   \special{pdf:mapline unisong at Unicode@ unicode :4:Songti.ttc}
-%   \special{pdf:mapline unikai at Unicode@  unicode :4:Kaiti.ttc}
-% \end{verbatim}
-% 而 \tn{pdfmapline} 似乎不支持带索引的 \texttt{ttc} 字体,\file{Songti.ttc} 默认
-% 使用的是 Songti SC Black,\file{Kaiti.ttc} 默认使用的是 Kaiti SC Black。
-% 华文黑体不能通过这种方式使用:
-% \begin{verbatim}
-%   \special{pdf:mapline unihei at Unicode@ unicode \detokenize{华文黑体}.ttf}
-% \end{verbatim}
-% \dvipdfmx{} 不能生成 PDF,报下述错误:
-% \begin{verbatim}
-%   ** WARNING ** UCS-4 TrueType cmap table...
-%   ** ERROR ** Unable to read OpenType/TrueType Unicode cmap table.
-% \end{verbatim}
-% 如果将 CMap 改为 UniGB-UTF16-H,错误信息是
-% \begin{verbatim}
-%   ** WARNING ** No usable TrueType cmap table found for font "华文黑体.ttf".
-%   ** WARNING ** CID character collection for this font is set to "Adobe-GB1"
-%   ** ERROR ** Cannot continue without this...
-% \end{verbatim}
-% 在 \pdfTeX{} 下生成的 PDF 只有方框^^A
-% \footnote{\url{http://www.newsmth.net/bbscon.php?bid=460&id=312640}}。
-% 华文细黑和华文仿宋的情况类似。
-% 这确认为 \dvipdfmx{} 的 bug^^A
-% \begingroup\makeatletter\@makeother\#\@firstofone{\endgroup
-% \footnote{\url{https://github.com/clerkma/ptex-ng/blob/master/texk/libdpx/cidtype2.c#L597}}}。
-%
-% \changes{v2.4.14}{2018/05/01}{配置 \texttt{macnew} 的默认字体设置。}
-%
 % |macnew| 在默认字体设置方面,引入了多字重的宋体作为罗马字族,
 % 以及引入了苹方黑体作为无衬线字族。
-%
 % 由于 Songti SC Light 的字重与 STSong 及 Windows 上的 SimSun 更接近,故默认字重
-% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。下方关于 |zhsong| 的字族
-% 设置也有同样的情况。
+% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。黑体、圆体等设置
+% 也有类似的情况。
 %
 %    \begin{macrocode}
 %<*macold|macnew>
-\sys_if_engine_pdftex:TF
+\ctex_fontset_case:nnnn
   { \ctex_fontset_error:n { mac } }
-  {
-    \sys_if_engine_uptex:TF
-      { \ctex_fontset_error:n { mac } }
-      {
 %<*macold>
-        \setCJKmainfont [ BoldFont = STHeiti , ItalicFont = STKaiti ] { STSong }
-        \setCJKsansfont [ BoldFont = STHeiti ] { STXihei }
+  { \ctex_fontset_error:n { macold } }
+  { \ctex_fontset_error:n { macold } }
 %</macold>
 %<*macnew>
-        \setCJKmainfont
+  {
+    \ctex_zhmap_case:nnn
+      {
+        \setCJKmainfont { :3:Songti.ttc }
           [
-               UprightFont = *~Light ,
-                  BoldFont = *~Bold ,
-                ItalicFont = Kaiti~SC ,
-            BoldItalicFont = Kaiti~SC~Bold
-          ] { Songti~SC }
-        \setCJKsansfont { PingFang~SC }
+            BoldFont       = :1:Songti.ttc,
+            ItalicFont     = :0:Kaiti.ttc,
+            BoldItalicFont = :3:Kaiti.ttc,
+          ]
+        \setCJKsansfont { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ]
+        \setCJKmonofont { STFANGSO.ttf    }
+        \setCJKfamilyfont { zhsong } { :3:Songti.ttc   } [ BoldFont = :1:Songti.ttc   ]
+        \setCJKfamilyfont { zhhei  } { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ]
+        \setCJKfamilyfont { zhkai  } { :0:Kaiti.ttc    } [ BoldFont = :3:Kaiti.ttc    ]
+        \setCJKfamilyfont { zhfs   } { STFANGSO.ttf    }
+        \setCJKfamilyfont { zhli   } { :0:Baoli.ttc    }
+        \setCJKfamilyfont { zhyou  } { :4:Yuanti.ttc   } [ BoldFont = :0:Yuanti.ttc   ]
+        \ctex_punct_set:n { mac }
+        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
+        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhheil  }
+        \ctex_punct_map_family:nn   { \CJKttdefault         } { zhfs    }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
+        \ctex_punct_map_bfseries:nn { \CJKsfdefault         } { zhhei   }
+        \ctex_punct_map_bfseries:nn { zhyou                 } { zhyoub  }
+      }
+      {
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhmacfonts }
+        \ctex_punct_set:n { mac }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
+      }
+      { \ctex_fontset_error:n { macnew } }
+  }
+  {
+    \ctex_set_upmap:nnn { upserif   } { :3:Songti.ttc } { :1:Songti.ttc }
+    \ctex_set_upmap:nnn { upserifit } { :0:Kaiti.ttc  } { }
+    \ctex_set_upmap:nnn { upstsl    } { :0:Baoli.ttc  } { }
+    \ctex_set_upmap:nnn { upstht    } { :4:Yuanti.ttc } { }
+    \ctex_set_upmap_unicode:nnn { upsans } { :2:PingFang.ttc } { :8:PingFang.ttc }
+    \ctex_set_upmap_unicode:nnn { upmono } { STFANGSO.ttf    } { }
+    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } { upzhserifb }
+    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } { upzhsansb  }
+    \ctex_set_upfamily:nnn { zhfs   } { upzhmono    } { }
+    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } { }
+    \ctex_set_upfamily:nnn { zhli   } { upschrm     } { }
+    \ctex_set_upfamily:nnn { zhyou  } { upschgt     } { }
+  }
 %</macnew>
-        \setCJKmonofont { STFangsong }
+  {
 %<*macold>
-        \setCJKfamilyfont { zhsong } { STSong }
-        \setCJKfamilyfont { zhhei }  { STHeiti }
+    \setCJKmainfont { STSong     }
+      [ BoldFont = STHeiti, ItalicFont = STKaiti ]
+    \setCJKsansfont { STXihei    } [ BoldFont = STHeiti ]
+    \setCJKmonofont { STFangsong }
+    \setCJKfamilyfont { zhsong } { STSong     }
+    \setCJKfamilyfont { zhhei  } { STHeiti    }
+    \setCJKfamilyfont { zhfs   } { STFangsong }
+    \setCJKfamilyfont { zhkai  } { STKaiti    }
 %</macold>
 %<*macnew>
-        \setCJKfamilyfont { zhsong }
-          [
-               UprightFont = *~Light ,
-                  BoldFont = *~Bold ,
-          ] { Songti~SC }
-        \setCJKfamilyfont { zhhei }  { Heiti~SC }
-        \setCJKfamilyfont { zhpf }   { PingFang~SC }
+    \setCJKmainfont { Songti~SC~Light }
+      [
+        BoldFont       = Songti~SC~Bold,
+        ItalicFont     = Kaiti~SC,
+        BoldItalicFont = Kaiti~SC~Bold
+      ]
+    \setCJKsansfont { PingFang~SC }
+    \setCJKmonofont { STFangsong  }
+    \setCJKfamilyfont { zhsong } { Songti~SC~Light } [ BoldFont = Songti~SC~Bold ]
+    \setCJKfamilyfont { zhhei  } { Heiti~SC~Light  } [ BoldFont = Heiti~SC~Medium ]
+    \setCJKfamilyfont { zhpf   } { PingFang~SC     }
+    \setCJKfamilyfont { zhfs   } { STFangsong      }
+    \setCJKfamilyfont { zhkai  } { Kaiti~SC        } [ BoldFont = Kaiti~SC~Bold ]
+    \setCJKfamilyfont { zhli   } { Baoli~SC        }
+    \setCJKfamilyfont { zhyou  } { Yuanti~SC~Light } [ BoldFont = Yuanti~SC~Regular ]
 %</macnew>
-        \setCJKfamilyfont { zhfs }   { STFangsong }
-%<macold>\setCJKfamilyfont { zhkai }  { STKaiti }
-%<macnew>\setCJKfamilyfont { zhkai }  { Kaiti~SC }
-      }
   }
 %</macold|macnew>
 %    \end{macrocode}
 %
-% \subsubsection{\pkg{ctex-fontset-founder.def}}
+% \paragraph{\opt{ubuntu}}
 %
-%    \begin{macrocode}
-%<*founder>
-%    \end{macrocode}
+% \changes{v2.5}{2019/11/07}{\opt{ubuntu} 改用思源(Noto CJK)和文鼎字库,不再
+% 支持使用 \pdfLaTeX{} 编译。}
 %
-% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。}
-%
 %    \begin{macrocode}
-\sys_if_engine_pdftex:TF
+%<*ubuntu>
+\ctex_fontset_case:nnnn
+  { \ctex_fontset_error:n { ubuntu } }
   {
     \ctex_zhmap_case:nnn
       {
-        \setCJKmainfont
-          [ BoldFont = FZXBSK.TTF , ItalicFont = FZKTK.TTF ] { FZSSK.TTF }
-        \setCJKsansfont [ BoldFont = FZHTK.TTF ] { FZXH1K.TTF }
-        \setCJKmonofont { FZFSK.TTF }
-        \setCJKfamilyfont { zhsong } [ BoldFont = FZXBSK.TTF ] { FZSSK.TTF }
-        \setCJKfamilyfont { zhhei }  { FZHTK.TTF }
-        \setCJKfamilyfont { zhkai }  { FZKTK.TTF }
-        \setCJKfamilyfont { zhfs }   { FZFSK.TTF }
-        \setCJKfamilyfont { zhli }   { FZLSK.TTF }
-        \setCJKfamilyfont { zhyou } [ BoldFont = FZY3K.TTF ] { FZY1K.TTF }
-        \ctex_punct_set:n { founder }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_family:nn { \CJKsfdefault } { zhheil }
-        \ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault , zhsong } { zhsongb }
-        \ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei }
-        \ctex_punct_map_bfseries:nn { zhyou } { zhyoub }
+        \setCJKmainfont { :2:NotoSerifCJK-Regular.ttc }
+          [ BoldFont = :2:NotoSerifCJK-Bold.ttc, ItalicFont = gkai00mp.ttf ]
+        \setCJKsansfont { :2:NotoSansCJK-Regular.ttc  }
+          [ BoldFont = :2:NotoSansCJK-Bold.ttc  ]
+        \setCJKmonofont { :2:NotoSerifCJK-Regular.ttc }
+          [ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
+        \setCJKfamilyfont { zhsong } { :2:NotoSerifCJK-Regular.ttc }
+          [ BoldFont = :2:NotoSerifCJK-Bold.ttc ]
+        \setCJKfamilyfont { zhhei  } { :2:NotoSansCJK-Regular.ttc  }
+          [ BoldFont = :2:NotoSansCJK-Bold.ttc  ]
+        \setCJKfamilyfont { zhkai  } { gkai00mp.ttf  }
+        \ctex_punct_set:n { fandol }
+        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
+        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhhei   }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
+        \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei  } { zhheib  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
       }
       {
-        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfounderfonts }
-        \ctex_punct_set:n { founder }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { zhubuntufonts }
+        \ctex_punct_set:n { ubuntu }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
-      { \ctex_fontset_error:n { founder } }
+      { \ctex_fontset_error:n { ubuntu } }
   }
   {
-    \sys_if_engine_uptex:TF
-      {
-        \ctex_set_upfonts:nnnnnn
-          { FZSSK.TTF } { FZXBSK.TTF } { FZKTK.TTF }
-          { FZXH1K.TTF } { FZHTK.TTF }
-          { FZFSK.TTF }
-        \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
-        \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
-        \ctex_set_upfamily:nnn { zhfs } { upzhmono} {}
-        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
-        \ctex_set_upfamily:nnn { zhli } { upschrm } {}
-        \ctex_set_upmap:nnn { upstsl } { FZLSK.TTF } {}
-        \ctex_set_upfamily:nnn { zhyou } { upschgt } {}
-        \ctex_set_upmap:nnn { upstht } { FZY1K.TTF } {}
-      }
-      {
-        \setCJKmainfont
-          [ BoldFont = FZXiaoBiaoSong-B05 , ItalicFont = FZKai-Z03 ] { FZShuSong-Z01 }
-        \setCJKsansfont [ BoldFont = FZHei-B01 ] { FZXiHeiI-Z08 }
-        \setCJKmonofont { FZFangSong-Z02 }
-        \setCJKfamilyfont { zhsong } [ BoldFont = FZXiaoBiaoSong-B05 ] { FZShuSong-Z01 }
-        \setCJKfamilyfont { zhhei }  { FZHei-B01 }
-        \setCJKfamilyfont { zhkai }  { FZKai-Z03 }
-        \setCJKfamilyfont { zhfs }   { FZFangSong-Z02 }
-        \setCJKfamilyfont { zhli }   { FZLiShu-S01 }
-        \setCJKfamilyfont { zhyou } [ BoldFont = FZZhunYuan-M02 ] { FZXiYuan-M01 }
-      }
+    \ctex_set_upmap_unicode:nnn { upserif }
+      { :2:NotoSerifCJK-Regular.ttc } { :2:NotoSerifCJK-Bold.ttc }
+    \ctex_set_upmap_unicode:nnn { upsans  }
+      { :2:NotoSansCJK-Regular.ttc  } { :2:NotoSansCJK-Bold.ttc  }
+    \ctex_set_upmap_unicode:nnn { upmono  }
+      { :2:NotoSerifCJK-Regular.ttc } { }
+    \ctex_set_upmap:nnn { upserifit } { gkai00mp.ttf  } { }
+    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } { upzhserifb }
+    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } { upzhsansb  }
+    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } { }
   }
+  {
+    \setCJKmainfont { Noto~Serif~CJK~SC } [ ItalicFont = AR~PL~KaitiM~GB ]
+    \setCJKsansfont { Noto~Sans~CJK~SC  }
+    \setCJKmonofont { Noto~Serif~CJK~SC }
+    \setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC }
+    \setCJKfamilyfont { zhhei  } { Noto~Sans~CJK~SC  }
+    \setCJKfamilyfont { zhkai  } { AR~PL~KaitiM~GB   }
+  }
+%</ubuntu>
 %    \end{macrocode}
 %
+% \paragraph{\opt{windows}}
+%
+% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免
+%   权限问题。}
+% \changes{v2.5}{2019/11/04}{使用环境变量代替绝对路径查找字体。}
+% \changes{v2.5}{2019/11/05}{不再支持 Windows XP 系统,\opt{windowsold} 和
+%   \opt{windowsnew} 成为过时字库选项。}
+%
+% \begin{variable}{ \c_@@_msyh_suffix_tl}
+% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要
+% 加以区分。
 %    \begin{macrocode}
-%</founder>
-%<*ubuntu>
+%<*windows>
+\file_if_exist:nTF { \c_dollar_str WINDIR/Fonts/msyh.ttc }
+  { \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } }
+  {
+    \file_if_exist:nTF { msyh.ttc }
+      { \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } }
+      { \tl_const:Nn \c_@@_msyh_suffix_tl { ttf } }
+  }
 %    \end{macrocode}
+% \end{variable}
 %
-% \subsubsection{\pkg{ctex-fontset-ubuntu.def}}
-%
-% 以下根据 Ubuntu 12.04 的中文字体情况设置。CMap 不清楚应该是什么,指定为
-% UniGB-UTF16-H 还是有警告:
-% \begin{verbatim}
-%   ** WARNING ** UCS-4 TrueType cmap table...
-% \end{verbatim}
-% 需要注意的是 \file{uming.ttc} 和 \file{ukai.ttc} 看起来像有四种字形的样子,但
-% 其实只有“令”和“骨”这区区两个字有新字形,其余都取旧字形^^A
-% \footnote{\url{http://www.freedesktop.org/wiki/Software/CJKUnifonts/Download/}}。
 %    \begin{macrocode}
-\sys_if_engine_pdftex:TF
+\ctex_fontset_case:nnn
   {
     \ctex_zhmap_case:nnn
       {
-        \setCJKmainfont
-          [ BoldFont = wqy-zenhei.ttc , ItalicFont = ukai.ttc ] { uming.ttc }
-        \setCJKsansfont { wqy-zenhei.ttc }
-        \setCJKmonofont { uming.ttc }
-        \setCJKfamilyfont { zhsong } { uming.ttc }
-        \setCJKfamilyfont { zhhei }  { wqy-zenhei.ttc }
-        \setCJKfamilyfont { zhkai }  { ukai.ttc }
-        \ctex_punct_set:n { ubuntu }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
-        \ctex_punct_map_family:nn { \CJKttdefault } { zhsong }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
+        \ctex_punct_set:n { windows }
+        \setCJKmainfont { simsun.ttc }
+          [ BoldFont = simhei.ttf, ItalicFont = simkai.ttf ]
+        \setCJKsansfont { msyh.\c_@@_msyh_suffix_tl }
+          [ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ]
+        \setCJKmonofont { simfang.ttf }
+        \setCJKfamilyfont { zhsong  } { simsun.ttc  }
+        \setCJKfamilyfont { zhhei   } { simhei.ttf  }
+        \setCJKfamilyfont { zhfs    } { simfang.ttf }
+        \setCJKfamilyfont { zhkai   } { simkai.ttf  }
+        \setCJKfamilyfont { zhyahei } { msyh.\c_@@_msyh_suffix_tl }
+          [ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ]
+        \setCJKfamilyfont { zhli    } { simli.ttf   }
+        \setCJKfamilyfont { zhyou   } { simyou.ttf  }
+        \ctex_punct_map_family:nn   { \CJKrmdefault          } { zhsong   }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault          } { zhhei    }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault          } { zhkai    }
+        \ctex_punct_map_family:nn   { \CJKsfdefault          } { zhyahei  }
+        \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhyahei } { zhyaheib }
+        \ctex_punct_map_family:nn   { \CJKttdefault          } { zhfs     }
       }
       {
-        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { zhubuntufonts }
-        \ctex_punct_set:n { ubuntu }
-        \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
-        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
-        \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
+        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhwindowsfonts }
+        \ctex_punct_set:n { windows }
+        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
+        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
+        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
       }
-      { \ctex_fontset_error:n { ubuntu } }
-  }
-  {
-    \sys_if_engine_uptex:TF
       {
-        \ctex_set_upfonts:nnnnnn
-          { uming.ttc } { wqy-zenhei.ttc } { ukai.ttc }
-          { wqy-zenhei.ttc } { wqy-zenhei.ttc }
-          { uming.ttc }
-        \ctex_set_upfamily:nnn { zhsong } { upzhserif } {}
-        \ctex_set_upfamily:nnn { zhhei } { upzhsans } {}
-        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
+        \tl_set:Nn \CJKrmdefault { rm }
+        \tl_set:Nn \CJKsfdefault { sf }
+        \tl_set:Nn \CJKttdefault { tt }
       }
-      {
-        \setCJKmainfont
-          [ BoldFont = WenQuanYi~Zen~Hei , ItalicFont = AR~PL~UKai~CN ] { AR~PL~UMing~CN }
-        \setCJKsansfont { WenQuanYi~Zen~Hei }
-        \setCJKmonofont { AR~PL~UMing~CN }
-        \setCJKfamilyfont { zhsong } { AR~PL~UMing~CN }
-        \setCJKfamilyfont { zhhei }  { WenQuanYi~Zen~Hei }
-        \setCJKfamilyfont { zhkai }  { AR~PL~UKai~CN }
-      }
   }
+  {
+    \ctex_set_upfonts:nnnnnn
+      { simsun.ttc                   }
+      { simhei.ttf                   }
+      { simkai.ttf                   }
+      { msyh.\c_@@_msyh_suffix_tl    }
+      { msyhbd.\c_@@_msyh_suffix_tl  }
+      { simfang.ttf                  }
+    \ctex_set_upfamily:nnn { zhsong  } { upzhserif   } {}
+    \ctex_set_upfamily:nnn { zhhei   } { upzhserifb  } {}
+    \ctex_set_upfamily:nnn { zhfs    } { upzhmono    } {}
+    \ctex_set_upfamily:nnn { zhkai   } { upzhserifit } {}
+    \ctex_set_upfamily:nnn { zhyahei } { upzhsans    } { upzhsansb }
+    \ctex_set_upfamily:nnn { zhli    } { upschrm     } {}
+    \ctex_set_upfamily:nnn { zhyou   } { upschgt     } {}
+    \ctex_set_upmap:nnn { upstsl } { simli.ttf  } {}
+    \ctex_set_upmap:nnn { upstht } { simyou.ttf } {}
+  }
+  {
+    \setCJKmainfont   { SimSun } [ BoldFont = SimHei , ItalicFont = KaiTi ]
+    \setCJKsansfont   { Microsoft~YaHei } [ BoldFont = *~Bold ]
+    \setCJKmonofont   { FangSong }
+    \setCJKfamilyfont { zhsong  } { SimSun          }
+    \setCJKfamilyfont { zhhei   } { SimHei          }
+    \setCJKfamilyfont { zhfs    } { FangSong        }
+    \setCJKfamilyfont { zhkai   } { KaiTi           }
+    \setCJKfamilyfont { zhyahei } { Microsoft~YaHei } [ BoldFont = *~Bold ]
+    \setCJKfamilyfont { zhli    } { LiSu            }
+    \setCJKfamilyfont { zhyou   } { YouYuan         }
+  }
+%</windows>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-%</ubuntu>
-%    \end{macrocode}
-%
 % \subsubsection{中文字体命令}
-% \changes{v2.4.14}{2018/05/01}{为 \texttt{macnew} 配置字体命令。}
+% \changes{v2.4.14}{2018/05/01}{为 \opt{macnew} 配置字体命令。}
 %
+% \begin{macro}{\songti,\heiti,\fangsong,\kaishu,\lishu,\youyuan,\yahei,\pingfang}
+% 使用 \upLaTeX{} 编译时,\opt{macnew} 字库中由于传统黑体(黑体-简)无法使用,
+% 我们用苹方来代替。同时 \tn{yahei}、\tn{pingfang} 命令被设置为与 \tn{heiti} 相同。
 %    \begin{macrocode}
-%<*!windows&!mac>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-\NewDocumentCommand \songti   { } { \CJKfamily { zhsong } }
-\NewDocumentCommand \heiti    { } { \CJKfamily { zhhei } }
-%<!ubuntu>\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } }
-\NewDocumentCommand \kaishu   { } { \CJKfamily { zhkai } }
-%<*windowsnew|windowsold|founder>
-\NewDocumentCommand \lishu    { } { \CJKfamily { zhli } }
-\NewDocumentCommand \youyuan  { } { \CJKfamily { zhyou } }
-%</windowsnew|windowsold|founder>
-%<windowsnew>\NewDocumentCommand \yahei    { } { \CJKfamily { zhyahei } }
+%<*!mac>
+\NewDocumentCommand \songti   { } { \CJKfamily { zhsong  } }
+\NewDocumentCommand \heiti    { } { \CJKfamily { zhhei   } }
+%<!ubuntu>\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs    } }
+\NewDocumentCommand \kaishu   { } { \CJKfamily { zhkai   } }
+%<*windows|founder|macnew>
+\NewDocumentCommand \lishu    { } { \CJKfamily { zhli    } }
+\NewDocumentCommand \youyuan  { } { \CJKfamily { zhyou   } }
+%</windows|founder|macnew>
+%<windows>\NewDocumentCommand \yahei    { } { \CJKfamily { zhyahei } }
 %<*macnew>
-\NewDocumentCommand \yahei    { } { \CJKfamily { zhpf } }
-\NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } }
+\bool_lazy_or:nnTF
+  { \sys_if_engine_pdftex_p: }
+  { \sys_if_engine_uptex_p:  }
+  {
+    \cs_new_eq:NN \yahei    \heiti
+    \cs_new_eq:NN \pingfang \heiti
+  }
+  {
+    \NewDocumentCommand \yahei    { } { \CJKfamily { zhpf } }
+    \NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } }
+  }
 %</macnew>
+%</!mac>
 %    \end{macrocode}
+% \end{macro}
 %
 %    \begin{macrocode}
-%</!windows&!mac>
 %</fontset>
-%<*zhmap>
 %    \end{macrocode}
 %
 % \subsubsection{\pkg{zhmetrics} 的字体映射}
@@ -10209,12 +10535,13 @@
 %
 % 确认 \tn{catcode},没有重复载入检查。
 %    \begin{macrocode}
+%<*zhmap>
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -10244,6 +10571,7 @@
 \expandafter\x\csname ctex at zhmap@endinput\endcsname
 %    \end{macrocode}
 %
+% \begin{macro}[int]{\ifzhmappdf}
 %    \begin{macrocode}
 \begingroup\expandafter\endgroup
 \expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname
@@ -10253,7 +10581,9 @@
   \else ifctexpdf\fi
 \endcsname
 %    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}[int]{\ProvidesFile}
 % 提供非 \LaTeX{} 格式下的 \tn{ProvidesFile}。
 %    \begin{macrocode}
 \begingroup
@@ -10266,77 +10596,22 @@
 \fi
 \endgroup
 %    \end{macrocode}
+% \end{macro}
 %
-% \paragraph{\pkg{zhwindowsfonts.tex}}
-%
+% 文件标识信息。
 %    \begin{macrocode}
-%<*windows>
-\ProvidesFile{zhwindowsfonts.tex}%
-  [2019/05/29 v2.4.16 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
-\ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <simsun.ttc}
-  \pdfmapline{=gbksong at UGBK@ <simsun.ttc}
-  \pdfmapline{=gbkkai at UGBK@  <simkai.ttf}
-  \pdfmapline{=gbkhei at UGBK@  <simhei.ttf}
-  \pdfmapline{=gbkfs at UGBK@   <simfang.ttf}
-  \pdfmapline{=gbkli at UGBK@   <simli.ttf}
-  \pdfmapline{=gbkyou at UGBK@  <simyou.ttf}
-
-  \pdfmapline{=cyberb at Unicode@  <simsun.ttc}
-  \pdfmapline{=unisong at Unicode@ <simsun.ttc}
-  \pdfmapline{=unikai at Unicode@  <simkai.ttf}
-  \pdfmapline{=unihei at Unicode@  <simhei.ttf}
-  \pdfmapline{=unifs at Unicode@   <simfang.ttf}
-  \pdfmapline{=unili at Unicode@   <simli.ttf}
-  \pdfmapline{=uniyou at Unicode@  <simyou.ttf}
-
-  \pdfmapline{=gbksongsl at UGBK@ <simsun.ttc}
-  \pdfmapline{=gbkkaisl at UGBK@  <simkai.ttf}
-  \pdfmapline{=gbkheisl at UGBK@  <simhei.ttf}
-  \pdfmapline{=gbkfssl at UGBK@   <simfang.ttf}
-  \pdfmapline{=gbklisl at UGBK@   <simli.ttf}
-  \pdfmapline{=gbkyousl at UGBK@  <simyou.ttf}
-
-  \pdfmapline{=unisongsl at Unicode@ <simsun.ttc}
-  \pdfmapline{=unikaisl at Unicode@  <simkai.ttf}
-  \pdfmapline{=uniheisl at Unicode@  <simhei.ttf}
-  \pdfmapline{=unifssl at Unicode@   <simfang.ttf}
-  \pdfmapline{=unilisl at Unicode@   <simli.ttf}
-  \pdfmapline{=uniyousl at Unicode@  <simyou.ttf}
-
-\else
-  \special{pdf:mapline gbk at UGBK@     unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline gbksong at UGBK@ unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline gbkkai at UGBK@  unicode simkai.ttf -v 70}
-  \special{pdf:mapline gbkhei at UGBK@  unicode simhei.ttf -v 150}
-  \special{pdf:mapline gbkfs at UGBK@   unicode simfang.ttf -v 50}
-  \special{pdf:mapline gbkli at UGBK@   unicode simli.ttf -v 150}
-  \special{pdf:mapline gbkyou at UGBK@  unicode simyou.ttf -v 60}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline unisong at Unicode@ unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline unikai at Unicode@  unicode simkai.ttf -v 70}
-  \special{pdf:mapline unihei at Unicode@  unicode simhei.ttf -v 150}
-  \special{pdf:mapline unifs at Unicode@   unicode simfang.ttf -v 50}
-  \special{pdf:mapline unili at Unicode@   unicode simli.ttf -v 150}
-  \special{pdf:mapline uniyou at Unicode@  unicode simyou.ttf -v 60}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode :0:simsun.ttc -s .167 -v 50}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode simkai.ttf -s .167 -v 70}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode simhei.ttf -s .167 -v 150}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode simfang.ttf -s .167 -v 50}
-  \special{pdf:mapline gbklisl at UGBK@   unicode simli.ttf -s .167 -v 150}
-  \special{pdf:mapline gbkyousl at UGBK@  unicode simyou.ttf -s .167 -v 60}
-
-  \special{pdf:mapline unisongsl at Unicode@ unicode :0:simsun.ttc -s .167 -v 50}
-  \special{pdf:mapline unikaisl at Unicode@  unicode simkai.ttf -s .167 -v 70}
-  \special{pdf:mapline uniheisl at Unicode@  unicode simhei.ttf -s .167 -v 150}
-  \special{pdf:mapline unifssl at Unicode@   unicode simfang.ttf -s .167 -v 50}
-  \special{pdf:mapline unilisl at Unicode@   unicode simli.ttf -s .167 -v 150}
-  \special{pdf:mapline uniyousl at Unicode@  unicode simyou.ttf -s .167 -v 60}
-
-%</windows>
+%<adobe>\ProvidesFile{zhadobefonts.tex}%
+%<adobe>  [2020/05/02 v2.5.1 Adobe font map loader for DVIPDFMx (CTEX)]
+%<fandol>\ProvidesFile{zhfandolfonts.tex}%
+%<fandol>  [2020/05/02 v2.5.1 Fandol font map loader for DVIPDFMx (CTEX)]
+%<founder>\ProvidesFile{zhfounderfonts.tex}%
+%<founder>  [2020/05/02 v2.5.1 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
+%<mac>\ProvidesFile{zhmacfonts.tex}%
+%<mac>  [2020/05/02 v2.5.1 Mac font map loader for pdfTeX and DVIPDFMx (CTEX)]
+%<ubuntu>\ProvidesFile{zhubuntufonts.tex}%
+%<ubuntu>  [2020/05/02 v2.5.1 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
+%<windows>\ProvidesFile{zhwindowsfonts.tex}%
+%<windows>  [2020/05/02 v2.5.1 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
 %    \end{macrocode}
 %
 % \paragraph{\pkg{zhadobefonts.tex}}
@@ -10343,35 +10618,28 @@
 %
 %    \begin{macrocode}
 %<*adobe>
-\ProvidesFile{zhadobefonts.tex}%
-  [2019/05/29 v2.4.16 Adobe font map loader for DVIPDFMx (CTEX)]
-
 \ifzhmappdf
 %% pdfTeX does not support OTF fonts
-
 \else
-  \special{pdf:mapline gbk at UGBK@     UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline gbksong at UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline gbkkai at UGBK@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
-  \special{pdf:mapline gbkhei at UGBK@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
-  \special{pdf:mapline gbkfs at UGBK@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
-
-  \special{pdf:mapline cyberb at Unicode@  UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline unisong at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline unikai at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
-  \special{pdf:mapline unihei at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
-  \special{pdf:mapline unifs at Unicode@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
-
-  \special{pdf:mapline gbksongsl at UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
-
-  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
+  \special{pdf:mapline gbkhei at UGBK@       UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
+  \special{pdf:mapline gbkfs at UGBK@        UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
+  \special{pdf:mapline unihei at Unicode@    UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
+  \special{pdf:mapline unifs at Unicode@     UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H AdobeSongStd-Light.otf       -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H AdobeKaitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     UniGB-UTF16-H AdobeHeitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf       -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf    -s .167}
   \special{pdf:mapline unifssl at Unicode@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
-
+\fi
 %</adobe>
 %    \end{macrocode}
 %
@@ -10379,35 +10647,28 @@
 %
 %    \begin{macrocode}
 %<*fandol>
-\ProvidesFile{zhfandolfonts.tex}%
-  [2019/05/29 v2.4.16 Fandol font map loader for DVIPDFMx (CTEX)]
-
 \ifzhmappdf
 %% pdfTeX does not support OTF fonts
-
 \else
-  \special{pdf:mapline gbk at UGBK@     UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline gbksong at UGBK@ UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline gbkkai at UGBK@  UniGB-UTF16-H FandolKai-Regular.otf}
-  \special{pdf:mapline gbkhei at UGBK@  UniGB-UTF16-H FandolHei-Regular.otf}
-  \special{pdf:mapline gbkfs at UGBK@   UniGB-UTF16-H FandolFang-Regular.otf}
-
-  \special{pdf:mapline cyberb at Unicode@  UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline unisong at Unicode@ UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline unikai at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf}
-  \special{pdf:mapline unihei at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf}
-  \special{pdf:mapline unifs at Unicode@   UniGB-UTF16-H FandolFang-Regular.otf}
-
-  \special{pdf:mapline gbksongsl at UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  UniGB-UTF16-H FandolKai-Regular.otf -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  UniGB-UTF16-H FandolHei-Regular.otf -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   UniGB-UTF16-H FandolFang-Regular.otf -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H FandolKai-Regular.otf}
+  \special{pdf:mapline gbkhei at UGBK@       UniGB-UTF16-H FandolHei-Regular.otf}
+  \special{pdf:mapline gbkfs at UGBK@        UniGB-UTF16-H FandolFang-Regular.otf}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H FandolKai-Regular.otf}
+  \special{pdf:mapline unihei at Unicode@    UniGB-UTF16-H FandolHei-Regular.otf}
+  \special{pdf:mapline unifs at Unicode@     UniGB-UTF16-H FandolFang-Regular.otf}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H FandolSong-Regular.otf -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H FandolKai-Regular.otf  -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     UniGB-UTF16-H FandolHei-Regular.otf  -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      UniGB-UTF16-H FandolFang-Regular.otf -s .167}
   \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf  -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf  -s .167}
   \special{pdf:mapline unifssl at Unicode@   UniGB-UTF16-H FandolFang-Regular.otf -s .167}
-
+\fi
 %</fandol>
 %    \end{macrocode}
 %
@@ -10415,33 +10676,27 @@
 %
 %    \begin{macrocode}
 %<*founder>
-\ProvidesFile{zhfounderfonts.tex}%
-  [2019/05/29 v2.4.16 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
 \ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <FZSSK.TTF}
-  \pdfmapline{=gbksong at UGBK@ <FZSSK.TTF}
-  \pdfmapline{=gbkkai at UGBK@  <FZKTK.TTF}
-  \pdfmapline{=gbkhei at UGBK@  <FZHTK.TTF}
-  \pdfmapline{=gbkfs at UGBK@   <FZFSK.TTF}
-  \pdfmapline{=gbkli at UGBK@   <FZLSK.TTF}
-  \pdfmapline{=gbkyou at UGBK@  <FZY1K.TTF}
-
-  \pdfmapline{=cyberb at Unicode@  <FZSSK.TTF}
-  \pdfmapline{=unisong at Unicode@ <FZSSK.TTF}
-  \pdfmapline{=unikai at Unicode@  <FZKTK.TTF}
-  \pdfmapline{=unihei at Unicode@  <FZHTK.TTF}
-  \pdfmapline{=unifs at Unicode@   <FZFSK.TTF}
-  \pdfmapline{=unili at Unicode@   <FZLSK.TTF}
-  \pdfmapline{=uniyou at Unicode@  <FZY1K.TTF}
-
-  \pdfmapline{=gbksongsl at UGBK@ <FZSSK.TTF}
-  \pdfmapline{=gbkkaisl at UGBK@  <FZKTK.TTF}
-  \pdfmapline{=gbkheisl at UGBK@  <FZHTK.TTF}
-  \pdfmapline{=gbkfssl at UGBK@   <FZFSK.TTF}
-  \pdfmapline{=gbklisl at UGBK@   <FZLSK.TTF}
-  \pdfmapline{=gbkyousl at UGBK@  <FZY1K.TTF}
-
+  \pdfmapline{=gbk at UGBK@          <FZSSK.TTF}
+  \pdfmapline{=gbksong at UGBK@      <FZSSK.TTF}
+  \pdfmapline{=gbkkai at UGBK@       <FZKTK.TTF}
+  \pdfmapline{=gbkhei at UGBK@       <FZHTK.TTF}
+  \pdfmapline{=gbkfs at UGBK@        <FZFSK.TTF}
+  \pdfmapline{=gbkli at UGBK@        <FZLSK.TTF}
+  \pdfmapline{=gbkyou at UGBK@       <FZY1K.TTF}
+  \pdfmapline{=cyberb at Unicode@    <FZSSK.TTF}
+  \pdfmapline{=unisong at Unicode@   <FZSSK.TTF}
+  \pdfmapline{=unikai at Unicode@    <FZKTK.TTF}
+  \pdfmapline{=unihei at Unicode@    <FZHTK.TTF}
+  \pdfmapline{=unifs at Unicode@     <FZFSK.TTF}
+  \pdfmapline{=unili at Unicode@     <FZLSK.TTF}
+  \pdfmapline{=uniyou at Unicode@    <FZY1K.TTF}
+  \pdfmapline{=gbksongsl at UGBK@    <FZSSK.TTF}
+  \pdfmapline{=gbkkaisl at UGBK@     <FZKTK.TTF}
+  \pdfmapline{=gbkheisl at UGBK@     <FZHTK.TTF}
+  \pdfmapline{=gbkfssl at UGBK@      <FZFSK.TTF}
+  \pdfmapline{=gbklisl at UGBK@      <FZLSK.TTF}
+  \pdfmapline{=gbkyousl at UGBK@     <FZY1K.TTF}
   \pdfmapline{=unisongsl at Unicode@ <FZSSK.TTF}
   \pdfmapline{=unikaisl at Unicode@  <FZKTK.TTF}
   \pdfmapline{=uniheisl at Unicode@  <FZHTK.TTF}
@@ -10448,31 +10703,27 @@
   \pdfmapline{=unifssl at Unicode@   <FZFSK.TTF}
   \pdfmapline{=unilisl at Unicode@   <FZLSK.TTF}
   \pdfmapline{=uniyousl at Unicode@  <FZY1K.TTF}
-
 \else
-  \special{pdf:mapline gbk at UGBK@     unicode FZSSK.TTF}
-  \special{pdf:mapline gbksong at UGBK@ unicode FZSSK.TTF}
-  \special{pdf:mapline gbkkai at UGBK@  unicode FZKTK.TTF}
-  \special{pdf:mapline gbkhei at UGBK@  unicode FZHTK.TTF}
-  \special{pdf:mapline gbkfs at UGBK@   unicode FZFSK.TTF}
-  \special{pdf:mapline gbkli at UGBK@   unicode FZLSK.TTF}
-  \special{pdf:mapline gbkyou at UGBK@  unicode FZY1K.TTF}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode FZSSK.TTF}
-  \special{pdf:mapline unisong at Unicode@ unicode FZSSK.TTF}
-  \special{pdf:mapline unikai at Unicode@  unicode FZKTK.TTF}
-  \special{pdf:mapline unihei at Unicode@  unicode FZHTK.TTF}
-  \special{pdf:mapline unifs at Unicode@   unicode FZFSK.TTF}
-  \special{pdf:mapline unili at Unicode@   unicode FZLSK.TTF}
-  \special{pdf:mapline uniyou at Unicode@  unicode FZY1K.TTF}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode FZSSK.TTF -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode FZKTK.TTF -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode FZHTK.TTF -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode FZFSK.TTF -s .167}
-  \special{pdf:mapline gbklisl at UGBK@   unicode FZLSK.TTF -s .167}
-  \special{pdf:mapline gbkyousl at UGBK@  unicode FZY1K.TTF -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          unicode FZSSK.TTF}
+  \special{pdf:mapline gbksong at UGBK@      unicode FZSSK.TTF}
+  \special{pdf:mapline gbkkai at UGBK@       unicode FZKTK.TTF}
+  \special{pdf:mapline gbkhei at UGBK@       unicode FZHTK.TTF}
+  \special{pdf:mapline gbkfs at UGBK@        unicode FZFSK.TTF}
+  \special{pdf:mapline gbkli at UGBK@        unicode FZLSK.TTF}
+  \special{pdf:mapline gbkyou at UGBK@       unicode FZY1K.TTF}
+  \special{pdf:mapline cyberb at Unicode@    unicode FZSSK.TTF}
+  \special{pdf:mapline unisong at Unicode@   unicode FZSSK.TTF}
+  \special{pdf:mapline unikai at Unicode@    unicode FZKTK.TTF}
+  \special{pdf:mapline unihei at Unicode@    unicode FZHTK.TTF}
+  \special{pdf:mapline unifs at Unicode@     unicode FZFSK.TTF}
+  \special{pdf:mapline unili at Unicode@     unicode FZLSK.TTF}
+  \special{pdf:mapline uniyou at Unicode@    unicode FZY1K.TTF}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode FZSSK.TTF -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode FZKTK.TTF -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode FZHTK.TTF -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode FZFSK.TTF -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      unicode FZLSK.TTF -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     unicode FZY1K.TTF -s .167}
   \special{pdf:mapline unisongsl at Unicode@ unicode FZSSK.TTF -s .167}
   \special{pdf:mapline unikaisl at Unicode@  unicode FZKTK.TTF -s .167}
   \special{pdf:mapline uniheisl at Unicode@  unicode FZHTK.TTF -s .167}
@@ -10479,73 +10730,141 @@
   \special{pdf:mapline unifssl at Unicode@   unicode FZFSK.TTF -s .167}
   \special{pdf:mapline unilisl at Unicode@   unicode FZLSK.TTF -s .167}
   \special{pdf:mapline uniyousl at Unicode@  unicode FZY1K.TTF -s .167}
-
+\fi
 %</founder>
 %    \end{macrocode}
 %
+% \paragraph{\pkg{zhmacfonts.tex}}
+%
+% \changes{v2.5}{2020/01/15}{增加字体映射文件 \file{zhmacfonts.tex}。}
+%
+%    \begin{macrocode}
+%<*mac>
+\ifzhmappdf
+%% pdfTeX does not support OTF fonts
+\else
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H :0:Kaiti.ttc}
+  \special{pdf:mapline gbkhei at UGBK@       unicode       :2:PingFang.ttc}
+  \special{pdf:mapline gbkfs at UGBK@        unicode       STFANGSO.ttf}
+  \special{pdf:mapline gbkli at UGBK@        UniGB-UTF16-H :0:Baoli.ttc}
+  \special{pdf:mapline gbkyou at UGBK@       UniGB-UTF16-H :4:Yuanti.ttc}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H :0:Kaiti.ttc}
+  \special{pdf:mapline unihei at Unicode@    unicode       :2:PingFang.ttc}
+  \special{pdf:mapline unifs at Unicode@     unicode       STFANGSO.ttf}
+  \special{pdf:mapline unili at Unicode@     UniGB-UTF16-H :0:Baoli.ttc}
+  \special{pdf:mapline uniyou at Unicode@    UniGB-UTF16-H :4:Yuanti.ttc}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H :3:Songti.ttc   -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H :0:Kaiti.ttc    -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode       :2:PingFang.ttc -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode       STFANGSO.ttf    -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      UniGB-UTF16-H :0:Baoli.ttc    -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     UniGB-UTF16-H :4:Yuanti.ttc   -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H :3:Songti.ttc   -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H :0:Kaiti.ttc    -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode       :2:PingFang.ttc -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode       STFANGSO.ttf    -s .167}
+  \special{pdf:mapline unilisl at Unicode@   UniGB-UTF16-H :0:Baoli.ttc    -s .167}
+  \special{pdf:mapline uniyousl at Unicode@  UniGB-UTF16-H :4:Yuanti.ttc   -s .167}
+\fi
+%</mac>
+%    \end{macrocode}
+%
 % \paragraph{\pkg{zhubuntufonts.tex}}
 %
 %    \begin{macrocode}
 %<*ubuntu>
-\ProvidesFile{zhubuntufonts.tex}%
-  [2019/05/29 v2.4.16 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
 \ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <uming.ttc}
-  \pdfmapline{=gbksong at UGBK@ <uming.ttc}
-  \pdfmapline{=gbkkai at UGBK@  <ukai.ttc}
-  \pdfmapline{=gbkhei at UGBK@  <wqy-zenhei.ttc}
-  \pdfmapline{=gbkfs at UGBK@   <uming.ttc}
-  \pdfmapline{=gbkyou at UGBK@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=cyberb at Unicode@  <uming.ttc}
-  \pdfmapline{=unisong at Unicode@ <uming.ttc}
-  \pdfmapline{=unikai at Unicode@  <ukai.ttc}
-  \pdfmapline{=unihei at Unicode@  <wqy-zenhei.ttc}
-  \pdfmapline{=unifs at Unicode@   <uming.ttc}
-  \pdfmapline{=uniyou at Unicode@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=gbksongsl at UGBK@ <uming.ttc}
-  \pdfmapline{=gbkkaisl at UGBK@  <ukai.ttc}
-  \pdfmapline{=gbkheisl at UGBK@  <wqy-zenhei.ttc}
-  \pdfmapline{=gbkfssl at UGBK@   <uming.ttc}
-  \pdfmapline{=gbkyousl at UGBK@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=unisongsl at Unicode@ <uming.ttc}
-  \pdfmapline{=unikaisl at Unicode@  <ukai.ttc}
-  \pdfmapline{=uniheisl at Unicode@  <wqy-zenhei.ttc}
-  \pdfmapline{=unifssl at Unicode@   <uming.ttc}
-  \pdfmapline{=uniyousl at Unicode@  <wqy-zenhei.ttc}
-
+%% pdfTeX does not support OTF fonts
 \else
-  \special{pdf:mapline gbk at UGBK@     unicode :0:uming.ttc}
-  \special{pdf:mapline gbksong at UGBK@ unicode :0:uming.ttc}
-  \special{pdf:mapline gbkkai at UGBK@  unicode :0:ukai.ttc}
-  \special{pdf:mapline gbkhei at UGBK@  unicode :0:wqy-zenhei.ttc}
-  \special{pdf:mapline gbkfs at UGBK@   unicode :0:uming.ttc}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode :0:uming.ttc}
-  \special{pdf:mapline unisong at Unicode@ unicode :0:uming.ttc}
-  \special{pdf:mapline unikai at Unicode@  unicode :0:ukai.ttc}
-  \special{pdf:mapline unihei at Unicode@  unicode :0:wqy-zenhei.ttc}
-  \special{pdf:mapline unifs at Unicode@   unicode :0:uming.ttc}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode :0:uming.ttc -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode :0:ukai.ttc -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode :0:wqy-zenhei.ttc -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode :0:uming.ttc -s .167}
-
-  \special{pdf:mapline unisongsl at Unicode@ unicode :0:uming.ttc -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  unicode :0:ukai.ttc -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  unicode :0:wqy-zenhei.ttc -s .167}
-  \special{pdf:mapline unifssl at Unicode@   unicode :0:uming.ttc -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbksong at UGBK@      unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbkkai at UGBK@       unicode gkai00mp.ttf}
+  \special{pdf:mapline gbkhei at UGBK@       unicode :2:NotoSansCJK-Regular.ttc}
+  \special{pdf:mapline gbkfs at UGBK@        unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline cyberb at Unicode@    unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline unisong at Unicode@   unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline unikai at Unicode@    unicode gkai00mp.ttf}
+  \special{pdf:mapline unihei at Unicode@    unicode :2:NotoSansCJK-Regular.ttc}
+  \special{pdf:mapline unifs at Unicode@     unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode gkai00mp.ttf                -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode :2:NotoSansCJK-Regular.ttc  -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  unicode gkai00mp.ttf                -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode :2:NotoSansCJK-Regular.ttc  -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+\fi
 %</ubuntu>
 %    \end{macrocode}
 %
+% \paragraph{\pkg{zhwindowsfonts.tex}}
+%
 %    \begin{macrocode}
+%<*windows>
+\ifzhmappdf
+  \pdfmapline{=gbk at UGBK@          <simsun.ttc}
+  \pdfmapline{=gbksong at UGBK@      <simsun.ttc}
+  \pdfmapline{=gbkkai at UGBK@       <simkai.ttf}
+  \pdfmapline{=gbkhei at UGBK@       <simhei.ttf}
+  \pdfmapline{=gbkfs at UGBK@        <simfang.ttf}
+  \pdfmapline{=gbkli at UGBK@        <simli.ttf}
+  \pdfmapline{=gbkyou at UGBK@       <simyou.ttf}
+  \pdfmapline{=cyberb at Unicode@    <simsun.ttc}
+  \pdfmapline{=unisong at Unicode@   <simsun.ttc}
+  \pdfmapline{=unikai at Unicode@    <simkai.ttf}
+  \pdfmapline{=unihei at Unicode@    <simhei.ttf}
+  \pdfmapline{=unifs at Unicode@     <simfang.ttf}
+  \pdfmapline{=unili at Unicode@     <simli.ttf}
+  \pdfmapline{=uniyou at Unicode@    <simyou.ttf}
+  \pdfmapline{=gbksongsl at UGBK@    <simsun.ttc}
+  \pdfmapline{=gbkkaisl at UGBK@     <simkai.ttf}
+  \pdfmapline{=gbkheisl at UGBK@     <simhei.ttf}
+  \pdfmapline{=gbkfssl at UGBK@      <simfang.ttf}
+  \pdfmapline{=gbklisl at UGBK@      <simli.ttf}
+  \pdfmapline{=gbkyousl at UGBK@     <simyou.ttf}
+  \pdfmapline{=unisongsl at Unicode@ <simsun.ttc}
+  \pdfmapline{=unikaisl at Unicode@  <simkai.ttf}
+  \pdfmapline{=uniheisl at Unicode@  <simhei.ttf}
+  \pdfmapline{=unifssl at Unicode@   <simfang.ttf}
+  \pdfmapline{=unilisl at Unicode@   <simli.ttf}
+  \pdfmapline{=uniyousl at Unicode@  <simyou.ttf}
+\else
+  \special{pdf:mapline gbk at UGBK@          unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline gbksong at UGBK@      unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline gbkkai at UGBK@       unicode simkai.ttf    -v 70}
+  \special{pdf:mapline gbkhei at UGBK@       unicode simhei.ttf    -v 150}
+  \special{pdf:mapline gbkfs at UGBK@        unicode simfang.ttf   -v 50}
+  \special{pdf:mapline gbkli at UGBK@        unicode simli.ttf     -v 150}
+  \special{pdf:mapline gbkyou at UGBK@       unicode simyou.ttf    -v 60}
+  \special{pdf:mapline cyberb at Unicode@    unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline unisong at Unicode@   unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline unikai at Unicode@    unicode simkai.ttf    -v 70}
+  \special{pdf:mapline unihei at Unicode@    unicode simhei.ttf    -v 150}
+  \special{pdf:mapline unifs at Unicode@     unicode simfang.ttf   -v 50}
+  \special{pdf:mapline unili at Unicode@     unicode simli.ttf     -v 150}
+  \special{pdf:mapline uniyou at Unicode@    unicode simyou.ttf    -v 60}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode :0:simsun.ttc -v 50  -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode simkai.ttf    -v 70  -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode simhei.ttf    -v 150 -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode simfang.ttf   -v 50  -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      unicode simli.ttf     -v 150 -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     unicode simyou.ttf    -v 60  -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ unicode :0:simsun.ttc -v 50  -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  unicode simkai.ttf    -v 70  -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode simhei.ttf    -v 150 -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode simfang.ttf   -v 50  -s .167}
+  \special{pdf:mapline unilisl at Unicode@   unicode simli.ttf     -v 150 -s .167}
+  \special{pdf:mapline uniyousl at Unicode@  unicode simyou.ttf    -v 60  -s .167}
 \fi
-
+%</windows>
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \ctex at zhmap@endinput
 %</zhmap>
 %    \end{macrocode}
@@ -10562,7 +10881,7 @@
 \ExplSyntaxOn
 \sys_if_engine_xetex:F
   {
-    \msg_new:nn { ctex } { xetex }
+    \msg_new:nnn { ctex } { xetex }
       { XeTeX~is~required~to~compile~this~document! }
     \msg_fatal:nn { ctex } { xetex }
   }
@@ -10588,7 +10907,7 @@
 % \begin{macro}[int]{\ctex_make_spa:nn}
 % |#1| 是 \file{spa} 文件名,|#2| 是由 CJK 族名与字体构成的逗号列表。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_make_spa:nn #1#2
+\cs_new_protected:Npn \ctex_make_spa:nn #1#2
   {
     \iow_open:Nn \g_@@_spa_iow {#1}
     \clist_map_inline:nn {#2}
@@ -10619,7 +10938,7 @@
         }
     \group_end:
   }
-\cs_new_protected_nopar:Npn \@@_save_bounds:n #1
+\cs_new_protected:Npn \@@_save_bounds:n #1
   {
     \clist_put_right:Nx \l_@@_punct_bounds_clist
       {
@@ -10632,7 +10951,7 @@
 %
 % \pkg{CJKpunct} 要求的格式是边界空白宽度与 1\,em 的比值的一百倍。
 %    \begin{macrocode}
-\cs_new_nopar:Npn \@@_calc_bounds:nn #1#2
+\cs_new:Npn \@@_calc_bounds:nn #1#2
   {
     \fp_eval:n
       {
@@ -10652,7 +10971,6 @@
 %    \begin{macrocode}
 %<*make>
 \input ctexspamacro %
-
 \MAKESPA {ctexpunct.spa}
   {
     {adobezhsong}     {AdobeSongStd-Light} ,
@@ -10659,6 +10977,7 @@
     {adobezhhei}      {AdobeHeitiStd-Regular} ,
     {adobezhkai}      {AdobeKaitiStd-Regular} ,
     {adobezhfs}       {AdobeFangsongStd-Regular} ,
+%
     {fandolzhsong}    {FandolSong} ,
     {fandolzhsongb}   {FandolSong-Bold} ,
     {fandolzhhei}     {FandolHei} ,
@@ -10665,6 +10984,7 @@
     {fandolzhheib}    {FandolHei-Bold} ,
     {fandolzhkai}     {FandolKai} ,
     {fandolzhfs}      {FandolFang} ,
+%
     {founderzhsong}   {FZShuSong-Z01} ,
     {founderzhsongb}  {FZXiaoBiaoSong-B05} ,
     {founderzhhei}    {FZHei-B01} ,
@@ -10674,9 +10994,26 @@
     {founderzhli}     {FZLiShu-S01} ,
     {founderzhyou}    {FZXiYuan-M01} ,
     {founderzhyoub}   {FZZhunYuan-M02} ,
-    {ubuntuzhsong}    {AR PL UMing CN} ,
-    {ubuntuzhhei}     {WenQuanYi Zen Hei} ,
-    {ubuntuzhkai}     {AR PL UKai CN} ,
+%
+    {maczhsong}       {Songti SC Light} ,
+    {maczhsongb}      {Songti SC Bold} ,
+    {maczhhei}        {Heiti SC Medium} ,
+    {maczhheil}       {Heiti SC Light} ,
+    {maczhkai}        {Kaiti SC} ,
+    {maczhkaib}       {Kaiti SC Bold} ,
+    {maczhfs}         {STFangsong} ,
+    {maczhli}         {Baoli SC} ,
+    {maczhyou}        {Yuanti SC Light} ,
+    {maczhyoub}       {Yuanti SC Regular} ,
+    {maczhpf}         {PingFang SC} ,
+    {maczhpfb}        {PingFang SC Semibold} ,
+%
+    {ubuntuzhsong}    {Noto Serif CJK SC} ,
+    {ubuntuzhsongb}   {Noto Serif CJK SC Bold} ,
+    {ubuntuzhhei}     {Noto Sans CJK SC} ,
+    {ubuntuzhheib}    {Noto Sans CJK SC Bold} ,
+    {ubuntuzhkai}     {AR PL KaitiM GB} ,
+%
     {windowszhsong}   {SimSun} ,
     {windowszhhei}    {SimHei} ,
     {windowszhkai}    {KaiTi} ,
@@ -10686,7 +11023,6 @@
     {windowszhyahei}  {Microsoft YaHei} ,
     {windowszhyaheib} {Microsoft YaHei Bold}
   }
-
 \primitive\end
 %</make>
 %</spa>
@@ -10827,6 +11163,7 @@
 % \subsection{\pkg{ctexhook} 宏包}
 %
 % \changes{v2.2}{2015/06/26}{将文档开头和宏包末尾钩子提取到 \pkg{ctexhook} 宏包中。}
+% \changes{v2.5}{2020/04/21}{增加宏包开头钩子。}
 %
 %    \begin{macrocode}
 %<*ctexhook>
@@ -10835,13 +11172,13 @@
 % \begin{macro}[int]{\ctex_at_end_preamble:n,\ctex_after_end_preamble:n}
 % 实现 \pkg{etoolbox} 宏包的 \tn{AtEndPreamble} 和 \tn{AfterEndPreamble}。
 %    \begin{macrocode}
-\cs_new_protected:Npn \ctex_at_end_preamble:n #1
-  { \tl_gput_right:Nn \g_@@_end_preamble_hook_tl {#1} }
-\cs_new_protected:Npn \ctex_after_end_preamble:n #1
-  { \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl {#1} }
-\cs_new_protected_nopar:Npn \CTEX at document@left at hook
+\cs_new_protected:Npn \ctex_at_end_preamble:n
+  { \tl_gput_right:Nn \g_@@_end_preamble_hook_tl }
+\cs_new_protected:Npn \ctex_after_end_preamble:n
+  { \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl }
+\cs_new_protected:Npn \CTEX at document@left at hook
   { \group_end: \g_@@_end_preamble_hook_tl \group_begin: }
-\cs_new_protected_nopar:Npn \CTEX at document@right at hook
+\cs_new_protected:Npn \CTEX at document@right at hook
   { \scan_stop: \g_@@_after_end_preamble_hook_tl \tex_ignorespaces:D }
 \cs_set_nopar:Npx \document
   {
@@ -10854,51 +11191,93 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[int]{\ctex_at_begin_package:nn}
+% 如果宏包已经被载入,则钩子无效,给出警告。
+% 在 \pkg{filehook} 的钩子\emph{之前}起作用。
+%    \begin{macrocode}
+\cs_new_protected:Npn \ctex_at_begin_package:nn #1
+  {
+    \@ifpackageloaded {#1}
+      { \@@_package_loaded_warning:nn {#1} }
+      { \ctex_gadd_package_hook:nnn { begin } {#1} }
+  }
+\cs_new_protected:Npn \@@_package_loaded_warning:nn #1#2
+  { \msg_warning:nnx { ctex } { invalid-hook } {#1} }
+\msg_new:nnn { ctex } { invalid-hook }
+  {
+    Package~`#1'~is~loaded. \\
+    \token_to_str:N \ctex_at_begin_package:nn \{#1\}\{...\}~is~invalid.
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[int]{\ctex_at_end_package:nn}
 % 与 \pkg{filehook} 的 \tn{AtEndOfPackageFile*} 类似,如果原来没有在载入宏包则
 % 在宏包末尾执行语句,否则立即执行。
+% 在 \pkg{filehook} 的钩子\emph{之后}起作用。
 %    \begin{macrocode}
-\cs_new_protected:Npn \ctex_at_end_package:nn #1#2
+\cs_new_protected:Npn \ctex_at_end_package:nn #1
   {
     \@ifpackageloaded {#1}
-      {#2}
-      { \ctex_gadd_hook:cn { g_@@_at_end_ #1 _hook_tl } {#2} }
+      { \use:n }
+      { \ctex_gadd_package_hook:nnn { end } {#1} }
   }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]{\ctex_gadd_hook:Nn, \ctex_gadd_hook:cn}
+% \begin{macro}[int]{\ctex_gadd_package_hook:nnn,
+% \ctex_gadd_hook:Nn, \ctex_gadd_hook:cn}
 % 给钩子附加内容。
 %    \begin{macrocode}
-\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2
+\cs_new_protected:Npn \ctex_gadd_package_hook:nnn #1#2
+  { \ctex_gadd_hook:cn { g_@@_at_ #1 _ #2 _hook_tl } }
+\cs_new_protected:Npn \ctex_gadd_hook:Nn #1
   {
     \tl_if_exist:NF #1 { \tl_new:N #1 }
-    \tl_gput_right:Nn #1 {#2}
+    \tl_gput_right:Nn #1
   }
 \cs_generate_variant:Nn \ctex_gadd_hook:Nn { c }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[int]{\ctex_package_end_hook:n, \ctex_package_end_hook:o}
-% 宏包末尾钩子,只执行一次,用后清除。
+% \begin{macro}[int]{\ctex_use_package_hook:nn}
+% 宏包钩子,只执行一次,用后清除。
 %    \begin{macrocode}
-\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1
+\cs_new_protected:Npn \ctex_use_package_hook:nn #1#2
   {
-    \cs_if_exist_use:cT { g_@@_at_end_ #1 _hook_tl }
-      { \cs_undefine:c { g_@@_at_end_ #1 _hook_tl } }
+    \group_begin: \exp_args:NNc \group_end:
+    \@@_use_package_hook_aux:N { g_@@_at_ #1 _ #2 _hook_tl }
   }
-\cs_generate_variant:Nn \ctex_package_end_hook:n { o }
+\cs_new_protected:Npn \@@_use_package_hook_aux:N #1
+  { \cs_if_exist_use:NT #1 { \cs_undefine:N #1 } }
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}[int]{\@reset at ptions,\CTEX at reset@ptions at hook}
+% \tn{@pushfilename} 内部的 \tn{@currname} 和 \tn{@currext} 保存的是
+% 前一个宏包的状态,不能使用。需要对其后的 \tn{@reset at ptions} 做补丁来实现
+% \cs{ctex_at_begin_package:nn} 的功能。
+%    \begin{macrocode}
+\tl_put_right:Nn \@reset at ptions { \CTEX at reset@ptions at hook }
+\cs_new_protected:Npn \CTEX at reset@ptions at hook
+  {
+    \cs_if_eq:NNT \@currext \@pkgextension
+      { \ctex_use_package_hook:nn { begin } { \@currname } }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[int]{\@popfilename,\CTEX at popfilename@hook}
 % 对 \tn{@popfilename} 做补丁来实现 \cs{ctex_at_end_package:nn} 的功能。
 %    \begin{macrocode}
-\tl_put_left:Nn \@popfilename
+\tl_put_left:Nn \@popfilename { \CTEX at popfilename@hook }
+\cs_new_protected:Npn \CTEX at popfilename@hook
   {
     \cs_if_eq:NNT \@currext \@pkgextension
-      { \ctex_package_end_hook:o { \@currname } }
+      { \ctex_use_package_hook:nn { end } { \@currname } }
   }
 %    \end{macrocode}
+% \end{macro}
 %
 %    \begin{macrocode}
 %</ctexhook>
@@ -10913,10 +11292,6 @@
 %<*ctexpatch>
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-\cs_if_exist:NF \str_new:N { \RequirePackage { l3str } }
-%    \end{macrocode}
-%
 % \begin{macro}[int]{\ctex_patch_cmd_once:NnnnTF}
 % 只进行第一次匹配进行替换。参数 |#2| 是宏重建时的 \tn{catcode} 设置。
 %    \begin{macrocode}
@@ -10988,14 +11363,14 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \ctex_patch_boot:NNnnTF #1#2#3#4#5#6
   {
-    \tl_set:Nn \@@_patch_true:w {#5}
-    \tl_set:Nn \@@_patch_false:w {#6}
+    \cs_set_protected:Npx \@@_patch_true:w  { \exp_not:n {#5} }
+    \cs_set_protected:Npx \@@_patch_false:w { \exp_not:n {#6} }
     \group_begin:
       \char_set_catcode_other:n { 35 }
       \ctex_parse_name:NN #1 #2 {#3} {#4}
   }
-\tl_new:N \@@_patch_true:w
-\tl_new:N \@@_patch_false:w
+\cs_new_eq:NN \@@_patch_true:w  \use_i:nn
+\cs_new_eq:NN \@@_patch_false:w \use_ii:nn
 %    \end{macrocode}
 % \end{macro}
 %
@@ -11040,7 +11415,7 @@
                   \exp_not:N ##2
                   \exp_not:c { ##3 ~ }
                   \exp_not:c { #1##3 }
-              } {##3} ##1
+              } { ##3 } ##1
           }
           { ##1##2 }
       }
@@ -11057,8 +11432,8 @@
                 \str_if_eq:eeTF
                   { \exp_not:n { #1 at protected@ ##3 #1##3 } }
                   {
-                    \exp_last_unbraced:Nf \@@_parse_name:w
-                      \cs_replacement_spec:N ##3 #3 ~ #2 \q_stop
+                    \exp_last_unbraced:Ne \@@_parse_name:w
+                      { \cs_replacement_spec:N ##3 } #3 ~ #2 \q_stop
                   }
                   { #1##5 ~ } { ##5 ~ }
               }
@@ -11270,903 +11645,4 @@
 %
 % \Finale
 %
-% \endinput
-%
-% \DisableImplementation
-%
-% \begin{implementation}
-%
-% \subsection{\cls{ctxdoc}}
-%
-%    \begin{macrocode}
-%<*ctxdoc>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-%<@@=ctxdoc>
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-\ExplSyntaxOff
-\let\pdfmdfivesum\mdfivesum
-\DeclareOption*{\PassOptionsToClass{\CurrentOption}{l3doc}}
-\PassOptionsToClass{a4paper,full}{l3doc}
-\ProcessOptions
-\@namedef{ver at thumbpdf.sty}{9999/99/99}
-\LoadClass{l3doc}
-\RequirePackage[UTF8, punct = kaiming, heading, fontset = none,
-  linespread = 1.2, sub3section]{ctex}
-\ifxetex
-  \xeCJKsetup{AutoFakeBold=false}
-\fi
-\ctexset{
-  fontset,
-  abstractname   = 简介,
-  indexname      = 代码索引,
-  section        = {
-    format = \Large\bfseries\raggedright,
-    name   = {第,节},
-  },
-}
-\RequirePackage[toc]{multitoc}
-\RequirePackage{geometry}
-\RequirePackage{tabularx}
-\RequirePackage{makecell}
-\RequirePackage{threeparttable}
-\RequirePackage{siunitx}
-\RequirePackage{unicode-math}
-\RequirePackage{xcolor}
-\RequirePackage{caption}
-\RequirePackage{fancyvrb-ex}
-\RequirePackage{zref-base}
-\geometry{includemp,hmargin={0mm,15mm},vmargin={25mm,15mm},footskip=7mm}
-\hypersetup{pdfstartview=FitH,bookmarksdepth=subparagraph}
-\setcounter{secnumdepth}{4}
-\setcounter{tocdepth}{2}
-\newcommand*\email{\nolinkurl}
-\setmainfont{TeX Gyre Pagella}
-\setsansfont{TeX Gyre Heros}
-\setmonofont[
-  HyphenChar = None ,
-  UprightFont=* Light, BoldFont=* Bold,
-  SlantedFont=* Light Oblique]{CMU Typewriter Text}
-\setmathfont{texgyrepagella-math.otf}
-\captionsetup{strut=off, labelsep=quad, labelfont+=bf}
-%% <--- http://tex.stackexchange.com/a/40896
-\patchcmd{\@addtocurcol}%
-    {\vskip \intextsep}%
-    {\edef\save at first@penalty{\the\lastpenalty}\unpenalty
-     \ifnum \lastpenalty = \@M  % hopefully the OR penalty
-        \unpenalty
-     \else
-        \penalty \save at first@penalty \relax % put it back
-     \fi
-      \ifnum\outputpenalty <-\@Mii
-                         \addvspace\intextsep
-                         \vskip\parskip
-      \else
-                         \addvspace\intextsep
-      \fi}%
-    {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}
-\patchcmd{\@addtocurcol}%
-    {\vskip\intextsep \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi}%
-    {\ifnum\outputpenalty <-\@Mii
-       \aftergroup\vskip\aftergroup\intextsep
-       \aftergroup\nointerlineskip
-     \else
-       \vskip\intextsep
-     \fi}%
-    {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}
-\patchcmd{\@getpen}{\@M}{\@Mi}
-  {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}
-%% --->
-%% 不对代码实现的 \section 以下标题编目录。
-\AtBeginEnvironment{implementation}{%
-  \ifnum\value{tocdepth}>\@ne
-    \addtocontents{toc}{\protect\value{tocdepth}=1\relax}%
-  \fi}
-\ifxetex
-  \let\ctexdocverbaddon\xeCJKVerbAddon
-  \def\ctexdisableecglue{\xeCJKsetup{CJKecglue}}
-  \def\ctexplainps{\xeCJKsetup{PunctStyle=plain}}
-  \appto\meta at font@select{\ifinner\ctexdisableecglue\fi}
-\else
-  \let\ctexdocverbaddon\relax
-  \let\ctexplainps\relax
-  \def\ctexdisableecglue{\ltjsetparameter{autoxspacing=false}}
-  \appto\meta at font@select{\ctexdisableecglue}
-\fi
-\setlist{noitemsep,topsep=\smallskipamount}
-\setlist[1]{labelindent=\parindent}
-\setlist[enumerate]{leftmargin=*}
-\setlist[itemize]{leftmargin=*}
-\newlist{optdesc}{description}{3}
-%% 设置间距为 \marginparsep,与 l3doc 一致
-\setlist[optdesc]{%
-  font=\mdseries\small\ttfamily,align=right,listparindent=\parindent,
-  labelsep=\marginparsep,labelindent=-\marginparsep,leftmargin=*}
-%% 重新定义 threeparttable 包的 tablenotes 环境
-\renewlist{tablenotes}{description}{1}
-\setlist[tablenotes]{%
-  format=\normalfont\tnote at item,align=right,listparindent=\parindent,
-  labelindent=\tabcolsep,leftmargin=*,rightmargin=\tabcolsep,
-  after=\@noparlisttrue}
-\AtBeginEnvironment{tablenotes}{%
-  \setlength\parindent{2\ccwd}%
-  \normalfont\footnotesize}
-\AtBeginEnvironment{threeparttable}{%
-  \stepcounter{tpt at id}%
-  \edef\curr at tpt@id{tpt@\arabic{tpt at id}}}
-\newcounter{tpt at id}
-\def\tnote at item#1{%
-  \Hy at raisedlink{\hyper at anchor{\curr at tpt@id-#1}}#1}
-\def\TPTtagStyle#1{\hyperlink{\curr at tpt@id-#1}{#1}}
-\fvset{
-  fontsize=\small,baselinestretch=1,numbersep=5pt,
-  formatcom=\ctexdocverbaddon,
-  listparameters=\setlength\topsep{\MacrocodeTopsep}}
-\DefineVerbatimEnvironment{frameverb}{Verbatim}{%
-  gobble=4,
-  frame=single,framesep=8pt,
-  listparameters=
-    \setlength\topsep{\medskipamount}%
-    \appto\FV at EndList{\nointerlineskip}}
-\DefineVerbatimEnvironment{ctexexam}{Verbatim}{%
-  gobble=4,
-  frame=single,framesep=10pt,
-  label=\rule{0pt}{12pt}\textnormal{\bfseries 例 \arabic{ctexexam}},
-  listparameters=
-    \setlength\topsep{\bigskipamount}%
-    \refstepcounter{ctexexam}\ctexexamlabelref
-    \appto\FV at EndList{\nointerlineskip}}
-\define at key{FV}{labelref}{\def\ctexexamlabelref{\label{#1}}}
-\let\ctexexamlabelref\empty
-\newcounter{ctexexam}
-\BeforeBeginEnvironment{function}{\par\nointerlineskip}
-\AtEndEnvironment{function}{%
-  \par\xdef\ctexfixprevdepth{\prevdepth=\the\prevdepth\space}}
-\AfterEndEnvironment{function}{\ctexfixprevdepth}
-\AtBeginEnvironment{syntax}{\linespread{1}\ctexplainps\ctexdisableecglue}
-\BeforeBeginEnvironment{SideBySideExample}{\par\addvspace{\medskipamount}}
-\newcommand*\exptarget{\Hy at raisedlink{\hypertarget{expstar}{}}}
-\newcommand*\rexptarget{\Hy at raisedlink{\hypertarget{rexpstar}{}}}
-\newcommand*\expstar{\hyperlink{expstar}{$\star$}}
-\newcommand*\rexpstar{\hyperlink{rexpstar}{\ding{73}}}
-\ExplSyntaxOn
-%% l3doc 会设置列表环境中 \listparindent=\z@,我们在这里恢复它。
-\cs_set_eq:NN \list \__codedoc_oldlist:nn
-\cs_new_nopar:Npn \zihaopt #1
-  {
-    \exp_last_unbraced:Nf \tl_head:w
-      { \prop_item:Nn \c__ctex_font_size_prop {#1} } { } \q_stop
-  }
-%% 抑制首段的 \parskip
-\ctex_patch_cmd_once:NnnnTF \__codedoc_function_descr_start:w
-  { }
-  { \noindent }
-  { \skip_vertical:n { -\parskip } \noindent }
-  { \iow_term:n { *** ~ SUCCESS ~ *** } }
-  { \iow_term:n { *** ~ FAIL ~ *** } }
-%% l3doc 会在 function 环境的 syntax 和 descr 盒子中间加上 \medskipamount 的距离。
-%% 但是若 syntax 盒子为空(未使用 syntax 环境),就会显得不好看。
-%% 此时我们通过将 \medskipamount 设置为零来修正。若盒子非空,则将 \parskip 还回去。
-\ctex_preto_cmd:NnnTF \__codedoc_function_assemble:
-  { }
-  { \ctex_doc_fix_yoffset: }
-  { \iow_term:n { *** ~ SUCCESS ~ *** } }
-  { \iow_term:n { *** ~ FAIL ~ *** } }
-\cs_new_protected_nopar:Npn \ctex_doc_fix_yoffset:
-  {
-    \box_if_empty:NTF \g__codedoc_syntax_box
-      { \skip_zero:N \medskipamount }
-      { \skip_add:Nn \medskipamount { \parskip } }
-  }
-%% 左侧边注的函数列表采用单倍行距
-\ctex_preto_cmd:NnnTF \__codedoc_typeset_functions:
-  { }
-  { \MacroFont }
-  { \iow_term:n { *** ~ SUCCESS ~ *** } }
-  { \iow_term:n { *** ~ FAIL ~ *** } }
-\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_init:
-  { }
-  { \hbox:n }
-  { \MacroFont \hbox:n }
-  { \iow_term:n { *** ~ SUCCESS ~ *** } }
-  { \iow_term:n { *** ~ FAIL ~ *** } }
-\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_dump:
-  { }
-  { \hbox_unpack_drop:N }
-  { \MacroFont \hbox_unpack_drop:N }
-  { \iow_term:n { *** ~ SUCCESS ~ *** } }
-  { \iow_term:n { *** ~ FAIL ~ *** } }
-\cs_set_eq:NN \__codedoc_macro_end_style:n \use_none:n
-\cs_set_protected:Npn \__codedoc_macro_typeset_one:nN #1#2
-  {
-    \vbox_set:Nn \l__codedoc_macro_box
-      {
-        \MacroFont
-        \vbox_unpack_drop:N \l__codedoc_macro_box
-        \hbox_set:Nn \l_tmpa_box
-          { \__codedoc_print_macroname:nN {#1} #2 }
-        \dim_set:Nn \l_tmpa_dim { \marginparwidth - \labelsep }
-        \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l_tmpa_dim
-          {
-            \box_resize_to_wd_and_ht:Nnn \l_tmpa_box
-              { \l_tmpa_dim }
-              { \box_ht:N \l_tmpa_box }
-          }
-        \hbox_overlap_left:n
-          {
-            \box_use:N \l_tmpa_box
-            \skip_horizontal:n { \marginparsep - \labelsep }
-          }
-      }
-    \int_incr:N \l__codedoc_macro_int
-  }
-\cs_set_protected:Npn \__codedoc_print_macroname:nN #1#2
-  {
-    \strut
-    \__codedoc_get_hyper_target:xN
-      {
-        \exp_not:n {#1}
-        \bool_if:NT #2 { \tl_to_str:n {TF} }
-      }
-      \l__codedoc_tmpa_tl
-    \cs_if_exist:cTF { r@ \l__codedoc_tmpa_tl }
-      { \exp_args:NNo \label at hyperref [ \l__codedoc_tmpa_tl ] }
-      { \use:n }
-      {
-        \tl_set:Nn \l__codedoc_tmpa_tl {#1}
-        \tl_replace_all:Non \l__codedoc_tmpa_tl
-          { \c_catcode_other_space_tl }
-          { \fontspec_visible_space: }
-        \__codedoc_macroname_prefix:o \l__codedoc_tmpa_tl
-        \__codedoc_macroname_suffix:N #2
-      }
-  }
-\AtBeginEnvironment { syntax }
-  {
-    \char_set_catcode_active:N \|
-    \char_set_active_eq:NN \| \orbar
-    \char_set_catcode_active:N \(
-    \char_set_active_eq:NN \( \defaultvalaux
-  }
-%% 不对目录中出现的 \cs 和 \tn 等编索引
-\DeclareDocumentCommand \StopSpecialIndexModule { }
-  { \cs_set_eq:NN \__codedoc_special_index_module:nnnnN \use_none:nnnnn }
-\tl_map_inline:nn { \actualchar \encapchar \levelchar }
-  { \exp_args:Nx \DoNotIndex { \bslash \tl_to_str:N #1 } }
-\DeclareDocumentCommand \package { o m }
-  {
-    \exp_args:Nx \href
-      {
-        http \c_colon_str //www.ctan.org/pkg/
-        \IfNoValueTF {#1} { \str_fold_case:n {#2} } {#1}
-      }
-      { \pkg {#2} }
-  }
-\DeclareDocumentCommand \GetFileId { m }
-  {
-    \GetFileInfo {#1}
-    \file_get:nnNTF { \c_sys_jobname_str .id }
-      { \int_set:Nn \tex_endlinechar:D { -1 } } \l_@@_tmp_tl
-      { \exp_after:wN \GetIdInfo \l_@@_tmp_tl }
-      { \GetIdInfo $Id$ }
-      { \fileinfo }
-  }
-\cs_new_eq:NN \@@_ltx_changes:nnn \changes@
-\cs_set_protected:Npn \changes@ #1#2
-  {
-    \@@_save_version_date:nn {#1} {#2}
-    \tl_if_empty:nTF {#1}
-      { \@@_ltx_changes:nnn }
-      { \@@_version_zfill:wnnn #1 \q_stop }
-      {#1} {#2}
-  }
-\cs_new_protected:Npn \@@_version_zfill:wnnn #1#2 \q_stop
-  {
-    \str_if_eq:nnTF {#1} { v }
-      { \@@_version_zfill:nnnn {#2} }
-      { \@@_ltx_changes:nnn }
-  }
-\cs_new_protected:Npn \@@_version_zfill:nnnn #1#2
-  {
-    \tl_clear:N \l_@@_tmp_tl
-    \int_zero:N \l_tmpa_int
-    \seq_set_split:Nnn \l_tmpa_seq { . } {#1}
-    \seq_map_function:NN \l_tmpa_seq \@@_version_zfill:n
-    \int_compare:nNnF \l_tmpa_int > 2
-      {
-        \tl_put_right:Nx \l_@@_tmp_tl
-          { \prg_replicate:nn { 3 - \l_tmpa_int } { 00000 } }
-      }
-    \@@_ltx_changes:nnn { \l_@@_tmp_tl \actualchar #2 }
-  }
-\tl_new:N \l_@@_tmp_tl
-\cs_new_protected:Npn \@@_version_zfill:n #1
-  {
-    \int_incr:N \l_tmpa_int
-    \tl_put_right:Nx \l_@@_tmp_tl
-      {
-        \prg_replicate:nn
-          { \int_max:nn { 0 } { 5 - \tl_count:n {#1} } } { 0 }
-        \exp_not:n {#1}
-      }
-  }
-\cs_new_protected:Npn \@@_save_version_date:nn #1#2
-  {
-    \prop_get:NnNTF \g_@@_version_date_prop {#1} \l_@@_tmp_tl
-      { \exp_after:wN \@@_save_version_date:nnnn \l_@@_tmp_tl {#2} {#1} }
-      { \@@_save_version_date:nnn {#1} {#2} {#2} }
-  }
-\cs_new_protected:Npn \@@_save_version_date:nnnn #1#2#3#4
-  {
-    \@@_if_date_later:nnTF {#1} {#3}
-      { \@@_save_version_date:nnn {#4} {#3} {#2} }
-      {
-        \@@_if_date_later:nnT {#3} {#2}
-          { \@@_save_version_date:nnn {#4} {#1} {#3} }
-      }
-  }
-\prg_new_conditional:Npnn \@@_if_date_later:nn #1#2 { TF , T }
-  {
-    \if_int_compare:w \@@_parse_date:w #1 / / / 0 \q_stop >
-                      \@@_parse_date:w #2 / / / 0 \q_stop \exp_stop_f:
-      \prg_return_true: \else: \prg_return_false: \fi:
-  }
-\cs_new:Npn \@@_parse_date:w #1/#2/#3/ #4 \q_stop
-  { #1#2#3 }
-\cs_new_protected:Npn \@@_save_version_date:nnn #1#2#3
-  { \prop_gput:Nnn \g_@@_version_date_prop {#1} { {#2} {#3} } }
-\cs_new_protected:Npn \CTEX at versionitem #1 \efill
-  {
-    \@idxitem
-    \prop_get:NnNTF \g_@@_version_date_prop {#1} \l_@@_tmp_tl
-      { \exp_after:wN \@@_version_item:nnn \l_@@_tmp_tl {#1} }
-      { \BOOM }
-  }
-\cs_new_protected:Npn \@@_version_item:nnn #1#2#3
-  {
-    \noindent
-    \Hy at raisedlink { \belowpdfbookmark {#3} { HD.#3 } }
-    \textbf {#3} \hfill
-    \hbox:n
-      {
-        \footnotesize
-        \str_if_eq:nnTF {#1} {#2}
-          { ( #1 ) }
-          { ( #1 ~ -- ~ #2 ) }
-      }
-    \par \nopagebreak
-  }
-\prop_new:N \g_@@_version_date_prop
-\ctex_patch_cmd:Nnn \HDorg at theglossary
-  { \let \item \@idxitem }
-  { \let \item \CTEX at versionitem }
-\ctex_patch_cmd:Nnn \l at section    { 2.5em } { 1.5em }
-\ctex_patch_cmd:Nnn \l at subsection { 2.5em } { 1.5em }
-\ctex_patch_cmd:Nnn \@wrglossary
-  { hdpindex }
-  {
-    \ifnum \c at HD@hypercount = \z@
-      hdpindex
-    \else
-      hdclindex { \the \c at HD@hypercount }
-    \fi
-  }
-%% 重定义 macrocode 环境的实现,逐行处理
-\cs_set_protected_nopar:Npn \xmacro at code
-  { \@@_marco_code:w }
-\cs_set_protected_nopar:Npn \sxmacro at code
-  {
-    \fontspec_print_visible_spaces:
-    \xmacro at code
-  }
-\cs_new_protected_nopar:Npn \@@_marco_code:w
-  {
-    \ifcodeline at index
-      \@@_marco_every_par:n { \@@_code_line_no: }
-    \else:
-      \@@_marco_every_par:n { }
-    \fi:
-    \exp_args:Nx \@@_make_finish_tag:n { \@currenvir }
-    \@@_verbatim_start:w
-  }
-\cs_new_protected:Npn \@@_marco_every_par:n #1
-  {
-    \everypar
-      {
-        \everypar {#1}
-        \if at inlabel
-          \global \@inlabelfalse
-          \@noparlistfalse
-          \llap { \box \@labels \hskip \leftskip }
-        \fi
-        #1
-      }
-  }
-\ctex_patch_cmd:Nnn \macro at code
-  { \if at inlabel \leavevmode \fi }
-  { \partopsep \z at skip }
-\group_begin:
-  \int_set:Nn \tex_endlinechar:D { -1 }
-  \use:n
-    {
-      \char_set_catcode_active:n { 32 }
-      \tl_const:Nn \c_@@_active_space_tl
-    }
-    { }
-\group_end:
-\group_begin:
-  \char_set_catcode_active:n { 13 }
-  \cs_new_protected:Npx \@@_make_finish_tag:n #1
-    {
-      \tl_set:Nn \exp_not:N \l_@@_verbatim_finish_tl
-        {
-          \c_percent_str
-          \prg_replicate:nn { 4 }
-            { \exp_not:o { \c_@@_active_space_tl } }
-          \exp_not:o { \active at escape@char } end
-          \c_left_brace_str #1 \c_right_brace_str
-          \exp_not:N ^^M
-        }
-    }
-  \cs_new_protected:Npn \@@_verbatim_start:w #1
-    {
-      \str_if_eq:nnTF {#1} { ^^M }
-        { \@@_verbatim_read_line:w }
-        { \@@_verbatim_read_line:w #1 }
-    }
-  \cs_new_protected:Npn \@@_verbatim_read_line:w #1 ^^M
-    {
-      \tl_set:Nn \l_@@_verbatim_line_tl { #1 ^^M }
-      \tl_if_eq:NNTF \l_@@_verbatim_line_tl \l_@@_verbatim_finish_tl
-        { \exp_args:Nx \end { \@currenvir } }
-        {
-          \@@_verbatim_process_line:
-          \@@_verbatim_read_line:w
-        }
-    }
-  \cs_new_protected:Npn \@@_swap_cr:
-    { \exp_after:wN \@@_swap_cr:w \l_@@_verbatim_line_tl }
-  \cs_new_protected:Npn \@@_swap_cr:w #1 ^^M
-    {
-      \group_insert_after:N ^^M
-      \tl_set:Nn \l_@@_verbatim_line_tl {#1}
-    }
-  \tl_const:Nn \c_@@_active_cr_tl { ^^M }
-\group_end:
-\tl_new:N \l_@@_verbatim_line_tl
-\tl_new:N \l_@@_verbatim_finish_tl
-\tl_new:N \g_@@_verbatim_verb_stop_tl
-\cs_new_protected_nopar:Npn \@@_process_normal_line:
-  {
-    \str_if_eq:eeTF
-      { \str_head:N \l_@@_verbatim_line_tl } { \c_percent_str }
-      { \@@_check_angle:x { \tl_tail:N \l_@@_verbatim_line_tl } }
-      { \@@_output_line: }
-  }
-\cs_new_protected_nopar:Npn \@@_process_verb_line:
-  {
-    \tl_if_eq:NNTF \l_@@_verbatim_line_tl \g_@@_verbatim_verb_stop_tl
-      {
-        \tl_gclear:N \g_@@_verbatim_verb_stop_tl
-        \cs_gset_eq:NN \@@_verbatim_process_line: \@@_process_normal_line:
-        \@@_output_module:nn
-          { \color { verb at guard } }
-          {
-            \@@_swap_cr:
-            \@@_module_pop:n { \l_@@_verbatim_line_tl }
-          }
-      }
-      { \tl_use:N \l_@@_verbatim_line_tl }
-  }
-\cs_new_eq:NN \@@_verbatim_process_line: \@@_process_normal_line:
-\DeclareDocumentCommand \CheckModules { }
-  { \cs_set_eq:NN \@@_verbatim_process_line: \@@_process_normal_line: }
-\DeclareDocumentCommand \DontCheckModules { }
-  { \cs_set_eq:NN \@@_verbatim_process_line: \@@_output_line: }
-\cs_new_protected:Npn \@@_check_angle:n #1
-  {
-     \str_if_eq:eeTF { \str_head:n {#1} } { < }
-      { \@@_check_module:x { \tl_tail:n {#1} } }
-      { \@@_output_percent_line: }
-  }
-\cs_generate_variant:Nn \@@_check_angle:n { x }
-\cs_new_protected:Npn \@@_check_module:n #1
-  {
-    \exp_args:Nx \str_case:nnF { \str_head:n {#1} }
-      {
-        { * } { \@@_module_star:w }
-        { / } { \@@_module_slash:w }
-        { @ } { \@@_module_at:w }
-        { < } { \@@_module_verb:w }
-      }
-      { \@@_module_pm:w }
-    #1 \q_stop
-  }
-\cs_generate_variant:Nn \@@_check_module:n { x }
-\group_begin:
-  \char_set_catcode_active:N \>
-  \cs_new_protected:Npn \@@_module_star:w #1 > #2 \q_stop
-    {
-      \@@_output_module:nn
-        { \@@_star_color: }
-        { \@@_module_push:n { \@@_module_angle:n {#1} } }
-      \@@_output_line:n {#2}
-      \@@_star_format:
-    }
-  \cs_new_protected:Npn \@@_module_slash:w #1 > #2 \q_stop
-    {
-      \@@_output_module:nn
-        { \@@_slash_color: }
-        { \@@_module_pop:n { \@@_module_angle:n {#1} } }
-      \@@_output_line:n {#2}
-      \@@_slash_format:
-    }
-  \cs_new_protected:Npn \@@_module_at:w @ @ = #1 > #2 \q_stop
-    {
-      \@@_output_module:nn
-        { \color { at at guard } }
-        { \@@_module_angle:n { @ @ = #1 } }
-      \tl_gset:Nn \g__codedoc_module_name_tl {#1}
-      \@@_output_line:n {#2}
-    }
-  \cs_new_protected:Npn \@@_module_pm:w #1 > #2 \q_stop
-    {
-      \tex_noindent:D
-      \hbox_overlap_left:n
-        {
-          \@@_output_module:nn
-            { \@@_pm_color: }
-            { \@@_module_angle:n {#1} }
-          \skip_horizontal:n { \leftskip + \smallskipamount }
-        }
-      \group_begin:
-        \@@_pm_format:
-        \@@_output_line:n {#2}
-      \group_end:
-    }
-  \cs_new_protected:Npn \@@_module_verb:w #1 \q_stop
-    {
-      \cs_gset_eq:NN \@@_verbatim_process_line: \@@_process_verb_line:
-      \tl_gset:Nx \g_@@_verbatim_verb_stop_tl
-        { \c_percent_str \tl_tail:n {#1} }
-      \@@_output_module:nn
-        { \color { verb at guard } }
-        {
-          \@@_swap_cr:
-          \@@_module_push:n { \l_@@_verbatim_line_tl }
-        }
-    }
-\group_end:
-\cs_new_protected_nopar:Npn \@@_output_line:
-  {
-    \tex_noindent:D
-    \@@_replace_at_at:N \l_@@_verbatim_line_tl
-    \tl_use:N \l_@@_verbatim_line_tl
-  }
-\cs_new_protected:Npn \@@_replace_at_at:N #1
-  {
-    \tl_if_empty:NF \g__codedoc_module_name_tl
-      {
-        \exp_args:NNo \@@_replace_at_at_aux:Nn
-          #1 \g__codedoc_module_name_tl
-      }
-  }
-\cs_new_protected:Npn \@@_replace_at_at_aux:Nn #1#2
-  {
-    \tl_replace_all:Nnn #1 { _ @ @ } { _ _ #2 }
-    \tl_replace_all:Nnn #1 {   @ @ } { _ _ #2 }
-  }
-\cs_new_protected:Npn \@@_output_line:n #1
-  {
-    \tl_set:Nn \l_@@_verbatim_line_tl {#1}
-    \tl_if_eq:NNTF \l_@@_verbatim_line_tl \c_@@_active_cr_tl
-      { \tl_use:N \l_@@_verbatim_line_tl }
-      {
-        \str_if_eq:eeTF
-          { \str_head:N \l_@@_verbatim_line_tl }
-          { \c_percent_str }
-          { \@@_output_percent_line: }
-          { \@@_output_line: }
-      }
-  }
-\cs_new_protected:Npn \@@_output_percent_line:
-  {
-    \tex_noindent:D
-    \group_begin:
-      \color { code at gray }
-      \@@_swap_cr:
-      \str_if_eq:eeTF { \f at shape } { \updefault }
-        { \slshape }
-        { \upshape }
-      \@@_output_line:
-    \group_end:
-  }
-\cs_new_protected_nopar:Npn \@@_module_push:n
-  { \exp_args:No \@@_module_push_aux:nn { \int_use:N \c at HD@hypercount } }
-\cs_new_protected:Npn \@@_module_push_aux:nn #1
-  {
-    \seq_gpush:Nn \g_@@_module_dest_seq {#1}
-    \hypersetup { hidelinks }
-    \exp_args:Nx \hdclindex
-      { \zref at extractdefault { HD.#1 } { guard at end } { 1 } } { }
-  }
-\cs_new_protected_nopar:Npn \@@_module_pop:n
-  {
-    \seq_gpop:NNTF \g_@@_module_dest_seq \l_@@_tmp_tl
-      { \exp_args:No \@@_module_pop_aux:nn { \l_@@_tmp_tl } }
-      { \BOOM \use:n }
-  }
-\cs_new_protected:Npn \@@_module_pop_aux:nn #1
-  {
-    \zref at labelbylist { HD.#1 } { ctxdoc }
-    \hypersetup { hidelinks }
-    \hdclindex {#1} { }
-  }
-\seq_new:N \g_@@_module_dest_seq
-\zref at newlist { ctxdoc }
-\zref at newprop { guard at end } [ 1 ]
-  { \int_eval:n { \c at HD@hypercount - 1 } }
-\zref at addprop { ctxdoc } { guard at end }
-\cs_new_protected_nopar:Npn \@@_star_format:
-  {
-    \seq_gpush:No \g_@@_slash_format_seq { \macro at font }
-    \seq_gpop:NNF \g_@@_star_format_seq \l_@@_format_tl
-      { \@@_pop_format: }
-    \@@_select_format:
-  }
-\cs_new_protected_nopar:Npn \@@_slash_format:
-  {
-    \seq_gpop:NNTF \g_@@_slash_format_seq \l_@@_format_tl
-      {
-        \seq_gpush:No \g_@@_star_format_seq { \macro at font }
-        \@@_select_format:
-      }
-      { \BOOM }
-  }
-\cs_new_protected_nopar:Npn \@@_pm_format:
-  {
-    \seq_get:NNF \g_@@_star_format_seq \l_@@_format_tl
-      {
-        \@@_pop_format:
-        \seq_gpush:No \g_@@_star_format_seq { \l_@@_format_tl }
-      }
-    \cs_if_eq:NNF \macro at font \l_@@_format_tl
-      { \l_@@_format_tl }
-  }
-\cs_new_protected_nopar:Npn \@@_pop_format:
-  {
-    \seq_gpop_left:NN \g_@@_format_seq \l_@@_format_tl
-    \seq_gput_right:No \g_@@_format_seq { \l_@@_format_tl }
-  }
-\cs_new_protected_nopar:Npn \@@_select_format:
-  {
-    \cs_if_eq:NNF \macro at font \l_@@_format_tl
-      {
-        \cs_gset_eq:NN \macro at font \l_@@_format_tl
-        \macro at font
-      }
-  }
-\tl_new:N \l_@@_format_tl
-\seq_new:N \g_@@_format_seq
-\seq_new:N \g_@@_star_format_seq
-\seq_new:N \g_@@_slash_format_seq
-\seq_gput_right:Nn \g_@@_format_seq { \MacroFont }
-\seq_gput_right:Nn \g_@@_format_seq { \AltMacroFont }
-\cs_set_protected:Npn \MacroFont
-  {
-    \linespread { 1 }
-    \small
-    \fontseries { \mddefault }
-    \fontshape  { \updefault }
-    \ttfamily
-    \ctexdocverbaddon
-  }
-\cs_set_protected:Npn \AltMacroFont
-  {
-    \linespread { 1 }
-    \small
-    \fontseries { \mddefault }
-    \fontshape  { \sldefault }
-    \ttfamily
-    \ctexdocverbaddon
-  }
-\AtBeginDocument
-  {
-    \tl_gset:Nx \macro at font
-      { \seq_item:Nn \g_@@_format_seq { 1 } }
-  }
-\cs_new_protected:Npn \@@_output_module:nn #1#2
-  {
-    \tex_noindent:D
-    \group_begin:
-      #1
-      \footnotesize \normalfont \sffamily #2
-    \group_end:
-  }
-\cs_new_protected_nopar:Npn \@@_star_color:
-  {
-    \seq_gpop:NNTF \g_@@_star_color_seq \current at color
-      { \set at color }
-      { \@@_select_color: }
-    \seq_gpush:No \g_@@_slash_color_seq { \current at color }
-  }
-\cs_new_protected_nopar:Npn \@@_slash_color:
-  {
-    \seq_gpop:NNTF \g_@@_slash_color_seq \current at color
-      {
-        \set at color
-        \seq_gpush:No \g_@@_star_color_seq { \current at color }
-      }
-      { \BOOM }
-  }
-\cs_new_protected_nopar:Npn \@@_pm_color:
-  {
-    \seq_get:NNTF \g_@@_star_color_seq \current at color
-      { \set at color }
-      {
-        \@@_select_color:
-        \seq_gpush:No \g_@@_star_color_seq { \current at color }
-      }
-  }
-\seq_new:N \g_@@_star_color_seq
-\seq_new:N \g_@@_slash_color_seq
-\cs_new_protected_nopar:Npn \@@_select_color:
-  { \color { guard at series!!+ } }
-\definecolorseries { guard at series }
-  { cmyk } { last } { blue } { purple }
-\resetcolorseries [ 3 ] { guard at series }
-\definecolor { verb at guard } { rgb }  { 0.5  , 0.5 , 0 }
-\definecolor { at at guard }   { rgb }  { 0.5  , 0   , 0.5 }
-\definecolor { code at gray }  { gray } { 0.5 }
-\cs_new_protected:Npn \@@_module_angle:n #1
-  { \textlangle #1 \textrangle }
-\cs_new_protected_nopar:Npn \@@_code_line_no:
-  {
-    \int_gincr:N \c at CodelineNo
-    \hbox_overlap_left:n
-      {
-        \hbox_to_wd:nn
-          { \MacroIndent }
-          {
-            \HD at target
-            \tex_hss:D
-            \@@_code_line_no_style:
-            \theCodelineNo \enspace
-          }
-        \tex_kern:D \@totalleftmargin
-      }
-  }
-\tl_set:Nn \theCodelineNo
-  { \arabic { CodelineNo } }
-\cs_new_protected_nopar:Npn \@@_code_line_no_style:
-  { \color { code at gray } \normalfont \sffamily \tiny }
-\cs_set_protected:Npn \HD at SetMacroIndent #1
-  {
-    \group_begin:
-      \settowidth \MacroIndent
-        {
-          \@@_code_line_no_style:
-          \prg_replicate:nn { \tl_count:n {#1} } { 0 }
-          \enspace
-        }
-      \dim_gset_eq:NN \MacroIndent \MacroIndent
-    \group_end:
-  }
-\ExplSyntaxOff
-\AtBeginDocument{\addtocontents{toc}{\StopSpecialIndexModule}}
-\pdfstringdefDisableCommands{%
-  \let\path\meta
-  \let\opt\@firstofone}
-\preto\@thehead{\cslet{MakeUppercase\space}{\@iden}}
-\def\orbar{\textup{\textbar}}
-\def\defaultval#1{\textbf{\textup{#1}}}
-\def\defaultvalaux#1){\defaultval{#1}}
-\def\TF{true\orbar false}
-\def\TTF{\defaultval{true}\orbar false}
-\def\TFF{true\orbar\defaultval{false}}
-\protected\def\opt{\texttt}
-\def\pdfTeX{\hologo{pdfTeX}}
-\def\XeTeX{\hologo{XeTeX}}
-\def\XeLaTeX{\hologo{XeLaTeX}}
-\def\LuaLaTeX{\hologo{LuaLaTeX}}
-\def\pdfLaTeX{\hologo{pdfLaTeX}}
-\def\LaTeX{\hologo{LaTeX}}
-\def\LaTeXe{\hologo{LaTeX2e}}
-\def\LaTeXiii{\hologo{LaTeX3}}
-\def\dvipdfmx{DVIPDFM\textit{x}}
-\def\TeX{\hologo{TeX}}
-\def\ApTeX{Ap\TeX}
-\def\ApLaTeX{Ap\LaTeX}
-\def\upTeX{up\TeX}
-\def\upLaTeX{up\LaTeX}
-\def\bashcmd{\texttt}
-\def\TeXLive{\TeX\ Live}
-\def\MiKTeX{\hologo{MiKTeX}}
-\def\BSTACK{\begin{tabular}[t]{@{}l@{}}}
-\def\ESTACK{\end{tabular}}
-\newenvironment{defaultcapconfig}{%
-  \MakePercentComment
-  \input{ctex-name-utf8.cfg}%
-  \ExplSyntaxOff
-  \MakePercentIgnore}{}
-\def\ctexkit{\href{https://github.com/CTeX-org/ctex-kit/}{\texttt{ctex-kit}}}
-\def\ctexkitrev#1{%
-  \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}}
-\appto\GlossaryParms{%
-  \raggedcolumns
-  \let\Hy at writebookmark\HDorg at writebookmark
-  \def\@idxitem{\par\hangindent 2em }%
-  \def\subitem{\@idxitem\hspace*{1em}}%
-  \def\subsubitem{\@idxitem\hspace*{2em}}}
-\def\glossaryname{版本历史}
-\GlossaryPrologue{\section{\glossaryname}}
-\IndexPrologue{%
-  \section{\indexname}
-  \textit{意大利体的数字表示描述对应索引项的页码;
-  带下划线的数字表示定义对应索引项的代码行号;
-  罗马字体的数字表示使用对应索引项的代码行号。}}
-\def\IndexLayout{%
-  \newgeometry{hmargin=15mm,vmargin={25mm,15mm},footskip=7mm}%
-  \setlength\IndexMin{.5\textheight}%
-  \ctexset{section/numbering=false}%
-  \StopSpecialIndexModule}
-\EnableCrossrefs
-\CodelineIndex
-\RecordChanges
-%    \end{macrocode}
-%
-%    \begin{macrocode}
-%</ctxdoc>
-%    \end{macrocode}
-%
-% \subsection{\pkg{ctxdocstrip}}
-%
-%    \begin{macrocode}
-%<*docstrip>
-\csname ctxdocstriploaded\endcsname
-\let\ctxdocstriploaded\endinput
-\input l3docstrip %
-\edef\ctxresetcatcode{%
-  \catcode\number`\$=\the\catcode`\$\relax}
-\makeOther\$
-\def\plusOption+#1>#2$#3$\endLine{%
-  \maybeMsg{<+#1 . >}%
-  \Evaluate{#1}%
-  \def\ctxCMD{#2}%
-  \def\ctxID{$#3$}%
-  \def\do##1##2##3{%
-    \if1\Expr{##2}%
-      \readIDFile
-      \StreamPut##1{\inLine}%
-    \fi
-  }%
-  \activefiles
-}
-\def\readIDFile{%
-  \openin\inputcheck=\jobname.id\relax
-  \ifeof\inputcheck\else
-    \read \inputcheck to \inLine
-    \closein\inputcheck
-    \ifx\inLine\empty\else
-      \let\ctxID\inLine
-    \fi
-  \fi
-  \maybeMsg{^^J\ctxID^^J}%
-  \def\inLine{\ctxCMD\ctxID}%
-}
-\keepsilent
-\askforoverwritefalse
-\declarepreamble\emptypreamble
-\endpreamble
-\declarepostamble\emptypostamble
-\endpostamble
-\ctxresetcatcode
-%</docstrip>
-%    \end{macrocode}
-%
-% \end{implementation}
-%
 \endinput

Added: trunk/Master/texmf-dist/source/latex/ctex/ctex.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/ctex/ctex.ins	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/ctex/ctex.ins	2020-05-02 22:24:14 UTC (rev 54976)
@@ -0,0 +1,299 @@
+%%
+%% This is file `ctex.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ctex.dtx  (with options: `install')
+%% 
+%%     Copyright (C) 2003--2020
+%%     CTEX.ORG and any individual authors listed in the documentation.
+%% ---------------------------------------------------------------------
+%% 
+%%     This work may be distributed and/or modified under the
+%%     conditions of the LaTeX Project Public License, either
+%%     version 1.3c of this license or (at your option) any later
+%%     version. This version of this license is in
+%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
+%%     and the latest version of this license is in
+%%        http://www.latex-project.org/lppl.txt
+%%     and version 1.3 or later is part of all distributions of
+%%     LaTeX version 2005/12/01 or later.
+%% 
+%%     This work has the LPPL maintenance status "maintained".
+%% 
+%% ---------------------------------------------------------------------
+%% 
+
+\input ctxdocstrip %
+
+\preamble
+
+    Copyright (C) 2003--2020
+    CTEX.ORG and any individual authors listed in the documentation.
+---------------------------------------------------------------------
+
+    This work may be distributed and/or modified under the
+    conditions of the LaTeX Project Public License, either
+    version 1.3c of this license or (at your option) any later
+    version. This version of this license is in
+       http://www.latex-project.org/lppl/lppl-1-3c.txt
+    and the latest version of this license is in
+       http://www.latex-project.org/lppl.txt
+    and version 1.3 or later is part of all distributions of
+    LaTeX version 2005/12/01 or later.
+
+    This work has the LPPL maintenance status "maintained".
+
+---------------------------------------------------------------------
+
+\endpreamble
+\postamble
+
+    This package consists of the files ctex.dtx,
+                                       ctxdoc.cls,
+                                       ctxdocstrip.tex,
+                                       ctex-zhconv.lua,
+                                       ctex-zhconv-make.lua,
+                 and the derived files ctex.pdf,
+                                       ctex.ins,
+                                       ctex.sty,
+                                       ctexsize.sty,
+                                       ctexheading.sty,
+                                       ctexart.cls,
+                                       ctexbook.cls,
+                                       ctexrep.cls,
+                                       ctexbeamer.cls,
+                                       ctexcap.sty,
+                                       ctexhook.sty,
+                                       ctexpatch.sty,
+                                       ctex-c5size.clo,
+                                       ctex-cs4size.clo,
+                                       ctex-heading-article.def,
+                                       ctex-heading-book.def,
+                                       ctex-heading-report.def,
+                                       ctex-heading-beamer.def,
+                                       ctex-scheme-plain.def,
+                                       ctex-scheme-plain-article.def,
+                                       ctex-scheme-plain-book.def,
+                                       ctex-scheme-plain-report.def,
+                                       ctex-scheme-plain-beamer.def,
+                                       ctex-scheme-chinese.def,
+                                       ctex-scheme-chinese-article.def,
+                                       ctex-scheme-chinese-book.def,
+                                       ctex-scheme-chinese-report.def,
+                                       ctex-scheme-chinese-beamer.def,
+                                       ctex-name-gbk.cfg,
+                                       ctex-name-utf8.cfg,
+                                       ctex.cfg,
+                                       ctexopts.cfg,
+                                       ctexbackend.cfg,
+                                       ctex-engine-pdftex.def,
+                                       ctex-engine-xetex.def,
+                                       ctex-engine-luatex.def,
+                                       ctex-engine-aptex.def,
+                                       ctex-engine-uptex.def,
+                                       c19rm.fd,
+                                       c19sf.fd,
+                                       c19tt.fd,
+                                       c70rm.fd,
+                                       c70sf.fd,
+                                       c70tt.fd,
+                                       jy2zhrm.fd,
+                                       jy2zhsf.fd,
+                                       jy2zhtt.fd,
+                                       jt2zhrm.fd,
+                                       jt2zhsf.fd,
+                                       jt2zhtt.fd,
+                                       ctex-fontset-adobe.def,
+                                       ctex-fontset-fandol.def,
+                                       ctex-fontset-founder.def,
+                                       ctex-fontset-mac.def,
+                                       ctex-fontset-macnew.def,
+                                       ctex-fontset-macold.def,
+                                       ctex-fontset-ubuntu.def,
+                                       ctex-fontset-windows.def,
+                                       ctexspa.def,
+                                       ctexpunct.spa,
+                                       ctexmakespa.tex,
+                                       ctexspamacro.tex,
+                                       zhadobefonts.tex,
+                                       zhfandolfonts.tex,
+                                       zhfounderfonts.tex,
+                                       zhmacfonts.tex,
+                                       zhubuntufonts.tex,
+                                       zhwindowsfonts.tex,
+                                       ctex-zhconv-index.lua,
+                                       translator-theorem-dictionary-ChineseGBK.dict,
+                                       translator-theorem-dictionary-ChineseUTF8.dict, and
+                                       README.md.
+\endpostamble
+
+\generate
+  {
+    \usedir{tex/latex/ctex}
+    \file{ctex.sty}                        {\from{\jobname.dtx}{style,ctex}}
+    \file{ctexsize.sty}                    {\from{\jobname.dtx}{style,ctexsize}}
+    \file{ctexheading.sty}                 {\from{\jobname.dtx}{style,ctexheading}}
+    \file{ctexart.cls}                     {\from{\jobname.dtx}{class,article}}
+    \file{ctexbook.cls}                    {\from{\jobname.dtx}{class,book}}
+    \file{ctexrep.cls}                     {\from{\jobname.dtx}{class,report}}
+    \file{ctexbeamer.cls}                  {\from{\jobname.dtx}{class,beamer}}
+    \usepostamble\emptypostamble
+    \file{ctexcap.sty}                     {\from{\jobname.dtx}{ctexcap}}
+    \file{ctexhook.sty}                    {\from{\jobname.dtx}{ctexhook}}
+    \file{ctexpatch.sty}                   {\from{\jobname.dtx}{ctexpatch}}
+    \file{ctex-c5size.clo}                 {\from{\jobname.dtx}{c5size}}
+    \file{ctex-cs4size.clo}                {\from{\jobname.dtx}{cs4size}}
+    \file{ctex-heading-article.def}        {\from{\jobname.dtx}{heading,article}}
+    \file{ctex-heading-book.def}           {\from{\jobname.dtx}{heading,book}}
+    \file{ctex-heading-report.def}         {\from{\jobname.dtx}{heading,report}}
+    \file{ctex-heading-beamer.def}         {\from{\jobname.dtx}{heading,beamer}}
+    \file{ctex-scheme-plain.def}           {\from{\jobname.dtx}{scheme,generic,plain}}
+    \file{ctex-scheme-plain-article.def}   {\from{\jobname.dtx}{scheme,article,plain}}
+    \file{ctex-scheme-plain-book.def}      {\from{\jobname.dtx}{scheme,book,plain}}
+    \file{ctex-scheme-plain-report.def}    {\from{\jobname.dtx}{scheme,report,plain}}
+    \file{ctex-scheme-plain-beamer.def}    {\from{\jobname.dtx}{scheme,beamer,plain}}
+    \file{ctex-scheme-chinese.def}         {\from{\jobname.dtx}{scheme,generic,chinese}}
+    \file{ctex-scheme-chinese-article.def} {\from{\jobname.dtx}{scheme,article,chinese}}
+    \file{ctex-scheme-chinese-book.def}    {\from{\jobname.dtx}{scheme,book,chinese}}
+    \file{ctex-scheme-chinese-report.def}  {\from{\jobname.dtx}{scheme,report,chinese}}
+    \file{ctex-scheme-chinese-beamer.def}  {\from{\jobname.dtx}{scheme,beamer,chinese}}
+ \ctxfile{GBK}{ctex-name-gbk.cfg}          {\from{\jobname.dtx}{name,GBK}}
+    \file{ctex-name-utf8.cfg}              {\from{\jobname.dtx}{name,UTF8}}
+    \file{ctex.cfg}                        {\from{\jobname.dtx}{config}}
+    \file{ctexopts.cfg}                    {\from{\jobname.dtx}{ctexopts}}
+    \file{ctexbackend.cfg}                 {\from{\jobname.dtx}{backend}}
+    \file{ctex-engine-pdftex.def}          {\from{\jobname.dtx}{pdftex}}
+    \file{ctex-engine-xetex.def}           {\from{\jobname.dtx}{xetex}}
+    \file{ctex-engine-luatex.def}          {\from{\jobname.dtx}{luatex}}
+    \file{ctex-engine-aptex.def}           {\from{\jobname.dtx}{aptex}}
+    \file{ctex-engine-uptex.def}           {\from{\jobname.dtx}{uptex}}
+    \file{c19rm.fd}                        {\from{\jobname.dtx}{fd,rm,c19}}
+    \file{c19sf.fd}                        {\from{\jobname.dtx}{fd,sf,c19}}
+    \file{c19tt.fd}                        {\from{\jobname.dtx}{fd,tt,c19}}
+    \file{c70rm.fd}                        {\from{\jobname.dtx}{fd,rm,c70}}
+    \file{c70sf.fd}                        {\from{\jobname.dtx}{fd,sf,c70}}
+    \file{c70tt.fd}                        {\from{\jobname.dtx}{fd,tt,c70}}
+    \file{jy2zhrm.fd}                      {\from{\jobname.dtx}{fd,rm,jy2}}
+    \file{jy2zhsf.fd}                      {\from{\jobname.dtx}{fd,sf,jy2}}
+    \file{jy2zhtt.fd}                      {\from{\jobname.dtx}{fd,tt,jy2}}
+    \file{jt2zhrm.fd}                      {\from{\jobname.dtx}{fd,rm,jt2}}
+    \file{jt2zhsf.fd}                      {\from{\jobname.dtx}{fd,sf,jt2}}
+    \file{jt2zhtt.fd}                      {\from{\jobname.dtx}{fd,tt,jt2}}
+    \file{ctex-fontset-adobe.def}          {\from{\jobname.dtx}{fontset,adobe}}
+    \file{ctex-fontset-fandol.def}         {\from{\jobname.dtx}{fontset,fandol}}
+    \file{ctex-fontset-founder.def}        {\from{\jobname.dtx}{fontset,founder}}
+    \file{ctex-fontset-mac.def}            {\from{\jobname.dtx}{fontset,mac}}
+    \file{ctex-fontset-macnew.def}         {\from{\jobname.dtx}{fontset,macnew}}
+    \file{ctex-fontset-macold.def}         {\from{\jobname.dtx}{fontset,macold}}
+    \file{ctex-fontset-ubuntu.def}         {\from{\jobname.dtx}{fontset,ubuntu}}
+    \file{ctex-fontset-windows.def}        {\from{\jobname.dtx}{fontset,windows}}
+ \ctxfile{GBK}{translator-theorem-dictionary-ChineseGBK.dict}
+                                           {\from{\jobname.dtx}{dict,theorem,GBK}}
+    \file{translator-theorem-dictionary-ChineseUTF8.dict}
+                                           {\from{\jobname.dtx}{dict,theorem,UTF8}}
+    \file{ctexspa.def}                     {\from{\jobname.dtx}{ctexspa}
+                                            \from{ctexpunct.spa}{}}
+    \usedir{tex/generic/ctex}
+    \file{ctexmakespa.tex}                 {\from{\jobname.dtx}{spa,make}}
+    \file{ctexspamacro.tex}                {\from{\jobname.dtx}{spa,macro}}
+    \file{zhadobefonts.tex}                {\from{\jobname.dtx}{zhmap,adobe}}
+    \file{zhfandolfonts.tex}               {\from{\jobname.dtx}{zhmap,fandol}}
+    \file{zhfounderfonts.tex}              {\from{\jobname.dtx}{zhmap,founder}}
+    \file{zhmacfonts.tex}                  {\from{\jobname.dtx}{zhmap,mac}}
+    \file{zhubuntufonts.tex}               {\from{\jobname.dtx}{zhmap,ubuntu}}
+    \file{zhwindowsfonts.tex}              {\from{\jobname.dtx}{zhmap,windows}}
+    \nopreamble\nopostamble
+    \usedir{doc/latex/ctex}
+    \file{README.md}                       {\from{\jobname.dtx}{readme}}
+  }
+
+\catcode32=12\space
+
+\Msg{*************************************************************}
+\Msg{*                                                           *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into proper directories searched by TeX:             *}
+\Msg{*                                                           *}
+\Msg{* The recommended directory is TDS:tex/latex/ctex           *}
+\Msg{*                                                           *}
+\Msg{*     ctex.sty                                              *}
+\Msg{*     ctexsize.sty                                          *}
+\Msg{*     ctexheading.sty                                       *}
+\Msg{*     ctexart.cls                                           *}
+\Msg{*     ctexbook.cls                                          *}
+\Msg{*     ctexrep.cls                                           *}
+\Msg{*     ctexbeamer.cls                                        *}
+\Msg{*     ctexcap.sty                                           *}
+\Msg{*     ctexhook.sty                                          *}
+\Msg{*     ctexpatch.sty                                         *}
+\Msg{*     ctex-c5size.clo                                       *}
+\Msg{*     ctex-cs4size.clo                                      *}
+\Msg{*     ctex-heading-article.def                              *}
+\Msg{*     ctex-heading-book.def                                 *}
+\Msg{*     ctex-heading-report.def                               *}
+\Msg{*     ctex-heading-beamer.def                               *}
+\Msg{*     ctex-scheme-plain.def                                 *}
+\Msg{*     ctex-scheme-plain-article.def                         *}
+\Msg{*     ctex-scheme-plain-book.def                            *}
+\Msg{*     ctex-scheme-plain-report.def                          *}
+\Msg{*     ctex-scheme-plain-beamer.def                          *}
+\Msg{*     ctex-scheme-chinese.def                               *}
+\Msg{*     ctex-scheme-chinese-article.def                       *}
+\Msg{*     ctex-scheme-chinese-book.def                          *}
+\Msg{*     ctex-scheme-chinese-report.def                        *}
+\Msg{*     ctex-scheme-chinese-beamer.def                        *}
+\Msg{*     ctex-name-gbk.cfg                                     *}
+\Msg{*     ctex-name-utf8.cfg                                    *}
+\Msg{*     ctex.cfg                                              *}
+\Msg{*     ctexopts.cfg                                          *}
+\Msg{*     ctexbackend.cfg                                       *}
+\Msg{*     ctex-engine-pdftex.def                                *}
+\Msg{*     ctex-engine-xetex.def                                 *}
+\Msg{*     ctex-engine-luatex.def                                *}
+\Msg{*     ctex-engine-aptex.def                                 *}
+\Msg{*     ctex-engine-uptex.def                                 *}
+\Msg{*     c19rm.fd                                              *}
+\Msg{*     c19sf.fd                                              *}
+\Msg{*     c19tt.fd                                              *}
+\Msg{*     c70rm.fd                                              *}
+\Msg{*     c70sf.fd                                              *}
+\Msg{*     c70tt.fd                                              *}
+\Msg{*     jy2zhrm.fd                                            *}
+\Msg{*     jy2zhsf.fd                                            *}
+\Msg{*     jy2zhtt.fd                                            *}
+\Msg{*     jt2zhrm.fd                                            *}
+\Msg{*     jt2zhsf.fd                                            *}
+\Msg{*     jt2zhtt.fd                                            *}
+\Msg{*     ctex-fontset-adobe.def                                *}
+\Msg{*     ctex-fontset-fandol.def                               *}
+\Msg{*     ctex-fontset-founder.def                              *}
+\Msg{*     ctex-fontset-mac.def                                  *}
+\Msg{*     ctex-fontset-macnew.def                               *}
+\Msg{*     ctex-fontset-macold.def                               *}
+\Msg{*     ctex-fontset-ubuntu.def                               *}
+\Msg{*     ctex-fontset-windows.def                              *}
+\Msg{*     ctexspa.def                                           *}
+\Msg{*     ctexmakespa.tex                                       *}
+\Msg{*     ctexspamacro.tex                                      *}
+\Msg{*     zhadobefonts.tex                                      *}
+\Msg{*     zhfandolfonts.tex                                     *}
+\Msg{*     zhfounderfonts.tex                                    *}
+\Msg{*     zhmacfonts.tex                                        *}
+\Msg{*     zhubuntufonts.tex                                     *}
+\Msg{*     zhwindowsfonts.tex                                    *}
+\Msg{*     translator-theorem-dictionary-ChineseGBK.dict         *}
+\Msg{*     translator-theorem-dictionary-ChineseUTF8.dict        *}
+\Msg{*                                                           *}
+\Msg{* To produce the documentation run the file ctex.dtx        *}
+\Msg{* through XeLaTeX.                                          *}
+\Msg{*                                                           *}
+\Msg{* Happy TeXing!                                             *}
+\Msg{*                                                           *}
+\Msg{*************************************************************}
+
+\endbatchfile
+%% 
+%%
+%% End of file `ctex.ins'.

Modified: trunk/Master/texmf-dist/source/latex/ctex/ctexpunct.spa
===================================================================
--- trunk/Master/texmf-dist/source/latex/ctex/ctexpunct.spa	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/source/latex/ctex/ctexpunct.spa	2020-05-02 22:24:14 UTC (rev 54976)
@@ -17,9 +17,23 @@
 \ctexspadef{founderzhli}{69,19,58,9,48,21,45,27,48,25,47,32,48,27,48,39,48,21,43,17,47,33,47,33,0,0,11,11,11,61,13,63,17,66,7,80,20,70,19,68,20,70,3,54,9,9,25,48,32,47,27,48,40,48,21,48,17,43,33,47,33,47,19,69,9,58,21,48,27,45,,,}
 \ctexspadef{founderzhyou}{67,16,61,11,48,11,45,14,48,20,48,17,48,16,48,39,48,12,42,16,48,30,48,30,0,0,12,11,11,61,9,59,17,67,11,83,20,70,18,69,21,70,4,54,12,12,20,48,17,48,16,48,39,48,12,48,16,41,30,48,29,48,16,67,11,61,11,48,14,45,,,}
 \ctexspadef{founderzhyoub}{69,18,60,10,46,13,43,16,46,17,45,20,46,18,46,31,45,13,38,14,44,29,46,30,-3,0,10,9,9,61,9,59,19,69,7,82,18,68,18,67,20,69,2,52,17,17,17,46,20,45,18,46,32,46,13,45,14,38,29,44,30,46,19,69,10,60,14,46,17,43,,,}
-\ctexspadef{ubuntuzhsong}{66,21,58,7,58,8,55,11,59,18,71,7,71,2,40,38,58,13,52,4,64,6,58,14,7,7,11,10,38,38,38,38,17,73,21,70,13,78,13,75,27,63,4,52,4,5,18,59,7,71,2,71,38,40,13,58,4,51,6,64,14,58,16,70,8,56,10,58,11,54,,,}
-\ctexspadef{ubuntuzhhei}{6,6,4,4,60,10,61,11,62,12,65,15,67,15,62,15,63,13,57,6,19,52,63,13,-0,0,11,11,10,70,10,68,44,44,45,44,44,44,44,44,43,45,27,27,19,16,12,62,15,65,15,67,15,62,13,63,6,56,3,68,13,63,6,6,4,4,10,60,11,61,,,}
-\ctexspadef{ubuntuzhkai}{68,20,58,9,58,8,55,11,59,18,59,20,59,18,53,23,58,13,52,4,58,8,58,14,7,7,11,10,38,38,38,38,40,42,43,43,43,43,43,43,43,43,25,28,10,11,18,59,20,59,18,59,24,53,13,58,4,51,8,58,14,58,17,70,9,58,10,58,11,54,,,}
+\ctexspadef{maczhsong}{4,4,4,4,63,14,59,7,63,13,64,13,70,12,59,13,61,12,47,7,56,7,58,8,0,0,11,11,10,68,13,63,17,68,20,70,20,70,18,68,20,70,12,59,18,18,14,62,10,66,12,69,9,64,12,61,7,47,7,56,8,58,4,4,4,4,14,63,7,59,,,}
+\ctexspadef{maczhsongb}{4,4,4,4,62,13,49,13,62,10,65,10,59,13,62,14,61,12,43,9,56,4,56,14,0,0,11,10,7,67,13,62,15,66,18,67,18,69,16,66,18,69,10,60,14,10,10,62,10,64,12,60,14,62,12,61,9,43,4,56,14,56,4,4,4,4,12,62,12,50,,,}
+\ctexspadef{maczhhei}{68,15,58,4,62,13,56,6,61,11,65,12,66,16,63,12,59,14,51,5,55,5,60,10,0,0,8,11,13,60,13,62,20,70,20,70,20,70,20,70,20,70,3,54,9,10,10,62,12,65,16,65,9,66,14,60,7,48,5,55,10,60,14,68,4,58,13,62,6,56,,,}
+\ctexspadef{maczhheil}{71,17,65,7,60,11,56,6,59,9,67,10,66,15,64,13,58,14,51,6,53,6,60,8,0,0,9,10,10,61,12,62,20,70,20,70,20,70,20,70,21,71,4,55,9,9,9,59,10,67,15,66,13,64,14,58,6,51,6,53,8,60,17,71,7,65,11,60,6,56,,,}
+\ctexspadef{maczhkai}{5,5,6,3,63,14,59,7,63,13,62,12,60,11,61,15,61,12,47,7,56,7,58,8,0,0,12,11,10,68,13,63,18,67,20,69,19,69,17,67,19,70,14,57,15,10,14,62,10,65,10,60,13,63,12,61,7,47,7,56,8,58,4,4,4,5,14,63,7,59,,,}
+\ctexspadef{maczhkaib}{5,6,4,4,65,10,54,8,62,14,63,9,65,10,60,14,61,13,50,8,58,10,60,10,0,0,10,10,11,68,13,63,17,68,18,68,18,68,17,68,19,69,11,59,15,12,13,62,9,63,9,66,13,60,13,61,8,50,10,58,10,61,6,5,4,4,9,65,8,55,,,}
+\ctexspadef{maczhfs}{71,14,62,8,63,14,59,7,63,13,62,12,60,11,61,15,61,12,47,7,56,7,58,8,0,0,12,11,10,68,13,63,18,67,20,69,19,69,17,67,19,70,7,58,15,10,14,62,10,65,10,60,13,63,12,61,7,47,7,56,8,58,15,68,8,60,14,63,7,59,,,}
+\ctexspadef{maczhli}{4,2,7,4,69,2,61,4,65,6,62,6,48,2,46,1,67,5,52,4,61,3,65,3,0,-0,10,7,10,64,11,66,18,67,43,41,18,67,15,67,19,67,11,57,14,13,4,67,6,63,2,47,1,50,5,67,4,52,3,61,3,65,4,2,7,4,6,67,4,61,,,}
+\ctexspadef{maczhyou}{5,5,5,9,71,4,58,4,71,4,75,6,75,6,69,5,73,4,57,4,59,4,63,4,0,0,12,12,12,64,13,66,19,70,15,75,19,72,18,71,19,72,5,58,11,11,4,71,6,75,6,75,5,69,4,73,4,57,4,59,4,63,5,5,7,10,4,71,4,58,,,}
+\ctexspadef{maczhyoub}{3,3,4,7,69,2,57,2,70,2,74,4,74,6,67,3,71,2,55,2,58,4,63,4,0,0,10,10,9,62,12,62,17,68,13,72,17,68,16,68,18,68,4,56,10,10,2,70,4,74,6,74,3,67,2,71,2,55,4,58,4,63,3,4,5,7,2,69,2,57,,,}
+\ctexspadef{maczhpf}{12,8,12,8,65,3,62,3,67,3,70,8,72,4,67,4,65,8,51,6,63,3,66,5,0,0,11,11,13,63,12,62,12,74,12,76,19,69,18,68,19,69,3,53,8,8,3,67,8,70,4,72,4,67,8,65,6,51,3,63,5,66,8,12,8,12,3,65,3,62,,,}
+\ctexspadef{maczhpfb}{12,8,12,8,64,3,61,3,66,3,67,8,70,4,65,4,63,8,47,6,61,3,64,5,0,0,9,9,11,61,11,61,11,71,11,73,17,67,17,66,17,67,2,52,7,7,3,66,8,67,4,70,4,65,8,63,6,47,3,61,5,64,8,12,8,12,3,64,3,61,,,}
+\ctexspadef{ubuntuzhsong}{77,8,57,8,66,4,60,4,71,4,65,6,71,4,58,3,53,4,52,4,61,4,62,4,4,4,11,11,4,71,4,68,8,77,9,78,17,70,15,70,19,69,6,55,9,9,4,71,6,65,4,71,3,58,4,53,4,52,4,61,4,62,8,77,8,57,4,66,4,60,,,}
+\ctexspadef{ubuntuzhsongb}{75,8,53,8,65,3,62,3,72,3,64,6,72,3,57,3,53,3,53,3,62,3,63,3,4,4,11,11,3,69,4,68,5,77,6,77,18,65,18,65,17,67,4,54,7,7,3,72,6,64,3,72,3,57,3,53,3,53,3,62,3,63,8,75,8,53,3,65,3,62,,,}
+\ctexspadef{ubuntuzhhei}{81,5,62,4,65,3,60,3,71,4,70,5,71,3,70,4,59,5,53,4,62,3,67,3,5,5,10,10,5,66,4,65,14,67,16,68,18,67,15,66,19,69,3,54,8,8,4,71,5,70,3,71,4,70,5,59,4,53,3,62,3,67,5,81,4,62,3,65,3,60,,,}
+\ctexspadef{ubuntuzhheib}{80,4,60,2,64,3,60,3,69,2,66,4,71,3,68,3,56,5,52,3,63,3,66,3,5,5,9,9,4,64,3,64,16,61,18,62,16,66,13,64,16,66,3,53,5,5,2,69,4,66,3,71,3,68,5,56,3,52,3,63,3,66,4,80,2,60,3,64,3,60,,,}
+\ctexspadef{ubuntuzhkai}{53,33,53,19,58,8,59,9,61,11,60,10,62,12,60,10,56,6,54,4,58,8,58,8,7,7,15,15,26,53,29,53,19,67,22,68,30,60,27,59,26,63,7,57,25,23,11,61,10,60,12,62,10,60,6,56,3,54,8,58,8,58,32,54,19,53,8,58,9,59,,,}
 \ctexspadef{windowszhsong}{67,13,46,13,62,14,61,14,65,17,57,14,55,14,53,18,64,11,54,10,47,11,49,14,3,3,10,10,11,64,14,64,11,71,13,73,12,73,12,73,23,63,14,52,15,13,16,66,14,57,14,55,19,52,11,66,9,54,11,48,14,51,14,68,13,48,14,62,14,61,,,}
 \ctexspadef{windowszhhei}{78,9,56,9,50,20,50,20,50,23,61,11,54,14,50,26,50,16,50,7,47,11,49,14,0,0,9,11,14,64,13,63,14,72,14,73,19,68,18,68,25,64,15,48,12,12,22,50,11,60,14,55,25,50,16,50,7,50,11,48,14,51,8,79,8,56,18,50,18,50,,,}
 \ctexspadef{windowszhkai}{67,13,46,13,50,20,50,20,50,23,61,11,54,14,50,26,50,16,50,7,47,11,49,14,0,0,10,10,11,64,13,63,11,71,13,73,17,68,17,68,23,63,15,48,12,12,22,50,11,60,14,55,25,50,16,50,7,50,11,48,14,51,14,68,13,48,18,50,18,50,,,}

Modified: trunk/Master/texmf-dist/tex/generic/ctex/ctexmakespa.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/ctexmakespa.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/ctexmakespa.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `spa,make')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,14 +20,11 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \input ctexspamacro %
-
 \MAKESPA {ctexpunct.spa}
   {
     {adobezhsong}     {AdobeSongStd-Light} ,
@@ -49,9 +46,23 @@
     {founderzhli}     {FZLiShu-S01} ,
     {founderzhyou}    {FZXiYuan-M01} ,
     {founderzhyoub}   {FZZhunYuan-M02} ,
-    {ubuntuzhsong}    {AR PL UMing CN} ,
-    {ubuntuzhhei}     {WenQuanYi Zen Hei} ,
-    {ubuntuzhkai}     {AR PL UKai CN} ,
+    {maczhsong}       {Songti SC Light} ,
+    {maczhsongb}      {Songti SC Bold} ,
+    {maczhhei}        {Heiti SC Medium} ,
+    {maczhheil}       {Heiti SC Light} ,
+    {maczhkai}        {Kaiti SC} ,
+    {maczhkaib}       {Kaiti SC Bold} ,
+    {maczhfs}         {STFangsong} ,
+    {maczhli}         {Baoli SC} ,
+    {maczhyou}        {Yuanti SC Light} ,
+    {maczhyoub}       {Yuanti SC Regular} ,
+    {maczhpf}         {PingFang SC} ,
+    {maczhpfb}        {PingFang SC Semibold} ,
+    {ubuntuzhsong}    {Noto Serif CJK SC} ,
+    {ubuntuzhsongb}   {Noto Serif CJK SC Bold} ,
+    {ubuntuzhhei}     {Noto Sans CJK SC} ,
+    {ubuntuzhheib}    {Noto Sans CJK SC Bold} ,
+    {ubuntuzhkai}     {AR PL KaitiM GB} ,
     {windowszhsong}   {SimSun} ,
     {windowszhhei}    {SimHei} ,
     {windowszhkai}    {KaiTi} ,
@@ -61,7 +72,6 @@
     {windowszhyahei}  {Microsoft YaHei} ,
     {windowszhyaheib} {Microsoft YaHei Bold}
   }
-
 \primitive\end
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/generic/ctex/ctexspamacro.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/ctexspamacro.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/ctexspamacro.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `spa,macro')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,17 +20,15 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \input expl3-generic %
 \ExplSyntaxOn
 \sys_if_engine_xetex:F
   {
-    \msg_new:nn { ctex } { xetex }
+    \msg_new:nnn { ctex } { xetex }
       { XeTeX~is~required~to~compile~this~document! }
     \msg_fatal:nn { ctex } { xetex }
   }
@@ -42,7 +40,7 @@
     "FF01 , "FF1F , "FF05 , "3015 , "FF09 , "FF3D , "FF5D , "3009 ,
     "300B , "3017 , "3011 , "2019 , "201D , "300D , "300F
   }
-\cs_new_protected_nopar:Npn \ctex_make_spa:nn #1#2
+\cs_new_protected:Npn \ctex_make_spa:nn #1#2
   {
     \iow_open:Nn \g__ctex_spa_iow {#1}
     \clist_map_inline:nn {#2}
@@ -66,7 +64,7 @@
         }
     \group_end:
   }
-\cs_new_protected_nopar:Npn \__ctex_save_bounds:n #1
+\cs_new_protected:Npn \__ctex_save_bounds:n #1
   {
     \clist_put_right:Nx \l__ctex_punct_bounds_clist
       {
@@ -75,7 +73,7 @@
       }
   }
 \clist_new:N \l__ctex_punct_bounds_clist
-\cs_new_nopar:Npn \__ctex_calc_bounds:nn #1#2
+\cs_new:Npn \__ctex_calc_bounds:nn #1#2
   {
     \fp_eval:n
       {

Modified: trunk/Master/texmf-dist/tex/generic/ctex/ctxdocstrip.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/ctxdocstrip.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/ctxdocstrip.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -1,15 +1,10 @@
 %%
-%% This is file `ctxdocstrip.tex',
-%% generated with the docstrip utility.
+%% File ctxdocstrip.tex
 %%
-%% The original source files were:
+%%     Copyright (C) 2016--2020
+%%     CTEX.ORG and any individual authors listed in the documentation.
+%%---------------------------------------------------------------------
 %%
-%% ctex.dtx  (with options: `docstrip')
-%% 
-%%     Copyright (C) 2003--2019
-%%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
-%% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
 %%     version 1.3c of this license or (at your option) any later
@@ -19,19 +14,20 @@
 %%        http://www.latex-project.org/lppl.txt
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
-%% 
-%%     This work has the LPPL maintenance status `maintained'.
-%% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%% 
-%% ------------------------------------------------------------------------------
-%% 
-\csname ctxdocstriploaded\endcsname
-\let\ctxdocstriploaded\endinput
+%%
+%%     This work has the LPPL maintenance status "maintained".
+%%
+%%---------------------------------------------------------------------
+%%
+\csname ctxDocstripLoaded\endcsname
+\let\ctxDocstripLoaded\endinput
 \input l3docstrip %
-\edef\ctxresetcatcode{%
-  \catcode\number`\$=\the\catcode`\$\relax}
+\edef\ctxResetCatcode{%
+  \catcode\number`\$=\the\catcode`\$\relax
+  \catcode\number`\@=\the\catcode`\@\relax
+}
 \makeOther\$
+\catcode`\@=11\relax
 \def\plusOption+#1>#2$#3$\endLine{%
   \maybeMsg{<+#1 . >}%
   \Evaluate{#1}%
@@ -39,13 +35,13 @@
   \def\ctxID{$#3$}%
   \def\do##1##2##3{%
     \if1\Expr{##2}%
-      \readIDFile
+      \ctxReadIDFile
       \StreamPut##1{\inLine}%
     \fi
   }%
   \activefiles
 }
-\def\readIDFile{%
+\def\ctxReadIDFile{%
   \openin\inputcheck=\jobname.id\relax
   \ifeof\inputcheck\else
     \read \inputcheck to \inLine
@@ -63,7 +59,52 @@
 \endpreamble
 \declarepostamble\emptypostamble
 \endpostamble
-\ctxresetcatcode
-%% 
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname directlua\endcsname\relax
+  \expandafter\ctxResetCatcode\expandafter\endinput
+\fi
+\let\OriginalStreamClose\StreamClose
+\def\ctxStreamClose#1{%
+  \OriginalStreamClose{#1}%
+  \ctxConvFile{#1}%
+}
+\def\ctxConvFile#1{%
+  \ifcsname zhconv@\csstring#1\endcsname
+    \ctxConv{\lastnamedcs}%
+            {\begincsname pth@\csstring#1\endcsname}%
+  \fi
+}
+\def\ctxLuaFunc{%
+  \directlua{
+    local zhconv = require("ctex-zhconv").conv
+    local scan_arg = token.scan_argument
+    local t = lua.get_functions_table()
+    local id = 233
+    while t[id] do id = id + 1 end
+    t[id] = function ()
+      local enc  = scan_arg()
+      local file = scan_arg()
+      return zhconv(enc, file, file)
+    end
+    token.set_lua("ctxConv", id, "global", "protected")
+  }%
+  \global\let\ctxLuaFunc\relax
+}
+\def\convfile{%
+  \ifx\@file\file
+    \expandafter\ctxfile\else
+    \expandafter\setconvfile\fi
+}
+\def\setconvfile#1#2{%
+  \ctxLuaFunc
+  \Name\def{zhconv@#2}{#1}%
+  \let\StreamClose\ctxStreamClose
+}
+\def\ctxfile#1#2{%
+  \setconvfile{#1}{#2}%
+  \file{#2}%
+}
+\ctxResetCatcode
 %%
-%% End of file `ctxdocstrip.tex'.
+%%
+%% End of file ctxdocstrip.tex

Modified: trunk/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `zhmap,adobe')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -76,36 +74,29 @@
 \fi
 \endgroup
 \ProvidesFile{zhadobefonts.tex}%
-  [2019/05/29 v2.4.16 Adobe font map loader for DVIPDFMx (CTEX)]
-
+  [2020/05/02 v2.5.1 Adobe font map loader for DVIPDFMx (CTEX)]
 \ifzhmappdf
 %% pdfTeX does not support OTF fonts
-
 \else
-  \special{pdf:mapline gbk at UGBK@     UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline gbksong at UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline gbkkai at UGBK@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
-  \special{pdf:mapline gbkhei at UGBK@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
-  \special{pdf:mapline gbkfs at UGBK@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
-
-  \special{pdf:mapline cyberb at Unicode@  UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline unisong at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf}
-  \special{pdf:mapline unikai at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
-  \special{pdf:mapline unihei at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
-  \special{pdf:mapline unifs at Unicode@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
-
-  \special{pdf:mapline gbksongsl at UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
-
-  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167}
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
+  \special{pdf:mapline gbkhei at UGBK@       UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
+  \special{pdf:mapline gbkfs at UGBK@        UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H AdobeSongStd-Light.otf}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H AdobeKaitiStd-Regular.otf}
+  \special{pdf:mapline unihei at Unicode@    UniGB-UTF16-H AdobeHeitiStd-Regular.otf}
+  \special{pdf:mapline unifs at Unicode@     UniGB-UTF16-H AdobeFangsongStd-Regular.otf}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H AdobeSongStd-Light.otf       -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H AdobeKaitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     UniGB-UTF16-H AdobeHeitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf       -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H AdobeKaitiStd-Regular.otf    -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H AdobeHeitiStd-Regular.otf    -s .167}
   \special{pdf:mapline unifssl at Unicode@   UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167}
-
 \fi
-
 \ctex at zhmap@endinput
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `zhmap,fandol')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -76,36 +74,29 @@
 \fi
 \endgroup
 \ProvidesFile{zhfandolfonts.tex}%
-  [2019/05/29 v2.4.16 Fandol font map loader for DVIPDFMx (CTEX)]
-
+  [2020/05/02 v2.5.1 Fandol font map loader for DVIPDFMx (CTEX)]
 \ifzhmappdf
 %% pdfTeX does not support OTF fonts
-
 \else
-  \special{pdf:mapline gbk at UGBK@     UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline gbksong at UGBK@ UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline gbkkai at UGBK@  UniGB-UTF16-H FandolKai-Regular.otf}
-  \special{pdf:mapline gbkhei at UGBK@  UniGB-UTF16-H FandolHei-Regular.otf}
-  \special{pdf:mapline gbkfs at UGBK@   UniGB-UTF16-H FandolFang-Regular.otf}
-
-  \special{pdf:mapline cyberb at Unicode@  UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline unisong at Unicode@ UniGB-UTF16-H FandolSong-Regular.otf}
-  \special{pdf:mapline unikai at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf}
-  \special{pdf:mapline unihei at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf}
-  \special{pdf:mapline unifs at Unicode@   UniGB-UTF16-H FandolFang-Regular.otf}
-
-  \special{pdf:mapline gbksongsl at UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  UniGB-UTF16-H FandolKai-Regular.otf -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  UniGB-UTF16-H FandolHei-Regular.otf -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   UniGB-UTF16-H FandolFang-Regular.otf -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H FandolKai-Regular.otf}
+  \special{pdf:mapline gbkhei at UGBK@       UniGB-UTF16-H FandolHei-Regular.otf}
+  \special{pdf:mapline gbkfs at UGBK@        UniGB-UTF16-H FandolFang-Regular.otf}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H FandolSong-Regular.otf}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H FandolKai-Regular.otf}
+  \special{pdf:mapline unihei at Unicode@    UniGB-UTF16-H FandolHei-Regular.otf}
+  \special{pdf:mapline unifs at Unicode@     UniGB-UTF16-H FandolFang-Regular.otf}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H FandolSong-Regular.otf -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H FandolKai-Regular.otf  -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     UniGB-UTF16-H FandolHei-Regular.otf  -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      UniGB-UTF16-H FandolFang-Regular.otf -s .167}
   \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H FandolSong-Regular.otf -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H FandolKai-Regular.otf  -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  UniGB-UTF16-H FandolHei-Regular.otf  -s .167}
   \special{pdf:mapline unifssl at Unicode@   UniGB-UTF16-H FandolFang-Regular.otf -s .167}
-
 \fi
-
 \ctex at zhmap@endinput
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `zhmap,founder')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -76,32 +74,28 @@
 \fi
 \endgroup
 \ProvidesFile{zhfounderfonts.tex}%
-  [2019/05/29 v2.4.16 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
+  [2020/05/02 v2.5.1 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
 \ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <FZSSK.TTF}
-  \pdfmapline{=gbksong at UGBK@ <FZSSK.TTF}
-  \pdfmapline{=gbkkai at UGBK@  <FZKTK.TTF}
-  \pdfmapline{=gbkhei at UGBK@  <FZHTK.TTF}
-  \pdfmapline{=gbkfs at UGBK@   <FZFSK.TTF}
-  \pdfmapline{=gbkli at UGBK@   <FZLSK.TTF}
-  \pdfmapline{=gbkyou at UGBK@  <FZY1K.TTF}
-
-  \pdfmapline{=cyberb at Unicode@  <FZSSK.TTF}
-  \pdfmapline{=unisong at Unicode@ <FZSSK.TTF}
-  \pdfmapline{=unikai at Unicode@  <FZKTK.TTF}
-  \pdfmapline{=unihei at Unicode@  <FZHTK.TTF}
-  \pdfmapline{=unifs at Unicode@   <FZFSK.TTF}
-  \pdfmapline{=unili at Unicode@   <FZLSK.TTF}
-  \pdfmapline{=uniyou at Unicode@  <FZY1K.TTF}
-
-  \pdfmapline{=gbksongsl at UGBK@ <FZSSK.TTF}
-  \pdfmapline{=gbkkaisl at UGBK@  <FZKTK.TTF}
-  \pdfmapline{=gbkheisl at UGBK@  <FZHTK.TTF}
-  \pdfmapline{=gbkfssl at UGBK@   <FZFSK.TTF}
-  \pdfmapline{=gbklisl at UGBK@   <FZLSK.TTF}
-  \pdfmapline{=gbkyousl at UGBK@  <FZY1K.TTF}
-
+  \pdfmapline{=gbk at UGBK@          <FZSSK.TTF}
+  \pdfmapline{=gbksong at UGBK@      <FZSSK.TTF}
+  \pdfmapline{=gbkkai at UGBK@       <FZKTK.TTF}
+  \pdfmapline{=gbkhei at UGBK@       <FZHTK.TTF}
+  \pdfmapline{=gbkfs at UGBK@        <FZFSK.TTF}
+  \pdfmapline{=gbkli at UGBK@        <FZLSK.TTF}
+  \pdfmapline{=gbkyou at UGBK@       <FZY1K.TTF}
+  \pdfmapline{=cyberb at Unicode@    <FZSSK.TTF}
+  \pdfmapline{=unisong at Unicode@   <FZSSK.TTF}
+  \pdfmapline{=unikai at Unicode@    <FZKTK.TTF}
+  \pdfmapline{=unihei at Unicode@    <FZHTK.TTF}
+  \pdfmapline{=unifs at Unicode@     <FZFSK.TTF}
+  \pdfmapline{=unili at Unicode@     <FZLSK.TTF}
+  \pdfmapline{=uniyou at Unicode@    <FZY1K.TTF}
+  \pdfmapline{=gbksongsl at UGBK@    <FZSSK.TTF}
+  \pdfmapline{=gbkkaisl at UGBK@     <FZKTK.TTF}
+  \pdfmapline{=gbkheisl at UGBK@     <FZHTK.TTF}
+  \pdfmapline{=gbkfssl at UGBK@      <FZFSK.TTF}
+  \pdfmapline{=gbklisl at UGBK@      <FZLSK.TTF}
+  \pdfmapline{=gbkyousl at UGBK@     <FZY1K.TTF}
   \pdfmapline{=unisongsl at Unicode@ <FZSSK.TTF}
   \pdfmapline{=unikaisl at Unicode@  <FZKTK.TTF}
   \pdfmapline{=uniheisl at Unicode@  <FZHTK.TTF}
@@ -108,31 +102,27 @@
   \pdfmapline{=unifssl at Unicode@   <FZFSK.TTF}
   \pdfmapline{=unilisl at Unicode@   <FZLSK.TTF}
   \pdfmapline{=uniyousl at Unicode@  <FZY1K.TTF}
-
 \else
-  \special{pdf:mapline gbk at UGBK@     unicode FZSSK.TTF}
-  \special{pdf:mapline gbksong at UGBK@ unicode FZSSK.TTF}
-  \special{pdf:mapline gbkkai at UGBK@  unicode FZKTK.TTF}
-  \special{pdf:mapline gbkhei at UGBK@  unicode FZHTK.TTF}
-  \special{pdf:mapline gbkfs at UGBK@   unicode FZFSK.TTF}
-  \special{pdf:mapline gbkli at UGBK@   unicode FZLSK.TTF}
-  \special{pdf:mapline gbkyou at UGBK@  unicode FZY1K.TTF}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode FZSSK.TTF}
-  \special{pdf:mapline unisong at Unicode@ unicode FZSSK.TTF}
-  \special{pdf:mapline unikai at Unicode@  unicode FZKTK.TTF}
-  \special{pdf:mapline unihei at Unicode@  unicode FZHTK.TTF}
-  \special{pdf:mapline unifs at Unicode@   unicode FZFSK.TTF}
-  \special{pdf:mapline unili at Unicode@   unicode FZLSK.TTF}
-  \special{pdf:mapline uniyou at Unicode@  unicode FZY1K.TTF}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode FZSSK.TTF -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode FZKTK.TTF -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode FZHTK.TTF -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode FZFSK.TTF -s .167}
-  \special{pdf:mapline gbklisl at UGBK@   unicode FZLSK.TTF -s .167}
-  \special{pdf:mapline gbkyousl at UGBK@  unicode FZY1K.TTF -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          unicode FZSSK.TTF}
+  \special{pdf:mapline gbksong at UGBK@      unicode FZSSK.TTF}
+  \special{pdf:mapline gbkkai at UGBK@       unicode FZKTK.TTF}
+  \special{pdf:mapline gbkhei at UGBK@       unicode FZHTK.TTF}
+  \special{pdf:mapline gbkfs at UGBK@        unicode FZFSK.TTF}
+  \special{pdf:mapline gbkli at UGBK@        unicode FZLSK.TTF}
+  \special{pdf:mapline gbkyou at UGBK@       unicode FZY1K.TTF}
+  \special{pdf:mapline cyberb at Unicode@    unicode FZSSK.TTF}
+  \special{pdf:mapline unisong at Unicode@   unicode FZSSK.TTF}
+  \special{pdf:mapline unikai at Unicode@    unicode FZKTK.TTF}
+  \special{pdf:mapline unihei at Unicode@    unicode FZHTK.TTF}
+  \special{pdf:mapline unifs at Unicode@     unicode FZFSK.TTF}
+  \special{pdf:mapline unili at Unicode@     unicode FZLSK.TTF}
+  \special{pdf:mapline uniyou at Unicode@    unicode FZY1K.TTF}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode FZSSK.TTF -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode FZKTK.TTF -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode FZHTK.TTF -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode FZFSK.TTF -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      unicode FZLSK.TTF -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     unicode FZY1K.TTF -s .167}
   \special{pdf:mapline unisongsl at Unicode@ unicode FZSSK.TTF -s .167}
   \special{pdf:mapline unikaisl at Unicode@  unicode FZKTK.TTF -s .167}
   \special{pdf:mapline uniheisl at Unicode@  unicode FZHTK.TTF -s .167}
@@ -139,9 +129,7 @@
   \special{pdf:mapline unifssl at Unicode@   unicode FZFSK.TTF -s .167}
   \special{pdf:mapline unilisl at Unicode@   unicode FZLSK.TTF -s .167}
   \special{pdf:mapline uniyousl at Unicode@  unicode FZY1K.TTF -s .167}
-
 \fi
-
 \ctex at zhmap@endinput
 %% 
 %%

Added: trunk/Master/texmf-dist/tex/generic/ctex/zhmacfonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhmacfonts.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhmacfonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -0,0 +1,111 @@
+%%
+%% This is file `zhmacfonts.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ctex.dtx  (with options: `zhmap,mac')
+%% 
+%%     Copyright (C) 2003--2020
+%%     CTEX.ORG and any individual authors listed in the documentation.
+%% ---------------------------------------------------------------------
+%% 
+%%     This work may be distributed and/or modified under the
+%%     conditions of the LaTeX Project Public License, either
+%%     version 1.3c of this license or (at your option) any later
+%%     version. This version of this license is in
+%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
+%%     and the latest version of this license is in
+%%        http://www.latex-project.org/lppl.txt
+%%     and version 1.3 or later is part of all distributions of
+%%     LaTeX version 2005/12/01 or later.
+%% 
+%%     This work has the LPPL maintenance status "maintained".
+%% 
+%% ---------------------------------------------------------------------
+%% 
+\begingroup\catcode61\catcode48\catcode32=10\relax%
+  \catcode 35=6 % #
+  \catcode123=1 % {
+  \catcode125=2 % }
+  \toks0{\endlinechar=\the\endlinechar\relax}%
+  \toks2{\endlinechar=-1 }%
+  \def\x#1 #2 {%
+    \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
+    \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
+  \x  13  5 % carriage return
+  \x  32 10 % space
+  \x  35  6 % #
+  \x  40 12 % (
+  \x  41 12 % )
+  \x  45 12 % -
+  \x  46 12 % .
+  \x  47 12 % /
+  \x  58 12 % :
+  \x  60 12 % <
+  \x  61 12 % =
+  \x  64 11 % @
+  \x  91 12 % [
+  \x  93 12 % ]
+  \x 123  1 % {
+  \x 125  2 % }
+  \edef\x#1{\endgroup%
+    \edef\noexpand#1{%
+      \the\toks0 %
+      \let\noexpand\noexpand\noexpand#1%
+          \noexpand\noexpand\noexpand\undefined%
+      \noexpand\noexpand\noexpand\endinput}%
+    \the\toks2}%
+\expandafter\x\csname ctex at zhmap@endinput\endcsname
+\begingroup\expandafter\endgroup
+\expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname
+  \expandafter\ifx\csname ifctexpdf\endcsname\relax
+    \expandafter\ifx\csname pdfoutput\endcsname\relax
+      iffalse\else\ifnum\pdfoutput < 1 iffalse\else iftrue\fi\fi
+  \else ifctexpdf\fi
+\endcsname
+\begingroup
+\expandafter\ifx\csname ProvidesFile\endcsname\relax
+  \long\def\x#1\ProvidesFile#2[#3]{%
+    #1%
+    \immediate\write-1{File: #2 #3}%
+    \expandafter\xdef\csname ver@#2\endcsname{#3}}
+  \expandafter\x%
+\fi
+\endgroup
+\ProvidesFile{zhmacfonts.tex}%
+  [2020/05/02 v2.5.1 Mac font map loader for pdfTeX and DVIPDFMx (CTEX)]
+\ifzhmappdf
+%% pdfTeX does not support OTF fonts
+\else
+  \special{pdf:mapline gbk at UGBK@          UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline gbksong at UGBK@      UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline gbkkai at UGBK@       UniGB-UTF16-H :0:Kaiti.ttc}
+  \special{pdf:mapline gbkhei at UGBK@       unicode       :2:PingFang.ttc}
+  \special{pdf:mapline gbkfs at UGBK@        unicode       STFANGSO.ttf}
+  \special{pdf:mapline gbkli at UGBK@        UniGB-UTF16-H :0:Baoli.ttc}
+  \special{pdf:mapline gbkyou at UGBK@       UniGB-UTF16-H :4:Yuanti.ttc}
+  \special{pdf:mapline cyberb at Unicode@    UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline unisong at Unicode@   UniGB-UTF16-H :3:Songti.ttc}
+  \special{pdf:mapline unikai at Unicode@    UniGB-UTF16-H :0:Kaiti.ttc}
+  \special{pdf:mapline unihei at Unicode@    unicode       :2:PingFang.ttc}
+  \special{pdf:mapline unifs at Unicode@     unicode       STFANGSO.ttf}
+  \special{pdf:mapline unili at Unicode@     UniGB-UTF16-H :0:Baoli.ttc}
+  \special{pdf:mapline uniyou at Unicode@    UniGB-UTF16-H :4:Yuanti.ttc}
+  \special{pdf:mapline gbksongsl at UGBK@    UniGB-UTF16-H :3:Songti.ttc   -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     UniGB-UTF16-H :0:Kaiti.ttc    -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode       :2:PingFang.ttc -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode       STFANGSO.ttf    -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      UniGB-UTF16-H :0:Baoli.ttc    -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     UniGB-UTF16-H :4:Yuanti.ttc   -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ UniGB-UTF16-H :3:Songti.ttc   -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  UniGB-UTF16-H :0:Kaiti.ttc    -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode       :2:PingFang.ttc -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode       STFANGSO.ttf    -s .167}
+  \special{pdf:mapline unilisl at Unicode@   UniGB-UTF16-H :0:Baoli.ttc    -s .167}
+  \special{pdf:mapline uniyousl at Unicode@  UniGB-UTF16-H :4:Yuanti.ttc   -s .167}
+\fi
+\ctex at zhmap@endinput
+%% 
+%%
+%% End of file `zhmacfonts.tex'.


Property changes on: trunk/Master/texmf-dist/tex/generic/ctex/zhmacfonts.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `zhmap,ubuntu')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -76,60 +74,29 @@
 \fi
 \endgroup
 \ProvidesFile{zhubuntufonts.tex}%
-  [2019/05/29 v2.4.16 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
+  [2020/05/02 v2.5.1 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
 \ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <uming.ttc}
-  \pdfmapline{=gbksong at UGBK@ <uming.ttc}
-  \pdfmapline{=gbkkai at UGBK@  <ukai.ttc}
-  \pdfmapline{=gbkhei at UGBK@  <wqy-zenhei.ttc}
-  \pdfmapline{=gbkfs at UGBK@   <uming.ttc}
-  \pdfmapline{=gbkyou at UGBK@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=cyberb at Unicode@  <uming.ttc}
-  \pdfmapline{=unisong at Unicode@ <uming.ttc}
-  \pdfmapline{=unikai at Unicode@  <ukai.ttc}
-  \pdfmapline{=unihei at Unicode@  <wqy-zenhei.ttc}
-  \pdfmapline{=unifs at Unicode@   <uming.ttc}
-  \pdfmapline{=uniyou at Unicode@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=gbksongsl at UGBK@ <uming.ttc}
-  \pdfmapline{=gbkkaisl at UGBK@  <ukai.ttc}
-  \pdfmapline{=gbkheisl at UGBK@  <wqy-zenhei.ttc}
-  \pdfmapline{=gbkfssl at UGBK@   <uming.ttc}
-  \pdfmapline{=gbkyousl at UGBK@  <wqy-zenhei.ttc}
-
-  \pdfmapline{=unisongsl at Unicode@ <uming.ttc}
-  \pdfmapline{=unikaisl at Unicode@  <ukai.ttc}
-  \pdfmapline{=uniheisl at Unicode@  <wqy-zenhei.ttc}
-  \pdfmapline{=unifssl at Unicode@   <uming.ttc}
-  \pdfmapline{=uniyousl at Unicode@  <wqy-zenhei.ttc}
-
+%% pdfTeX does not support OTF fonts
 \else
-  \special{pdf:mapline gbk at UGBK@     unicode :0:uming.ttc}
-  \special{pdf:mapline gbksong at UGBK@ unicode :0:uming.ttc}
-  \special{pdf:mapline gbkkai at UGBK@  unicode :0:ukai.ttc}
-  \special{pdf:mapline gbkhei at UGBK@  unicode :0:wqy-zenhei.ttc}
-  \special{pdf:mapline gbkfs at UGBK@   unicode :0:uming.ttc}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode :0:uming.ttc}
-  \special{pdf:mapline unisong at Unicode@ unicode :0:uming.ttc}
-  \special{pdf:mapline unikai at Unicode@  unicode :0:ukai.ttc}
-  \special{pdf:mapline unihei at Unicode@  unicode :0:wqy-zenhei.ttc}
-  \special{pdf:mapline unifs at Unicode@   unicode :0:uming.ttc}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode :0:uming.ttc -s .167}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode :0:ukai.ttc -s .167}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode :0:wqy-zenhei.ttc -s .167}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode :0:uming.ttc -s .167}
-
-  \special{pdf:mapline unisongsl at Unicode@ unicode :0:uming.ttc -s .167}
-  \special{pdf:mapline unikaisl at Unicode@  unicode :0:ukai.ttc -s .167}
-  \special{pdf:mapline uniheisl at Unicode@  unicode :0:wqy-zenhei.ttc -s .167}
-  \special{pdf:mapline unifssl at Unicode@   unicode :0:uming.ttc -s .167}
-
+  \special{pdf:mapline gbk at UGBK@          unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbksong at UGBK@      unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbkkai at UGBK@       unicode gkai00mp.ttf}
+  \special{pdf:mapline gbkhei at UGBK@       unicode :2:NotoSansCJK-Regular.ttc}
+  \special{pdf:mapline gbkfs at UGBK@        unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline cyberb at Unicode@    unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline unisong at Unicode@   unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline unikai at Unicode@    unicode gkai00mp.ttf}
+  \special{pdf:mapline unihei at Unicode@    unicode :2:NotoSansCJK-Regular.ttc}
+  \special{pdf:mapline unifs at Unicode@     unicode :2:NotoSerifCJK-Regular.ttc}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode gkai00mp.ttf                -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode :2:NotoSansCJK-Regular.ttc  -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  unicode gkai00mp.ttf                -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode :2:NotoSansCJK-Regular.ttc  -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode :2:NotoSerifCJK-Regular.ttc -s .167}
 \fi
-
 \ctex at zhmap@endinput
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `zhmap,windows')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \begingroup\catcode61\catcode48\catcode32=10\relax%
   \catcode 35=6 % #
   \catcode123=1 % {
   \catcode125=2 % }
   \toks0{\endlinechar=\the\endlinechar\relax}%
-  \toks2{\endlinechar=13 }%
+  \toks2{\endlinechar=-1 }%
   \def\x#1 #2 {%
     \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}%
     \toks2\expandafter{\the\toks2 \catcode#1=#2 }}%
@@ -76,32 +74,28 @@
 \fi
 \endgroup
 \ProvidesFile{zhwindowsfonts.tex}%
-  [2019/05/29 v2.4.16 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
-
+  [2020/05/02 v2.5.1 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
 \ifzhmappdf
-  \pdfmapline{=gbk at UGBK@     <simsun.ttc}
-  \pdfmapline{=gbksong at UGBK@ <simsun.ttc}
-  \pdfmapline{=gbkkai at UGBK@  <simkai.ttf}
-  \pdfmapline{=gbkhei at UGBK@  <simhei.ttf}
-  \pdfmapline{=gbkfs at UGBK@   <simfang.ttf}
-  \pdfmapline{=gbkli at UGBK@   <simli.ttf}
-  \pdfmapline{=gbkyou at UGBK@  <simyou.ttf}
-
-  \pdfmapline{=cyberb at Unicode@  <simsun.ttc}
-  \pdfmapline{=unisong at Unicode@ <simsun.ttc}
-  \pdfmapline{=unikai at Unicode@  <simkai.ttf}
-  \pdfmapline{=unihei at Unicode@  <simhei.ttf}
-  \pdfmapline{=unifs at Unicode@   <simfang.ttf}
-  \pdfmapline{=unili at Unicode@   <simli.ttf}
-  \pdfmapline{=uniyou at Unicode@  <simyou.ttf}
-
-  \pdfmapline{=gbksongsl at UGBK@ <simsun.ttc}
-  \pdfmapline{=gbkkaisl at UGBK@  <simkai.ttf}
-  \pdfmapline{=gbkheisl at UGBK@  <simhei.ttf}
-  \pdfmapline{=gbkfssl at UGBK@   <simfang.ttf}
-  \pdfmapline{=gbklisl at UGBK@   <simli.ttf}
-  \pdfmapline{=gbkyousl at UGBK@  <simyou.ttf}
-
+  \pdfmapline{=gbk at UGBK@          <simsun.ttc}
+  \pdfmapline{=gbksong at UGBK@      <simsun.ttc}
+  \pdfmapline{=gbkkai at UGBK@       <simkai.ttf}
+  \pdfmapline{=gbkhei at UGBK@       <simhei.ttf}
+  \pdfmapline{=gbkfs at UGBK@        <simfang.ttf}
+  \pdfmapline{=gbkli at UGBK@        <simli.ttf}
+  \pdfmapline{=gbkyou at UGBK@       <simyou.ttf}
+  \pdfmapline{=cyberb at Unicode@    <simsun.ttc}
+  \pdfmapline{=unisong at Unicode@   <simsun.ttc}
+  \pdfmapline{=unikai at Unicode@    <simkai.ttf}
+  \pdfmapline{=unihei at Unicode@    <simhei.ttf}
+  \pdfmapline{=unifs at Unicode@     <simfang.ttf}
+  \pdfmapline{=unili at Unicode@     <simli.ttf}
+  \pdfmapline{=uniyou at Unicode@    <simyou.ttf}
+  \pdfmapline{=gbksongsl at UGBK@    <simsun.ttc}
+  \pdfmapline{=gbkkaisl at UGBK@     <simkai.ttf}
+  \pdfmapline{=gbkheisl at UGBK@     <simhei.ttf}
+  \pdfmapline{=gbkfssl at UGBK@      <simfang.ttf}
+  \pdfmapline{=gbklisl at UGBK@      <simli.ttf}
+  \pdfmapline{=gbkyousl at UGBK@     <simyou.ttf}
   \pdfmapline{=unisongsl at Unicode@ <simsun.ttc}
   \pdfmapline{=unikaisl at Unicode@  <simkai.ttf}
   \pdfmapline{=uniheisl at Unicode@  <simhei.ttf}
@@ -108,40 +102,34 @@
   \pdfmapline{=unifssl at Unicode@   <simfang.ttf}
   \pdfmapline{=unilisl at Unicode@   <simli.ttf}
   \pdfmapline{=uniyousl at Unicode@  <simyou.ttf}
-
 \else
-  \special{pdf:mapline gbk at UGBK@     unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline gbksong at UGBK@ unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline gbkkai at UGBK@  unicode simkai.ttf -v 70}
-  \special{pdf:mapline gbkhei at UGBK@  unicode simhei.ttf -v 150}
-  \special{pdf:mapline gbkfs at UGBK@   unicode simfang.ttf -v 50}
-  \special{pdf:mapline gbkli at UGBK@   unicode simli.ttf -v 150}
-  \special{pdf:mapline gbkyou at UGBK@  unicode simyou.ttf -v 60}
-
-  \special{pdf:mapline cyberb at Unicode@  unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline unisong at Unicode@ unicode :0:simsun.ttc -v 50}
-  \special{pdf:mapline unikai at Unicode@  unicode simkai.ttf -v 70}
-  \special{pdf:mapline unihei at Unicode@  unicode simhei.ttf -v 150}
-  \special{pdf:mapline unifs at Unicode@   unicode simfang.ttf -v 50}
-  \special{pdf:mapline unili at Unicode@   unicode simli.ttf -v 150}
-  \special{pdf:mapline uniyou at Unicode@  unicode simyou.ttf -v 60}
-
-  \special{pdf:mapline gbksongsl at UGBK@ unicode :0:simsun.ttc -s .167 -v 50}
-  \special{pdf:mapline gbkkaisl at UGBK@  unicode simkai.ttf -s .167 -v 70}
-  \special{pdf:mapline gbkheisl at UGBK@  unicode simhei.ttf -s .167 -v 150}
-  \special{pdf:mapline gbkfssl at UGBK@   unicode simfang.ttf -s .167 -v 50}
-  \special{pdf:mapline gbklisl at UGBK@   unicode simli.ttf -s .167 -v 150}
-  \special{pdf:mapline gbkyousl at UGBK@  unicode simyou.ttf -s .167 -v 60}
-
-  \special{pdf:mapline unisongsl at Unicode@ unicode :0:simsun.ttc -s .167 -v 50}
-  \special{pdf:mapline unikaisl at Unicode@  unicode simkai.ttf -s .167 -v 70}
-  \special{pdf:mapline uniheisl at Unicode@  unicode simhei.ttf -s .167 -v 150}
-  \special{pdf:mapline unifssl at Unicode@   unicode simfang.ttf -s .167 -v 50}
-  \special{pdf:mapline unilisl at Unicode@   unicode simli.ttf -s .167 -v 150}
-  \special{pdf:mapline uniyousl at Unicode@  unicode simyou.ttf -s .167 -v 60}
-
+  \special{pdf:mapline gbk at UGBK@          unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline gbksong at UGBK@      unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline gbkkai at UGBK@       unicode simkai.ttf    -v 70}
+  \special{pdf:mapline gbkhei at UGBK@       unicode simhei.ttf    -v 150}
+  \special{pdf:mapline gbkfs at UGBK@        unicode simfang.ttf   -v 50}
+  \special{pdf:mapline gbkli at UGBK@        unicode simli.ttf     -v 150}
+  \special{pdf:mapline gbkyou at UGBK@       unicode simyou.ttf    -v 60}
+  \special{pdf:mapline cyberb at Unicode@    unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline unisong at Unicode@   unicode :0:simsun.ttc -v 50}
+  \special{pdf:mapline unikai at Unicode@    unicode simkai.ttf    -v 70}
+  \special{pdf:mapline unihei at Unicode@    unicode simhei.ttf    -v 150}
+  \special{pdf:mapline unifs at Unicode@     unicode simfang.ttf   -v 50}
+  \special{pdf:mapline unili at Unicode@     unicode simli.ttf     -v 150}
+  \special{pdf:mapline uniyou at Unicode@    unicode simyou.ttf    -v 60}
+  \special{pdf:mapline gbksongsl at UGBK@    unicode :0:simsun.ttc -v 50  -s .167}
+  \special{pdf:mapline gbkkaisl at UGBK@     unicode simkai.ttf    -v 70  -s .167}
+  \special{pdf:mapline gbkheisl at UGBK@     unicode simhei.ttf    -v 150 -s .167}
+  \special{pdf:mapline gbkfssl at UGBK@      unicode simfang.ttf   -v 50  -s .167}
+  \special{pdf:mapline gbklisl at UGBK@      unicode simli.ttf     -v 150 -s .167}
+  \special{pdf:mapline gbkyousl at UGBK@     unicode simyou.ttf    -v 60  -s .167}
+  \special{pdf:mapline unisongsl at Unicode@ unicode :0:simsun.ttc -v 50  -s .167}
+  \special{pdf:mapline unikaisl at Unicode@  unicode simkai.ttf    -v 70  -s .167}
+  \special{pdf:mapline uniheisl at Unicode@  unicode simhei.ttf    -v 150 -s .167}
+  \special{pdf:mapline unifssl at Unicode@   unicode simfang.ttf   -v 50  -s .167}
+  \special{pdf:mapline unilisl at Unicode@   unicode simli.ttf     -v 150 -s .167}
+  \special{pdf:mapline uniyousl at Unicode@  unicode simyou.ttf    -v 60  -s .167}
 \fi
-
 \ctex at zhmap@endinput
 %% 
 %%

Modified: trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `name,GBK')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,16 +20,14 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Caption with encoding GBK (CTEX)}
 \ProvidesExplFile{ctex-name-gbk.cfg}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \keys_set_known:nn { ctex }
   {
     contentsname   = Ŀ¼ ,

Modified: trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `name,UTF8')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,16 +20,14 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-  {Caption with encoding UTF8 (CTEX)}
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
+  {Caption with encoding UTF-8 (CTEX)}
 \ProvidesExplFile{ctex-name-utf8.cfg}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \keys_set_known:nn { ctex }
   {
     contentsname   = 目录 ,

Modified: trunk/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `config')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,16 +20,14 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Configuration file (CTEX)}
 \ProvidesExplFile{\ExplFileName.cfg}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 %%
 %% 
 %%

Added: trunk/Master/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg	2020-05-02 22:24:14 UTC (rev 54976)
@@ -0,0 +1,51 @@
+%%
+%% This is file `ctexbackend.cfg',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% ctex.dtx  (with options: `backend')
+%% 
+%%     Copyright (C) 2003--2020
+%%     CTEX.ORG and any individual authors listed in the documentation.
+%% ---------------------------------------------------------------------
+%% 
+%%     This work may be distributed and/or modified under the
+%%     conditions of the LaTeX Project Public License, either
+%%     version 1.3c of this license or (at your option) any later
+%%     version. This version of this license is in
+%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
+%%     and the latest version of this license is in
+%%        http://www.latex-project.org/lppl.txt
+%%     and version 1.3 or later is part of all distributions of
+%%     LaTeX version 2005/12/01 or later.
+%% 
+%%     This work has the LPPL maintenance status "maintained".
+%% 
+%% ---------------------------------------------------------------------
+%% 
+\ProvidesFile{ctexbackend.cfg}%
+  [2020/05/02 v2.5.1 Backend configuration file (CTEX)]
+\begingroup
+\expandafter\ifx\csname Umathchardef\endcsname\relax
+\else\expandafter\endgroup\expandafter\endinput\fi
+  \ifodd
+    \expandafter\ifx\csname      pdfoutput\endcsname\relax
+    \expandafter\ifx\csname enablecjktoken\endcsname\relax 0\else 1\fi
+                                   \else\ifnum\pdfoutput>0 0\else 1\fi\fi\space
+    \def\x#1{%
+      \if\relax\detokenize{#1}\relax
+        \gdef\@classoptionslist{dvipdfmx}%
+      \else
+        \let\CTEX at add\@ne
+        \@tfor\x:={dvips}{dvipdfmx}{dvisvgm}\do{%
+          \expandafter\in@\expandafter{\expandafter,\x,}{,#1,}%
+          \ifin@ \let\CTEX at add\tw@ \@break at tfor \fi}%
+        \ifodd\CTEX at add \gdef\@classoptionslist{dvipdfmx,#1}\fi
+      \fi}
+    \expandafter\x\expandafter{\@classoptionslist}
+  \fi
+\endgroup
+%% 
+%%
+%% End of file `ctexbackend.cfg'.


Property changes on: trunk/Master/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `ctexopts')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Option configuration file (CTEX)}
 \ProvidesExplFile{ctexopts.cfg}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 %%
-%% \keys_set:nn { ctex / option } { fontset = windowsnew }
+%% \ctex_set:nn { option } { fontset = windows }
 %% 
 %%
 %% End of file `ctexopts.cfg'.

Deleted: trunk/Master/texmf-dist/tex/latex/ctex/ctex-article.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-article.def	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-article.def	2020-05-02 22:24:14 UTC (rev 54976)
@@ -1,671 +0,0 @@
-%%
-%% This is file `ctex-article.def',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% ctex.dtx  (with options: `heading,article')
-%% 
-%%     Copyright (C) 2003--2019
-%%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
-%% 
-%%     This work may be distributed and/or modified under the
-%%     conditions of the LaTeX Project Public License, either
-%%     version 1.3c of this license or (at your option) any later
-%%     version. This version of this license is in
-%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
-%%     and the latest version of this license is in
-%%        http://www.latex-project.org/lppl.txt
-%%     and version 1.3 or later is part of all distributions of
-%%     LaTeX version 2005/12/01 or later.
-%% 
-%%     This work has the LPPL maintenance status `maintained'.
-%% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-  {Heading modification for article (CTEX)}
-\ProvidesExplFile{ctex-article.def}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
-\seq_const_from_clist:Nn \c__ctex_section_headings_seq
-  { section , subsection , subsubsection , paragraph , subparagraph }
-\seq_new:N \c__ctex_headings_seq
-\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
-\seq_gput_left:Nn \c__ctex_headings_seq { part }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
-  {
-    \tl_new:c { CTEX at pre#1 }
-    \tl_new:c { CTEX at post#1 }
-    \tl_const:cx { CTEXthe#1 }
-      {
-        \exp_not:c { CTEX at pre#1 }
-        \exp_not:c { CTEX at the#1 }
-        \exp_not:c { CTEX at post#1 }
-      }
-    \tl_const:cx { CTEX@#1name }
-      {
-        \group_begin:
-          \exp_not:c { CTEX@#1 at nameformat }
-            {
-              \exp_not:c { CTEX at pre#1 }
-              \exp_not:N \tl_if_empty:NTF
-              \exp_not:c { CTEX@#1 at numberformat }
-                { \exp_not:c { CTEX at the#1 } }
-                {
-                  \group_begin:
-                    \exp_not:c { CTEX@#1 at numberformat }
-                    \exp_not:c { CTEX at the#1 }
-                  \group_end:
-                }
-              \exp_not:c { CTEX at post#1 }
-            }
-        \group_end:
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
-  {
-    \tl_put_right:Nx \l__ctex_tmp_tl
-      {
-        #1                  .meta:nn = { ctex / #1 } { ####1 } ,
-        #1 / name            .code:n =
-          { \ctex_assign_heading_name:nn {#1} { ####1 } } ,
-        #1 / number        .tl_set:N = \exp_not:c { CTEX at the#1 } ,
-        #1 / beforeskip    .tl_set:N = \exp_not:c { CTEX@#1 at beforeskip } ,
-        #1 / afterskip     .tl_set:N = \exp_not:c { CTEX@#1 at afterskip} ,
-        #1 / indent        .tl_set:N = \exp_not:c { CTEX@#1 at indent } ,
-        #1 / numbering   .bool_set:N = \exp_not:c { CTEX@#1 at numbering } ,
-        #1 / numbering    .initial:n = true ,
-        #1 / beforeskip   .initial:n = \c_zero_skip ,
-        #1 / afterskip    .initial:n = \c_zero_skip ,
-        #1 / indent       .initial:n = \c_zero_dim ,
-        #1 / beforeskip   .value_required:n = true ,
-        #1 / afterskip    .value_required:n = true ,
-        #1 / indent       .value_required:n = true ,
-        #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1 at afterindent } ,
-        #1 / fixskip     .bool_set:N = \exp_not:c { CTEX@#1 at fixskip } ,
-        #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
-        #1 / hang         .initial:n = true ,
-        #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
-        \__ctex_plus_key_aux:nn {#1} { break } ,
-        \__ctex_plus_key_aux:nn {#1} { format } ,
-        \__ctex_plus_key_aux:nn {#1} { nameformat } ,
-        \__ctex_plus_key_aux:nn {#1} { numberformat } ,
-        \__ctex_plus_key_aux:nn {#1} { titleformat } ,
-        \__ctex_plus_key_aux:nn {#1} { aftername } ,
-        \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
-      }
-  }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
-  {
-    #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
-    #1 / #2 +   .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } } ,
-    #1 / #2 ~ + .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } }
-  }
-\NewDocumentCommand \ctex_assign_heading_name:nn
-  { m > { \SplitArgument { 1 } { , } } +m }
-  { \__ctex_assign_heading_name:nnn {#1} #2 }
-\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
-  {
-    \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
-      { \tl_clear:c { CTEX at post#1 } }
-      { \tl_set:cn { CTEX at post#1 } {#3} }
-  }
-\group_begin:
-\tl_clear:N \l__ctex_tmp_tl
-\seq_map_inline:Nn \c__ctex_headings_seq
-  {
-    \__ctex_initial_heading:n {#1}
-    \__ctex_def_heading_keys:n {#1}
-  }
-\use:x
-  {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
-  {
-    \par
-    \dim_set:Nn \tex_prevdepth:D { -1000pt }
-    \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
-  }
-\skip_new:N \l__ctex_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
-  { \skip_set:Nn \l__ctex_heading_skip }
-\cs_new_eq:NN \CTEX at headingskip \l__ctex_heading_skip
-\ProvideDocumentCommand \partmark { m }
-  { \markboth { } { } }
-\cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
-  { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
-  { \cs_set_eq:NN \CTEXifname \use_ii:nn }
-\cs_new_protected:Npn \CTEX at addtocline #1#2
-  { \addcontentsline { toc } {#1} { \use:c { CTEX@#1 at tocline } {#1} {#2} } }
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l__ctex_autoindent_tl }
-\renewcommand\part{%
-   \if at noskipsec \leavevmode \fi
-   \par
-   \CTEX at part@break
-   \CTEX at setheadingskip \CTEX at part@beforeskip
-   \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-   \addvspace \CTEX at headingskip
-   \ifodd \CTEX at part@afterindent
-     \@afterindenttrue
-   \else
-     \@afterindentfalse
-   \fi
-   \secdef\@part\@spart}
-\def\@part[#1]#2{%
-  \ifnum \c at secnumdepth >\m at ne
-    \ifodd \CTEX at part@numbering
-      \CTEX at ifnametrue
-      \refstepcounter{part}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{part*}%
-    \fi
-  \else
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor{part*}%
-  \fi
-  \CTEX at gettitle{#1}%
-  \CTEX at addtocline{part}{#1}%
-  {\interlinepenalty \@M
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-   \CTEX at part@titleformat{#2}%
-   \partmark{#1}%
-   \CTEX at part@aftertitle}%
-  \nobreak
-  \CTEX at setheadingskip \CTEX at part@afterskip
-  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-  \vskip \CTEX at headingskip
-  \@afterheading}
-\def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-     \nobreak
-     \CTEX at setheadingskip \CTEX at part@afterskip
-     \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-     \vskip \CTEX at headingskip
-     \@afterheading}
-\def\@startsection#1#2#3#4#5#6{%
-  \if at noskipsec \leavevmode \fi
-  \par
-  \CTEX at update@sectionformat at n{#1}%
-  \ifodd \CTEX at afterindent
-    \@afterindenttrue
-  \else
-    \@afterindentfalse
-  \fi
-  \if at nobreak
-    \everypar{}%
-  \else
-    \csname CTEX@#1 at break\endcsname
-    \CTEX at setheadingskip{#4}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \addvspace \CTEX at headingskip
-  \fi
-  \@ifstar
-    {\CTEX at makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}%
-    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
-\def\@seccntformat#1{%
-  \csname CTEX@#1name\endcsname
-  \csname CTEX@#1 at aftername\endcsname}
-\def\@sect#1#2#3#4#5#6[#7]#8{%
-  \ifnum #2>\c at secnumdepth
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@sect{#1*}%
-    \let\@svsec\@empty
-  \else
-    \ifodd \csname CTEX@#1 at numbering\endcsname
-      \CTEX at ifnametrue
-      \refstepcounter{#1}%
-      \protected at edef\@svsec{\@seccntformat{#1}\relax}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{#1*}%
-      \let\@svsec\@empty
-    \fi
-  \fi
-  \CTEX at gettitle{#7}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-        \interlinepenalty \@M
-        \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
-    \endgroup
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}%
-  \else
-    \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}}%
-  \fi
-  \@xsect{#5}}
-\def\@ssect#1#2#3#4#5{%
-  \CTEX at ifnamefalse
-  \CTEX at gettitle{#5}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-          \interlinepenalty \@M
-          \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
-    \endgroup
-  \else
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
-  \fi
-  \@xsect{#3}}
-\def\@xsect#1{%
-  \unless \ifodd \CTEX at runin
-    \par \nobreak
-    \CTEX at setheadingskip{#1}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \vskip \CTEX at headingskip
-    \@afterheading
-  \else
-    \@nobreakfalse
-    \global\@noskipsectrue
-    \everypar{%
-      \if at noskipsec
-        \global\@noskipsecfalse
-       {\setbox\z@\lastbox}%
-        \clubpenalty\@M
-        \begingroup \@svsechd \endgroup
-        \unskip
-        \hskip\glueexpr #1\relax
-      \else
-        \clubpenalty \@clubpenalty
-        \everypar{}%
-      \fi}%
-  \fi
-  \ignorespaces}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
-  {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \__ctex_indent_aux: #2 } }
-      {#2}
-  }
-\cs_new_protected_nopar:Npn \__ctex_indent_aux:
-  {
-    \dim_compare:nNnF \parindent = \c_zero_dim
-      { \skip_horizontal:n { \parindent } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at hangfrom
-  {
-    \bool_if:NTF \CTEX at hang
-      { \@hangfrom }
-      { \noindent \use:n }
-  }
-\cs_new_protected_nopar:Npn \CTEX at update@sectionformat at n #1
-  {
-    \cs_set_eq:Nc \CTEX at titleformat@n { CTEX@#1 at titleformat }
-    \cs_set_eq:Nc \CTEX at aftertitle    { CTEX@#1 at aftertitle }
-    \cs_set_eq:Nc \CTEX at afterindent   { CTEX@#1 at afterindent }
-    \cs_set_eq:Nc \CTEX at fixskip       { CTEX@#1 at fixskip }
-    \cs_set_eq:Nc \CTEX at hang          { CTEX@#1 at hang }
-    \cs_set_eq:Nc \CTEX at runin         { CTEX@#1 at runin }
-  }
-\cs_new_eq:NN \CTEX at titleformat@n \use:n
-\cs_new_eq:NN \CTEX at aftertitle \prg_do_nothing:
-\cs_new_eq:NN \CTEX at afterindent \c_true_bool
-\cs_new_eq:NN \CTEX at fixskip \c_false_bool
-\cs_new_eq:NN \CTEX at hang \c_true_bool
-\cs_new_eq:NN \CTEX at runin \c_false_bool
-\cs_new:Npn \CTEX at part@tocline #1#2
-  {
-    \CTEXifname
-      { \CTEXthepart \hspace { 1em } }
-      { }
-    #2
-  }
-\cs_new_nopar:Npn \CTEXnumberline #1
-  {
-    \CTEXifname
-      { \protect \numberline { \use:c { CTEXthe #1 } } }
-      { }
-  }
-\int_zero:N \l__ctex_tmp_int
-\seq_map_inline:Nn \c__ctex_section_headings_seq
-  {
-    \int_incr:N \l__ctex_tmp_int
-    \cs_gset_protected_nopar:cpx  {#1}
-      {
-        \exp_not:N \@startsection {#1}
-          { \int_use:N \l__ctex_tmp_int }
-          { \exp_not:c { CTEX@#1 at indent } }
-          { \exp_not:c { CTEX@#1 at beforeskip } }
-          { \exp_not:c { CTEX@#1 at afterskip } }
-          { \exp_not:N \normalfont \exp_not:c { CTEX@#1 at format } }
-      }
-    \cs_new:cpn { CTEX@#1 at tocline } ##1##2
-      { \CTEXnumberline { ##1 } ##2 }
-  }
-\keys_define:nn { ctex }
-  {
-    appendix                .meta:nn = { ctex / appendix } {#1} ,
-    appendix / name          .code:n =
-      { \ctex_assign_heading_name:nn { appendix } {#1} } ,
-    appendix / number      .tl_set:N = \CTEX at appendix@number ,
-    appendix / numbering .bool_set:N = \CTEX at appendix@numbering ,
-    appendix / numbering  .initial:n = true
-  }
-\tl_new:N \CTEX at preappendix
-\tl_new:N \CTEX at postappendix
-\cs_new_eq:NN \CTEX at save@appendix \appendix
-\cs_gset_protected_nopar:Npn \appendix
-  {
-    \CTEX at save@appendix
-    \gdef \CTEX at presection { \CTEX at preappendix }
-    \gdef \CTEX at thesection { \CTEX at appendix@number }
-    \gdef \CTEX at postsection { \CTEX at postappendix }
-    \gdef \CTEX at section@numbering { \CTEX at appendix@numbering }
-  }
-\cs_new_protected_nopar:Npn \CTEX at makeanchor #1
-  { }
-\seq_const_from_clist:Nn \c__ctex_headings_cs_seq
-  { part , spart , sect , ssect }
-\seq_map_inline:Nn \c__ctex_headings_cs_seq
-  {
-    \cs_new_eq:cc { CTEX@ #1 } { @ #1 }
-    \cs_new_eq:cN { CTEX at makeanchor@ #1 } \CTEX at makeanchor
-  }
-\cs_new_protected_nopar:Npn \CTEX at hyperheadinghook
-  {
-    \group_begin:
-      \ifHy at implicit
-        \cs_set_eq:NN \H at old@chapter \Hy at org@chapter
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          {
-            \cs_if_eq:ccT { H at old@ ##1 } { CTEX@ ##1 }
-              {
-                \cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 }
-                \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor
-              }
-          }
-      \else:
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          { \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor }
-      \fi:
-    \group_end:
-  }
-\ctex_at_end_package:nn { hyperref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at makeanchor #1
-      {
-        \Hy at MakeCurrentHrefAuto {#1}
-        \Hy at raisedlink
-          {
-            \hyper at anchorstart { \@currentHref }
-            \hyper at anchorend
-          }
-      }
-    \CTEX at hyperheadinghook
-  }
-\cs_new_protected:Npn \CTEX at gettitle #1
-  { }
-\ctex_at_end_package:nn { nameref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at gettitle { \NR at gettitle }
-    \seq_map_inline:Nn \c__ctex_headings_cs_seq
-      {
-        \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
-          { \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_titlesec_hook:
-  {
-    \@ifpackagewith { titlesec } { explicit }
-      {
-        \cs_set_eq:NN \__ctex_titlesec_format:Nn
-                      \__ctex_titlesec_format_explicit:Nn
-      }
-      { }
-    \clist_map_inline:nn
-      { indentafter , noindentafter , indentfirst , nonindentfirst }
-      {
-        \@ifpackagewith { titlesec } { ##1 }
-          {
-            \clist_map_break:n
-              { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n }
-          }
-          { }
-      }
-    \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1
-  {
-    \__ctex_titlesec_format:n {#1}
-    \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1}
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1
-  {
-    \cs_if_free:cF { ttlf@#1 }
-      { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2
-  {
-    \tl_set:Nx #1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \tl_tail:N #1
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2
-  {
-    \cs_set_nopar:Npx #1 ##1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \exp_args:No \tl_tail:n { #1 { } }
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2
-  { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } }
-\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6
-  {
-    \exp_not:n { {#1} {#2} {#3} {#4} }
-    { \bool_if:cTF { CTEX@#6 at afterindent } { \@ne } { \z@ } }
-  }
-\@ifpackageloaded { titlesec }
-  { }
-  {
-    \ctex_at_end_package:nn { titlesec }
-      {
-        \@ifpackagewith { titlesec } { loadonly }
-          { }
-          { \ctex_titlesec_hook: }
-      }
-  }
-\ctex_at_end_package:nn { titlesec }
-  {
-    \cs_if_free:NF \ttl at tocpart
-      {
-        \cs_set_protected_nopar:Npn \ttl at tocpart
-          { \tl_set:Nn \ttl at a { \CTEXthepart \hspace { 1em } } }
-      }
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      {
-        \cs_if_exist:cF { ttl at toc #1 }
-          {
-            \cs_new_protected_nopar:cpx { ttl at toc #1 }
-              {
-                \tl_set:Nn \exp_not:N \ttl at a
-                  {
-                    \exp_not:N \protect
-                    \exp_not:N \numberline { \exp_not:c { CTEXthe #1 } }
-                  }
-              }
-          }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\cs_new_protected_nopar:Npn \ctex_titleps_hook:
-  {
-    \ctex_patch_cmd:Nnn \ttl at settopmark
-      { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
-      {
-        \protect \@namedef { the#1 } { \@nameuse { the#1 } }
-        \CTEX at titlepslabel@set {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#1 } { } }
-      {
-        \protect \@namedef { the#1 } { }
-        \CTEX at titlepslabel@clear {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#2 } { \@nameuse { the#2 } } }
-      {
-        \protect \@namedef { the#2 } { \@nameuse { the#2 } }
-        \CTEX at titlepslabel@set {#2}
-      }
-  }
-\group_end:
-\cs_new_nopar:Npn \CTEX at titlepslabel@set #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
-  }
-\cs_new_nopar:Npn \CTEX at titlepslabel@clear #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { } }
-  }
-\ctex_at_end_package:nn { titlesec }
-  { \cs_if_free:NF \ttl at settopmark { \ctex_titleps_hook: } }
-\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
-\ctex_at_end_package:nn { titleps }
-  {
-    \cs_set_protected_nopar:Npn \ttl at setifthe #1
-      {
-        \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 }
-          {
-            \CTEXifname
-              { \protect \@firstoftwo }
-              { \protect \@secondoftwo }
-          }
-      }
-    \seq_map_function:NN \c__ctex_headings_seq \ttl at setifthe
-  }
-\cs_new_protected:Npn \CTEX at toc@width at n #1
-  {
-    \hbox_set:Nn \l__ctex_tmp_box {#1}
-    \dim_set:Nn \@tempdima
-      {
-        \dim_max:nn { \@tempdima }
-          { \box_wd:N \l__ctex_tmp_box + \f at size \p@ / 2 }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\use:n
-  {
-    \group_end:
-    \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff }
-      { \CTEX at toc@width at n {#1} }
-      { }
-      { \ctex_patch_failure:N \numberline }
-    \@ifpackageloaded { tocloft }
-      { }
-      {
-        \ctex_at_end_package:nn { tocloft }
-          {
-            \ctex_preto_cmd:NnnTF \numberline
-              { \char_set_catcode_letter:n { 64 } }
-              { \CTEX at toc@width at n {#1} }
-              { }
-              { \ctex_patch_failure:N \numberline }
-          }
-      }
-  }
-\if at twoside
-  \ctex_patch_cmd:Nnn \ps at headings
-    { \ifnum \c at secnumdepth > \z@ \thesection \quad \fi }
-    { \CTEXifname { \CTEXthesection \quad } { } }
-  \ctex_patch_cmd:Nnn \ps at headings
-    { \ifnum \c at secnumdepth > \@ne \thesubsection \quad \fi }
-    { \CTEXifname { \CTEXthesubsection \quad } { } }
-\else:
-  \ctex_patch_cmd:Nnn \ps at headings
-    { \ifnum \c at secnumdepth > \m at ne \thesection \quad \fi }
-    { \CTEXifname { \CTEXthesection \quad } { } }
-\fi:
-\ctex_at_end_package:nn { fancyhdr }
-  {
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \z@ \thesection \hskip 1em \relax \fi }
-      { \CTEXifname { \CTEXthesection \quad } { } }
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi }
-      { \CTEXifname { \CTEXthesubsection \quad } { } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
-  {
-    \protected at edef \@currentlabel
-      {
-        \cs_if_exist:cTF { CTEX at the#1 }
-          { \exp_args:cc { p@#1 } { CTEX at the#1 } }
-          { \exp_not:o { \@currentlabel } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
-  {
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      { \ctex_fix_varioref_label:n { ##1 } }
-  }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
-  {
-    \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
-  }
-\@ifpackageloaded { varioref }
-  { \ctex_varioref_hook: }
-  {
-    \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
-    \RenewDocumentCommand \refstepcounter { m }
-      {
-        \CTEX at save@refstepcounter {#1}
-        \CTEX at setcurrentlabel@n {#1}
-      }
-    \ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: }
-  }
-\ctex_scheme_input:o { \l__ctex_scheme_tl }
-%% 
-%%
-%% End of file `ctex-article.def'.

Deleted: trunk/Master/texmf-dist/tex/latex/ctex/ctex-beamer.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-beamer.def	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-beamer.def	2020-05-02 22:24:14 UTC (rev 54976)
@@ -1,205 +0,0 @@
-%%
-%% This is file `ctex-beamer.def',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% ctex.dtx  (with options: `heading,beamer')
-%% 
-%%     Copyright (C) 2003--2019
-%%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
-%% 
-%%     This work may be distributed and/or modified under the
-%%     conditions of the LaTeX Project Public License, either
-%%     version 1.3c of this license or (at your option) any later
-%%     version. This version of this license is in
-%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
-%%     and the latest version of this license is in
-%%        http://www.latex-project.org/lppl.txt
-%%     and version 1.3 or later is part of all distributions of
-%%     LaTeX version 2005/12/01 or later.
-%% 
-%%     This work has the LPPL maintenance status `maintained'.
-%% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-  {Heading modification for beamer (CTEX)}
-\ProvidesExplFile{ctex-beamer.def}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
-\seq_const_from_clist:Nn \c__ctex_headings_seq
-  { part , section , subsection }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
-  {
-    \tl_new:c { CTEX at pre#1 }
-    \tl_new:c { CTEX at post#1 }
-    \tl_const:cx { CTEXthe#1 }
-      {
-        \exp_not:c { CTEX at pre#1 }
-        \exp_not:c { CTEX at the#1 }
-        \exp_not:c { CTEX at post#1 }
-      }
-    \tl_const:cx { CTEX@#1name }
-      {
-        \group_begin:
-          \exp_not:c { CTEX@#1 at nameformat }
-            {
-              \exp_not:c { CTEX at pre#1 }
-              \exp_not:N \tl_if_empty:NTF
-              \exp_not:c { CTEX@#1 at numberformat }
-                { \exp_not:c { CTEX at the#1 } }
-                {
-                  \group_begin:
-                    \exp_not:c { CTEX@#1 at numberformat }
-                    \exp_not:c { CTEX at the#1 }
-                  \group_end:
-                }
-              \exp_not:c { CTEX at post#1 }
-            }
-        \group_end:
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
-  {
-    \tl_put_right:Nx \l__ctex_tmp_tl
-      {
-        #1                  .meta:nn = { ctex / #1 } { ####1 } ,
-        #1 / name            .code:n =
-          { \ctex_assign_heading_name:nn {#1} { ####1 } } ,
-        #1 / number        .tl_set:N = \exp_not:c { CTEX at the#1 } ,
-        #1 / beforeskip    .tl_set:N = \exp_not:c { CTEX@#1 at beforeskip } ,
-        #1 / afterskip     .tl_set:N = \exp_not:c { CTEX@#1 at afterskip} ,
-        #1 / indent        .tl_set:N = \exp_not:c { CTEX@#1 at indent } ,
-        #1 / numbering   .bool_set:N = \exp_not:c { CTEX@#1 at numbering } ,
-        #1 / numbering    .initial:n = true ,
-        #1 / beforeskip   .initial:n = \c_zero_skip ,
-        #1 / afterskip    .initial:n = \c_zero_skip ,
-        #1 / indent       .initial:n = \c_zero_dim ,
-        #1 / beforeskip   .value_required:n = true ,
-        #1 / afterskip    .value_required:n = true ,
-        #1 / indent       .value_required:n = true ,
-        \__ctex_plus_key_aux:nn {#1} { format } ,
-        \__ctex_plus_key_aux:nn {#1} { nameformat } ,
-        \__ctex_plus_key_aux:nn {#1} { numberformat } ,
-        \__ctex_plus_key_aux:nn {#1} { titleformat } ,
-        \__ctex_plus_key_aux:nn {#1} { aftername } ,
-        \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
-      }
-  }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
-  {
-    #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
-    #1 / #2 +   .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } } ,
-    #1 / #2 ~ + .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } }
-  }
-\NewDocumentCommand \ctex_assign_heading_name:nn
-  { m > { \SplitArgument { 1 } { , } } +m }
-  { \__ctex_assign_heading_name:nnn {#1} #2 }
-\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
-  {
-    \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
-      { \tl_clear:c { CTEX at post#1 } }
-      { \tl_set:cn { CTEX at post#1 } {#3} }
-  }
-\group_begin:
-\tl_clear:N \l__ctex_tmp_tl
-\seq_map_inline:Nn \c__ctex_headings_seq
-  {
-    \__ctex_initial_heading:n {#1}
-    \__ctex_def_heading_keys:n {#1}
-  }
-\use:x
-  {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
-  }
-\ExplSyntaxOff
-\defbeamertemplate*{part page}{CTEX}[1][]{%
-  \begingroup
-    \CTEX at disableautoindent
-    \par \addvspace{\glueexpr\CTEX at part@beforeskip\relax}%
-    \CTEX at part@format
-    \parindent \dimexpr \CTEX at part@indent \relax
-    \ifodd \CTEX at part@numbering
-      \CTEX at partname \CTEX at part@aftername
-    \fi
-    \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
-      \CTEX at part@titleformat \insertpart \CTEX at part@aftertitle
-    \end{beamercolorbox}%
-    \par \addvspace{\glueexpr\CTEX at part@afterskip\relax}%
-  \endgroup
-}
-\defbeamertemplate*{section page}{CTEX}[1][]{%
-  \begingroup
-    \CTEX at disableautoindent
-    \par \addvspace{\glueexpr\CTEX at section@beforeskip\relax}%
-    \CTEX at section@format
-    \parindent \dimexpr \CTEX at section@indent \relax
-    \ifodd \CTEX at section@numbering
-      \CTEX at sectionname \CTEX at section@aftername
-    \fi
-    \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
-      \CTEX at section@titleformat \insertsection \CTEX at section@aftertitle
-    \end{beamercolorbox}%
-    \par \addvspace{\glueexpr\CTEX at section@afterskip\relax}%
-  \endgroup
-}
-\defbeamertemplate*{subsection page}{CTEX}[1][]{%
-  \begingroup
-    \CTEX at disableautoindent
-    \par \addvspace{\glueexpr\CTEX at subsection@beforeskip\relax}%
-    \CTEX at subsection@format
-    \parindent \dimexpr \CTEX at subsection@indent \relax
-    \ifodd \CTEX at subsection@numbering
-      \CTEX at subsectionname \CTEX at subsection@aftername
-    \fi
-    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
-      \CTEX at subsection@titleformat \insertsubsection \CTEX at subsection@aftertitle
-    \end{beamercolorbox}%
-    \par \addvspace{\glueexpr\CTEX at subsection@afterskip\relax}%
-  \endgroup
-}
-\defbeamertemplatealias{part page}{default}{CTEX}
-\defbeamertemplatealias{section page}{default}{CTEX}
-\defbeamertemplatealias{subsection page}{default}{CTEX}
-\ExplSyntaxOn
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
-  {
-    \protected at edef \@currentlabel
-      {
-        \cs_if_exist:cTF { CTEX at the#1 }
-          { \exp_args:cc { p@#1 } { CTEX at the#1 } }
-          { \exp_not:o { \@currentlabel } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
-  {
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      { \ctex_fix_varioref_label:n { ##1 } }
-  }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
-  {
-    \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
-  }
-\@ifpackageloaded { varioref }
-  { \ctex_varioref_hook: }
-  {
-    \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
-    \RenewDocumentCommand \refstepcounter { m }
-      {
-        \CTEX at save@refstepcounter {#1}
-        \CTEX at setcurrentlabel@n {#1}
-      }
-    \ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: }
-  }
-\ctex_scheme_input:o { \l__ctex_scheme_tl }
-%% 
-%%
-%% End of file `ctex-beamer.def'.

Deleted: trunk/Master/texmf-dist/tex/latex/ctex/ctex-book.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-book.def	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-book.def	2020-05-02 22:24:14 UTC (rev 54976)
@@ -1,798 +0,0 @@
-%%
-%% This is file `ctex-book.def',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% ctex.dtx  (with options: `heading,book')
-%% 
-%%     Copyright (C) 2003--2019
-%%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
-%% 
-%%     This work may be distributed and/or modified under the
-%%     conditions of the LaTeX Project Public License, either
-%%     version 1.3c of this license or (at your option) any later
-%%     version. This version of this license is in
-%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
-%%     and the latest version of this license is in
-%%        http://www.latex-project.org/lppl.txt
-%%     and version 1.3 or later is part of all distributions of
-%%     LaTeX version 2005/12/01 or later.
-%% 
-%%     This work has the LPPL maintenance status `maintained'.
-%% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-  {Heading modification for book (CTEX)}
-\ProvidesExplFile{ctex-book.def}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
-\seq_const_from_clist:Nn \c__ctex_section_headings_seq
-  { section , subsection , subsubsection , paragraph , subparagraph }
-\seq_new:N \c__ctex_headings_seq
-\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
-\seq_gput_left:Nn \c__ctex_headings_seq { chapter }
-\seq_gput_left:Nn \c__ctex_headings_seq { part }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
-  {
-    \tl_new:c { CTEX at pre#1 }
-    \tl_new:c { CTEX at post#1 }
-    \tl_const:cx { CTEXthe#1 }
-      {
-        \exp_not:c { CTEX at pre#1 }
-        \exp_not:c { CTEX at the#1 }
-        \exp_not:c { CTEX at post#1 }
-      }
-    \tl_const:cx { CTEX@#1name }
-      {
-        \group_begin:
-          \exp_not:c { CTEX@#1 at nameformat }
-            {
-              \exp_not:c { CTEX at pre#1 }
-              \exp_not:N \tl_if_empty:NTF
-              \exp_not:c { CTEX@#1 at numberformat }
-                { \exp_not:c { CTEX at the#1 } }
-                {
-                  \group_begin:
-                    \exp_not:c { CTEX@#1 at numberformat }
-                    \exp_not:c { CTEX at the#1 }
-                  \group_end:
-                }
-              \exp_not:c { CTEX at post#1 }
-            }
-        \group_end:
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
-  {
-    \tl_put_right:Nx \l__ctex_tmp_tl
-      {
-        #1                  .meta:nn = { ctex / #1 } { ####1 } ,
-        #1 / name            .code:n =
-          { \ctex_assign_heading_name:nn {#1} { ####1 } } ,
-        #1 / number        .tl_set:N = \exp_not:c { CTEX at the#1 } ,
-        #1 / beforeskip    .tl_set:N = \exp_not:c { CTEX@#1 at beforeskip } ,
-        #1 / afterskip     .tl_set:N = \exp_not:c { CTEX@#1 at afterskip} ,
-        #1 / indent        .tl_set:N = \exp_not:c { CTEX@#1 at indent } ,
-        #1 / numbering   .bool_set:N = \exp_not:c { CTEX@#1 at numbering } ,
-        #1 / numbering    .initial:n = true ,
-        #1 / beforeskip   .initial:n = \c_zero_skip ,
-        #1 / afterskip    .initial:n = \c_zero_skip ,
-        #1 / indent       .initial:n = \c_zero_dim ,
-        #1 / beforeskip   .value_required:n = true ,
-        #1 / afterskip    .value_required:n = true ,
-        #1 / indent       .value_required:n = true ,
-        #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1 at afterindent } ,
-        #1 / fixskip     .bool_set:N = \exp_not:c { CTEX@#1 at fixskip } ,
-        #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
-        #1 / hang         .initial:n = true ,
-        #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
-        \__ctex_plus_key_aux:nn {#1} { break } ,
-        \__ctex_plus_key_aux:nn {#1} { format } ,
-        \__ctex_plus_key_aux:nn {#1} { nameformat } ,
-        \__ctex_plus_key_aux:nn {#1} { numberformat } ,
-        \__ctex_plus_key_aux:nn {#1} { titleformat } ,
-        \__ctex_plus_key_aux:nn {#1} { aftername } ,
-        \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
-      }
-  }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
-  {
-    #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
-    #1 / #2 +   .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } } ,
-    #1 / #2 ~ + .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } }
-  }
-\NewDocumentCommand \ctex_assign_heading_name:nn
-  { m > { \SplitArgument { 1 } { , } } +m }
-  { \__ctex_assign_heading_name:nnn {#1} #2 }
-\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
-  {
-    \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
-      { \tl_clear:c { CTEX at post#1 } }
-      { \tl_set:cn { CTEX at post#1 } {#3} }
-  }
-\group_begin:
-\tl_set:Nn \l__ctex_tmp_tl
-  {
-    part    / pagestyle .tl_set:N = \CTEX at part@pagestyle ,
-    chapter / pagestyle .tl_set:N = \CTEX at chapter@pagestyle ,
-    chapter / lofskip   .tl_set:N = \CTEX at chapter@lofskip ,
-    chapter / lotskip   .tl_set:N = \CTEX at chapter@lotskip ,
-    chapter / lofskip  .initial:n = \c_zero_skip ,
-    chapter / lotskip  .initial:n = \c_zero_skip ,
-    chapter / lofskip  .value_required:n = true ,
-    chapter / lotskip  .value_required:n = true ,
-  }
-\seq_map_inline:Nn \c__ctex_headings_seq
-  {
-    \__ctex_initial_heading:n {#1}
-    \__ctex_def_heading_keys:n {#1}
-  }
-\use:x
-  {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at fixtopskip
-  {
-    \CTEX at fixheadingskip
-    \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim
-      { \skip_sub:Nn \l__ctex_heading_skip { \tex_topskip:D } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
-  {
-    \par
-    \dim_set:Nn \tex_prevdepth:D { -1000pt }
-    \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
-  }
-\skip_new:N \l__ctex_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
-  { \skip_set:Nn \l__ctex_heading_skip }
-\cs_new_eq:NN \CTEX at headingskip \l__ctex_heading_skip
-\ProvideDocumentCommand \partmark { m }
-  { \markboth { } { } }
-\cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
-  { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
-  { \cs_set_eq:NN \CTEXifname \use_ii:nn }
-\cs_new_protected_nopar:Npn \CTEX at addloflotskip #1
-  {
-    \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1 at lofskip } }
-    \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
-      {
-        \addtocontents { lof }
-          { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
-      }
-    \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1 at lotskip } }
-    \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
-      {
-        \addtocontents { lot }
-          { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
-      }
-  }
-\cs_new_protected:Npn \CTEX at addtocline #1#2
-  { \addcontentsline { toc } {#1} { \use:c { CTEX@#1 at tocline } {#1} {#2} } }
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l__ctex_autoindent_tl }
-\renewcommand\part{%
-  \CTEX at part@break
-  \thispagestyle{\CTEX at part@pagestyle}%
-  \if at twocolumn
-    \onecolumn
-    \@tempswatrue
-  \else
-    \@tempswafalse
-  \fi
-  \CTEX at setheadingskip \CTEX at part@beforeskip
-  \ifodd \CTEX at part@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  \secdef\@part\@spart}
-\def\@part[#1]#2{%
-  \ifnum \c at secnumdepth >-2\relax
-    \ifodd \CTEX at part@numbering
-      \CTEX at ifnametrue
-      \refstepcounter{part}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{part*}%
-    \fi
-  \else
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor{part*}%
-  \fi
-  \CTEX at gettitle{#1}%
-  \CTEX at addtocline{part}{#1}%
-   \partmark{#1}%
-  {\interlinepenalty \@M
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-   \CTEX at part@titleformat{#2}%
-   \CTEX at part@aftertitle}%
-  \@endpart}
-\def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-    \@endpart}
-\def\@endpart{%
-              \CTEX at setheadingskip \CTEX at part@afterskip
-              \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-              \vskip \CTEX at headingskip
-              \newpage
-              \if at twoside
-               \if at openright
-                \null
-                \thispagestyle{empty}%
-                \newpage
-               \fi
-              \fi
-              \if at tempswa
-                \twocolumn
-              \fi}
-\renewcommand\chapter{%
-                    \CTEX at chapter@break
-                    \thispagestyle{\CTEX at chapter@pagestyle}%
-                    \global\@topnum\z@
-                    \ifodd \CTEX at chapter@afterindent
-                      \@afterindenttrue
-                    \else
-                      \@afterindentfalse
-                    \fi
-                    \secdef\@chapter\@schapter}
-\def\@chapter[#1]#2{%
-  \ifnum \c at secnumdepth >\m at ne
-    \if at mainmatter
-      \ifodd \CTEX at chapter@numbering
-        \CTEX at ifnametrue
-        \refstepcounter{chapter}%
-        \typeout{\CTEXthechapter}%
-      \else
-        \CTEX at ifnamefalse
-        \CTEX at makeanchor{\Hy at chapapp*}%
-      \fi
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor@chapter{\Hy at chapapp*}%
-    \fi
-  \else
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@chapter{\Hy at chapapp*}%
-  \fi
-  \CTEX at gettitle{#1}%
-  \CTEX at addtocline{chapter}{#1}%
-  \chaptermark{#1}%
-  \CTEX at addloflotskip{chapter}%
-  \if at twocolumn
-    \@topnewpage[\@makechapterhead{#2}]%
-  \else
-    \@makechapterhead{#2}%
-  \@afterheading
-  \fi}
-\def\@schapter#1{%
-  \CTEX at ifnamefalse
-  \CTEX at makeanchor@schapter{\Hy at chapapp*}%
-  \CTEX at gettitle{#1}%
-  \if at twocolumn
-    \@topnewpage[\@makeschapterhead{#1}]%
-  \else
-    \@makeschapterhead{#1}%
-    \@afterheading
-  \fi}
-\def\@makechapterhead#1{%
-  \CTEX at setheadingskip \CTEX at chapter@beforeskip
-  \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}%
-     {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
-\def\@makeschapterhead#1{%
-  \CTEX at setheadingskip \CTEX at chapter@beforeskip
-  \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}{}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
-\def\@startsection#1#2#3#4#5#6{%
-  \if at noskipsec \leavevmode \fi
-  \par
-  \CTEX at update@sectionformat at n{#1}%
-  \ifodd \CTEX at afterindent
-    \@afterindenttrue
-  \else
-    \@afterindentfalse
-  \fi
-  \if at nobreak
-    \everypar{}%
-  \else
-    \csname CTEX@#1 at break\endcsname
-    \CTEX at setheadingskip{#4}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \addvspace \CTEX at headingskip
-  \fi
-  \@ifstar
-    {\CTEX at makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}%
-    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
-\def\@seccntformat#1{%
-  \csname CTEX@#1name\endcsname
-  \csname CTEX@#1 at aftername\endcsname}
-\def\@sect#1#2#3#4#5#6[#7]#8{%
-  \ifnum #2>\c at secnumdepth
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@sect{#1*}%
-    \let\@svsec\@empty
-  \else
-    \ifodd \csname CTEX@#1 at numbering\endcsname
-      \CTEX at ifnametrue
-      \refstepcounter{#1}%
-      \protected at edef\@svsec{\@seccntformat{#1}\relax}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{#1*}%
-      \let\@svsec\@empty
-    \fi
-  \fi
-  \CTEX at gettitle{#7}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-        \interlinepenalty \@M
-        \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
-    \endgroup
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}%
-  \else
-    \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}}%
-  \fi
-  \@xsect{#5}}
-\def\@ssect#1#2#3#4#5{%
-  \CTEX at ifnamefalse
-  \CTEX at gettitle{#5}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-          \interlinepenalty \@M
-          \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
-    \endgroup
-  \else
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
-  \fi
-  \@xsect{#3}}
-\def\@xsect#1{%
-  \unless \ifodd \CTEX at runin
-    \par \nobreak
-    \CTEX at setheadingskip{#1}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \vskip \CTEX at headingskip
-    \@afterheading
-  \else
-    \@nobreakfalse
-    \global\@noskipsectrue
-    \everypar{%
-      \if at noskipsec
-        \global\@noskipsecfalse
-       {\setbox\z@\lastbox}%
-        \clubpenalty\@M
-        \begingroup \@svsechd \endgroup
-        \unskip
-        \hskip\glueexpr #1\relax
-      \else
-        \clubpenalty \@clubpenalty
-        \everypar{}%
-      \fi}%
-  \fi
-  \ignorespaces}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
-  {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \__ctex_indent_aux: #2 } }
-      {#2}
-  }
-\cs_new_protected_nopar:Npn \__ctex_indent_aux:
-  {
-    \dim_compare:nNnF \parindent = \c_zero_dim
-      { \skip_horizontal:n { \parindent } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at hangfrom
-  {
-    \bool_if:NTF \CTEX at hang
-      { \@hangfrom }
-      { \noindent \use:n }
-  }
-\cs_new_protected_nopar:Npn \CTEX at update@sectionformat at n #1
-  {
-    \cs_set_eq:Nc \CTEX at titleformat@n { CTEX@#1 at titleformat }
-    \cs_set_eq:Nc \CTEX at aftertitle    { CTEX@#1 at aftertitle }
-    \cs_set_eq:Nc \CTEX at afterindent   { CTEX@#1 at afterindent }
-    \cs_set_eq:Nc \CTEX at fixskip       { CTEX@#1 at fixskip }
-    \cs_set_eq:Nc \CTEX at hang          { CTEX@#1 at hang }
-    \cs_set_eq:Nc \CTEX at runin         { CTEX@#1 at runin }
-  }
-\cs_new_eq:NN \CTEX at titleformat@n \use:n
-\cs_new_eq:NN \CTEX at aftertitle \prg_do_nothing:
-\cs_new_eq:NN \CTEX at afterindent \c_true_bool
-\cs_new_eq:NN \CTEX at fixskip \c_false_bool
-\cs_new_eq:NN \CTEX at hang \c_true_bool
-\cs_new_eq:NN \CTEX at runin \c_false_bool
-\cs_new:Npn \CTEX at part@tocline #1#2
-  {
-    \CTEXifname
-      { \CTEXthepart \hspace { 1em } }
-      { }
-    #2
-  }
-\cs_new:Npn \CTEX at chapter@tocline #1#2
-  {
-    \CTEXifname
-      { \protect \numberline { \CTEXthechapter \hspace { .3em } } }
-      { }
-    #2
-  }
-\cs_new_nopar:Npn \CTEXnumberline #1
-  {
-    \CTEXifname
-      { \protect \numberline { \use:c { CTEXthe #1 } } }
-      { }
-  }
-\int_zero:N \l__ctex_tmp_int
-\seq_map_inline:Nn \c__ctex_section_headings_seq
-  {
-    \int_incr:N \l__ctex_tmp_int
-    \cs_gset_protected_nopar:cpx  {#1}
-      {
-        \exp_not:N \@startsection {#1}
-          { \int_use:N \l__ctex_tmp_int }
-          { \exp_not:c { CTEX@#1 at indent } }
-          { \exp_not:c { CTEX@#1 at beforeskip } }
-          { \exp_not:c { CTEX@#1 at afterskip } }
-          { \exp_not:N \normalfont \exp_not:c { CTEX@#1 at format } }
-      }
-    \cs_new:cpn { CTEX@#1 at tocline } ##1##2
-      { \CTEXnumberline { ##1 } ##2 }
-  }
-\keys_define:nn { ctex }
-  {
-    appendix                .meta:nn = { ctex / appendix } {#1} ,
-    appendix / name          .code:n =
-      { \ctex_assign_heading_name:nn { appendix } {#1} } ,
-    appendix / number      .tl_set:N = \CTEX at appendix@number ,
-    appendix / numbering .bool_set:N = \CTEX at appendix@numbering ,
-    appendix / numbering  .initial:n = true
-  }
-\tl_new:N \CTEX at preappendix
-\tl_new:N \CTEX at postappendix
-\cs_new_eq:NN \CTEX at save@appendix \appendix
-\cs_gset_protected_nopar:Npn \appendix
-  {
-    \CTEX at save@appendix
-    \gdef \CTEX at prechapter { \CTEX at preappendix }
-    \gdef \CTEX at thechapter { \CTEX at appendix@number }
-    \gdef \CTEX at postchapter { \CTEX at postappendix }
-    \gdef \CTEX at chapter@numbering { \CTEX at appendix@numbering }
-  }
-\cs_new_protected_nopar:Npn \CTEX at makeanchor #1
-  { }
-\seq_const_from_clist:Nn \c__ctex_headings_cs_seq
-  { part , spart , chapter , schapter , sect , ssect }
-\seq_map_inline:Nn \c__ctex_headings_cs_seq
-  {
-    \cs_new_eq:cc { CTEX@ #1 } { @ #1 }
-    \cs_new_eq:cN { CTEX at makeanchor@ #1 } \CTEX at makeanchor
-  }
-\cs_new_protected_nopar:Npn \CTEX at hyperheadinghook
-  {
-    \group_begin:
-      \ifHy at implicit
-        \cs_set_eq:NN \H at old@chapter \Hy at org@chapter
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          {
-            \cs_if_eq:ccT { H at old@ ##1 } { CTEX@ ##1 }
-              {
-                \cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 }
-                \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor
-              }
-          }
-      \else:
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          { \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor }
-      \fi:
-    \group_end:
-  }
-\ctex_at_end_package:nn { hyperref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at makeanchor #1
-      {
-        \Hy at MakeCurrentHrefAuto {#1}
-        \Hy at raisedlink
-          {
-            \hyper at anchorstart { \@currentHref }
-            \hyper at anchorend
-          }
-      }
-    \CTEX at hyperheadinghook
-  }
-\cs_new_protected:Npn \CTEX at gettitle #1
-  { }
-\ctex_at_end_package:nn { nameref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at gettitle { \NR at gettitle }
-    \seq_map_inline:Nn \c__ctex_headings_cs_seq
-      {
-        \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
-          { \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_titlesec_hook:
-  {
-    \@ifpackagewith { titlesec } { explicit }
-      {
-        \cs_set_eq:NN \__ctex_titlesec_format:Nn
-                      \__ctex_titlesec_format_explicit:Nn
-      }
-      { }
-    \clist_map_inline:nn
-      { indentafter , noindentafter , indentfirst , nonindentfirst }
-      {
-        \@ifpackagewith { titlesec } { ##1 }
-          {
-            \clist_map_break:n
-              { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n }
-          }
-          { }
-      }
-    \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1
-  {
-    \__ctex_titlesec_format:n {#1}
-    \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1}
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1
-  {
-    \cs_if_free:cF { ttlf@#1 }
-      { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2
-  {
-    \tl_set:Nx #1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \tl_tail:N #1
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2
-  {
-    \cs_set_nopar:Npx #1 ##1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \exp_args:No \tl_tail:n { #1 { } }
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2
-  { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } }
-\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6
-  {
-    \exp_not:n { {#1} {#2} {#3} {#4} }
-    { \bool_if:cTF { CTEX@#6 at afterindent } { \@ne } { \z@ } }
-  }
-\@ifpackageloaded { titlesec }
-  { }
-  {
-    \ctex_at_end_package:nn { titlesec }
-      {
-        \@ifpackagewith { titlesec } { loadonly }
-          { }
-          { \ctex_titlesec_hook: }
-      }
-  }
-\ctex_at_end_package:nn { titlesec }
-  {
-    \tl_set:Nn \ttl at chapterout { \typeout { \CTEXthechapter } }
-    \cs_if_free:NF \ttl at tocpart
-      {
-        \cs_set_protected_nopar:Npn \ttl at tocpart
-          { \tl_set:Nn \ttl at a { \CTEXthepart \hspace { 1em } } }
-      }
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      {
-        \cs_if_exist:cF { ttl at toc #1 }
-          {
-            \cs_new_protected_nopar:cpx { ttl at toc #1 }
-              {
-                \tl_set:Nn \exp_not:N \ttl at a
-                  {
-                    \exp_not:N \protect
-                    \exp_not:N \numberline { \exp_not:c { CTEXthe #1 } }
-                  }
-              }
-          }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\cs_new_protected_nopar:Npn \ctex_titleps_hook:
-  {
-    \ctex_patch_cmd:Nnn \ttl at settopmark
-      { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
-      {
-        \protect \@namedef { the#1 } { \@nameuse { the#1 } }
-        \CTEX at titlepslabel@set {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#1 } { } }
-      {
-        \protect \@namedef { the#1 } { }
-        \CTEX at titlepslabel@clear {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#2 } { \@nameuse { the#2 } } }
-      {
-        \protect \@namedef { the#2 } { \@nameuse { the#2 } }
-        \CTEX at titlepslabel@set {#2}
-      }
-  }
-\group_end:
-\cs_new_nopar:Npn \CTEX at titlepslabel@set #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
-  }
-\cs_new_nopar:Npn \CTEX at titlepslabel@clear #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { } }
-  }
-\ctex_at_end_package:nn { titlesec }
-  { \cs_if_free:NF \ttl at settopmark { \ctex_titleps_hook: } }
-\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
-\ctex_at_end_package:nn { titleps }
-  {
-    \cs_set_protected_nopar:Npn \ttl at setifthe #1
-      {
-        \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 }
-          {
-            \CTEXifname
-              { \protect \@firstoftwo }
-              { \protect \@secondoftwo }
-          }
-      }
-    \seq_map_function:NN \c__ctex_headings_seq \ttl at setifthe
-  }
-\cs_new_protected:Npn \CTEX at toc@width at n #1
-  {
-    \hbox_set:Nn \l__ctex_tmp_box {#1}
-    \dim_set:Nn \@tempdima
-      {
-        \dim_max:nn { \@tempdima }
-          { \box_wd:N \l__ctex_tmp_box + \f at size \p@ / 2 }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\use:n
-  {
-    \group_end:
-    \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff }
-      { \CTEX at toc@width at n {#1} }
-      { }
-      { \ctex_patch_failure:N \numberline }
-    \@ifpackageloaded { tocloft }
-      { }
-      {
-        \ctex_at_end_package:nn { tocloft }
-          {
-            \ctex_preto_cmd:NnnTF \numberline
-              { \char_set_catcode_letter:n { 64 } }
-              { \CTEX at toc@width at n {#1} }
-              { }
-              { \ctex_patch_failure:N \numberline }
-          }
-      }
-  }
-\ctex_patch_cmd:Nnn \ps at headings
-  {
-    \ifnum \c at secnumdepth > \m at ne \if at mainmatter
-      \@chapapp \ \thechapter . ~ \ %
-    \fi \fi
-  }
-  { \CTEXifname { \CTEXthechapter \quad } { } }
-\if at twoside
-  \ctex_patch_cmd:Nnn \ps at headings
-    { \ifnum \c at secnumdepth > \z@ \thesection . ~ \ \fi }
-    { \CTEXifname { \CTEXthesection \quad } { } }
-\fi:
-\ctex_at_end_package:nn { fancyhdr }
-  {
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \m at ne \@chapapp \ \thechapter . ~ \ \fi }
-      { \CTEXifname { \CTEXthechapter \quad } { } }
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \z@ \thesection . ~ \ \fi }
-      { \CTEXifname { \CTEXthesection \quad } { } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
-  {
-    \protected at edef \@currentlabel
-      {
-        \cs_if_exist:cTF { CTEX at the#1 }
-          { \exp_args:cc { p@#1 } { CTEX at the#1 } }
-          { \exp_not:o { \@currentlabel } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
-  {
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      { \ctex_fix_varioref_label:n { ##1 } }
-  }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
-  {
-    \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
-  }
-\@ifpackageloaded { varioref }
-  { \ctex_varioref_hook: }
-  {
-    \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
-    \RenewDocumentCommand \refstepcounter { m }
-      {
-        \CTEX at save@refstepcounter {#1}
-        \CTEX at setcurrentlabel@n {#1}
-      }
-    \ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: }
-  }
-\ctex_scheme_input:o { \l__ctex_scheme_tl }
-%% 
-%%
-%% End of file `ctex-book.def'.

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `c5size')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,16 +20,14 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {c5size option (CTEX)}
 \ProvidesExplFile{ctex-c5size.clo}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \ctex_set_font_size:Nnn \normalsize { 5 }
   {
     \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `cs4size')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,16 +20,14 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {cs4size option (CTEX)}
 \ProvidesExplFile{ctex-cs4size.clo}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \ctex_set_font_size:Nnn \normalsize { -4 }
   {
     \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@

Deleted: trunk/Master/texmf-dist/tex/latex/ctex/ctex-report.def
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex-report.def	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex-report.def	2020-05-02 22:24:14 UTC (rev 54976)
@@ -1,793 +0,0 @@
-%%
-%% This is file `ctex-report.def',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% ctex.dtx  (with options: `heading,report')
-%% 
-%%     Copyright (C) 2003--2019
-%%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
-%% 
-%%     This work may be distributed and/or modified under the
-%%     conditions of the LaTeX Project Public License, either
-%%     version 1.3c of this license or (at your option) any later
-%%     version. This version of this license is in
-%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
-%%     and the latest version of this license is in
-%%        http://www.latex-project.org/lppl.txt
-%%     and version 1.3 or later is part of all distributions of
-%%     LaTeX version 2005/12/01 or later.
-%% 
-%%     This work has the LPPL maintenance status `maintained'.
-%% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
-%% 
-%% ------------------------------------------------------------------------------
-%% 
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
-  {Heading modification for report (CTEX)}
-\ProvidesExplFile{ctex-report.def}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
-\seq_const_from_clist:Nn \c__ctex_section_headings_seq
-  { section , subsection , subsubsection , paragraph , subparagraph }
-\seq_new:N \c__ctex_headings_seq
-\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
-\seq_gput_left:Nn \c__ctex_headings_seq { chapter }
-\seq_gput_left:Nn \c__ctex_headings_seq { part }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
-  {
-    \tl_new:c { CTEX at pre#1 }
-    \tl_new:c { CTEX at post#1 }
-    \tl_const:cx { CTEXthe#1 }
-      {
-        \exp_not:c { CTEX at pre#1 }
-        \exp_not:c { CTEX at the#1 }
-        \exp_not:c { CTEX at post#1 }
-      }
-    \tl_const:cx { CTEX@#1name }
-      {
-        \group_begin:
-          \exp_not:c { CTEX@#1 at nameformat }
-            {
-              \exp_not:c { CTEX at pre#1 }
-              \exp_not:N \tl_if_empty:NTF
-              \exp_not:c { CTEX@#1 at numberformat }
-                { \exp_not:c { CTEX at the#1 } }
-                {
-                  \group_begin:
-                    \exp_not:c { CTEX@#1 at numberformat }
-                    \exp_not:c { CTEX at the#1 }
-                  \group_end:
-                }
-              \exp_not:c { CTEX at post#1 }
-            }
-        \group_end:
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
-  {
-    \tl_put_right:Nx \l__ctex_tmp_tl
-      {
-        #1                  .meta:nn = { ctex / #1 } { ####1 } ,
-        #1 / name            .code:n =
-          { \ctex_assign_heading_name:nn {#1} { ####1 } } ,
-        #1 / number        .tl_set:N = \exp_not:c { CTEX at the#1 } ,
-        #1 / beforeskip    .tl_set:N = \exp_not:c { CTEX@#1 at beforeskip } ,
-        #1 / afterskip     .tl_set:N = \exp_not:c { CTEX@#1 at afterskip} ,
-        #1 / indent        .tl_set:N = \exp_not:c { CTEX@#1 at indent } ,
-        #1 / numbering   .bool_set:N = \exp_not:c { CTEX@#1 at numbering } ,
-        #1 / numbering    .initial:n = true ,
-        #1 / beforeskip   .initial:n = \c_zero_skip ,
-        #1 / afterskip    .initial:n = \c_zero_skip ,
-        #1 / indent       .initial:n = \c_zero_dim ,
-        #1 / beforeskip   .value_required:n = true ,
-        #1 / afterskip    .value_required:n = true ,
-        #1 / indent       .value_required:n = true ,
-        #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1 at afterindent } ,
-        #1 / fixskip     .bool_set:N = \exp_not:c { CTEX@#1 at fixskip } ,
-        #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
-        #1 / hang         .initial:n = true ,
-        #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
-        \__ctex_plus_key_aux:nn {#1} { break } ,
-        \__ctex_plus_key_aux:nn {#1} { format } ,
-        \__ctex_plus_key_aux:nn {#1} { nameformat } ,
-        \__ctex_plus_key_aux:nn {#1} { numberformat } ,
-        \__ctex_plus_key_aux:nn {#1} { titleformat } ,
-        \__ctex_plus_key_aux:nn {#1} { aftername } ,
-        \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
-      }
-  }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
-  {
-    #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
-    #1 / #2 +   .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } } ,
-    #1 / #2 ~ + .code:n =
-      { \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ####1 } }
-  }
-\NewDocumentCommand \ctex_assign_heading_name:nn
-  { m > { \SplitArgument { 1 } { , } } +m }
-  { \__ctex_assign_heading_name:nnn {#1} #2 }
-\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
-  {
-    \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
-      { \tl_clear:c { CTEX at post#1 } }
-      { \tl_set:cn { CTEX at post#1 } {#3} }
-  }
-\group_begin:
-\tl_set:Nn \l__ctex_tmp_tl
-  {
-    part    / pagestyle .tl_set:N = \CTEX at part@pagestyle ,
-    chapter / pagestyle .tl_set:N = \CTEX at chapter@pagestyle ,
-    chapter / lofskip   .tl_set:N = \CTEX at chapter@lofskip ,
-    chapter / lotskip   .tl_set:N = \CTEX at chapter@lotskip ,
-    chapter / lofskip  .initial:n = \c_zero_skip ,
-    chapter / lotskip  .initial:n = \c_zero_skip ,
-    chapter / lofskip  .value_required:n = true ,
-    chapter / lotskip  .value_required:n = true ,
-  }
-\seq_map_inline:Nn \c__ctex_headings_seq
-  {
-    \__ctex_initial_heading:n {#1}
-    \__ctex_def_heading_keys:n {#1}
-  }
-\use:x
-  {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at fixtopskip
-  {
-    \CTEX at fixheadingskip
-    \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim
-      { \skip_sub:Nn \l__ctex_heading_skip { \tex_topskip:D } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
-  {
-    \par
-    \dim_set:Nn \tex_prevdepth:D { -1000pt }
-    \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
-  }
-\skip_new:N \l__ctex_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
-  { \skip_set:Nn \l__ctex_heading_skip }
-\cs_new_eq:NN \CTEX at headingskip \l__ctex_heading_skip
-\ProvideDocumentCommand \partmark { m }
-  { \markboth { } { } }
-\cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
-  { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
-  { \cs_set_eq:NN \CTEXifname \use_ii:nn }
-\cs_new_protected_nopar:Npn \CTEX at addloflotskip #1
-  {
-    \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1 at lofskip } }
-    \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
-      {
-        \addtocontents { lof }
-          { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
-      }
-    \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1 at lotskip } }
-    \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
-      {
-        \addtocontents { lot }
-          { \protect \addvspace { \skip_use:N \l__ctex_heading_skip } }
-      }
-  }
-\cs_new_protected:Npn \CTEX at addtocline #1#2
-  { \addcontentsline { toc } {#1} { \use:c { CTEX@#1 at tocline } {#1} {#2} } }
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l__ctex_autoindent_tl }
-\renewcommand\part{%
-  \CTEX at part@break
-  \thispagestyle{\CTEX at part@pagestyle}%
-  \if at twocolumn
-    \onecolumn
-    \@tempswatrue
-  \else
-    \@tempswafalse
-  \fi
-  \CTEX at setheadingskip \CTEX at part@beforeskip
-  \ifodd \CTEX at part@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  \secdef\@part\@spart}
-\def\@part[#1]#2{%
-  \ifnum \c at secnumdepth >-2\relax
-    \ifodd \CTEX at part@numbering
-      \CTEX at ifnametrue
-      \refstepcounter{part}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{part*}%
-    \fi
-  \else
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor{part*}%
-  \fi
-  \CTEX at gettitle{#1}%
-  \CTEX at addtocline{part}{#1}%
-   \partmark{#1}%
-  {\interlinepenalty \@M
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-   \CTEX at part@titleformat{#2}%
-   \CTEX at part@aftertitle}%
-  \@endpart}
-\def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-    \@endpart}
-\def\@endpart{%
-              \CTEX at setheadingskip \CTEX at part@afterskip
-              \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-              \vskip \CTEX at headingskip
-              \newpage
-              \if at twoside
-               \if at openright
-                \null
-                \thispagestyle{empty}%
-                \newpage
-               \fi
-              \fi
-              \if at tempswa
-                \twocolumn
-              \fi}
-\renewcommand\chapter{%
-                    \CTEX at chapter@break
-                    \thispagestyle{\CTEX at chapter@pagestyle}%
-                    \global\@topnum\z@
-                    \ifodd \CTEX at chapter@afterindent
-                      \@afterindenttrue
-                    \else
-                      \@afterindentfalse
-                    \fi
-                    \secdef\@chapter\@schapter}
-\def\@chapter[#1]#2{%
-  \ifnum \c at secnumdepth >\m at ne
-      \ifodd \CTEX at chapter@numbering
-        \CTEX at ifnametrue
-        \refstepcounter{chapter}%
-        \typeout{\CTEXthechapter}%
-      \else
-        \CTEX at ifnamefalse
-        \CTEX at makeanchor{\Hy at chapapp*}%
-      \fi
-  \else
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@chapter{\Hy at chapapp*}%
-  \fi
-  \CTEX at gettitle{#1}%
-  \CTEX at addtocline{chapter}{#1}%
-  \chaptermark{#1}%
-  \CTEX at addloflotskip{chapter}%
-  \if at twocolumn
-    \@topnewpage[\@makechapterhead{#2}]%
-  \else
-    \@makechapterhead{#2}%
-  \@afterheading
-  \fi}
-\def\@schapter#1{%
-  \CTEX at ifnamefalse
-  \CTEX at makeanchor@schapter{\Hy at chapapp*}%
-  \CTEX at gettitle{#1}%
-  \if at twocolumn
-    \@topnewpage[\@makeschapterhead{#1}]%
-  \else
-    \@makeschapterhead{#1}%
-    \@afterheading
-  \fi}
-\def\@makechapterhead#1{%
-  \CTEX at setheadingskip \CTEX at chapter@beforeskip
-  \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}%
-     {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
-\def\@makeschapterhead#1{%
-  \CTEX at setheadingskip \CTEX at chapter@beforeskip
-  \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
-  \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}{}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
-\def\@startsection#1#2#3#4#5#6{%
-  \if at noskipsec \leavevmode \fi
-  \par
-  \CTEX at update@sectionformat at n{#1}%
-  \ifodd \CTEX at afterindent
-    \@afterindenttrue
-  \else
-    \@afterindentfalse
-  \fi
-  \if at nobreak
-    \everypar{}%
-  \else
-    \csname CTEX@#1 at break\endcsname
-    \CTEX at setheadingskip{#4}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \addvspace \CTEX at headingskip
-  \fi
-  \@ifstar
-    {\CTEX at makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}%
-    {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}}
-\def\@seccntformat#1{%
-  \csname CTEX@#1name\endcsname
-  \csname CTEX@#1 at aftername\endcsname}
-\def\@sect#1#2#3#4#5#6[#7]#8{%
-  \ifnum #2>\c at secnumdepth
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@sect{#1*}%
-    \let\@svsec\@empty
-  \else
-    \ifodd \csname CTEX@#1 at numbering\endcsname
-      \CTEX at ifnametrue
-      \refstepcounter{#1}%
-      \protected at edef\@svsec{\@seccntformat{#1}\relax}%
-    \else
-      \CTEX at ifnamefalse
-      \CTEX at makeanchor{#1*}%
-      \let\@svsec\@empty
-    \fi
-  \fi
-  \CTEX at gettitle{#7}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-        \interlinepenalty \@M
-        \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
-    \endgroup
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}%
-  \else
-    \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}}%
-  \fi
-  \@xsect{#5}}
-\def\@ssect#1#2#3#4#5{%
-  \CTEX at ifnamefalse
-  \CTEX at gettitle{#5}%
-  \unless \ifodd \CTEX at runin
-    \begingroup
-      #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-          \interlinepenalty \@M
-          \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
-    \endgroup
-  \else
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
-  \fi
-  \@xsect{#3}}
-\def\@xsect#1{%
-  \unless \ifodd \CTEX at runin
-    \par \nobreak
-    \CTEX at setheadingskip{#1}%
-    \ifodd \CTEX at fixskip \CTEX at fixheadingskip \fi
-    \vskip \CTEX at headingskip
-    \@afterheading
-  \else
-    \@nobreakfalse
-    \global\@noskipsectrue
-    \everypar{%
-      \if at noskipsec
-        \global\@noskipsecfalse
-       {\setbox\z@\lastbox}%
-        \clubpenalty\@M
-        \begingroup \@svsechd \endgroup
-        \unskip
-        \hskip\glueexpr #1\relax
-      \else
-        \clubpenalty \@clubpenalty
-        \everypar{}%
-      \fi}%
-  \fi
-  \ignorespaces}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
-  {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \__ctex_indent_aux: #2 } }
-      {#2}
-  }
-\cs_new_protected_nopar:Npn \__ctex_indent_aux:
-  {
-    \dim_compare:nNnF \parindent = \c_zero_dim
-      { \skip_horizontal:n { \parindent } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at hangfrom
-  {
-    \bool_if:NTF \CTEX at hang
-      { \@hangfrom }
-      { \noindent \use:n }
-  }
-\cs_new_protected_nopar:Npn \CTEX at update@sectionformat at n #1
-  {
-    \cs_set_eq:Nc \CTEX at titleformat@n { CTEX@#1 at titleformat }
-    \cs_set_eq:Nc \CTEX at aftertitle    { CTEX@#1 at aftertitle }
-    \cs_set_eq:Nc \CTEX at afterindent   { CTEX@#1 at afterindent }
-    \cs_set_eq:Nc \CTEX at fixskip       { CTEX@#1 at fixskip }
-    \cs_set_eq:Nc \CTEX at hang          { CTEX@#1 at hang }
-    \cs_set_eq:Nc \CTEX at runin         { CTEX@#1 at runin }
-  }
-\cs_new_eq:NN \CTEX at titleformat@n \use:n
-\cs_new_eq:NN \CTEX at aftertitle \prg_do_nothing:
-\cs_new_eq:NN \CTEX at afterindent \c_true_bool
-\cs_new_eq:NN \CTEX at fixskip \c_false_bool
-\cs_new_eq:NN \CTEX at hang \c_true_bool
-\cs_new_eq:NN \CTEX at runin \c_false_bool
-\cs_new:Npn \CTEX at part@tocline #1#2
-  {
-    \CTEXifname
-      { \CTEXthepart \hspace { 1em } }
-      { }
-    #2
-  }
-\cs_new:Npn \CTEX at chapter@tocline #1#2
-  {
-    \CTEXifname
-      { \protect \numberline { \CTEXthechapter \hspace { .3em } } }
-      { }
-    #2
-  }
-\cs_new_nopar:Npn \CTEXnumberline #1
-  {
-    \CTEXifname
-      { \protect \numberline { \use:c { CTEXthe #1 } } }
-      { }
-  }
-\int_zero:N \l__ctex_tmp_int
-\seq_map_inline:Nn \c__ctex_section_headings_seq
-  {
-    \int_incr:N \l__ctex_tmp_int
-    \cs_gset_protected_nopar:cpx  {#1}
-      {
-        \exp_not:N \@startsection {#1}
-          { \int_use:N \l__ctex_tmp_int }
-          { \exp_not:c { CTEX@#1 at indent } }
-          { \exp_not:c { CTEX@#1 at beforeskip } }
-          { \exp_not:c { CTEX@#1 at afterskip } }
-          { \exp_not:N \normalfont \exp_not:c { CTEX@#1 at format } }
-      }
-    \cs_new:cpn { CTEX@#1 at tocline } ##1##2
-      { \CTEXnumberline { ##1 } ##2 }
-  }
-\keys_define:nn { ctex }
-  {
-    appendix                .meta:nn = { ctex / appendix } {#1} ,
-    appendix / name          .code:n =
-      { \ctex_assign_heading_name:nn { appendix } {#1} } ,
-    appendix / number      .tl_set:N = \CTEX at appendix@number ,
-    appendix / numbering .bool_set:N = \CTEX at appendix@numbering ,
-    appendix / numbering  .initial:n = true
-  }
-\tl_new:N \CTEX at preappendix
-\tl_new:N \CTEX at postappendix
-\cs_new_eq:NN \CTEX at save@appendix \appendix
-\cs_gset_protected_nopar:Npn \appendix
-  {
-    \CTEX at save@appendix
-    \gdef \CTEX at prechapter { \CTEX at preappendix }
-    \gdef \CTEX at thechapter { \CTEX at appendix@number }
-    \gdef \CTEX at postchapter { \CTEX at postappendix }
-    \gdef \CTEX at chapter@numbering { \CTEX at appendix@numbering }
-  }
-\cs_new_protected_nopar:Npn \CTEX at makeanchor #1
-  { }
-\seq_const_from_clist:Nn \c__ctex_headings_cs_seq
-  { part , spart , chapter , schapter , sect , ssect }
-\seq_map_inline:Nn \c__ctex_headings_cs_seq
-  {
-    \cs_new_eq:cc { CTEX@ #1 } { @ #1 }
-    \cs_new_eq:cN { CTEX at makeanchor@ #1 } \CTEX at makeanchor
-  }
-\cs_new_protected_nopar:Npn \CTEX at hyperheadinghook
-  {
-    \group_begin:
-      \ifHy at implicit
-        \cs_set_eq:NN \H at old@chapter \Hy at org@chapter
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          {
-            \cs_if_eq:ccT { H at old@ ##1 } { CTEX@ ##1 }
-              {
-                \cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 }
-                \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor
-              }
-          }
-      \else:
-        \seq_map_inline:Nn \c__ctex_headings_cs_seq
-          { \cs_gset_eq:cN { CTEX at makeanchor@ ##1 } \CTEX at makeanchor }
-      \fi:
-    \group_end:
-  }
-\ctex_at_end_package:nn { hyperref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at makeanchor #1
-      {
-        \Hy at MakeCurrentHrefAuto {#1}
-        \Hy at raisedlink
-          {
-            \hyper at anchorstart { \@currentHref }
-            \hyper at anchorend
-          }
-      }
-    \CTEX at hyperheadinghook
-  }
-\cs_new_protected:Npn \CTEX at gettitle #1
-  { }
-\ctex_at_end_package:nn { nameref }
-  {
-    \cs_gset_protected_nopar:Npn \CTEX at gettitle { \NR at gettitle }
-    \seq_map_inline:Nn \c__ctex_headings_cs_seq
-      {
-        \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
-          { \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_titlesec_hook:
-  {
-    \@ifpackagewith { titlesec } { explicit }
-      {
-        \cs_set_eq:NN \__ctex_titlesec_format:Nn
-                      \__ctex_titlesec_format_explicit:Nn
-      }
-      { }
-    \clist_map_inline:nn
-      { indentafter , noindentafter , indentfirst , nonindentfirst }
-      {
-        \@ifpackagewith { titlesec } { ##1 }
-          {
-            \clist_map_break:n
-              { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n }
-          }
-          { }
-      }
-    \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1
-  {
-    \__ctex_titlesec_format:n {#1}
-    \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1}
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1
-  {
-    \cs_if_free:cF { ttlf@#1 }
-      { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2
-  {
-    \tl_set:Nx #1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \tl_tail:N #1
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2
-  {
-    \cs_set_nopar:Npx #1 ##1
-      {
-        \bool_if:cTF { CTEX@#2 at runin }
-          { \exp_not:N \ttlh at runin }
-          { \exp_not:N \ttlh at hang }
-        \exp_args:No \tl_tail:n { #1 { } }
-      }
-  }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2
-  { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } }
-\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6
-  {
-    \exp_not:n { {#1} {#2} {#3} {#4} }
-    { \bool_if:cTF { CTEX@#6 at afterindent } { \@ne } { \z@ } }
-  }
-\@ifpackageloaded { titlesec }
-  { }
-  {
-    \ctex_at_end_package:nn { titlesec }
-      {
-        \@ifpackagewith { titlesec } { loadonly }
-          { }
-          { \ctex_titlesec_hook: }
-      }
-  }
-\ctex_at_end_package:nn { titlesec }
-  {
-    \tl_set:Nn \ttl at chapterout { \typeout { \CTEXthechapter } }
-    \cs_if_free:NF \ttl at tocpart
-      {
-        \cs_set_protected_nopar:Npn \ttl at tocpart
-          { \tl_set:Nn \ttl at a { \CTEXthepart \hspace { 1em } } }
-      }
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      {
-        \cs_if_exist:cF { ttl at toc #1 }
-          {
-            \cs_new_protected_nopar:cpx { ttl at toc #1 }
-              {
-                \tl_set:Nn \exp_not:N \ttl at a
-                  {
-                    \exp_not:N \protect
-                    \exp_not:N \numberline { \exp_not:c { CTEXthe #1 } }
-                  }
-              }
-          }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\cs_new_protected_nopar:Npn \ctex_titleps_hook:
-  {
-    \ctex_patch_cmd:Nnn \ttl at settopmark
-      { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
-      {
-        \protect \@namedef { the#1 } { \@nameuse { the#1 } }
-        \CTEX at titlepslabel@set {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#1 } { } }
-      {
-        \protect \@namedef { the#1 } { }
-        \CTEX at titlepslabel@clear {#1}
-      }
-    \ctex_patch_cmd:Nnn \ttl at setsubmark
-      { \protect \@namedef { the#2 } { \@nameuse { the#2 } } }
-      {
-        \protect \@namedef { the#2 } { \@nameuse { the#2 } }
-        \CTEX at titlepslabel@set {#2}
-      }
-  }
-\group_end:
-\cs_new_nopar:Npn \CTEX at titlepslabel@set #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
-  }
-\cs_new_nopar:Npn \CTEX at titlepslabel@clear #1
-  {
-    \cs_if_free:cF { CTEXthe#1 }
-      { \protect \@namedef { CTEXthe#1 } { } }
-  }
-\ctex_at_end_package:nn { titlesec }
-  { \cs_if_free:NF \ttl at settopmark { \ctex_titleps_hook: } }
-\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
-\ctex_at_end_package:nn { titleps }
-  {
-    \cs_set_protected_nopar:Npn \ttl at setifthe #1
-      {
-        \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 }
-          {
-            \CTEXifname
-              { \protect \@firstoftwo }
-              { \protect \@secondoftwo }
-          }
-      }
-    \seq_map_function:NN \c__ctex_headings_seq \ttl at setifthe
-  }
-\cs_new_protected:Npn \CTEX at toc@width at n #1
-  {
-    \hbox_set:Nn \l__ctex_tmp_box {#1}
-    \dim_set:Nn \@tempdima
-      {
-        \dim_max:nn { \@tempdima }
-          { \box_wd:N \l__ctex_tmp_box + \f at size \p@ / 2 }
-      }
-  }
-\group_begin:
-\char_set_catcode_other:N \#
-\use:n
-  {
-    \group_end:
-    \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff }
-      { \CTEX at toc@width at n {#1} }
-      { }
-      { \ctex_patch_failure:N \numberline }
-    \@ifpackageloaded { tocloft }
-      { }
-      {
-        \ctex_at_end_package:nn { tocloft }
-          {
-            \ctex_preto_cmd:NnnTF \numberline
-              { \char_set_catcode_letter:n { 64 } }
-              { \CTEX at toc@width at n {#1} }
-              { }
-              { \ctex_patch_failure:N \numberline }
-          }
-      }
-  }
-\ctex_patch_cmd:Nnn \ps at headings
-  {
-    \ifnum \c at secnumdepth > \m at ne
-      \@chapapp \ \thechapter . ~ \ %
-    \fi
-  }
-  { \CTEXifname { \CTEXthechapter \quad } { } }
-\if at twoside
-  \ctex_patch_cmd:Nnn \ps at headings
-    { \ifnum \c at secnumdepth > \z@ \thesection . ~ \ \fi }
-    { \CTEXifname { \CTEXthesection \quad } { } }
-\fi:
-\ctex_at_end_package:nn { fancyhdr }
-  {
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \m at ne \@chapapp \ \thechapter . ~ \ \fi }
-      { \CTEXifname { \CTEXthechapter \quad } { } }
-    \ctex_patch_cmd:Nnn \ps at fancy
-      { \ifnum \c at secnumdepth > \z@ \thesection . ~ \ \fi }
-      { \CTEXifname { \CTEXthesection \quad } { } }
-  }
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
-  {
-    \protected at edef \@currentlabel
-      {
-        \cs_if_exist:cTF { CTEX at the#1 }
-          { \exp_args:cc { p@#1 } { CTEX at the#1 } }
-          { \exp_not:o { \@currentlabel } }
-      }
-  }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
-  {
-    \seq_map_inline:Nn \c__ctex_headings_seq
-      { \ctex_fix_varioref_label:n { ##1 } }
-  }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
-  {
-    \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
-  }
-\@ifpackageloaded { varioref }
-  { \ctex_varioref_hook: }
-  {
-    \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
-    \RenewDocumentCommand \refstepcounter { m }
-      {
-        \CTEX at save@refstepcounter {#1}
-        \CTEX at setcurrentlabel@n {#1}
-      }
-    \ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: }
-  }
-\ctex_scheme_input:o { \l__ctex_scheme_tl }
-%% 
-%%
-%% End of file `ctex-report.def'.

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctex.sty	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctex.sty	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `style,ctex')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,16 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{expl3}
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Chinese adapter in LaTeX (CTEX)}
 \ProvidesExplPackage{\ExplFileName}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \tl_const:Nx \c__ctex_version_tl
   { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } }
 \msg_new:nnnn { ctex } { subpackage-loaded }
@@ -50,11 +48,11 @@
 \msg_new:nnnn { ctex } { l3-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~bundles\\\\
+    Please~update~an~up-to-date~version~of~the~bundles\\\\
     `l3kernel'~and~`l3packages'\\\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
-\@ifpackagelater { expl3 } { 2019/03/05 } { }
+\@ifpackagelater { expl3 } { 2020/04/06 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
 \str_const:Nx \c__ctex_engine_str
   { \cs_if_exist:NTF \ngostype { aptex } { \c_sys_engine_str } }
@@ -68,11 +66,20 @@
   }
   { \msg_critical:nnx { ctex } { engine-not-supported } { \c__ctex_engine_str } }
 \RequirePackage { ctexhook , ctexpatch }
-\RequirePackage { fix-cm , everysel }
+\RequirePackage { fix-cm }
+\RequirePackage { everysel }
 \tl_clear_new:N \l__ctex_tmp_tl
 \int_new:N \l__ctex_tmp_int
 \box_new:N \l__ctex_tmp_box
 \dim_new:N \l__ctex_tmp_dim
+\cs_new_protected:Npn \ctex_define_option:n
+  { \keys_define:nn { ctex / option } }
+\cs_new_protected:Npn \ctex_define:n
+  { \keys_define:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:n
+  { \keys_set:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:nn #1
+  { \keys_set:nn { ctex / #1 } }
 \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3
   {
     \use:x
@@ -88,9 +95,9 @@
         #3
       }
   }
-\cs_new_protected_nopar:Npn \ctex_file_input:n #1
+\cs_new_protected:Npn \ctex_file_input:n #1
   { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
-\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
+\cs_new_protected:Npn \ctex_scheme_input:n #1
   {
     \ctex_file_wrapper:nnn
       { }
@@ -110,7 +117,7 @@
 \msg_new:nnnn { ctex } { package-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~package~`#1'\\
+    Please~update~an~up-to-date~version~of~the~package~`#1'\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
 \sys_if_output_pdf:TF
@@ -129,27 +136,35 @@
 \exp_last_unbraced:NNNNo
   \cs_new:Npn \__ctex_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop
     { \tl_if_empty:nT {#2} { \ccwd } }
-\tl_new:N \l__ctex_encoding_tl
-\tl_set:Nx \l__ctex_encoding_tl
-  { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
+\tl_new:N \g__ctex_encoding_tl
 \bool_new:N \g__ctex_zhmCJK_bool
 \tl_new:N \l__ctex_autoindent_tl
 \cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
 \cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
-\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfPackage }
+\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfPackage }
 \msg_new:nnn { ctex } { invalid-option }
   { Option~`\l_keys_key_tl'~is~invalid~in~current~mode. }
 \msg_new:nnn { ctex } { invalid-value }
   { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
+\cs_new_protected:Npn \ctex_deprecated_option:n
+  { \msg_warning:nnn { ctex } { deprecated-option } }
+\cs_new_protected:Npn \ctex_set_deprecated_option:n #1
+  {
+    \ctex_deprecated_option:n { Option~`#1'~is~set. }
+    \ctex_set:nn { option } {#1}
+  }
+\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
+  {
+    \msg_warning:nnxx { ctex } { deprecated-command }
+      { \token_to_str:N #1 } { \exp_not:n {#2} }
+  }
 \msg_new:nnn { ctex } { deprecated-option }
-  { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 }
+  { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
 \msg_new:nnn { ctex } { deprecated-command }
-  { Command~ #1 is~ deprecated.\\ #2 }
-\msg_new:nnn { ctex } { deprecated-environment }
-  { Environment~ `#1'~ is~ deprecated.\\ #2 }
+  { Command~`#1'~is~deprecated.\\ #2 }
 \int_new:N \g__ctex_font_size_int
-\int_set:Nn \g__ctex_font_size_int { -1 }
-\keys_define:nn { ctex / option }
+\int_gset:Nn \g__ctex_font_size_int { -1 }
+\ctex_define_option:n
   {
     zihao .choice: ,
     zihao .value_required:n = true ,
@@ -156,18 +171,8 @@
     zihao /     5  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
     zihao /    -4  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
     zihao / false  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
-    c5size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=5'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = 5 }
-      } ,
-    cs4size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=-4'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = -4 }
-      } ,
+    c5size  .code:n = { \ctex_set_deprecated_option:n { zihao =  5 } } ,
+    cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
     c5size  .value_forbidden:n = true ,
     cs4size .value_forbidden:n = true ,
     linespread  .fp_set:N = \l__ctex_line_spread_fp ,
@@ -192,56 +197,38 @@
       } ,
     indent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.~
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     indent .value_forbidden:n = true ,
     noindent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     noindent .value_forbidden:n = true ,
-    GBK  .code:n = { \tl_set:Nn \l__ctex_encoding_tl { GBK } } ,
-    UTF8 .code:n = { \tl_set:Nn \l__ctex_encoding_tl { UTF8 } } ,
-    GBK  .value_forbidden:n = true ,
-    UTF8 .value_forbidden:n = true ,
-    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
-    nofonts    .code:n =
+    GBK  .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \sys_if_engine_pdftex:TF
+          { \tl_gset:Nn \g__ctex_encoding_tl { GBK } }
           {
-            Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
+            \msg_warning:nn { ctex } { invalid-option }
+            \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
           }
-        \keys_set:nn { ctex / option } { fontset = none }
       } ,
-    adobefonts .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = adobe }
-      } ,
-    winfonts   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = windows }
-      } ,
+    UTF8 .code:n = { \tl_gset:Nn \g__ctex_encoding_tl { UTF8 } } ,
+    GBK  .value_forbidden:n = true ,
+    UTF8 .value_forbidden:n = true ,
+    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
+    nofonts    .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
+    adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
+    winfonts   .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
     nofonts    .value_forbidden:n = true ,
     winfonts   .value_forbidden:n = true ,
     adobefonts .value_forbidden:n = true ,
@@ -263,35 +250,21 @@
         \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
       } ,
     nozhmap   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zhmap=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { zhmap = false }
-      } ,
+      { \ctex_set_deprecated_option:n { zhmap = false } } ,
     nozhmap   .value_forbidden:n = true ,
     punct   .tl_set:N = \l__ctex_punct_tl ,
     punct  .default:n = { quanjiao } ,
     punct  .initial:n = { quanjiao } ,
-    nopunct   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `punct=plain'~ is~ set.  }
-        \keys_set:nn { ctex / option } { punct = plain }
-      } ,
+    nopunct   .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
     nopunct   .value_forbidden:n = true ,
     space .choices:nn =
       { true , auto , false }
       {
         \exp_args:Nx \ctex_at_end:n
-          { \keys_set:nn { ctex } { space = \l_keys_choice_tl } }
+          { \ctex_set:n { space = \l_keys_choice_tl } }
       } ,
     space  .default:n = { true } ,
-    nospace   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `space=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { space = false }
-      } ,
+    nospace   .code:n = { \ctex_deprecated_option:nn { space = false } } ,
     nospace   .value_forbidden:n = true ,
     heading .bool_set:N = \l__ctex_heading_bool ,
     sub3section .code:n =
@@ -303,35 +276,37 @@
     scheme .tl_set:N  = \l__ctex_scheme_tl ,
     scheme .default:n = { chinese } ,
     scheme .initial:n = { chinese } ,
-    cap    .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = chinese' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = chinese }
-      } ,
-    nocap  .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = plain' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = plain }
-      } ,
+    cap    .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
+    nocap  .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
     cap    .value_forbidden:n = true ,
     nocap  .value_forbidden:n = true ,
-    fntef    .code:n =
+    fntef .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `(xe)CJKfntef'~ package~ is~ always~ loaded. }
+        \sys_if_engine_xetex:TF
+          {
+            \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
+            \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
+          }
+          {
+            \sys_if_engine_pdftex:TF
+              {
+                \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
+                \ctex_at_end:n { \RequirePackage { CJKfntef } }
+              }
+              {
+                \ctex_deprecated_option:n
+                  { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
+              }
+          }
       } ,
     fancyhdr .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `fancyhdr'~ package~ is~ loaded. }
-        \RequirePackage { fancyhdr }
+        \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
+        \ctex_at_end:n { \RequirePackage { fancyhdr } }
       } ,
     hyperref .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `hyperref'~ package~ will~ be~ loaded. }
+        \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
         \ctex_at_end:n
           {
             \cs_if_exist:NF \hypersetup
@@ -354,34 +329,50 @@
         #1 .value_forbidden:n = true ,
       }
   }
-\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l__ctex_tmp_tl } } }
+\exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
 \tl_clear:N \l__ctex_tmp_tl
 \ctex_file_input:n { ctexopts.cfg }
 \ProcessKeysOptions { ctex / option }
+\msg_new:nnn { ctex } { pdftex-utf8 }
+  { UTF8~will~be~used~as~the~default~encoding. }
+\tl_if_empty:NT \g__ctex_encoding_tl
+  {
+    \sys_if_engine_pdftex:T
+      { \msg_warning:nn { ctex } { pdftex-utf8 } }
+    \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
+  }
 \@ifpackageloaded { hyperref }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \hypersetup {#1} }
   }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \PassOptionsToPackage {#1} { hyperref } }
   }
 \ctex_file_input:n { \c__ctex_engine_file_str }
-\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
-\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
+\NewDocumentCommand \ctexset { } { \ctex_set:n }
+\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
-      { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXsetup { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXsetup
+          { \ctexset {~#2~=~{~#1~}~}~is~set. }
+        \ctex_set:nn {#2} {#1}
+      }
   }
-\NewDocumentCommand \CTEXoptions { +o }
+\NewDocumentCommand \CTEXoptions { +O { } }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions }
-      { \ctexset~ {~ #1~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXoptions { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXoptions
+          { \ctexset {~#1~}~is~set. }
+        \ctex_set:n {#1}
+      }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     autoindent .choice: ,
     autoindent .default:n = { true } ,
@@ -399,9 +390,9 @@
       }
   }
 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
-\cs_new_protected_nopar:Npn \ctex_select_size:
+\cs_new_protected:Npn \ctex_select_size:
   { \cs_if_free:NTF \size at update { \ctex_update_size: } { \selectfont } }
-\cs_new_protected_nopar:Npn \ctex_update_size:
+\cs_new_protected:Npn \ctex_update_size:
   {
     \tl_if_eq:NNTF \l__ctex_ziju_tl \c__ctex_zero_tl
       {
@@ -415,7 +406,7 @@
 \tl_set_eq:NN \l__ctex_ziju_tl \c__ctex_zero_tl
 \ctex_add_to_selectfont:n
   { \cs_if_free:NF \size at update { \ctex_update_size: } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     linestretch .code:n =
       {
@@ -426,7 +417,7 @@
   }
 \tl_new:N \l__ctex_line_stretch_tl
 \tl_set:Nn \l__ctex_line_stretch_tl { \ccwd }
-\cs_new_protected_nopar:Npn \ctex_update_stretch:
+\cs_new_protected:Npn \ctex_update_stretch:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_tmp_dim { \l__ctex_line_stretch_tl }
@@ -461,7 +452,7 @@
         \ctex_update_ccglue:
       }
   }
-\cs_new_protected_nopar:Npn \ctex_update_parindent:
+\cs_new_protected:Npn \ctex_update_parindent:
   {
     \tl_if_empty:NF \l__ctex_autoindent_tl
       {
@@ -471,12 +462,12 @@
   }
 \NewDocumentCommand \ziju { m }
   { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ziju:n #1
+\cs_new_protected:Npn \ctex_ziju:n #1
   {
     \tl_set:Nx \l__ctex_ziju_tl { \fp_eval:n {#1} }
     \ctex_select_size:
   }
-\cs_new_protected_nopar:Npn \ctex_update_ziju:
+\cs_new_protected:Npn \ctex_update_ziju:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_ziju_dim { \l__ctex_ziju_tl \ccwd }
@@ -508,19 +499,20 @@
 \dim_new:N \l__ctex_ziju_dim
 \NewDocumentCommand \CTEXindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent }
-      { \parindent is~ set~ to~ 2\ccwd. }
-    \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd }
+    \ctex_deprecated_command:Nn \CTEXindent
+      { \parindent is~set~to~2\ccwd. }
+    \ctex_update_ccwd:
+    \dim_set:Nn \parindent { 2 \ccwd }
   }
 \NewDocumentCommand \CTEXnoindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent }
-      { \parindent is~ set~ to~ 0pt. }
+    \ctex_deprecated_command:Nn \CTEXnoindent
+      { \parindent is~set~to~0pt. }
     \dim_zero:N \parindent
   }
-\PassOptionsToPackage { encoding = \l__ctex_encoding_tl } { zhnumber }
+\PassOptionsToPackage { encoding = \g__ctex_encoding_tl } { zhnumber }
 \RequirePackage { zhnumber }
-\cs_new_nopar:Npn \chinese { \zhnum_counter:n }
+\cs_new:Npn \chinese { \zhnum_counter:n }
 \cs_new_eq:NN \@chinese \@zhnum
 \cs_new_eq:NN \Chinese \chinese
 \cs_new_eq:NN \CTEXcounter \use_none:n
@@ -538,7 +530,7 @@
 \NewDocumentCommand \CTEXdigits { m m }
   { \protected at edef #1 { \zhdigits {#2} } }
 \cs_set_eq:NN \CTEX at todayold \today
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     today .choice: ,
     today / old     .code:n =
@@ -564,7 +556,7 @@
     \tl_new:N \proofname
     \tl_set:Nn \proofname { Proof }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     contentsname   .tl_set:N = \contentsname ,
     listfigurename .tl_set:N = \listfigurename ,
@@ -583,7 +575,7 @@
   }
 \tl_if_exist:NTF \insertcontinuationtext
   {
-    \keys_define:nn { ctex }
+    \ctex_define:n
       {
         algorithmname .tl_set:N = \algorithmname ,
         bibname       .tl_set:N = \bibname ,
@@ -593,13 +585,13 @@
   }
   {
     \tl_if_exist:NTF \bibname
-      { \keys_define:nn { ctex } { bibname .tl_set:N = \bibname } }
+      { \ctex_define:n { bibname .tl_set:N = \bibname } }
       {
         \tl_if_exist:NTF \refname
-          { \keys_define:nn { ctex } { bibname .tl_set:N = \refname } }
+          { \ctex_define:n { bibname .tl_set:N = \refname } }
           {
             \msg_warning:nn { ctex } { ctexbibname }
-            \keys_define:nn { ctex } { bibname .tl_set:N = \ctexbibname }
+            \ctex_define:n { bibname .tl_set:N = \ctexbibname }
           }
       }
   }
@@ -629,12 +621,12 @@
           { \tl_const:Nn \c__ctex_class_tl { article } }
         \msg_warning:nnx { ctex } { not-standard-class } { \c__ctex_class_tl }
       }
-    \ctex_file_input:n { ctex- \c__ctex_class_tl .def }
+    \ctex_file_input:n { ctex-heading- \c__ctex_class_tl .def }
   }
   { \ctex_scheme_input:o { \l__ctex_scheme_tl } }
 \NewDocumentCommand \zihao { m }
   { \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_zihao:n #1
+\cs_new_protected:Npn \ctex_zihao:n #1
   {
     \prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl
       { \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont }
@@ -649,7 +641,7 @@
   }
 \prop_new:N \c__ctex_font_size_prop
 \seq_new:N \c__ctex_font_size_seq
-\cs_new_protected_nopar:Npn \__ctex_save_font_size:nn #1#2
+\cs_new_protected:Npn \__ctex_save_font_size:nn #1#2
   {
     \use:x
       {
@@ -681,12 +673,12 @@
     {  0 } { 42   bp }
   }
   { \__ctex_save_font_size:nn #1 }
-\cs_new_protected_nopar:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
   {
     \__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} }
     \exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl
   }
-\cs_new_protected_nopar:Npn \__ctex_get_font_sizes:Nn #1#2
+\cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2
   {
     \tl_clear:N #1
     \tl_map_inline:nn {#2}
@@ -723,14 +715,14 @@
       { \msg_error:nnn { ctex } { fontsize } {#2} }
   }
 \cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4
-  { \cs_set_protected_nopar:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
-\if_case:w \g__ctex_font_size_int
-  \ctex_file_input:n { ctex-c5size.clo }
-\or:
-  \ctex_file_input:n { ctex-cs4size.clo }
-\fi:
-\fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp }
+  { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
+\int_case:nn { \g__ctex_font_size_int }
   {
+    { 0 } { \ctex_file_input:n { ctex-c5size.clo } }
+    { 1 } { \ctex_file_input:n { ctex-cs4size.clo } }
+  }
+\fp_if_nan:nF { \l__ctex_line_spread_fp }
+  {
     \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp }
     \group_begin: \footnotesize \exp_args:NNNo \group_end:
     \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox }
@@ -740,47 +732,76 @@
   { C \TeX }
 \ctex_at_end_package:nn { hyperref }
   { \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     captiondelimiter .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           { You~can~load~the~package~`caption'~to~get~its~functionality. }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_fontset_error:n #1
+\cs_new_protected:Npn \ctex_fontset_error:n #1
   { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} }
 \msg_new:nnn { ctex } { fontset-unavailable }
   { CTeX~fontset~`#1'~is~unavailable~in~current~mode. }
-\cs_new_protected_nopar:Npn \ctex_load_fontset:
+\cs_new:Npx \ctex_fontset_case:nnn #1#2#3
   {
-    \tl_if_empty:NTF \g__ctex_fontset_tl
+    \sys_if_engine_pdftex:TF
+      {#1}
+      { \sys_if_engine_uptex:TF {#2} {#3} }
+  }
+\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4
+  {
+    \sys_if_engine_pdftex:TF
+      { \sys_if_output_pdf:TF   {#1} {#2} }
+      { \sys_if_engine_uptex:TF {#3} {#4} }
+  }
+\cs_new_protected:Npn \ctex_detect_platform:
+  {
+    \sys_if_platform_windows:TF
+      { \tl_gset:Nn \g__ctex_fontset_tl { windows } }
       {
-        \ctex_detected_platform:
-        \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
+        \ctex_if_platform_macos:TF
+          { \tl_gset:Nn \g__ctex_fontset_tl { mac    } }
+          { \tl_gset:Nn \g__ctex_fontset_tl { fandol } }
       }
+  }
+\cs_new_protected:Npn \ctex_if_platform_macos:TF
+  { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
+\cs_new_protected:Npn \ctex_load_fontset:
+  {
+    \tl_if_empty:NTF \g__ctex_fontset_tl
+      { \ctex_detect_platform: }
       {
-        \file_if_exist:nTF { ctex-fontset- \g__ctex_fontset_tl .def }
-          { \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def } }
+        \bool_lazy_or:nnTF
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsnew } }
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsold } }
           {
-            \use:x
+            \msg_warning:nnxx { ctex } { deprecated-fontset }
+              { \g__ctex_fontset_tl } { windows }
+            \tl_gset:Nn \g__ctex_fontset_tl { windows }
+          }
+          {
+            \file_if_exist:nF { ctex-fontset- \g__ctex_fontset_tl .def }
               {
-                \ctex_detected_platform:
-                \msg_error:nnxx { ctex } { fontset-not-found }
-                  { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                \use:x
+                  {
+                    \ctex_detect_platform:
+                    \msg_error:nnxx { ctex } { fontset-not-found }
+                      { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                  }
               }
-            \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
           }
       }
+    \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
   }
-\@onlypreamble \ctex_load_fontset:
+\msg_new:nnn { ctex } { deprecated-fontset }
+  { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. }
 \msg_new:nnnn { ctex } { fontset-not-found }
-  {
-    CTeX~fontset~`#1'~could~not~be~found.\\
-    Fontset~`#2'~will~be~used~instead.
-  }
+  { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. }
   { You~may~run~`mktexlsr'~firstly. }
-\keys_define:nn { ctex }
+\@onlypreamble \ctex_load_fontset:
+\ctex_define:n
   {
     fontset .code:n =
       {
@@ -810,14 +831,16 @@
   }
   { Only~one~fontset~can~be~loaded~in~the~preamble. }
 \msg_new:nnn { ctex } { fontset-only-preamble }
-  {
-    The~ `fontset'~ option~ can~ be~ used~ only~ in~ preamble.
-  }
+  { The~`fontset'~option~can~be~used~only~in~preamble. }
 \str_if_eq:onF { \g__ctex_fontset_tl } { none }
   { \ctex_load_fontset: }
 \ctex_at_end:n { \ctex_file_input:n { ctex.cfg } }
 %% 
-%%     This package consists of the file  ctex.dtx,
+%%     This package consists of the files ctex.dtx,
+%%                                        ctxdoc.cls,
+%%                                        ctxdocstrip.tex,
+%%                                        ctex-zhconv.lua,
+%%                                        ctex-zhconv-make.lua,
 %%                  and the derived files ctex.pdf,
 %%                                        ctex.ins,
 %%                                        ctex.sty,
@@ -827,16 +850,15 @@
 %%                                        ctexbook.cls,
 %%                                        ctexrep.cls,
 %%                                        ctexbeamer.cls,
-%%                                        ctxdoc.cls,
 %%                                        ctexcap.sty,
 %%                                        ctexhook.sty,
 %%                                        ctexpatch.sty,
 %%                                        ctex-c5size.clo,
 %%                                        ctex-cs4size.clo,
-%%                                        ctex-article.def,
-%%                                        ctex-book.def,
-%%                                        ctex-report.def,
-%%                                        ctex-beamer.def,
+%%                                        ctex-heading-article.def,
+%%                                        ctex-heading-book.def,
+%%                                        ctex-heading-report.def,
+%%                                        ctex-heading-beamer.def,
 %%                                        ctex-scheme-plain.def,
 %%                                        ctex-scheme-plain-article.def,
 %%                                        ctex-scheme-plain-book.def,
@@ -851,6 +873,7 @@
 %%                                        ctex-name-utf8.cfg,
 %%                                        ctex.cfg,
 %%                                        ctexopts.cfg,
+%%                                        ctexbackend.cfg,
 %%                                        ctex-engine-pdftex.def,
 %%                                        ctex-engine-xetex.def,
 %%                                        ctex-engine-luatex.def,
@@ -868,26 +891,25 @@
 %%                                        jt2zhrm.fd,
 %%                                        jt2zhsf.fd,
 %%                                        jt2zhtt.fd,
-%%                                        ctex-fontset-windows.def,
-%%                                        ctex-fontset-windowsnew.def,
-%%                                        ctex-fontset-windowsold.def,
 %%                                        ctex-fontset-adobe.def,
 %%                                        ctex-fontset-fandol.def,
+%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-mac.def,
 %%                                        ctex-fontset-macnew.def,
 %%                                        ctex-fontset-macold.def,
-%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-ubuntu.def,
+%%                                        ctex-fontset-windows.def,
 %%                                        ctexspa.def,
 %%                                        ctexpunct.spa,
 %%                                        ctexmakespa.tex,
 %%                                        ctexspamacro.tex,
-%%                                        ctxdocstrip.tex,
 %%                                        zhadobefonts.tex,
 %%                                        zhfandolfonts.tex,
 %%                                        zhfounderfonts.tex,
+%%                                        zhmacfonts.tex,
 %%                                        zhubuntufonts.tex,
 %%                                        zhwindowsfonts.tex,
+%%                                        ctex-zhconv-index.lua,
 %%                                        translator-theorem-dictionary-ChineseGBK.dict,
 %%                                        translator-theorem-dictionary-ChineseUTF8.dict, and
 %%                                        README.md.

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctexart.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctexart.cls	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctexart.cls	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `class,article')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,17 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \NeedsTeXFormat{LaTeX2e}
+\input{ctexbackend.cfg}
 \RequirePackage{expl3}
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Chinese adapter for class article (CTEX)}
 \ProvidesExplClass{ctexart}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \tl_const:Nx \c__ctex_version_tl
   { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } }
 \cs_new_eq:cN { ver at ctex.        \@pkgextension } \c__ctex_version_tl
@@ -42,11 +41,11 @@
 \msg_new:nnnn { ctex } { l3-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~bundles\\\\
+    Please~update~an~up-to-date~version~of~the~bundles\\\\
     `l3kernel'~and~`l3packages'\\\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
-\@ifpackagelater { expl3 } { 2019/03/05 } { }
+\@ifpackagelater { expl3 } { 2020/04/06 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
 \@ifpackagelater { l3keys2e } { 2015/12/20 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } }
@@ -62,11 +61,20 @@
   }
   { \msg_critical:nnx { ctex } { engine-not-supported } { \c__ctex_engine_str } }
 \RequirePackage { ctexhook , ctexpatch }
-\RequirePackage { fix-cm , everysel }
+\RequirePackage { fix-cm }
+\RequirePackage { everysel }
 \tl_clear_new:N \l__ctex_tmp_tl
 \int_new:N \l__ctex_tmp_int
 \box_new:N \l__ctex_tmp_box
 \dim_new:N \l__ctex_tmp_dim
+\cs_new_protected:Npn \ctex_define_option:n
+  { \keys_define:nn { ctex / option } }
+\cs_new_protected:Npn \ctex_define:n
+  { \keys_define:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:n
+  { \keys_set:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:nn #1
+  { \keys_set:nn { ctex / #1 } }
 \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3
   {
     \use:x
@@ -82,9 +90,9 @@
         #3
       }
   }
-\cs_new_protected_nopar:Npn \ctex_file_input:n #1
+\cs_new_protected:Npn \ctex_file_input:n #1
   { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
-\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
+\cs_new_protected:Npn \ctex_scheme_input:n #1
   {
     \ctex_file_wrapper:nnn
       { }
@@ -104,7 +112,7 @@
 \msg_new:nnnn { ctex } { package-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~package~`#1'\\
+    Please~update~an~up-to-date~version~of~the~package~`#1'\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
 \sys_if_output_pdf:TF
@@ -123,28 +131,36 @@
 \exp_last_unbraced:NNNNo
   \cs_new:Npn \__ctex_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop
     { \tl_if_empty:nT {#2} { \ccwd } }
-\tl_new:N \l__ctex_encoding_tl
-\tl_set:Nx \l__ctex_encoding_tl
-  { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
+\tl_new:N \g__ctex_encoding_tl
 \bool_new:N \g__ctex_zhmCJK_bool
 \tl_new:N \l__ctex_autoindent_tl
 \cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
 \cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
-\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfClass }
+\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass }
 \clist_new:N \g__ctex_std_options_clist
 \msg_new:nnn { ctex } { invalid-option }
   { Option~`\l_keys_key_tl'~is~invalid~in~current~mode. }
 \msg_new:nnn { ctex } { invalid-value }
   { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
+\cs_new_protected:Npn \ctex_deprecated_option:n
+  { \msg_warning:nnn { ctex } { deprecated-option } }
+\cs_new_protected:Npn \ctex_set_deprecated_option:n #1
+  {
+    \ctex_deprecated_option:n { Option~`#1'~is~set. }
+    \ctex_set:nn { option } {#1}
+  }
+\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
+  {
+    \msg_warning:nnxx { ctex } { deprecated-command }
+      { \token_to_str:N #1 } { \exp_not:n {#2} }
+  }
 \msg_new:nnn { ctex } { deprecated-option }
-  { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 }
+  { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
 \msg_new:nnn { ctex } { deprecated-command }
-  { Command~ #1 is~ deprecated.\\ #2 }
-\msg_new:nnn { ctex } { deprecated-environment }
-  { Environment~ `#1'~ is~ deprecated.\\ #2 }
+  { Command~`#1'~is~deprecated.\\ #2 }
 \int_new:N \g__ctex_font_size_int
-\int_set:Nn \g__ctex_font_size_int { -1 }
-\keys_define:nn { ctex / option }
+\int_gset:Nn \g__ctex_font_size_int { -1 }
+\ctex_define_option:n
   {
     zihao .choice: ,
     zihao .value_required:n = true ,
@@ -151,18 +167,8 @@
     zihao /     5  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
     zihao /    -4  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
     zihao / false  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
-    c5size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=5'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = 5 }
-      } ,
-    cs4size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=-4'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = -4 }
-      } ,
+    c5size  .code:n = { \ctex_set_deprecated_option:n { zihao =  5 } } ,
+    cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
     c5size  .value_forbidden:n = true ,
     cs4size .value_forbidden:n = true ,
     linespread  .fp_set:N = \l__ctex_line_spread_fp ,
@@ -187,56 +193,38 @@
       } ,
     indent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.~
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     indent .value_forbidden:n = true ,
     noindent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     noindent .value_forbidden:n = true ,
-    GBK  .code:n = { \tl_set:Nn \l__ctex_encoding_tl { GBK } } ,
-    UTF8 .code:n = { \tl_set:Nn \l__ctex_encoding_tl { UTF8 } } ,
-    GBK  .value_forbidden:n = true ,
-    UTF8 .value_forbidden:n = true ,
-    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
-    nofonts    .code:n =
+    GBK  .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \sys_if_engine_pdftex:TF
+          { \tl_gset:Nn \g__ctex_encoding_tl { GBK } }
           {
-            Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
+            \msg_warning:nn { ctex } { invalid-option }
+            \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
           }
-        \keys_set:nn { ctex / option } { fontset = none }
       } ,
-    adobefonts .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = adobe }
-      } ,
-    winfonts   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = windows }
-      } ,
+    UTF8 .code:n = { \tl_gset:Nn \g__ctex_encoding_tl { UTF8 } } ,
+    GBK  .value_forbidden:n = true ,
+    UTF8 .value_forbidden:n = true ,
+    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
+    nofonts    .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
+    adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
+    winfonts   .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
     nofonts    .value_forbidden:n = true ,
     winfonts   .value_forbidden:n = true ,
     adobefonts .value_forbidden:n = true ,
@@ -258,35 +246,21 @@
         \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
       } ,
     nozhmap   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zhmap=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { zhmap = false }
-      } ,
+      { \ctex_set_deprecated_option:n { zhmap = false } } ,
     nozhmap   .value_forbidden:n = true ,
     punct   .tl_set:N = \l__ctex_punct_tl ,
     punct  .default:n = { quanjiao } ,
     punct  .initial:n = { quanjiao } ,
-    nopunct   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `punct=plain'~ is~ set.  }
-        \keys_set:nn { ctex / option } { punct = plain }
-      } ,
+    nopunct   .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
     nopunct   .value_forbidden:n = true ,
     space .choices:nn =
       { true , auto , false }
       {
         \exp_args:Nx \ctex_at_end:n
-          { \keys_set:nn { ctex } { space = \l_keys_choice_tl } }
+          { \ctex_set:n { space = \l_keys_choice_tl } }
       } ,
     space  .default:n = { true } ,
-    nospace   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `space=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { space = false }
-      } ,
+    nospace   .code:n = { \ctex_deprecated_option:nn { space = false } } ,
     nospace   .value_forbidden:n = true ,
     heading .bool_set:N = \l__ctex_heading_bool ,
     sub3section .code:n =
@@ -298,35 +272,37 @@
     scheme .tl_set:N  = \l__ctex_scheme_tl ,
     scheme .default:n = { chinese } ,
     scheme .initial:n = { chinese } ,
-    cap    .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = chinese' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = chinese }
-      } ,
-    nocap  .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = plain' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = plain }
-      } ,
+    cap    .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
+    nocap  .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
     cap    .value_forbidden:n = true ,
     nocap  .value_forbidden:n = true ,
-    fntef    .code:n =
+    fntef .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `(xe)CJKfntef'~ package~ is~ always~ loaded. }
+        \sys_if_engine_xetex:TF
+          {
+            \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
+            \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
+          }
+          {
+            \sys_if_engine_pdftex:TF
+              {
+                \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
+                \ctex_at_end:n { \RequirePackage { CJKfntef } }
+              }
+              {
+                \ctex_deprecated_option:n
+                  { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
+              }
+          }
       } ,
     fancyhdr .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `fancyhdr'~ package~ is~ loaded. }
-        \RequirePackage { fancyhdr }
+        \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
+        \ctex_at_end:n { \RequirePackage { fancyhdr } }
       } ,
     hyperref .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `hyperref'~ package~ will~ be~ loaded. }
+        \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
         \ctex_at_end:n
           {
             \cs_if_exist:NF \hypersetup
@@ -352,9 +328,9 @@
         #1 .value_forbidden:n = true ,
       }
   }
-\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l__ctex_tmp_tl } } }
+\exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
 \tl_clear:N \l__ctex_tmp_tl
-\keys_define:nn { ctex / option }
+\ctex_define_option:n
   {
     unknown .code:n =
       { \clist_gput_right:No \g__ctex_std_options_clist { \CurrentOption } }
@@ -361,38 +337,54 @@
   }
 \ctex_file_input:n { ctexopts.cfg }
 \ProcessKeysOptions { ctex / option }
-\if_case:w \g__ctex_font_size_int
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt }
-\or:
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt }
-\fi:
+\msg_new:nnn { ctex } { pdftex-utf8 }
+  { UTF8~will~be~used~as~the~default~encoding. }
+\tl_if_empty:NT \g__ctex_encoding_tl
+  {
+    \sys_if_engine_pdftex:T
+      { \msg_warning:nn { ctex } { pdftex-utf8 } }
+    \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
+  }
+\int_case:nn { \g__ctex_font_size_int }
+  {
+    { 0 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt } }
+    { 1 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt } }
+  }
 \tl_const:Nn \c__ctex_class_tl { article }
 \PassOptionsToClass { \g__ctex_std_options_clist } { article }
 \LoadClass { article }
 \@ifpackageloaded { hyperref }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \hypersetup {#1} }
   }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \PassOptionsToPackage {#1} { hyperref } }
   }
 \ctex_file_input:n { \c__ctex_engine_file_str }
-\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
-\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
+\NewDocumentCommand \ctexset { } { \ctex_set:n }
+\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
-      { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXsetup { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXsetup
+          { \ctexset {~#2~=~{~#1~}~}~is~set. }
+        \ctex_set:nn {#2} {#1}
+      }
   }
-\NewDocumentCommand \CTEXoptions { +o }
+\NewDocumentCommand \CTEXoptions { +O { } }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions }
-      { \ctexset~ {~ #1~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXoptions { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXoptions
+          { \ctexset {~#1~}~is~set. }
+        \ctex_set:n {#1}
+      }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     autoindent .choice: ,
     autoindent .default:n = { true } ,
@@ -410,9 +402,9 @@
       }
   }
 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
-\cs_new_protected_nopar:Npn \ctex_select_size:
+\cs_new_protected:Npn \ctex_select_size:
   { \cs_if_free:NTF \size at update { \ctex_update_size: } { \selectfont } }
-\cs_new_protected_nopar:Npn \ctex_update_size:
+\cs_new_protected:Npn \ctex_update_size:
   {
     \tl_if_eq:NNTF \l__ctex_ziju_tl \c__ctex_zero_tl
       {
@@ -426,7 +418,7 @@
 \tl_set_eq:NN \l__ctex_ziju_tl \c__ctex_zero_tl
 \ctex_add_to_selectfont:n
   { \cs_if_free:NF \size at update { \ctex_update_size: } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     linestretch .code:n =
       {
@@ -437,7 +429,7 @@
   }
 \tl_new:N \l__ctex_line_stretch_tl
 \tl_set:Nn \l__ctex_line_stretch_tl { \ccwd }
-\cs_new_protected_nopar:Npn \ctex_update_stretch:
+\cs_new_protected:Npn \ctex_update_stretch:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_tmp_dim { \l__ctex_line_stretch_tl }
@@ -472,7 +464,7 @@
         \ctex_update_ccglue:
       }
   }
-\cs_new_protected_nopar:Npn \ctex_update_parindent:
+\cs_new_protected:Npn \ctex_update_parindent:
   {
     \tl_if_empty:NF \l__ctex_autoindent_tl
       {
@@ -482,12 +474,12 @@
   }
 \NewDocumentCommand \ziju { m }
   { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ziju:n #1
+\cs_new_protected:Npn \ctex_ziju:n #1
   {
     \tl_set:Nx \l__ctex_ziju_tl { \fp_eval:n {#1} }
     \ctex_select_size:
   }
-\cs_new_protected_nopar:Npn \ctex_update_ziju:
+\cs_new_protected:Npn \ctex_update_ziju:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_ziju_dim { \l__ctex_ziju_tl \ccwd }
@@ -519,19 +511,20 @@
 \dim_new:N \l__ctex_ziju_dim
 \NewDocumentCommand \CTEXindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent }
-      { \parindent is~ set~ to~ 2\ccwd. }
-    \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd }
+    \ctex_deprecated_command:Nn \CTEXindent
+      { \parindent is~set~to~2\ccwd. }
+    \ctex_update_ccwd:
+    \dim_set:Nn \parindent { 2 \ccwd }
   }
 \NewDocumentCommand \CTEXnoindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent }
-      { \parindent is~ set~ to~ 0pt. }
+    \ctex_deprecated_command:Nn \CTEXnoindent
+      { \parindent is~set~to~0pt. }
     \dim_zero:N \parindent
   }
-\PassOptionsToPackage { encoding = \l__ctex_encoding_tl } { zhnumber }
+\PassOptionsToPackage { encoding = \g__ctex_encoding_tl } { zhnumber }
 \RequirePackage { zhnumber }
-\cs_new_nopar:Npn \chinese { \zhnum_counter:n }
+\cs_new:Npn \chinese { \zhnum_counter:n }
 \cs_new_eq:NN \@chinese \@zhnum
 \cs_new_eq:NN \Chinese \chinese
 \cs_new_eq:NN \CTEXcounter \use_none:n
@@ -549,7 +542,7 @@
 \NewDocumentCommand \CTEXdigits { m m }
   { \protected at edef #1 { \zhdigits {#2} } }
 \cs_set_eq:NN \CTEX at todayold \today
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     today .choice: ,
     today / old     .code:n =
@@ -575,7 +568,7 @@
     \tl_new:N \proofname
     \tl_set:Nn \proofname { Proof }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     contentsname   .tl_set:N = \contentsname ,
     listfigurename .tl_set:N = \listfigurename ,
@@ -593,7 +586,7 @@
 \seq_new:N \c__ctex_headings_seq
 \seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
 \seq_gput_left:Nn \c__ctex_headings_seq { part }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
+\cs_new_protected:Npn \__ctex_initial_heading:n #1
   {
     \tl_new:c { CTEX at pre#1 }
     \tl_new:c { CTEX at post#1 }
@@ -623,7 +616,7 @@
         \group_end:
       }
   }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
+\cs_new_protected:Npn \__ctex_def_heading_keys:n #1
   {
     \tl_put_right:Nx \l__ctex_tmp_tl
       {
@@ -647,11 +640,8 @@
         #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
         #1 / hang         .initial:n = true ,
         #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
+        #1 / tocline      .cs_set:Np = \exp_not:c { CTEX@#1 at tocline}
+                                       \exp_not:n { ##1##2 } ,
         \__ctex_plus_key_aux:nn {#1} { break } ,
         \__ctex_plus_key_aux:nn {#1} { format } ,
         \__ctex_plus_key_aux:nn {#1} { nameformat } ,
@@ -661,7 +651,7 @@
         \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
       }
   }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
+\cs_new:Npn \__ctex_plus_key_aux:nn #1#2
   {
     #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
     #1 / #2 +   .code:n =
@@ -675,7 +665,7 @@
 \cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
   {
     \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
+    \tl_if_novalue:nTF {#3}
       { \tl_clear:c { CTEX at post#1 } }
       { \tl_set:cn { CTEX at post#1 } {#3} }
   }
@@ -686,45 +676,57 @@
     \__ctex_initial_heading:n {#1}
     \__ctex_def_heading_keys:n {#1}
   }
-\use:x
+\exp_args:NNo \group_end: \ctex_define:n { \l__ctex_tmp_tl }
+\cs_new_protected:Npn \CTEX at heading@format at initial
   {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
+    \normalfont
+    \tl_clear:N \l__ctex_autoindent_tl
+    \int_set:Nn \tex_interlinepenalty:D { 10 000 }
+    \tex_noindent:D
   }
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
+\cs_new_protected:Npn \ctex_indent_box:n #1
   {
+    \dim_set:Nn \tex_parindent:D {#1}
+    \__ctex_insert_indent:
+  }
+\cs_new_protected:Npn \__ctex_insert_indent:
+  {
+    \dim_compare:nNnF \tex_parindent:D = \c_zero_dim
+      { \tex_indent:D }
+  }
+\cs_new_eq:NN \CTEX at indentbox \ctex_indent_box:n
+\cs_new_protected:Npn \CTEX at fixheadingskip
+  {
     \par
     \dim_set:Nn \tex_prevdepth:D { -1000pt }
     \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
   }
 \skip_new:N \l__ctex_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
+\cs_new_protected:Npn \CTEX at setheadingskip
   { \skip_set:Nn \l__ctex_heading_skip }
 \cs_new_eq:NN \CTEX at headingskip \l__ctex_heading_skip
 \ProvideDocumentCommand \partmark { m }
   { \markboth { } { } }
 \cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
+\cs_new_protected:Npn \CTEX at ifnametrue
   { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
+\cs_new_protected:Npn \CTEX at ifnamefalse
   { \cs_set_eq:NN \CTEXifname \use_ii:nn }
 \cs_new_protected:Npn \CTEX at addtocline #1#2
   { \addcontentsline { toc } {#1} { \use:c { CTEX@#1 at tocline } {#1} {#2} } }
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l__ctex_autoindent_tl }
 \renewcommand\part{%
-   \if at noskipsec \leavevmode \fi
-   \par
-   \CTEX at part@break
-   \CTEX at setheadingskip \CTEX at part@beforeskip
-   \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-   \addvspace \CTEX at headingskip
-   \ifodd \CTEX at part@afterindent
-     \@afterindenttrue
-   \else
-     \@afterindentfalse
-   \fi
-   \secdef\@part\@spart}
+  \if at noskipsec \leavevmode \fi
+  \par
+  \CTEX at part@break
+  \CTEX at setheadingskip \CTEX at part@beforeskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \addvspace \CTEX at headingskip
+  \ifodd \CTEX at part@afterindent
+   \@afterindenttrue
+  \else
+   \@afterindentfalse
+  \fi
+  \secdef\@part\@spart}
 \def\@part[#1]#2{%
   \ifnum \c at secnumdepth >\m at ne
     \ifodd \CTEX at part@numbering
@@ -740,14 +742,15 @@
   \fi
   \CTEX at gettitle{#1}%
   \CTEX at addtocline{part}{#1}%
-  {\interlinepenalty \@M
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-   \CTEX at part@titleformat{#2}%
-   \partmark{#1}%
-   \CTEX at part@aftertitle}%
+  \partmark{#1}%
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}%
+        {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
+        \CTEX at part@titleformat{#2}%
+        \CTEX at part@aftertitle}\par
+  \endgroup
   \nobreak
   \CTEX at setheadingskip \CTEX at part@afterskip
   \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
@@ -754,20 +757,21 @@
   \vskip \CTEX at headingskip
   \@afterheading}
 \def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-     \nobreak
-     \CTEX at setheadingskip \CTEX at part@afterskip
-     \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-     \vskip \CTEX at headingskip
-     \@afterheading}
+  \CTEX at ifnamefalse
+  \CTEX at makeanchor@spart{part*}%
+  \CTEX at gettitle{#1}%
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}{}%
+      \CTEX at part@titleformat{#1}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
+  \nobreak
+  \CTEX at setheadingskip \CTEX at part@afterskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip
+  \@afterheading}
 \def\@startsection#1#2#3#4#5#6{%
   \if at noskipsec \leavevmode \fi
   \par
@@ -810,22 +814,22 @@
   \CTEX at gettitle{#7}%
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-        \interlinepenalty \@M
+        \CTEX at sectionhang{#3}{\@svsec}%
         \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
+        \csname CTEX@#1 at aftertitle\endcsname}\par
     \endgroup
     \csname #1mark\endcsname{#7}%
     \CTEX at addtocline{#1}{#7}%
   \else
     \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}}%
+      #6{%
+        {\CTEX at indentbox{#3}}\@svsec
+        \csname CTEX@#1 at titleformat\endcsname{#8}%
+        \csname CTEX@#1 at aftertitle\endcsname}%
+      \csname #1mark\endcsname{#7}%
+      \CTEX at addtocline{#1}{#7}}%
   \fi
   \@xsect{#5}}
 \def\@ssect#1#2#3#4#5{%
@@ -833,15 +837,15 @@
   \CTEX at gettitle{#5}%
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-          \interlinepenalty \@M
+        \CTEX at sectionhang{#1}{}%
           \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
+          \CTEX at aftertitle}\par
     \endgroup
   \else
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
+    \def\@svsechd{#4{{\CTEX at indentbox{#1}}%
+      \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
   \fi
   \@xsect{#3}}
 \def\@xsect#1{%
@@ -861,7 +865,7 @@
         \clubpenalty\@M
         \begingroup \@svsechd \endgroup
         \unskip
-        \hskip\glueexpr #1\relax
+        \CTEX at heading@glue{#1}%
       \else
         \clubpenalty \@clubpenalty
         \everypar{}%
@@ -868,26 +872,41 @@
       \fi}%
   \fi
   \ignorespaces}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
+\cs_new_protected:Npn \CTEX at headinghang #1
   {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \__ctex_indent_aux: #2 } }
-      {#2}
+    \ctex_heading_hang:cnn
+      { CTEX@#1 at hang }
+      { \use:c { CTEX@#1 at indent } }
   }
-\cs_new_protected_nopar:Npn \__ctex_indent_aux:
+\cs_new_protected:Npn \CTEX at sectionhang
+  { \ctex_heading_hang:Nnn \CTEX at hang }
+\cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3
   {
-    \dim_compare:nNnF \parindent = \c_zero_dim
-      { \skip_horizontal:n { \parindent } }
+    \dim_set:Nn \tex_parindent:D {#2}
+    \bool_if:NTF #1
+      { \ctex_hang_from:n }
+      { \use:n }
+      { \__ctex_insert_indent: #3 }
   }
-\cs_new_protected_nopar:Npn \CTEX at hangfrom
+\cs_new_protected:Npn \ctex_hang_from:n #1
   {
-    \bool_if:NTF \CTEX at hang
-      { \@hangfrom }
-      { \noindent \use:n }
+    \tex_noindent:D
+    \hbox_set:Nn \l__ctex_tmp_box {#1}
+    \tex_hangindent:D = \box_wd:N \l__ctex_tmp_box
+    \box_use_drop:N \l__ctex_tmp_box
   }
-\cs_new_protected_nopar:Npn \CTEX at update@sectionformat at n #1
+\cs_generate_variant:Nn \ctex_heading_hang:Nnn { c }
+\cs_new_protected:Npn \ctex_heading_glue:n #1
   {
+    \group_begin:
+      \skip_set:Nn \l__ctex_heading_skip {#1}
+      \dim_compare:nNnF \l__ctex_heading_skip = \c_zero_dim
+        { \skip_horizontal:N \l__ctex_heading_skip }
+    \group_end:
+  }
+\cs_new_eq:NN \CTEX at heading@glue \ctex_heading_glue:n
+\cs_new_protected:Npn \CTEX at update@sectionformat at n #1
+  {
     \cs_set_eq:Nc \CTEX at titleformat@n { CTEX@#1 at titleformat }
     \cs_set_eq:Nc \CTEX at aftertitle    { CTEX@#1 at aftertitle }
     \cs_set_eq:Nc \CTEX at afterindent   { CTEX@#1 at afterindent }
@@ -908,7 +927,7 @@
       { }
     #2
   }
-\cs_new_nopar:Npn \CTEXnumberline #1
+\cs_new:Npn \CTEXnumberline #1
   {
     \CTEXifname
       { \protect \numberline { \use:c { CTEXthe #1 } } }
@@ -918,7 +937,7 @@
 \seq_map_inline:Nn \c__ctex_section_headings_seq
   {
     \int_incr:N \l__ctex_tmp_int
-    \cs_gset_protected_nopar:cpx  {#1}
+    \cs_gset_protected:cpx  {#1}
       {
         \exp_not:N \@startsection {#1}
           { \int_use:N \l__ctex_tmp_int }
@@ -930,7 +949,7 @@
     \cs_new:cpn { CTEX@#1 at tocline } ##1##2
       { \CTEXnumberline { ##1 } ##2 }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     appendix                .meta:nn = { ctex / appendix } {#1} ,
     appendix / name          .code:n =
@@ -942,7 +961,7 @@
 \tl_new:N \CTEX at preappendix
 \tl_new:N \CTEX at postappendix
 \cs_new_eq:NN \CTEX at save@appendix \appendix
-\cs_gset_protected_nopar:Npn \appendix
+\cs_gset_protected:Npn \appendix
   {
     \CTEX at save@appendix
     \gdef \CTEX at presection { \CTEX at preappendix }
@@ -950,7 +969,7 @@
     \gdef \CTEX at postsection { \CTEX at postappendix }
     \gdef \CTEX at section@numbering { \CTEX at appendix@numbering }
   }
-\cs_new_protected_nopar:Npn \CTEX at makeanchor #1
+\cs_new_protected:Npn \CTEX at makeanchor #1
   { }
 \seq_const_from_clist:Nn \c__ctex_headings_cs_seq
   { part , spart , sect , ssect }
@@ -959,7 +978,7 @@
     \cs_new_eq:cc { CTEX@ #1 } { @ #1 }
     \cs_new_eq:cN { CTEX at makeanchor@ #1 } \CTEX at makeanchor
   }
-\cs_new_protected_nopar:Npn \CTEX at hyperheadinghook
+\cs_new_protected:Npn \CTEX at hyperheadinghook
   {
     \group_begin:
       \ifHy at implicit
@@ -980,7 +999,7 @@
   }
 \ctex_at_end_package:nn { hyperref }
   {
-    \cs_gset_protected_nopar:Npn \CTEX at makeanchor #1
+    \cs_gset_protected:Npn \CTEX at makeanchor #1
       {
         \Hy at MakeCurrentHrefAuto {#1}
         \Hy at raisedlink
@@ -995,7 +1014,7 @@
   { }
 \ctex_at_end_package:nn { nameref }
   {
-    \cs_gset_protected_nopar:Npn \CTEX at gettitle { \NR at gettitle }
+    \cs_gset_protected:Npn \CTEX at gettitle { \NR at gettitle }
     \seq_map_inline:Nn \c__ctex_headings_cs_seq
       {
         \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 }
@@ -1002,7 +1021,7 @@
           { \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_titlesec_hook:
+\cs_new_protected:Npn \ctex_titlesec_hook:
   {
     \@ifpackagewith { titlesec } { explicit }
       {
@@ -1022,17 +1041,17 @@
       }
     \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n
   }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1
+\cs_new_protected:Npn \__ctex_titlesec_hook:n #1
   {
     \__ctex_titlesec_format:n {#1}
     \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1}
   }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1
+\cs_new_protected:Npn \__ctex_titlesec_format:n #1
   {
     \cs_if_free:cF { ttlf@#1 }
       { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} }
   }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2
+\cs_new_protected:Npn \__ctex_titlesec_format:Nn #1#2
   {
     \tl_set:Nx #1
       {
@@ -1042,7 +1061,7 @@
         \tl_tail:N #1
       }
   }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2
+\cs_new_protected:Npn \__ctex_titlesec_format_explicit:Nn #1#2
   {
     \cs_set_nopar:Npx #1 ##1
       {
@@ -1052,7 +1071,7 @@
         \exp_args:No \tl_tail:n { #1 { } }
       }
   }
-\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2
+\cs_new_protected:Npn \__ctex_titlesec_spacing:Nn #1#2
   { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } }
 \cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6
   {
@@ -1073,7 +1092,7 @@
   {
     \cs_if_free:NF \ttl at tocpart
       {
-        \cs_set_protected_nopar:Npn \ttl at tocpart
+        \cs_set_protected:Npn \ttl at tocpart
           { \tl_set:Nn \ttl at a { \CTEXthepart \hspace { 1em } } }
       }
     \seq_map_inline:Nn \c__ctex_headings_seq
@@ -1080,7 +1099,7 @@
       {
         \cs_if_exist:cF { ttl at toc #1 }
           {
-            \cs_new_protected_nopar:cpx { ttl at toc #1 }
+            \cs_new_protected:cpx { ttl at toc #1 }
               {
                 \tl_set:Nn \exp_not:N \ttl at a
                   {
@@ -1093,7 +1112,7 @@
   }
 \group_begin:
 \char_set_catcode_other:N \#
-\cs_new_protected_nopar:Npn \ctex_titleps_hook:
+\cs_new_protected:Npn \ctex_titleps_hook:
   {
     \ctex_patch_cmd:Nnn \ttl at settopmark
       { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
@@ -1115,12 +1134,12 @@
       }
   }
 \group_end:
-\cs_new_nopar:Npn \CTEX at titlepslabel@set #1
+\cs_new:Npn \CTEX at titlepslabel@set #1
   {
     \cs_if_free:cF { CTEXthe#1 }
       { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
   }
-\cs_new_nopar:Npn \CTEX at titlepslabel@clear #1
+\cs_new:Npn \CTEX at titlepslabel@clear #1
   {
     \cs_if_free:cF { CTEXthe#1 }
       { \protect \@namedef { CTEXthe#1 } { } }
@@ -1130,9 +1149,9 @@
 \ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
 \ctex_at_end_package:nn { titleps }
   {
-    \cs_set_protected_nopar:Npn \ttl at setifthe #1
+    \cs_set_protected:Npn \ttl at setifthe #1
       {
-        \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 }
+        \exp_args:Nco \cs_set:Npn { ifthe #1 }
           {
             \CTEXifname
               { \protect \@firstoftwo }
@@ -1159,19 +1178,24 @@
       { \CTEX at toc@width at n {#1} }
       { }
       { \ctex_patch_failure:N \numberline }
-    \@ifpackageloaded { tocloft }
-      { }
+    \cs_new_protected:Npn \__ctex_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 at toc@width at 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 at toc@width at n {#1} }
+                  { }
+                  { \ctex_patch_failure:N \numberline }
+              }
           }
       }
   }
+\__ctex_patch_toc_width:n { tocloft  }
+\__ctex_patch_toc_width:n { titletoc }
 \if at twoside
   \ctex_patch_cmd:Nnn \ps at headings
     { \ifnum \c at secnumdepth > \z@ \thesection \quad \fi }
@@ -1193,7 +1217,7 @@
       { \ifnum \c at secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi }
       { \CTEXifname { \CTEXthesubsection \quad } { } }
   }
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
+\cs_new_protected:Npn \CTEX at setcurrentlabel@n #1
   {
     \protected at edef \@currentlabel
       {
@@ -1202,17 +1226,17 @@
           { \exp_not:o { \@currentlabel } }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
+\cs_new_protected:Npn \ctex_varioref_hook:
   {
     \seq_map_inline:Nn \c__ctex_headings_seq
       { \ctex_fix_varioref_label:n { ##1 } }
   }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
+\cs_new_protected:Npn \ctex_fix_varioref_label:n #1
   {
     \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
+      { \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX at the#1 } } }
   }
-\@ifpackageloaded { varioref }
+\cs_if_exist:NTF \labelformat
   { \ctex_varioref_hook: }
   {
     \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
@@ -1226,7 +1250,7 @@
 \ctex_scheme_input:o { \l__ctex_scheme_tl }
 \NewDocumentCommand \zihao { m }
   { \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_zihao:n #1
+\cs_new_protected:Npn \ctex_zihao:n #1
   {
     \prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl
       { \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont }
@@ -1241,7 +1265,7 @@
   }
 \prop_new:N \c__ctex_font_size_prop
 \seq_new:N \c__ctex_font_size_seq
-\cs_new_protected_nopar:Npn \__ctex_save_font_size:nn #1#2
+\cs_new_protected:Npn \__ctex_save_font_size:nn #1#2
   {
     \use:x
       {
@@ -1273,12 +1297,12 @@
     {  0 } { 42   bp }
   }
   { \__ctex_save_font_size:nn #1 }
-\cs_new_protected_nopar:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
   {
     \__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} }
     \exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl
   }
-\cs_new_protected_nopar:Npn \__ctex_get_font_sizes:Nn #1#2
+\cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2
   {
     \tl_clear:N #1
     \tl_map_inline:nn {#2}
@@ -1315,14 +1339,14 @@
       { \msg_error:nnn { ctex } { fontsize } {#2} }
   }
 \cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4
-  { \cs_set_protected_nopar:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
-\if_case:w \g__ctex_font_size_int
-  \ctex_file_input:n { ctex-c5size.clo }
-\or:
-  \ctex_file_input:n { ctex-cs4size.clo }
-\fi:
-\fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp }
+  { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
+\int_case:nn { \g__ctex_font_size_int }
   {
+    { 0 } { \ctex_file_input:n { ctex-c5size.clo } }
+    { 1 } { \ctex_file_input:n { ctex-cs4size.clo } }
+  }
+\fp_if_nan:nF { \l__ctex_line_spread_fp }
+  {
     \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp }
     \group_begin: \footnotesize \exp_args:NNNo \group_end:
     \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox }
@@ -1332,47 +1356,76 @@
   { C \TeX }
 \ctex_at_end_package:nn { hyperref }
   { \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     captiondelimiter .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           { You~can~load~the~package~`caption'~to~get~its~functionality. }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_fontset_error:n #1
+\cs_new_protected:Npn \ctex_fontset_error:n #1
   { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} }
 \msg_new:nnn { ctex } { fontset-unavailable }
   { CTeX~fontset~`#1'~is~unavailable~in~current~mode. }
-\cs_new_protected_nopar:Npn \ctex_load_fontset:
+\cs_new:Npx \ctex_fontset_case:nnn #1#2#3
   {
-    \tl_if_empty:NTF \g__ctex_fontset_tl
+    \sys_if_engine_pdftex:TF
+      {#1}
+      { \sys_if_engine_uptex:TF {#2} {#3} }
+  }
+\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4
+  {
+    \sys_if_engine_pdftex:TF
+      { \sys_if_output_pdf:TF   {#1} {#2} }
+      { \sys_if_engine_uptex:TF {#3} {#4} }
+  }
+\cs_new_protected:Npn \ctex_detect_platform:
+  {
+    \sys_if_platform_windows:TF
+      { \tl_gset:Nn \g__ctex_fontset_tl { windows } }
       {
-        \ctex_detected_platform:
-        \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
+        \ctex_if_platform_macos:TF
+          { \tl_gset:Nn \g__ctex_fontset_tl { mac    } }
+          { \tl_gset:Nn \g__ctex_fontset_tl { fandol } }
       }
+  }
+\cs_new_protected:Npn \ctex_if_platform_macos:TF
+  { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
+\cs_new_protected:Npn \ctex_load_fontset:
+  {
+    \tl_if_empty:NTF \g__ctex_fontset_tl
+      { \ctex_detect_platform: }
       {
-        \file_if_exist:nTF { ctex-fontset- \g__ctex_fontset_tl .def }
-          { \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def } }
+        \bool_lazy_or:nnTF
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsnew } }
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsold } }
           {
-            \use:x
+            \msg_warning:nnxx { ctex } { deprecated-fontset }
+              { \g__ctex_fontset_tl } { windows }
+            \tl_gset:Nn \g__ctex_fontset_tl { windows }
+          }
+          {
+            \file_if_exist:nF { ctex-fontset- \g__ctex_fontset_tl .def }
               {
-                \ctex_detected_platform:
-                \msg_error:nnxx { ctex } { fontset-not-found }
-                  { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                \use:x
+                  {
+                    \ctex_detect_platform:
+                    \msg_error:nnxx { ctex } { fontset-not-found }
+                      { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                  }
               }
-            \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
           }
       }
+    \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
   }
-\@onlypreamble \ctex_load_fontset:
+\msg_new:nnn { ctex } { deprecated-fontset }
+  { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. }
 \msg_new:nnnn { ctex } { fontset-not-found }
-  {
-    CTeX~fontset~`#1'~could~not~be~found.\\
-    Fontset~`#2'~will~be~used~instead.
-  }
+  { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. }
   { You~may~run~`mktexlsr'~firstly. }
-\keys_define:nn { ctex }
+\@onlypreamble \ctex_load_fontset:
+\ctex_define:n
   {
     fontset .code:n =
       {
@@ -1402,14 +1455,16 @@
   }
   { Only~one~fontset~can~be~loaded~in~the~preamble. }
 \msg_new:nnn { ctex } { fontset-only-preamble }
-  {
-    The~ `fontset'~ option~ can~ be~ used~ only~ in~ preamble.
-  }
+  { The~`fontset'~option~can~be~used~only~in~preamble. }
 \str_if_eq:onF { \g__ctex_fontset_tl } { none }
   { \ctex_load_fontset: }
 \ctex_at_end:n { \ctex_file_input:n { ctex.cfg } }
 %% 
-%%     This package consists of the file  ctex.dtx,
+%%     This package consists of the files ctex.dtx,
+%%                                        ctxdoc.cls,
+%%                                        ctxdocstrip.tex,
+%%                                        ctex-zhconv.lua,
+%%                                        ctex-zhconv-make.lua,
 %%                  and the derived files ctex.pdf,
 %%                                        ctex.ins,
 %%                                        ctex.sty,
@@ -1419,16 +1474,15 @@
 %%                                        ctexbook.cls,
 %%                                        ctexrep.cls,
 %%                                        ctexbeamer.cls,
-%%                                        ctxdoc.cls,
 %%                                        ctexcap.sty,
 %%                                        ctexhook.sty,
 %%                                        ctexpatch.sty,
 %%                                        ctex-c5size.clo,
 %%                                        ctex-cs4size.clo,
-%%                                        ctex-article.def,
-%%                                        ctex-book.def,
-%%                                        ctex-report.def,
-%%                                        ctex-beamer.def,
+%%                                        ctex-heading-article.def,
+%%                                        ctex-heading-book.def,
+%%                                        ctex-heading-report.def,
+%%                                        ctex-heading-beamer.def,
 %%                                        ctex-scheme-plain.def,
 %%                                        ctex-scheme-plain-article.def,
 %%                                        ctex-scheme-plain-book.def,
@@ -1443,6 +1497,7 @@
 %%                                        ctex-name-utf8.cfg,
 %%                                        ctex.cfg,
 %%                                        ctexopts.cfg,
+%%                                        ctexbackend.cfg,
 %%                                        ctex-engine-pdftex.def,
 %%                                        ctex-engine-xetex.def,
 %%                                        ctex-engine-luatex.def,
@@ -1460,26 +1515,25 @@
 %%                                        jt2zhrm.fd,
 %%                                        jt2zhsf.fd,
 %%                                        jt2zhtt.fd,
-%%                                        ctex-fontset-windows.def,
-%%                                        ctex-fontset-windowsnew.def,
-%%                                        ctex-fontset-windowsold.def,
 %%                                        ctex-fontset-adobe.def,
 %%                                        ctex-fontset-fandol.def,
+%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-mac.def,
 %%                                        ctex-fontset-macnew.def,
 %%                                        ctex-fontset-macold.def,
-%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-ubuntu.def,
+%%                                        ctex-fontset-windows.def,
 %%                                        ctexspa.def,
 %%                                        ctexpunct.spa,
 %%                                        ctexmakespa.tex,
 %%                                        ctexspamacro.tex,
-%%                                        ctxdocstrip.tex,
 %%                                        zhadobefonts.tex,
 %%                                        zhfandolfonts.tex,
 %%                                        zhfounderfonts.tex,
+%%                                        zhmacfonts.tex,
 %%                                        zhubuntufonts.tex,
 %%                                        zhwindowsfonts.tex,
+%%                                        ctex-zhconv-index.lua,
 %%                                        translator-theorem-dictionary-ChineseGBK.dict,
 %%                                        translator-theorem-dictionary-ChineseUTF8.dict, and
 %%                                        README.md.

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctexbeamer.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctexbeamer.cls	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctexbeamer.cls	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `class,beamer')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,17 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \NeedsTeXFormat{LaTeX2e}
+\input{ctexbackend.cfg}
 \RequirePackage{expl3}
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Chinese adapter for class beamer (CTEX)}
 \ProvidesExplClass{ctexbeamer}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \tl_const:Nx \c__ctex_version_tl
   { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } }
 \cs_new_eq:cN { ver at ctex.        \@pkgextension } \c__ctex_version_tl
@@ -42,11 +41,11 @@
 \msg_new:nnnn { ctex } { l3-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~bundles\\\\
+    Please~update~an~up-to-date~version~of~the~bundles\\\\
     `l3kernel'~and~`l3packages'\\\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
-\@ifpackagelater { expl3 } { 2019/03/05 } { }
+\@ifpackagelater { expl3 } { 2020/04/06 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
 \@ifpackagelater { l3keys2e } { 2015/12/20 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } }
@@ -62,11 +61,20 @@
   }
   { \msg_critical:nnx { ctex } { engine-not-supported } { \c__ctex_engine_str } }
 \RequirePackage { ctexhook , ctexpatch }
-\RequirePackage { fix-cm , everysel }
+\RequirePackage { fix-cm }
+\RequirePackage { everysel }
 \tl_clear_new:N \l__ctex_tmp_tl
 \int_new:N \l__ctex_tmp_int
 \box_new:N \l__ctex_tmp_box
 \dim_new:N \l__ctex_tmp_dim
+\cs_new_protected:Npn \ctex_define_option:n
+  { \keys_define:nn { ctex / option } }
+\cs_new_protected:Npn \ctex_define:n
+  { \keys_define:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:n
+  { \keys_set:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:nn #1
+  { \keys_set:nn { ctex / #1 } }
 \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3
   {
     \use:x
@@ -82,9 +90,9 @@
         #3
       }
   }
-\cs_new_protected_nopar:Npn \ctex_file_input:n #1
+\cs_new_protected:Npn \ctex_file_input:n #1
   { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
-\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
+\cs_new_protected:Npn \ctex_scheme_input:n #1
   {
     \ctex_file_wrapper:nnn
       { }
@@ -102,7 +110,7 @@
 \msg_new:nnnn { ctex } { package-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~package~`#1'\\
+    Please~update~an~up-to-date~version~of~the~package~`#1'\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
 \sys_if_output_pdf:TF
@@ -121,28 +129,36 @@
 \exp_last_unbraced:NNNNo
   \cs_new:Npn \__ctex_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop
     { \tl_if_empty:nT {#2} { \ccwd } }
-\tl_new:N \l__ctex_encoding_tl
-\tl_set:Nx \l__ctex_encoding_tl
-  { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
+\tl_new:N \g__ctex_encoding_tl
 \bool_new:N \g__ctex_zhmCJK_bool
 \tl_new:N \l__ctex_autoindent_tl
 \cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
 \cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
-\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfClass }
+\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass }
 \clist_new:N \g__ctex_std_options_clist
 \msg_new:nnn { ctex } { invalid-option }
   { Option~`\l_keys_key_tl'~is~invalid~in~current~mode. }
 \msg_new:nnn { ctex } { invalid-value }
   { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
+\cs_new_protected:Npn \ctex_deprecated_option:n
+  { \msg_warning:nnn { ctex } { deprecated-option } }
+\cs_new_protected:Npn \ctex_set_deprecated_option:n #1
+  {
+    \ctex_deprecated_option:n { Option~`#1'~is~set. }
+    \ctex_set:nn { option } {#1}
+  }
+\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
+  {
+    \msg_warning:nnxx { ctex } { deprecated-command }
+      { \token_to_str:N #1 } { \exp_not:n {#2} }
+  }
 \msg_new:nnn { ctex } { deprecated-option }
-  { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 }
+  { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
 \msg_new:nnn { ctex } { deprecated-command }
-  { Command~ #1 is~ deprecated.\\ #2 }
-\msg_new:nnn { ctex } { deprecated-environment }
-  { Environment~ `#1'~ is~ deprecated.\\ #2 }
+  { Command~`#1'~is~deprecated.\\ #2 }
 \int_new:N \g__ctex_font_size_int
-\int_set:Nn \g__ctex_font_size_int { -1 }
-\keys_define:nn { ctex / option }
+\int_gset:Nn \g__ctex_font_size_int { -1 }
+\ctex_define_option:n
   {
     zihao .choice: ,
     zihao .value_required:n = true ,
@@ -149,18 +165,8 @@
     zihao /     5  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
     zihao /    -4  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
     zihao / false  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
-    c5size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=5'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = 5 }
-      } ,
-    cs4size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=-4'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = -4 }
-      } ,
+    c5size  .code:n = { \ctex_set_deprecated_option:n { zihao =  5 } } ,
+    cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
     c5size  .value_forbidden:n = true ,
     cs4size .value_forbidden:n = true ,
     linespread  .fp_set:N = \l__ctex_line_spread_fp ,
@@ -185,56 +191,38 @@
       } ,
     indent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.~
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     indent .value_forbidden:n = true ,
     noindent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     noindent .value_forbidden:n = true ,
-    GBK  .code:n = { \tl_set:Nn \l__ctex_encoding_tl { GBK } } ,
-    UTF8 .code:n = { \tl_set:Nn \l__ctex_encoding_tl { UTF8 } } ,
-    GBK  .value_forbidden:n = true ,
-    UTF8 .value_forbidden:n = true ,
-    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
-    nofonts    .code:n =
+    GBK  .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \sys_if_engine_pdftex:TF
+          { \tl_gset:Nn \g__ctex_encoding_tl { GBK } }
           {
-            Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
+            \msg_warning:nn { ctex } { invalid-option }
+            \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
           }
-        \keys_set:nn { ctex / option } { fontset = none }
       } ,
-    adobefonts .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = adobe }
-      } ,
-    winfonts   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = windows }
-      } ,
+    UTF8 .code:n = { \tl_gset:Nn \g__ctex_encoding_tl { UTF8 } } ,
+    GBK  .value_forbidden:n = true ,
+    UTF8 .value_forbidden:n = true ,
+    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
+    nofonts    .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
+    adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
+    winfonts   .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
     nofonts    .value_forbidden:n = true ,
     winfonts   .value_forbidden:n = true ,
     adobefonts .value_forbidden:n = true ,
@@ -256,69 +244,57 @@
         \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
       } ,
     nozhmap   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zhmap=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { zhmap = false }
-      } ,
+      { \ctex_set_deprecated_option:n { zhmap = false } } ,
     nozhmap   .value_forbidden:n = true ,
     punct   .tl_set:N = \l__ctex_punct_tl ,
     punct  .default:n = { quanjiao } ,
     punct  .initial:n = { quanjiao } ,
-    nopunct   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `punct=plain'~ is~ set.  }
-        \keys_set:nn { ctex / option } { punct = plain }
-      } ,
+    nopunct   .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
     nopunct   .value_forbidden:n = true ,
     space .choices:nn =
       { true , auto , false }
       {
         \exp_args:Nx \ctex_at_end:n
-          { \keys_set:nn { ctex } { space = \l_keys_choice_tl } }
+          { \ctex_set:n { space = \l_keys_choice_tl } }
       } ,
     space  .default:n = { true } ,
-    nospace   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `space=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { space = false }
-      } ,
+    nospace   .code:n = { \ctex_deprecated_option:nn { space = false } } ,
     nospace   .value_forbidden:n = true ,
     heading .bool_set:N = \l__ctex_heading_bool ,
     scheme .tl_set:N  = \l__ctex_scheme_tl ,
     scheme .default:n = { chinese } ,
     scheme .initial:n = { chinese } ,
-    cap    .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = chinese' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = chinese }
-      } ,
-    nocap  .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = plain' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = plain }
-      } ,
+    cap    .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
+    nocap  .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
     cap    .value_forbidden:n = true ,
     nocap  .value_forbidden:n = true ,
-    fntef    .code:n =
+    fntef .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `(xe)CJKfntef'~ package~ is~ always~ loaded. }
+        \sys_if_engine_xetex:TF
+          {
+            \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
+            \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
+          }
+          {
+            \sys_if_engine_pdftex:TF
+              {
+                \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
+                \ctex_at_end:n { \RequirePackage { CJKfntef } }
+              }
+              {
+                \ctex_deprecated_option:n
+                  { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
+              }
+          }
       } ,
     fancyhdr .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `fancyhdr'~ package~ is~ loaded. }
-        \RequirePackage { fancyhdr }
+        \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
+        \ctex_at_end:n { \RequirePackage { fancyhdr } }
       } ,
     hyperref .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `hyperref'~ package~ will~ be~ loaded. }
+        \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
         \ctex_at_end:n
           {
             \cs_if_exist:NF \hypersetup
@@ -344,9 +320,9 @@
         #1 .value_forbidden:n = true ,
       }
   }
-\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l__ctex_tmp_tl } } }
+\exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
 \tl_clear:N \l__ctex_tmp_tl
-\keys_define:nn { ctex / option }
+\ctex_define_option:n
   {
     unknown .code:n =
       { \clist_gput_right:No \g__ctex_std_options_clist { \CurrentOption } }
@@ -353,38 +329,54 @@
   }
 \ctex_file_input:n { ctexopts.cfg }
 \ProcessKeysOptions { ctex / option }
-\if_case:w \g__ctex_font_size_int
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt }
-\or:
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt }
-\fi:
+\msg_new:nnn { ctex } { pdftex-utf8 }
+  { UTF8~will~be~used~as~the~default~encoding. }
+\tl_if_empty:NT \g__ctex_encoding_tl
+  {
+    \sys_if_engine_pdftex:T
+      { \msg_warning:nn { ctex } { pdftex-utf8 } }
+    \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
+  }
+\int_case:nn { \g__ctex_font_size_int }
+  {
+    { 0 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt } }
+    { 1 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt } }
+  }
 \tl_const:Nn \c__ctex_class_tl { beamer }
 \PassOptionsToClass { \g__ctex_std_options_clist } { beamer }
 \LoadClass { beamer }
 \@ifpackageloaded { hyperref }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \hypersetup {#1} }
   }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \PassOptionsToPackage {#1} { hyperref } }
   }
 \ctex_file_input:n { \c__ctex_engine_file_str }
-\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
-\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
+\NewDocumentCommand \ctexset { } { \ctex_set:n }
+\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
-      { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXsetup { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXsetup
+          { \ctexset {~#2~=~{~#1~}~}~is~set. }
+        \ctex_set:nn {#2} {#1}
+      }
   }
-\NewDocumentCommand \CTEXoptions { +o }
+\NewDocumentCommand \CTEXoptions { +O { } }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions }
-      { \ctexset~ {~ #1~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXoptions { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXoptions
+          { \ctexset {~#1~}~is~set. }
+        \ctex_set:n {#1}
+      }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     autoindent .choice: ,
     autoindent .default:n = { true } ,
@@ -402,9 +394,9 @@
       }
   }
 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
-\cs_new_protected_nopar:Npn \ctex_select_size:
+\cs_new_protected:Npn \ctex_select_size:
   { \cs_if_free:NTF \size at update { \ctex_update_size: } { \selectfont } }
-\cs_new_protected_nopar:Npn \ctex_update_size:
+\cs_new_protected:Npn \ctex_update_size:
   {
     \tl_if_eq:NNTF \l__ctex_ziju_tl \c__ctex_zero_tl
       {
@@ -418,7 +410,7 @@
 \tl_set_eq:NN \l__ctex_ziju_tl \c__ctex_zero_tl
 \ctex_add_to_selectfont:n
   { \cs_if_free:NF \size at update { \ctex_update_size: } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     linestretch .code:n =
       {
@@ -429,7 +421,7 @@
   }
 \tl_new:N \l__ctex_line_stretch_tl
 \tl_set:Nn \l__ctex_line_stretch_tl { \ccwd }
-\cs_new_protected_nopar:Npn \ctex_update_stretch:
+\cs_new_protected:Npn \ctex_update_stretch:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_tmp_dim { \l__ctex_line_stretch_tl }
@@ -464,7 +456,7 @@
         \ctex_update_ccglue:
       }
   }
-\cs_new_protected_nopar:Npn \ctex_update_parindent:
+\cs_new_protected:Npn \ctex_update_parindent:
   {
     \tl_if_empty:NF \l__ctex_autoindent_tl
       {
@@ -474,12 +466,12 @@
   }
 \NewDocumentCommand \ziju { m }
   { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ziju:n #1
+\cs_new_protected:Npn \ctex_ziju:n #1
   {
     \tl_set:Nx \l__ctex_ziju_tl { \fp_eval:n {#1} }
     \ctex_select_size:
   }
-\cs_new_protected_nopar:Npn \ctex_update_ziju:
+\cs_new_protected:Npn \ctex_update_ziju:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_ziju_dim { \l__ctex_ziju_tl \ccwd }
@@ -511,19 +503,20 @@
 \dim_new:N \l__ctex_ziju_dim
 \NewDocumentCommand \CTEXindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent }
-      { \parindent is~ set~ to~ 2\ccwd. }
-    \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd }
+    \ctex_deprecated_command:Nn \CTEXindent
+      { \parindent is~set~to~2\ccwd. }
+    \ctex_update_ccwd:
+    \dim_set:Nn \parindent { 2 \ccwd }
   }
 \NewDocumentCommand \CTEXnoindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent }
-      { \parindent is~ set~ to~ 0pt. }
+    \ctex_deprecated_command:Nn \CTEXnoindent
+      { \parindent is~set~to~0pt. }
     \dim_zero:N \parindent
   }
-\PassOptionsToPackage { encoding = \l__ctex_encoding_tl } { zhnumber }
+\PassOptionsToPackage { encoding = \g__ctex_encoding_tl } { zhnumber }
 \RequirePackage { zhnumber }
-\cs_new_nopar:Npn \chinese { \zhnum_counter:n }
+\cs_new:Npn \chinese { \zhnum_counter:n }
 \cs_new_eq:NN \@chinese \@zhnum
 \cs_new_eq:NN \Chinese \chinese
 \cs_new_eq:NN \CTEXcounter \use_none:n
@@ -541,7 +534,7 @@
 \NewDocumentCommand \CTEXdigits { m m }
   { \protected at edef #1 { \zhdigits {#2} } }
 \cs_set_eq:NN \CTEX at todayold \today
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     today .choice: ,
     today / old     .code:n =
@@ -567,7 +560,7 @@
     \tl_new:N \proofname
     \tl_set:Nn \proofname { Proof }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     contentsname   .tl_set:N = \contentsname ,
     listfigurename .tl_set:N = \listfigurename ,
@@ -585,7 +578,7 @@
   }
 \seq_const_from_clist:Nn \c__ctex_headings_seq
   { part , section , subsection }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
+\cs_new_protected:Npn \__ctex_initial_heading:n #1
   {
     \tl_new:c { CTEX at pre#1 }
     \tl_new:c { CTEX at post#1 }
@@ -615,7 +608,7 @@
         \group_end:
       }
   }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
+\cs_new_protected:Npn \__ctex_def_heading_keys:n #1
   {
     \tl_put_right:Nx \l__ctex_tmp_tl
       {
@@ -642,7 +635,7 @@
         \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
       }
   }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
+\cs_new:Npn \__ctex_plus_key_aux:nn #1#2
   {
     #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
     #1 / #2 +   .code:n =
@@ -656,7 +649,7 @@
 \cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
   {
     \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
+    \tl_if_novalue:nTF {#3}
       { \tl_clear:c { CTEX at post#1 } }
       { \tl_set:cn { CTEX at post#1 } {#3} }
   }
@@ -667,62 +660,73 @@
     \__ctex_initial_heading:n {#1}
     \__ctex_def_heading_keys:n {#1}
   }
-\use:x
+\exp_args:NNo \group_end: \ctex_define:n { \l__ctex_tmp_tl }
+\cs_new_protected:Npn \CTEX at heading@format at initial
   {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
+    \normalfont
+    \tl_clear:N \l__ctex_autoindent_tl
+    \int_set:Nn \tex_interlinepenalty:D { 10 000 }
+    \tex_noindent:D
   }
+\cs_new_protected:Npn \ctex_indent_box:n #1
+  {
+    \dim_set:Nn \tex_parindent:D {#1}
+    \__ctex_insert_indent:
+  }
+\cs_new_protected:Npn \__ctex_insert_indent:
+  {
+    \dim_compare:nNnF \tex_parindent:D = \c_zero_dim
+      { \tex_indent:D }
+  }
+\cs_new_eq:NN \CTEX at indentbox \ctex_indent_box:n
 \ExplSyntaxOff
 \defbeamertemplate*{part page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
     \par \addvspace{\glueexpr\CTEX at part@beforeskip\relax}%
-    \CTEX at part@format
-    \parindent \dimexpr \CTEX at part@indent \relax
-    \ifodd \CTEX at part@numbering
-      \CTEX at partname \CTEX at part@aftername
-    \fi
-    \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
-      \CTEX at part@titleformat \insertpart \CTEX at part@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at indentbox{\CTEX at part@indent}%
+      \ifodd \CTEX at part@numbering
+        \CTEX at partname \CTEX at part@aftername
+      \fi
+      \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
+        \CTEX at part@titleformat \insertpart \CTEX at part@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at part@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 \defbeamertemplate*{section page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
     \par \addvspace{\glueexpr\CTEX at section@beforeskip\relax}%
-    \CTEX at section@format
-    \parindent \dimexpr \CTEX at section@indent \relax
-    \ifodd \CTEX at section@numbering
-      \CTEX at sectionname \CTEX at section@aftername
-    \fi
-    \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
-      \CTEX at section@titleformat \insertsection \CTEX at section@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at section@format{%
+      \CTEX at indentbox{\CTEX at section@indent}%
+      \ifodd \CTEX at section@numbering
+        \CTEX at sectionname \CTEX at section@aftername
+      \fi
+      \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
+        \CTEX at section@titleformat \insertsection \CTEX at section@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at section@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 \defbeamertemplate*{subsection page}{CTEX}[1][]{%
   \begingroup
-    \CTEX at disableautoindent
     \par \addvspace{\glueexpr\CTEX at subsection@beforeskip\relax}%
-    \CTEX at subsection@format
-    \parindent \dimexpr \CTEX at subsection@indent \relax
-    \ifodd \CTEX at subsection@numbering
-      \CTEX at subsectionname \CTEX at subsection@aftername
-    \fi
-    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
-      \CTEX at subsection@titleformat \insertsubsection \CTEX at subsection@aftertitle
-    \end{beamercolorbox}%
+    \CTEX at heading@format at initial
+    \CTEX at subsection@format{%
+      \CTEX at indentbox{\CTEX at subsection@indent}%
+      \ifodd \CTEX at subsection@numbering
+        \CTEX at subsectionname \CTEX at subsection@aftername
+      \fi
+      \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
+        \CTEX at subsection@titleformat \insertsubsection \CTEX at subsection@aftertitle
+      \end{beamercolorbox}}%
     \par \addvspace{\glueexpr\CTEX at subsection@afterskip\relax}%
-  \endgroup
-}
+  \endgroup}
 \defbeamertemplatealias{part page}{default}{CTEX}
 \defbeamertemplatealias{section page}{default}{CTEX}
 \defbeamertemplatealias{subsection page}{default}{CTEX}
 \ExplSyntaxOn
-\cs_new_protected_nopar:Npn \CTEX at setcurrentlabel@n #1
+\cs_new_protected:Npn \CTEX at setcurrentlabel@n #1
   {
     \protected at edef \@currentlabel
       {
@@ -731,17 +735,17 @@
           { \exp_not:o { \@currentlabel } }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_varioref_hook:
+\cs_new_protected:Npn \ctex_varioref_hook:
   {
     \seq_map_inline:Nn \c__ctex_headings_seq
       { \ctex_fix_varioref_label:n { ##1 } }
   }
-\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1
+\cs_new_protected:Npn \ctex_fix_varioref_label:n #1
   {
     \tl_if_empty:cT { p@#1 }
-      { \exp_args:Nno \labelformat {#1} { \cs:w CTEX at the#1 \cs_end: } }
+      { \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX at the#1 } } }
   }
-\@ifpackageloaded { varioref }
+\cs_if_exist:NTF \labelformat
   { \ctex_varioref_hook: }
   {
     \cs_new_eq:NN \CTEX at save@refstepcounter \refstepcounter
@@ -755,7 +759,7 @@
 \ctex_scheme_input:o { \l__ctex_scheme_tl }
 \NewDocumentCommand \zihao { m }
   { \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_zihao:n #1
+\cs_new_protected:Npn \ctex_zihao:n #1
   {
     \prop_get:NnNTF \c__ctex_font_size_prop {#1} \l__ctex_font_size_tl
       { \exp_after:wN \fontsize \l__ctex_font_size_tl \selectfont }
@@ -770,7 +774,7 @@
   }
 \prop_new:N \c__ctex_font_size_prop
 \seq_new:N \c__ctex_font_size_seq
-\cs_new_protected_nopar:Npn \__ctex_save_font_size:nn #1#2
+\cs_new_protected:Npn \__ctex_save_font_size:nn #1#2
   {
     \use:x
       {
@@ -802,12 +806,12 @@
     {  0 } { 42   bp }
   }
   { \__ctex_save_font_size:nn #1 }
-\cs_new_protected_nopar:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
+\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4
   {
     \__ctex_get_font_sizes:Nn \l__ctex_font_size_tl { {#1} {#2} {#3} {#4} }
     \exp_after:wN \DeclareMathSizes \l__ctex_font_size_tl
   }
-\cs_new_protected_nopar:Npn \__ctex_get_font_sizes:Nn #1#2
+\cs_new_protected:Npn \__ctex_get_font_sizes:Nn #1#2
   {
     \tl_clear:N #1
     \tl_map_inline:nn {#2}
@@ -844,14 +848,14 @@
       { \msg_error:nnn { ctex } { fontsize } {#2} }
   }
 \cs_new_protected:Npn \__ctex_set_font_size:nnNn #1#2#3#4
-  { \cs_set_protected_nopar:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
-\if_case:w \g__ctex_font_size_int
-  \ctex_file_input:n { ctex-c5size.clo }
-\or:
-  \ctex_file_input:n { ctex-cs4size.clo }
-\fi:
-\fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp }
+  { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } }
+\int_case:nn { \g__ctex_font_size_int }
   {
+    { 0 } { \ctex_file_input:n { ctex-c5size.clo } }
+    { 1 } { \ctex_file_input:n { ctex-cs4size.clo } }
+  }
+\fp_if_nan:nF { \l__ctex_line_spread_fp }
+  {
     \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp }
     \group_begin: \footnotesize \exp_args:NNNo \group_end:
     \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox }
@@ -861,47 +865,76 @@
   { C \TeX }
 \ctex_at_end_package:nn { hyperref }
   { \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     captiondelimiter .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           { You~can~load~the~package~`caption'~to~get~its~functionality. }
       }
   }
-\cs_new_protected_nopar:Npn \ctex_fontset_error:n #1
+\cs_new_protected:Npn \ctex_fontset_error:n #1
   { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} }
 \msg_new:nnn { ctex } { fontset-unavailable }
   { CTeX~fontset~`#1'~is~unavailable~in~current~mode. }
-\cs_new_protected_nopar:Npn \ctex_load_fontset:
+\cs_new:Npx \ctex_fontset_case:nnn #1#2#3
   {
-    \tl_if_empty:NTF \g__ctex_fontset_tl
+    \sys_if_engine_pdftex:TF
+      {#1}
+      { \sys_if_engine_uptex:TF {#2} {#3} }
+  }
+\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4
+  {
+    \sys_if_engine_pdftex:TF
+      { \sys_if_output_pdf:TF   {#1} {#2} }
+      { \sys_if_engine_uptex:TF {#3} {#4} }
+  }
+\cs_new_protected:Npn \ctex_detect_platform:
+  {
+    \sys_if_platform_windows:TF
+      { \tl_gset:Nn \g__ctex_fontset_tl { windows } }
       {
-        \ctex_detected_platform:
-        \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
+        \ctex_if_platform_macos:TF
+          { \tl_gset:Nn \g__ctex_fontset_tl { mac    } }
+          { \tl_gset:Nn \g__ctex_fontset_tl { fandol } }
       }
+  }
+\cs_new_protected:Npn \ctex_if_platform_macos:TF
+  { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
+\cs_new_protected:Npn \ctex_load_fontset:
+  {
+    \tl_if_empty:NTF \g__ctex_fontset_tl
+      { \ctex_detect_platform: }
       {
-        \file_if_exist:nTF { ctex-fontset- \g__ctex_fontset_tl .def }
-          { \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def } }
+        \bool_lazy_or:nnTF
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsnew } }
+          { \str_if_eq_p:on { \g__ctex_fontset_tl } { windowsold } }
           {
-            \use:x
+            \msg_warning:nnxx { ctex } { deprecated-fontset }
+              { \g__ctex_fontset_tl } { windows }
+            \tl_gset:Nn \g__ctex_fontset_tl { windows }
+          }
+          {
+            \file_if_exist:nF { ctex-fontset- \g__ctex_fontset_tl .def }
               {
-                \ctex_detected_platform:
-                \msg_error:nnxx { ctex } { fontset-not-found }
-                  { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                \use:x
+                  {
+                    \ctex_detect_platform:
+                    \msg_error:nnxx { ctex } { fontset-not-found }
+                      { \g__ctex_fontset_tl } { \exp_not:N \g__ctex_fontset_tl }
+                  }
               }
-            \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
           }
       }
+    \ctex_file_input:n { ctex-fontset- \g__ctex_fontset_tl .def }
   }
-\@onlypreamble \ctex_load_fontset:
+\msg_new:nnn { ctex } { deprecated-fontset }
+  { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. }
 \msg_new:nnnn { ctex } { fontset-not-found }
-  {
-    CTeX~fontset~`#1'~could~not~be~found.\\
-    Fontset~`#2'~will~be~used~instead.
-  }
+  { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. }
   { You~may~run~`mktexlsr'~firstly. }
-\keys_define:nn { ctex }
+\@onlypreamble \ctex_load_fontset:
+\ctex_define:n
   {
     fontset .code:n =
       {
@@ -931,14 +964,16 @@
   }
   { Only~one~fontset~can~be~loaded~in~the~preamble. }
 \msg_new:nnn { ctex } { fontset-only-preamble }
-  {
-    The~ `fontset'~ option~ can~ be~ used~ only~ in~ preamble.
-  }
+  { The~`fontset'~option~can~be~used~only~in~preamble. }
 \str_if_eq:onF { \g__ctex_fontset_tl } { none }
   { \ctex_load_fontset: }
 \ctex_at_end:n { \ctex_file_input:n { ctex.cfg } }
 %% 
-%%     This package consists of the file  ctex.dtx,
+%%     This package consists of the files ctex.dtx,
+%%                                        ctxdoc.cls,
+%%                                        ctxdocstrip.tex,
+%%                                        ctex-zhconv.lua,
+%%                                        ctex-zhconv-make.lua,
 %%                  and the derived files ctex.pdf,
 %%                                        ctex.ins,
 %%                                        ctex.sty,
@@ -948,16 +983,15 @@
 %%                                        ctexbook.cls,
 %%                                        ctexrep.cls,
 %%                                        ctexbeamer.cls,
-%%                                        ctxdoc.cls,
 %%                                        ctexcap.sty,
 %%                                        ctexhook.sty,
 %%                                        ctexpatch.sty,
 %%                                        ctex-c5size.clo,
 %%                                        ctex-cs4size.clo,
-%%                                        ctex-article.def,
-%%                                        ctex-book.def,
-%%                                        ctex-report.def,
-%%                                        ctex-beamer.def,
+%%                                        ctex-heading-article.def,
+%%                                        ctex-heading-book.def,
+%%                                        ctex-heading-report.def,
+%%                                        ctex-heading-beamer.def,
 %%                                        ctex-scheme-plain.def,
 %%                                        ctex-scheme-plain-article.def,
 %%                                        ctex-scheme-plain-book.def,
@@ -972,6 +1006,7 @@
 %%                                        ctex-name-utf8.cfg,
 %%                                        ctex.cfg,
 %%                                        ctexopts.cfg,
+%%                                        ctexbackend.cfg,
 %%                                        ctex-engine-pdftex.def,
 %%                                        ctex-engine-xetex.def,
 %%                                        ctex-engine-luatex.def,
@@ -989,26 +1024,25 @@
 %%                                        jt2zhrm.fd,
 %%                                        jt2zhsf.fd,
 %%                                        jt2zhtt.fd,
-%%                                        ctex-fontset-windows.def,
-%%                                        ctex-fontset-windowsnew.def,
-%%                                        ctex-fontset-windowsold.def,
 %%                                        ctex-fontset-adobe.def,
 %%                                        ctex-fontset-fandol.def,
+%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-mac.def,
 %%                                        ctex-fontset-macnew.def,
 %%                                        ctex-fontset-macold.def,
-%%                                        ctex-fontset-founder.def,
 %%                                        ctex-fontset-ubuntu.def,
+%%                                        ctex-fontset-windows.def,
 %%                                        ctexspa.def,
 %%                                        ctexpunct.spa,
 %%                                        ctexmakespa.tex,
 %%                                        ctexspamacro.tex,
-%%                                        ctxdocstrip.tex,
 %%                                        zhadobefonts.tex,
 %%                                        zhfandolfonts.tex,
 %%                                        zhfounderfonts.tex,
+%%                                        zhmacfonts.tex,
 %%                                        zhubuntufonts.tex,
 %%                                        zhwindowsfonts.tex,
+%%                                        ctex-zhconv-index.lua,
 %%                                        translator-theorem-dictionary-ChineseGBK.dict,
 %%                                        translator-theorem-dictionary-ChineseUTF8.dict, and
 %%                                        README.md.

Modified: trunk/Master/texmf-dist/tex/latex/ctex/ctexbook.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ctex/ctexbook.cls	2020-05-02 21:03:20 UTC (rev 54975)
+++ trunk/Master/texmf-dist/tex/latex/ctex/ctexbook.cls	2020-05-02 22:24:14 UTC (rev 54976)
@@ -6,9 +6,9 @@
 %%
 %% ctex.dtx  (with options: `class,book')
 %% 
-%%     Copyright (C) 2003--2019
+%%     Copyright (C) 2003--2020
 %%     CTEX.ORG and any individual authors listed in the documentation.
-%% ------------------------------------------------------------------------------
+%% ---------------------------------------------------------------------
 %% 
 %%     This work may be distributed and/or modified under the
 %%     conditions of the LaTeX Project Public License, either
@@ -20,18 +20,17 @@
 %%     and version 1.3 or later is part of all distributions of
 %%     LaTeX version 2005/12/01 or later.
 %% 
-%%     This work has the LPPL maintenance status `maintained'.
+%%     This work has the LPPL maintenance status "maintained".
 %% 
-%%     The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang.
+%% ---------------------------------------------------------------------
 %% 
-%% ------------------------------------------------------------------------------
-%% 
 \NeedsTeXFormat{LaTeX2e}
+\input{ctexbackend.cfg}
 \RequirePackage{expl3}
-\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: ctex.dtx 320df30 2020-05-02 06:45:05 +0800 Qing Lee <sobenlee at gmail.com> $
   {Chinese adapter for class book (CTEX)}
 \ProvidesExplClass{ctexbook}
-  {\ExplFileDate}{2.4.16}{\ExplFileDescription}
+  {\ExplFileDate}{2.5.1}{\ExplFileDescription}
 \tl_const:Nx \c__ctex_version_tl
   { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } }
 \cs_new_eq:cN { ver at ctex.        \@pkgextension } \c__ctex_version_tl
@@ -42,11 +41,11 @@
 \msg_new:nnnn { ctex } { l3-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~bundles\\\\
+    Please~update~an~up-to-date~version~of~the~bundles\\\\
     `l3kernel'~and~`l3packages'\\\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
-\@ifpackagelater { expl3 } { 2019/03/05 } { }
+\@ifpackagelater { expl3 } { 2020/04/06 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
 \@ifpackagelater { l3keys2e } { 2015/12/20 } { }
   { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } }
@@ -62,11 +61,20 @@
   }
   { \msg_critical:nnx { ctex } { engine-not-supported } { \c__ctex_engine_str } }
 \RequirePackage { ctexhook , ctexpatch }
-\RequirePackage { fix-cm , everysel }
+\RequirePackage { fix-cm }
+\RequirePackage { everysel }
 \tl_clear_new:N \l__ctex_tmp_tl
 \int_new:N \l__ctex_tmp_int
 \box_new:N \l__ctex_tmp_box
 \dim_new:N \l__ctex_tmp_dim
+\cs_new_protected:Npn \ctex_define_option:n
+  { \keys_define:nn { ctex / option } }
+\cs_new_protected:Npn \ctex_define:n
+  { \keys_define:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:n
+  { \keys_set:nn { ctex } }
+\cs_new_protected:Npn \ctex_set:nn #1
+  { \keys_set:nn { ctex / #1 } }
 \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3
   {
     \use:x
@@ -82,9 +90,9 @@
         #3
       }
   }
-\cs_new_protected_nopar:Npn \ctex_file_input:n #1
+\cs_new_protected:Npn \ctex_file_input:n #1
   { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
-\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
+\cs_new_protected:Npn \ctex_scheme_input:n #1
   {
     \ctex_file_wrapper:nnn
       { }
@@ -104,7 +112,7 @@
 \msg_new:nnnn { ctex } { package-too-old }
   { Support~package~`#1'~too~old. }
   {
-    Please~update~an~up~to~date~version~of~the~package~`#1'\\
+    Please~update~an~up-to-date~version~of~the~package~`#1'\\
     using~your~TeX~package~manager~or~from~CTAN.
   }
 \sys_if_output_pdf:TF
@@ -123,28 +131,36 @@
 \exp_last_unbraced:NNNNo
   \cs_new:Npn \__ctex_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop
     { \tl_if_empty:nT {#2} { \ccwd } }
-\tl_new:N \l__ctex_encoding_tl
-\tl_set:Nx \l__ctex_encoding_tl
-  { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
+\tl_new:N \g__ctex_encoding_tl
 \bool_new:N \g__ctex_zhmCJK_bool
 \tl_new:N \l__ctex_autoindent_tl
 \cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n
 \cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn
-\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfClass }
+\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass }
 \clist_new:N \g__ctex_std_options_clist
 \msg_new:nnn { ctex } { invalid-option }
   { Option~`\l_keys_key_tl'~is~invalid~in~current~mode. }
 \msg_new:nnn { ctex } { invalid-value }
   { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. }
+\cs_new_protected:Npn \ctex_deprecated_option:n
+  { \msg_warning:nnn { ctex } { deprecated-option } }
+\cs_new_protected:Npn \ctex_set_deprecated_option:n #1
+  {
+    \ctex_deprecated_option:n { Option~`#1'~is~set. }
+    \ctex_set:nn { option } {#1}
+  }
+\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2
+  {
+    \msg_warning:nnxx { ctex } { deprecated-command }
+      { \token_to_str:N #1 } { \exp_not:n {#2} }
+  }
 \msg_new:nnn { ctex } { deprecated-option }
-  { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 }
+  { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 }
 \msg_new:nnn { ctex } { deprecated-command }
-  { Command~ #1 is~ deprecated.\\ #2 }
-\msg_new:nnn { ctex } { deprecated-environment }
-  { Environment~ `#1'~ is~ deprecated.\\ #2 }
+  { Command~`#1'~is~deprecated.\\ #2 }
 \int_new:N \g__ctex_font_size_int
-\int_set:Nn \g__ctex_font_size_int { -1 }
-\keys_define:nn { ctex / option }
+\int_gset:Nn \g__ctex_font_size_int { -1 }
+\ctex_define_option:n
   {
     zihao .choice: ,
     zihao .value_required:n = true ,
@@ -151,18 +167,8 @@
     zihao /     5  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 0 } } ,
     zihao /    -4  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 1 } } ,
     zihao / false  .code:n = { \int_gset:Nn \g__ctex_font_size_int { 2 } } ,
-    c5size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=5'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = 5 }
-      } ,
-    cs4size  .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zihao=-4'~ is~ set. }
-        \keys_set:nn { ctex / option } { zihao = -4 }
-      } ,
+    c5size  .code:n = { \ctex_set_deprecated_option:n { zihao =  5 } } ,
+    cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } ,
     c5size  .value_forbidden:n = true ,
     cs4size .value_forbidden:n = true ,
     linespread  .fp_set:N = \l__ctex_line_spread_fp ,
@@ -187,56 +193,38 @@
       } ,
     indent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.~
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     indent .value_forbidden:n = true ,
     noindent .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \ctex_deprecated_option:n
           {
-            The~ functionality~ has~ been~ removed.\\
-            It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~
-            options.
+            The~functionality~has~been~removed.\\
+            It's~better~to~set~the~heading~styles~via~`afterindent'~option.
           }
       } ,
     noindent .value_forbidden:n = true ,
-    GBK  .code:n = { \tl_set:Nn \l__ctex_encoding_tl { GBK } } ,
-    UTF8 .code:n = { \tl_set:Nn \l__ctex_encoding_tl { UTF8 } } ,
-    GBK  .value_forbidden:n = true ,
-    UTF8 .value_forbidden:n = true ,
-    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
-    nofonts    .code:n =
+    GBK  .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
+        \sys_if_engine_pdftex:TF
+          { \tl_gset:Nn \g__ctex_encoding_tl { GBK } }
           {
-            Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
+            \msg_warning:nn { ctex } { invalid-option }
+            \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
           }
-        \keys_set:nn { ctex / option } { fontset = none }
       } ,
-    adobefonts .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = adobe }
-      } ,
-    winfonts   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          {
-            Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~
-            fontset~ option.
-          }
-        \keys_set:nn { ctex / option } { fontset = windows }
-      } ,
+    UTF8 .code:n = { \tl_gset:Nn \g__ctex_encoding_tl { UTF8 } } ,
+    GBK  .value_forbidden:n = true ,
+    UTF8 .value_forbidden:n = true ,
+    fontset    .tl_gset:N = \g__ctex_fontset_tl ,
+    nofonts    .code:n = { \ctex_set_deprecated_option:n { fontset = none } } ,
+    adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } ,
+    winfonts   .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } ,
     nofonts    .value_forbidden:n = true ,
     winfonts   .value_forbidden:n = true ,
     adobefonts .value_forbidden:n = true ,
@@ -258,35 +246,21 @@
         \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn
       } ,
     nozhmap   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `zhmap=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { zhmap = false }
-      } ,
+      { \ctex_set_deprecated_option:n { zhmap = false } } ,
     nozhmap   .value_forbidden:n = true ,
     punct   .tl_set:N = \l__ctex_punct_tl ,
     punct  .default:n = { quanjiao } ,
     punct  .initial:n = { quanjiao } ,
-    nopunct   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `punct=plain'~ is~ set.  }
-        \keys_set:nn { ctex / option } { punct = plain }
-      } ,
+    nopunct   .code:n = \ctex_set_deprecated_option:n { punct = plain } ,
     nopunct   .value_forbidden:n = true ,
     space .choices:nn =
       { true , auto , false }
       {
         \exp_args:Nx \ctex_at_end:n
-          { \keys_set:nn { ctex } { space = \l_keys_choice_tl } }
+          { \ctex_set:n { space = \l_keys_choice_tl } }
       } ,
     space  .default:n = { true } ,
-    nospace   .code:n =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `space=false'~ is~ set. }
-        \keys_set:nn { ctex / option } { space = false }
-      } ,
+    nospace   .code:n = { \ctex_deprecated_option:nn { space = false } } ,
     nospace   .value_forbidden:n = true ,
     heading .bool_set:N = \l__ctex_heading_bool ,
     sub3section .code:n =
@@ -298,35 +272,37 @@
     scheme .tl_set:N  = \l__ctex_scheme_tl ,
     scheme .default:n = { chinese } ,
     scheme .initial:n = { chinese } ,
-    cap    .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = chinese' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = chinese }
-      } ,
-    nocap  .code:n    =
-      {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { Option~ `scheme = plain' ~ is~ set. }
-        \keys_set:nn { ctex / option } { scheme = plain }
-      } ,
+    cap    .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } ,
+    nocap  .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } ,
     cap    .value_forbidden:n = true ,
     nocap  .value_forbidden:n = true ,
-    fntef    .code:n =
+    fntef .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `(xe)CJKfntef'~ package~ is~ always~ loaded. }
+        \sys_if_engine_xetex:TF
+          {
+            \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. }
+            \ctex_at_end:n { \RequirePackage { xeCJKfntef } }
+          }
+          {
+            \sys_if_engine_pdftex:TF
+              {
+                \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. }
+                \ctex_at_end:n { \RequirePackage { CJKfntef } }
+              }
+              {
+                \ctex_deprecated_option:n
+                  { Furthermore,~option~`fntef'~is~invalid~in~current~mode. }
+              }
+          }
       } ,
     fancyhdr .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `fancyhdr'~ package~ is~ loaded. }
-        \RequirePackage { fancyhdr }
+        \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. }
+        \ctex_at_end:n { \RequirePackage { fancyhdr } }
       } ,
     hyperref .code:n =
       {
-        \msg_warning:nnn { ctex } { deprecated-option }
-          { `hyperref'~ package~ will~ be~ loaded. }
+        \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. }
         \ctex_at_end:n
           {
             \cs_if_exist:NF \hypersetup
@@ -352,9 +328,9 @@
         #1 .value_forbidden:n = true ,
       }
   }
-\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l__ctex_tmp_tl } } }
+\exp_args:No \ctex_define_option:n { \l__ctex_tmp_tl }
 \tl_clear:N \l__ctex_tmp_tl
-\keys_define:nn { ctex / option }
+\ctex_define_option:n
   {
     unknown .code:n =
       { \clist_gput_right:No \g__ctex_std_options_clist { \CurrentOption } }
@@ -361,38 +337,54 @@
   }
 \ctex_file_input:n { ctexopts.cfg }
 \ProcessKeysOptions { ctex / option }
-\if_case:w \g__ctex_font_size_int
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt }
-\or:
-  \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt }
-\fi:
+\msg_new:nnn { ctex } { pdftex-utf8 }
+  { UTF8~will~be~used~as~the~default~encoding. }
+\tl_if_empty:NT \g__ctex_encoding_tl
+  {
+    \sys_if_engine_pdftex:T
+      { \msg_warning:nn { ctex } { pdftex-utf8 } }
+    \tl_gset:Nn \g__ctex_encoding_tl { UTF8 }
+  }
+\int_case:nn { \g__ctex_font_size_int }
+  {
+    { 0 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 10pt } }
+    { 1 } { \clist_gput_right:Nn \g__ctex_std_options_clist { 12pt } }
+  }
 \tl_const:Nn \c__ctex_class_tl { book }
 \PassOptionsToClass { \g__ctex_std_options_clist } { book }
 \LoadClass { book }
 \@ifpackageloaded { hyperref }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \hypersetup {#1} }
   }
   {
-    \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1
+    \cs_new_protected:Npn \ctex_hypersetup:n #1
       { \PassOptionsToPackage {#1} { hyperref } }
   }
 \ctex_file_input:n { \c__ctex_engine_file_str }
-\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
-\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m }
+\NewDocumentCommand \ctexset { } { \ctex_set:n }
+\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup }
-      { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXsetup { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXsetup
+          { \ctexset {~#2~=~{~#1~}~}~is~set. }
+        \ctex_set:nn {#2} {#1}
+      }
   }
-\NewDocumentCommand \CTEXoptions { +o }
+\NewDocumentCommand \CTEXoptions { +O { } }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions }
-      { \ctexset~ {~ #1~ }~ is~ set. }
-    \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} }
+    \tl_if_blank:nTF {#1}
+      { \ctex_deprecated_command:Nn \CTEXoptions { } }
+      {
+        \ctex_deprecated_command:Nn \CTEXoptions
+          { \ctexset {~#1~}~is~set. }
+        \ctex_set:n {#1}
+      }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     autoindent .choice: ,
     autoindent .default:n = { true } ,
@@ -410,9 +402,9 @@
       }
   }
 \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: }
-\cs_new_protected_nopar:Npn \ctex_select_size:
+\cs_new_protected:Npn \ctex_select_size:
   { \cs_if_free:NTF \size at update { \ctex_update_size: } { \selectfont } }
-\cs_new_protected_nopar:Npn \ctex_update_size:
+\cs_new_protected:Npn \ctex_update_size:
   {
     \tl_if_eq:NNTF \l__ctex_ziju_tl \c__ctex_zero_tl
       {
@@ -426,7 +418,7 @@
 \tl_set_eq:NN \l__ctex_ziju_tl \c__ctex_zero_tl
 \ctex_add_to_selectfont:n
   { \cs_if_free:NF \size at update { \ctex_update_size: } }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     linestretch .code:n =
       {
@@ -437,7 +429,7 @@
   }
 \tl_new:N \l__ctex_line_stretch_tl
 \tl_set:Nn \l__ctex_line_stretch_tl { \ccwd }
-\cs_new_protected_nopar:Npn \ctex_update_stretch:
+\cs_new_protected:Npn \ctex_update_stretch:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_tmp_dim { \l__ctex_line_stretch_tl }
@@ -472,7 +464,7 @@
         \ctex_update_ccglue:
       }
   }
-\cs_new_protected_nopar:Npn \ctex_update_parindent:
+\cs_new_protected:Npn \ctex_update_parindent:
   {
     \tl_if_empty:NF \l__ctex_autoindent_tl
       {
@@ -482,12 +474,12 @@
   }
 \NewDocumentCommand \ziju { m }
   { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D }
-\cs_new_protected_nopar:Npn \ctex_ziju:n #1
+\cs_new_protected:Npn \ctex_ziju:n #1
   {
     \tl_set:Nx \l__ctex_ziju_tl { \fp_eval:n {#1} }
     \ctex_select_size:
   }
-\cs_new_protected_nopar:Npn \ctex_update_ziju:
+\cs_new_protected:Npn \ctex_update_ziju:
   {
     \ctex_update_em_unit:
     \dim_set:Nn \l__ctex_ziju_dim { \l__ctex_ziju_tl \ccwd }
@@ -519,19 +511,20 @@
 \dim_new:N \l__ctex_ziju_dim
 \NewDocumentCommand \CTEXindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent }
-      { \parindent is~ set~ to~ 2\ccwd. }
-    \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd }
+    \ctex_deprecated_command:Nn \CTEXindent
+      { \parindent is~set~to~2\ccwd. }
+    \ctex_update_ccwd:
+    \dim_set:Nn \parindent { 2 \ccwd }
   }
 \NewDocumentCommand \CTEXnoindent { }
   {
-    \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent }
-      { \parindent is~ set~ to~ 0pt. }
+    \ctex_deprecated_command:Nn \CTEXnoindent
+      { \parindent is~set~to~0pt. }
     \dim_zero:N \parindent
   }
-\PassOptionsToPackage { encoding = \l__ctex_encoding_tl } { zhnumber }
+\PassOptionsToPackage { encoding = \g__ctex_encoding_tl } { zhnumber }
 \RequirePackage { zhnumber }
-\cs_new_nopar:Npn \chinese { \zhnum_counter:n }
+\cs_new:Npn \chinese { \zhnum_counter:n }
 \cs_new_eq:NN \@chinese \@zhnum
 \cs_new_eq:NN \Chinese \chinese
 \cs_new_eq:NN \CTEXcounter \use_none:n
@@ -549,7 +542,7 @@
 \NewDocumentCommand \CTEXdigits { m m }
   { \protected at edef #1 { \zhdigits {#2} } }
 \cs_set_eq:NN \CTEX at todayold \today
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     today .choice: ,
     today / old     .code:n =
@@ -575,7 +568,7 @@
     \tl_new:N \proofname
     \tl_set:Nn \proofname { Proof }
   }
-\keys_define:nn { ctex }
+\ctex_define:n
   {
     contentsname   .tl_set:N = \contentsname ,
     listfigurename .tl_set:N = \listfigurename ,
@@ -594,7 +587,7 @@
 \seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq
 \seq_gput_left:Nn \c__ctex_headings_seq { chapter }
 \seq_gput_left:Nn \c__ctex_headings_seq { part }
-\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
+\cs_new_protected:Npn \__ctex_initial_heading:n #1
   {
     \tl_new:c { CTEX at pre#1 }
     \tl_new:c { CTEX at post#1 }
@@ -624,7 +617,7 @@
         \group_end:
       }
   }
-\cs_new_protected_nopar:Npn \__ctex_def_heading_keys:n #1
+\cs_new_protected:Npn \__ctex_def_heading_keys:n #1
   {
     \tl_put_right:Nx \l__ctex_tmp_tl
       {
@@ -648,11 +641,8 @@
         #1 / hang        .bool_set:N = \exp_not:c { CTEX@#1 at hang } ,
         #1 / hang         .initial:n = true ,
         #1 / runin       .bool_set:N = \exp_not:c { CTEX@#1 at runin } ,
-        #1 / tocline         .code:n =
-          {
-            \cs_set:Npn \exp_not:c { CTEX@#1 at tocline}
-                        \exp_not:n { ####1####2 } { ####1 }
-          } ,
+        #1 / tocline      .cs_set:Np = \exp_not:c { CTEX@#1 at tocline}
+                                       \exp_not:n { ##1##2 } ,
         \__ctex_plus_key_aux:nn {#1} { break } ,
         \__ctex_plus_key_aux:nn {#1} { format } ,
         \__ctex_plus_key_aux:nn {#1} { nameformat } ,
@@ -662,7 +652,7 @@
         \__ctex_plus_key_aux:nn {#1} { aftertitle } ,
       }
   }
-\cs_new_nopar:Npn \__ctex_plus_key_aux:nn #1#2
+\cs_new:Npn \__ctex_plus_key_aux:nn #1#2
   {
     #1 / #2   .tl_set:N = \exp_not:c { CTEX@#1@#2 } ,
     #1 / #2 +   .code:n =
@@ -676,7 +666,7 @@
 \cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
   {
     \tl_set:cn { CTEX at pre#1 } {#2}
-    \IfNoValueTF {#3}
+    \tl_if_novalue:nTF {#3}
       { \tl_clear:c { CTEX at post#1 } }
       { \tl_set:cn { CTEX at post#1 } {#3} }
   }
@@ -697,18 +687,32 @@
     \__ctex_initial_heading:n {#1}
     \__ctex_def_heading_keys:n {#1}
   }
-\use:x
+\exp_args:NNo \group_end: \ctex_define:n { \l__ctex_tmp_tl }
+\cs_new_protected:Npn \CTEX at heading@format at initial
   {
-    \group_end:
-    \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } }
+    \normalfont
+    \tl_clear:N \l__ctex_autoindent_tl
+    \int_set:Nn \tex_interlinepenalty:D { 10 000 }
+    \tex_noindent:D
   }
-\cs_new_protected_nopar:Npn \CTEX at fixtopskip
+\cs_new_protected:Npn \ctex_indent_box:n #1
   {
+    \dim_set:Nn \tex_parindent:D {#1}
+    \__ctex_insert_indent:
+  }
+\cs_new_protected:Npn \__ctex_insert_indent:
+  {
+    \dim_compare:nNnF \tex_parindent:D = \c_zero_dim
+      { \tex_indent:D }
+  }
+\cs_new_eq:NN \CTEX at indentbox \ctex_indent_box:n
+\cs_new_protected:Npn \CTEX at fixtopskip
+  {
     \CTEX at fixheadingskip
     \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim
       { \skip_sub:Nn \l__ctex_heading_skip { \tex_topskip:D } }
   }
-\cs_new_protected_nopar:Npn \CTEX at fixheadingskip
+\cs_new_protected:Npn \CTEX at fixheadingskip
   {
     \par
     \dim_set:Nn \tex_prevdepth:D { -1000pt }
@@ -715,17 +719,17 @@
     \skip_sub:Nn \l__ctex_heading_skip { \tex_parskip:D }
   }
 \skip_new:N \l__ctex_heading_skip
-\cs_new_protected_nopar:Npn \CTEX at setheadingskip
+\cs_new_protected:Npn \CTEX at setheadingskip
   { \skip_set:Nn \l__ctex_heading_skip }
 \cs_new_eq:NN \CTEX at headingskip \l__ctex_heading_skip
 \ProvideDocumentCommand \partmark { m }
   { \markboth { } { } }
 \cs_new_eq:NN \CTEXifname \use_ii:nn
-\cs_new_protected_nopar:Npn \CTEX at ifnametrue
+\cs_new_protected:Npn \CTEX at ifnametrue
   { \cs_set_eq:NN \CTEXifname \use_i:nn }
-\cs_new_protected_nopar:Npn \CTEX at ifnamefalse
+\cs_new_protected:Npn \CTEX at ifnamefalse
   { \cs_set_eq:NN \CTEXifname \use_ii:nn }
-\cs_new_protected_nopar:Npn \CTEX at addloflotskip #1
+\cs_new_protected:Npn \CTEX at addloflotskip #1
   {
     \skip_set:Nn \l__ctex_heading_skip { \use:c { CTEX@#1 at lofskip } }
     \skip_if_eq:nnF { \l__ctex_heading_skip } { \c_zero_skip }
@@ -742,8 +746,6 @@
   }
 \cs_new_protected:Npn \CTEX at addtocline #1#2
   { \addcontentsline { toc } {#1} { \use:c { CTEX@#1 at tocline } {#1} {#2} } }
-\cs_new_protected_nopar:Npn \CTEX at disableautoindent
-  { \tl_clear:N \l__ctex_autoindent_tl }
 \renewcommand\part{%
   \CTEX at part@break
   \thispagestyle{\CTEX at part@pagestyle}%
@@ -772,51 +774,53 @@
   \fi
   \CTEX at gettitle{#1}%
   \CTEX at addtocline{part}{#1}%
-   \partmark{#1}%
-  {\interlinepenalty \@M
-   \CTEX at disableautoindent
-   \normalfont \CTEX at part@format
-   \CTEX at hangindent{part}%
-     {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
-   \CTEX at part@titleformat{#2}%
-   \CTEX at part@aftertitle}%
+  \partmark{#1}%
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}%
+        {\CTEXifname{\CTEX at partname\CTEX at part@aftername}{}}%
+      \CTEX at part@titleformat{#2}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
   \@endpart}
 \def\@spart#1{%
-    \CTEX at ifnamefalse
-    \CTEX at makeanchor@spart{part*}%
-    \CTEX at gettitle{#1}%
-    {\interlinepenalty \@M
-     \CTEX at disableautoindent
-     \normalfont \CTEX at part@format
-     \CTEX at hangindent{part}{}%
-     \CTEX at part@titleformat{#1}%
-     \CTEX at part@aftertitle}%
-    \@endpart}
+  \CTEX at ifnamefalse
+  \CTEX at makeanchor@spart{part*}%
+  \CTEX at gettitle{#1}%
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at part@format{%
+      \CTEX at headinghang{part}{}%
+      \CTEX at part@titleformat{#1}%
+      \CTEX at part@aftertitle}\par
+  \endgroup
+  \@endpart}
 \def\@endpart{%
-              \CTEX at setheadingskip \CTEX at part@afterskip
-              \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
-              \vskip \CTEX at headingskip
-              \newpage
-              \if at twoside
-               \if at openright
-                \null
-                \thispagestyle{empty}%
-                \newpage
-               \fi
-              \fi
-              \if at tempswa
-                \twocolumn
-              \fi}
+  \CTEX at setheadingskip \CTEX at part@afterskip
+  \ifodd \CTEX at part@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip
+  \newpage
+  \if at twoside
+    \if at openright
+      \null
+      \thispagestyle{empty}%
+      \newpage
+    \fi
+  \fi
+  \if at tempswa
+    \twocolumn
+  \fi}
 \renewcommand\chapter{%
-                    \CTEX at chapter@break
-                    \thispagestyle{\CTEX at chapter@pagestyle}%
-                    \global\@topnum\z@
-                    \ifodd \CTEX at chapter@afterindent
-                      \@afterindenttrue
-                    \else
-                      \@afterindentfalse
-                    \fi
-                    \secdef\@chapter\@schapter}
+  \CTEX at chapter@break
+  \thispagestyle{\CTEX at chapter@pagestyle}%
+  \global\@topnum\z@
+  \ifodd \CTEX at chapter@afterindent
+    \@afterindenttrue
+  \else
+    \@afterindentfalse
+  \fi
+  \secdef\@chapter\@schapter}
 \def\@chapter[#1]#2{%
   \ifnum \c at secnumdepth >\m at ne
     \if at mainmatter
@@ -860,33 +864,33 @@
   \CTEX at setheadingskip \CTEX at chapter@beforeskip
   \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
   \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}%
-     {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at chapter@format{%
+      \CTEX at headinghang{chapter}%
+        {\CTEXifname{\CTEX at chaptername\CTEX at chapter@aftername}{}}%
+      \CTEX at chapter@titleformat{#1}%
+      \CTEX at chapter@aftertitle}\par
+  \endgroup
+  \nobreak
+  \CTEX at setheadingskip \CTEX at chapter@afterskip
+  \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip}
 \def\@makeschapterhead#1{%
   \CTEX at setheadingskip \CTEX at chapter@beforeskip
   \ifodd \CTEX at chapter@fixskip \CTEX at fixtopskip \fi
   \vspace*{\CTEX at headingskip}%
-  {\CTEX at disableautoindent
-   \normalfont \CTEX at chapter@format
-   \interlinepenalty\@M
-   \CTEX at hangindent{chapter}{}%
-   \CTEX at chapter@titleformat{#1}%
-   \CTEX at chapter@aftertitle
-   \nobreak
-   \CTEX at setheadingskip \CTEX at chapter@afterskip
-   \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
-   \vskip \CTEX at headingskip
-  }}
+  \begingroup
+    \CTEX at heading@format at initial
+    \CTEX at chapter@format{%
+      \CTEX at headinghang{chapter}{}%
+      \CTEX at chapter@titleformat{#1}%
+      \CTEX at chapter@aftertitle}\par
+  \endgroup
+  \nobreak
+  \CTEX at setheadingskip \CTEX at chapter@afterskip
+  \ifodd \CTEX at chapter@fixskip \CTEX at fixheadingskip \fi
+  \vskip \CTEX at headingskip}
 \def\@startsection#1#2#3#4#5#6{%
   \if at noskipsec \leavevmode \fi
   \par
@@ -929,22 +933,22 @@
   \CTEX at gettitle{#7}%
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #6{%
-        \CTEX at hangfrom{\hskip\glueexpr #3\relax\@svsec}%
-        \interlinepenalty \@M
+        \CTEX at sectionhang{#3}{\@svsec}%
         \csname CTEX@#1 at titleformat\endcsname{#8}%
-        \csname CTEX@#1 at aftertitle\endcsname}%
+        \csname CTEX@#1 at aftertitle\endcsname}\par
     \endgroup
     \csname #1mark\endcsname{#7}%
     \CTEX at addtocline{#1}{#7}%
   \else
     \def\@svsechd{%
-    #6{\hskip\glueexpr #3\relax
-      \@svsec
-      \csname CTEX@#1 at titleformat\endcsname{#8}%
-      \csname CTEX@#1 at aftertitle\endcsname}%
-    \csname #1mark\endcsname{#7}%
-    \CTEX at addtocline{#1}{#7}}%
+      #6{%
+        {\CTEX at indentbox{#3}}\@svsec
+        \csname CTEX@#1 at titleformat\endcsname{#8}%
+        \csname CTEX@#1 at aftertitle\endcsname}%
+      \csname #1mark\endcsname{#7}%
+      \CTEX at addtocline{#1}{#7}}%
   \fi
   \@xsect{#5}}
 \def\@ssect#1#2#3#4#5{%
@@ -952,15 +956,15 @@
   \CTEX at gettitle{#5}%
   \unless \ifodd \CTEX at runin
     \begingroup
+      \CTEX at heading@format at initial
       #4{%
-        \CTEX at hangfrom{\hskip\glueexpr #1\relax}%
-          \interlinepenalty \@M
+        \CTEX at sectionhang{#1}{}%
           \CTEX at titleformat@n{#5}%
-          \CTEX at aftertitle}%
+          \CTEX at aftertitle}\par
     \endgroup
   \else
-    \def\@svsechd{#4{\hskip\glueexpr #1\relax
-                     \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
+    \def\@svsechd{#4{{\CTEX at indentbox{#1}}%
+      \CTEX at titleformat@n{#5}\CTEX at aftertitle}}%
   \fi
   \@xsect{#3}}
 \def\@xsect#1{%
@@ -980,7 +984,7 @@
         \clubpenalty\@M
         \begingroup \@svsechd \endgroup
         \unskip
-        \hskip\glueexpr #1\relax
+        \CTEX at heading@glue{#1}%
       \else
         \clubpenalty \@clubpenalty
         \everypar{}%
@@ -987,26 +991,41 @@
       \fi}%
   \fi
   \ignorespaces}
-\cs_new_protected:Npn \CTEX at hangindent #1#2
+\cs_new_protected:Npn \CTEX at headinghang #1
   {
-    \dim_set:Nn \parindent { \use:c { CTEX@#1 at indent } }
-    \bool_if:cTF { CTEX@#1 at hang }
-      { \@hangfrom { \__ctex_indent_aux: #2 } }
-      {#2}
+    \ctex_heading_hang:cnn
+      { CTEX@#1 at ha