%%
%% This is file `ctexheading.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex-kernel.dtx  (with options: `style,ctexheading')
%% -----------------------------------------------------------------------
%%   Copyright (C) 2003--2026                                            *
%%   CTEX.ORG and any individual authors listed elsewhere in this file.  *
%% -----------------------------------------------------------------------
%%   This work may be distributed and/or modified under the conditions   *
%%   of the LaTeX Project Public License (LPPL), either version 1.3c of  *
%%   this license or (at your option) any later version.                 *
%%   The latest version of this license is in                            *
%%                                                                       *
%%       http://www.latex-project.org/lppl.txt                           *
%%                                                                       *
%%   and version 1.3c or later is part of all distributions of LaTeX     *
%%   version 2008 or later.                                              *
%%                                                                       *
%%   This work has the LPPL maintenance status `maintained'.             *
%% -----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[2026/06/01]
\RequirePackage{expl3}
\GetIdInfo $Id: ctex-kernel.dtx 2.6.3 2026-07-08 18:13:24 +0800 8c6212ee Mingyu Hsia <myhsia@outlook.com>$
  {Heading style modification (CTEX)}
\ProvidesExplPackage{ctexheading}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\cs_if_exist:NF \NewDocumentCommand
  { \RequirePackage { xparse } }
\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexheading }
\RequirePackage { ctexhook , ctexpatch }
\tl_clear_new:N \l__ctex_tmp_tl
\int_new:N \l__ctex_tmp_int
\box_new:N \l__ctex_tmp_box
\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_scheme_input:n #1
  {
    \ctex_push_file:
      \tl_if_exist:NTF \c__ctex_class_tl
        {
          \file_if_exist_input:nF { ctex-scheme- #1 - \c__ctex_class_tl .def }
            { \file_input:n  { ctex-scheme- #1 .def } }
        }
        { \file_input:n  { ctex-scheme- #1 .def } }
    \ctex_pop_file:
  }
\cs_generate_variant:Nn \ctex_scheme_input:n { o }
\int_new:N \g__ctex_section_depth_int
\int_gset:Nn \g__ctex_section_depth_int { 2 }
\ctex_define_option:n
  {
    sub3section .code:n =
      { \int_gset:Nn \g__ctex_section_depth_int { 3 } } ,
    sub4section .code:n =
      { \int_gset:Nn \g__ctex_section_depth_int { 4 } } ,
    sub3section .value_forbidden:n = true ,
    sub4section .value_forbidden:n = true ,
    scheme .tl_set:N  = \l__ctex_scheme_tl ,
    scheme .default:n = { plain } ,
    scheme .initial:n = { plain }
  }
\cs_if_exist:NTF \ProcessKeyOptions
  { \ProcessKeyOptions [ ctex / option ] }
  {
    \RequirePackage { l3keys2e }
    \ProcessKeysOptions { ctex / option }
  }
\NewDocumentCommand \ctexset { } { \ctex_set:n }
\clist_map_inline:nn { article , book , report , beamer }
  {
    \@ifclassloaded {#1}
      { \clist_map_break:n { \tl_const:Nn \c__ctex_std_class_tl {#1} } }
      { }
  }
\msg_new:nnn { ctex } { not-standard-class }
  {
    None~of~the~standard~document~classes~was~loaded.\\
    Heading~`#1'~is~selected.\\
    ctex~may~not~work~as~expected.
  }
\use:n
  {
    \tl_if_exist:NTF \c__ctex_std_class_tl
      { \cs_new_eq:NN \c__ctex_class_tl \c__ctex_std_class_tl }
      {
        \cs_if_exist:NTF \chapter
          {
            \cs_if_exist:NF \if@mainmatter
              { \cs_new_eq:NN \if@mainmatter \tex_iftrue:D }
            \tl_const:Nn \c__ctex_class_tl { book }
          }
          { \tl_const:Nn \c__ctex_class_tl { article } }
        \msg_warning:nne { ctex } { not-standard-class } { \c__ctex_class_tl }
      }
    \ctex_file_input:n { ctex-heading- \c__ctex_class_tl .def }
  }
%% -----------------------------------------------------------------------
%%   This work consists of the files ctex.dtx,                           *
%%                                   ctex-kernel.dtx,                    *
%%                                   ctex-engine.dtx,                    *
%%                                   ctex-scheme.dtx,                    *
%%                                   ctex-auxpkg.dtx,                    *
%%                                   ctex-fontset.dtx,                   *
%%                                   ctexpunct.spa,                      *
%%                                   ctxdoc.cls,                         *
%%                                   ctxdocstrip.tex,                    *
%%                                   ctex-zhconv.lua,                    *
%%                                   ctex-zhconv-index.lua,              *
%%                                   ctex-zhconv-make.lua,               *
%%                 the derived files 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,            *
%%                                   ctexbackend.cfg,                    *
%%                                   ctex-engine-pdftex.def,             *
%%                                   ctex-engine-xetex.def,              *
%%                                   ctex-engine-luatex.def,             *
%%                                   ctex-engine-aptex.def,              *
%%                                   ctex-engine-uptex.def,              *
%%                                   ctex-name-utf8.cfg,                 *
%%                                   ctex-name-gbk.cfg,                  *
%%                                   ctex.cfg,                           *
%%                                   ctexopts.cfg,                       *
%%                                   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-fontset-adobe.def,             *
%%                                   ctex-fontset-fandol.def,            *
%%                                   ctex-fontset-founder.def,           *
%%                                   ctex-fontset-hanyi.def,             *
%%                                   ctex-fontset-mac.def,               *
%%                                   ctex-fontset-macnew.def,            *
%%                                   ctex-fontset-macold.def,            *
%%                                   ctex-fontset-ubuntu.def,            *
%%                                   ctex-fontset-windows.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,                         *
%%                                   ctexspa.def,                        *
%%                     translator-theorem-dictionary-ChineseUTF8.dict,   *
%%                     translator-theorem-dictionary-ChineseGBK.dict,    *
%%                                   ctex-spa-make.tex,                  *
%%                                   ctex-spa-macro.tex,                 *
%%                                   ctex-zhmap-adobe.tex,               *
%%                                   ctex-zhmap-fandol.tex,              *
%%                                   ctex-zhmap-founder.tex,             *
%%                                   ctex-zhmap-hanyi.tex,               *
%%                                   ctex-zhmap-mac.tex,                 *
%%                                   ctex-zhmap-ubuntu.tex,              *
%%                                   ctex-zhmap-windows.tex,             *
%%           the documentation files ctex.pdf,                           *
%%                               and README.md.                          *
%% -----------------------------------------------------------------------
%%
%% End of file `ctexheading.sty'.
