%%
%% This is file `ctexheading.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex.dtx  (with options: `style,ctexheading')
%% 
%%     Copyright (C) 2003--2018
%%     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.
%% 
%% ------------------------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\GetIdInfo$Id: ctex.dtx 096f319 2018-05-02 19:51:41 +0800 Liam Huang <liamhuang0205@gmail.com> $
  {Heading style modification (CTEX)}
\ProvidesExplPackage{ctexheading}
  {\ExplFileDate}{2.4.14}{\ExplFileDescription}
\RequirePackage { xparse , l3keys2e }
\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_file_wrapper:nnn #1#2#3
  {
    \use:x
      {
        \ExplSyntaxOff
        \char_set_catcode_letter:n { 64 }
        #1
        \exp_not:n {#2}
        \bool_if:NTF \l__kernel_expl_bool
          { \ExplSyntaxOn }
          { \ExplSyntaxOff }
        \char_set_catcode:nn { 64 } { \char_value_catcode:n { 64 } }
        #3
      }
  }
\cs_new_protected_nopar:Npn \ctex_file_input:n #1
  { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } }
\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1
  {
    \ctex_file_wrapper:nnn
      { }
      {
        \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 } }
      }
      { }
  }
\cs_generate_variant:Nn \ctex_scheme_input:n { o }
\cs_new_eq:NN \g__ctex_section_depth_flag \c_two
\keys_define:nn { ctex / option }
  {
    sub3section .code:n =
      { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_three } ,
    sub4section .code:n =
      { \cs_gset_eq:NN \g__ctex_section_depth_flag \c_four } ,
    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 }
  }
\ProcessKeysOptions { ctex / option }
\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } }
\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:nnx { ctex } { not-standard-class } { \c__ctex_class_tl }
      }
    \ctex_file_input:n { ctex- \c__ctex_class_tl .def }
  }
%% 
%%     This package consists of the file  ctex.dtx,
%%                  and the derived files ctex.pdf,
%%                                        ctex.ins,
%%                                        ctex.sty,
%%                                        ctexsize.sty,
%%                                        ctexheading.sty,
%%                                        ctexart.cls,
%%                                        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-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,
%%                                        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,
%%                                        ctex-fontset-windows.def,
%%                                        ctex-fontset-windowsnew.def,
%%                                        ctex-fontset-windowsold.def,
%%                                        ctex-fontset-adobe.def,
%%                                        ctex-fontset-fandol.def,
%%                                        ctex-fontset-mac.def,
%%                                        ctex-fontset-macnew.def,
%%                                        ctex-fontset-macold.def,
%%                                        ctex-fontset-founder.def,
%%                                        ctex-fontset-ubuntu.def,
%%                                        ctexspa.def,
%%                                        ctexpunct.spa,
%%                                        ctexmakespa.tex,
%%                                        ctexspamacro.tex,
%%                                        ctxdocstrip.tex,
%%                                        zhadobefonts.tex,
%%                                        zhfandolfonts.tex,
%%                                        zhfounderfonts.tex,
%%                                        zhubuntufonts.tex,
%%                                        zhwindowsfonts.tex,
%%                                        translator-theorem-dictionary-ChineseGBK.dict,
%%                                        translator-theorem-dictionary-ChineseUTF8.dict, and
%%                                        README.md.
%%
%% End of file `ctexheading.sty'.
