%%
%% 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--2016
%%     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 f12457f 2016-05-16 00:55:34 +0800 Qing Lee <sobenlee@gmail.com> $
  {Heading modification for beamer (CTEX)}
\ProvidesExplFile{ctex-beamer.def}
  {\ExplFileDate}{2.4.2}{\ExplFileDescription}
\seq_new:N \c__ctex_headings_seq
\seq_gset_from_clist:Nn \c__ctex_headings_seq
  { part , section , subsection }
\cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1
  {
    \tl_new:c { CTEX@pre#1 }
    \tl_new:c { CTEX@post#1 }
    \tl_const:cx { CTEXthe#1 }
      {
        \exp_not:c { CTEX@pre#1 }
        \exp_not:c { CTEX@the#1 }
        \exp_not:c { CTEX@post#1 }
      }
    \tl_const:cx { CTEX@#1name }
      {
        \group_begin:
          \exp_not:c { CTEX@#1@nameformat }
            {
              \exp_not:c { CTEX@pre#1 }
              \exp_not:N \tl_if_empty:NTF
              \exp_not:c { CTEX@#1@numberformat }
                { \exp_not:c { CTEX@the#1 } }
                {
                  \group_begin:
                    \exp_not:c { CTEX@#1@numberformat }
                    \exp_not:c { CTEX@the#1 }
                  \group_end:
                }
              \exp_not:c { CTEX@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@the#1 } ,
        #1 / format        .tl_set:N = \exp_not:c { CTEX@#1@format } ,
        #1 / nameformat    .tl_set:N = \exp_not:c { CTEX@#1@nameformat } ,
        #1 / numberformat  .tl_set:N = \exp_not:c { CTEX@#1@numberformat } ,
        #1 / aftername     .tl_set:N = \exp_not:c { CTEX@#1@aftername } ,
        #1 / titleformat   .tl_set:N = \exp_not:c { CTEX@#1@titleformat } ,
        #1 / aftertitle    .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } ,
        #1 / beforeskip    .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } ,
        #1 / afterskip     .tl_set:N = \exp_not:c { CTEX@#1@afterskip} ,
        #1 / indent        .tl_set:N = \exp_not:c { CTEX@#1@indent } ,
        #1 / numbering   .bool_set:N = \exp_not:c { CTEX@#1@numbering } ,
        #1 / format+         .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } ,
        #1 / nameformat+     .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } ,
        #1 / numberformat+   .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } ,
        #1 / aftername+      .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } ,
        #1 / titleformat+    .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } ,
        #1 / aftertitle+     .code:n =
          { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } ,
        #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 ,
      }
  }
\NewDocumentCommand \ctex_assign_heading_name:nn
  { m > { \SplitArgument { \c_one } { , } } +m }
  { \__ctex_assign_heading_name:nnn {#1} #2 }
\cs_new_protected:Npn \__ctex_assign_heading_name:nnn #1#2#3
  {
    \tl_set:cn { CTEX@pre#1 } {#2}
    \IfNoValueTF {#3}
      { \tl_clear:c { CTEX@post#1 } }
      { \tl_set:cn { CTEX@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
    \par \addvspace{\glueexpr\CTEX@part@beforeskip\relax}%
    \parindent \dimexpr \CTEX@part@indent \relax
    \CTEX@part@format
    \ifodd \CTEX@part@numbering
      \CTEX@partname \CTEX@part@aftername
    \fi
    \begin{beamercolorbox}[sep=16pt,center,#1]{part title}
      \CTEX@part@titleformat \insertpart \CTEX@part@aftertitle
    \end{beamercolorbox}
    \par \addvspace{\glueexpr\CTEX@part@afterskip\relax}%
  \endgroup
}
\defbeamertemplate*{section page}{CTEX}[1][]{
  \begingroup
    \par \addvspace{\glueexpr\CTEX@section@beforeskip\relax}%
    \parindent \dimexpr \CTEX@section@indent \relax
    \CTEX@section@format
    \ifodd \CTEX@section@numbering
      \CTEX@sectionname \CTEX@section@aftername
    \fi
    \begin{beamercolorbox}[sep=12pt,center,#1]{part title}
      \CTEX@section@titleformat \insertsection \CTEX@section@aftertitle
    \end{beamercolorbox}
    \par \addvspace{\glueexpr\CTEX@section@afterskip\relax}%
  \endgroup
}
\defbeamertemplate*{subsection page}{CTEX}[1][]{
  \begingroup
    \par \addvspace{\glueexpr\CTEX@subsection@beforeskip\relax}%
    \parindent \dimexpr \CTEX@subsection@indent \relax
    \CTEX@subsection@format
    \ifodd \CTEX@subsection@numbering
      \CTEX@subsectionname \CTEX@subsection@aftername
    \fi
    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
      \CTEX@subsection@titleformat \insertsubsection \CTEX@subsection@aftertitle
    \end{beamercolorbox}
    \par \addvspace{\glueexpr\CTEX@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@setcurrentlabel@n #1
  {
    \protected@edef \@currentlabel
      {
        \cs_if_exist:cTF { CTEX@the#1 }
          { \exp_args:cc { p@#1 } { CTEX@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@the#1 \cs_end: } }
  }
\@ifpackageloaded { varioref }
  { \ctex_varioref_hook: }
  {
    \cs_new_eq:NN \CTEX@save@refstepcounter \refstepcounter
    \RenewDocumentCommand \refstepcounter { m }
      {
        \CTEX@save@refstepcounter {#1}
        \CTEX@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'.
