FvNCCR228 / SCU_Beamer_Slide-demo

四川大学非官方Beamer模板 | Unofficial Beamer Template for Sichuan University
LaTeX Project Public License v1.3c
86 stars 13 forks source link

Code reconstruction of theorem block on v1.1a. #1

Closed FvNCCR228 closed 2 years ago

FvNCCR228 commented 2 years ago

This issue presents the complete code of the v1.1a of the theorem block that will be released in the future.

\documentclass{article}

\usepackage{ctex}
\usepackage{xcolor}
\usepackage{tcolorbox}
\usepackage{xparse}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{cleveref}
\tcbuselibrary{most,xparse}

\definecolor{JXred}{cmyk}{0.12,0.92,0.95,0.20}
\definecolor{YYgrey}{cmyk}{0.47,0.37,0.37,0.00}
\definecolor{BSblue}{cmyk}{1.00,0.60,0.00,0.15}
\definecolor{HYgreen}{cmyk}{1.00,0.00,0.90,0.15}
\definecolor{YXyellow}{cmyk}{0.00,0.40,1.00,0.15}

\makeatletter
% 定理盒子主题颜色定义.
\def\beamer@scu@tcbcolortheo@theo{JXred}
\def\beamer@scu@tcbcolortheo@exa{YYgrey}
\def\beamer@scu@tcbcolortheo@def{BSblue}
\def\beamer@scu@tcbcolortheo@lem{HYgreen}
\def\beamer@scu@tcbcolortheo@cond{YXyellow}

% 定理盒子基础样式定义.
\def\beamer@scu@tcbstyletheo#1{%
    \tcbset{tcb#1style/.style=%
        {enhanced jigsaw,%
        drop fuzzy shadow southeast,%
        toprule=3mm,leftrule=1mm,%
        boxsep=-.5mm,arc=1.5mm,%
        left=1.8mm,right=2mm,top=2.5mm,%
        colback=\csname beamer@scu@tcbcolortheo@#1\endcsname!2!white,%
        colframe=\csname beamer@scu@tcbcolortheo@#1\endcsname,%
        opacityback=0.95,%
        attach boxed title to top left={%
            yshift=-4mm,xshift=2mm},%
        boxed title style={%
            arc=2.5mm,top=-.5mm,bottom=-.5mm,%
            leftrule=1.5mm,rightrule=1.5mm,%
            colback=\csname beamer@scu@tcbcolortheo@#1\endcsname!5!white,%
            colframe=\csname beamer@scu@tcbcolortheo@#1\endcsname},%
        fonttitle=\normalsize\bfseries,%
        coltitle=black}%
    }%
}

% 基础样式应用.
\beamer@scu@tcbstyletheo{theo}
\beamer@scu@tcbstyletheo{exa}
\beamer@scu@tcbstyletheo{def}
\beamer@scu@tcbstyletheo{lem}
\beamer@scu@tcbstyletheo{cond}

% 定理区块名称设置.
\def\beamer@scu@theonametheorem{定理}
\def\beamer@scu@theonameexample{例}
\def\beamer@scu@theonamealgorithm{算法}
\def\beamer@scu@theonamedefinition{定义}
\def\beamer@scu@theonameaxiom{公理}
\def\beamer@scu@theonameproperty{性质}
\def\beamer@scu@theonameproposition{命题}
\def\beamer@scu@theonamelemma{引理}
\def\beamer@scu@theonamecorollary{推论}
\def\beamer@scu@theonamecondition{条件}
\def\beamer@scu@theonameconclusion{结论}
\def\beamer@scu@theonameassumption{假设}
\def\beamer@scu@theonameremark{注}
\def\beamer@scu@theonameproof{证明}

% theorem, example, algorithm, definition, axiom, property, proposition, lemma, corollary, condition, conclusion, assumption 设置.
% 计数器定义.
\newcounter{beamer@scu@theorem@count}
\newcounter{beamer@scu@example@count}
\newcounter{beamer@scu@algorithm@count}
\newcounter{beamer@scu@definition@count}
\newcounter{beamer@scu@axiom@count}
\newcounter{beamer@scu@property@count}
\newcounter{beamer@scu@proposition@count}
\newcounter{beamer@scu@lemma@count}
\newcounter{beamer@scu@corollary@count}
\newcounter{beamer@scu@condition@count}
\newcounter{beamer@scu@conclusion@count}
\newcounter{beamer@scu@assumption@count}
% 智能引用名称定义.
\Crefname{beamer@scu@theorem@count}%
    {\beamer@scu@theonametheorem}%
    {\beamer@scu@theonametheorem}
\Crefname{beamer@scu@example@count}%
    {\beamer@scu@theonameexample}%
    {\beamer@scu@theonameexample}
\Crefname{beamer@scu@algorithm@count}%
    {\beamer@scu@theonamealgorithm}%
    {\beamer@scu@theonamealgorithm}
\Crefname{beamer@scu@definition@count}%
    {\beamer@scu@theonamedefinition}%
    {\beamer@scu@theonamedefinition}
\Crefname{beamer@scu@axiom@count}%
    {\beamer@scu@theonameaxiom}%
    {\beamer@scu@theonameaxiom}
\Crefname{beamer@scu@property@count}%
    {\beamer@scu@theonameproperty}%
    {\beamer@scu@theonameproperty}
\Crefname{beamer@scu@proposition@count}%
    {\beamer@scu@theonameproposition}%
    {\beamer@scu@theonameproposition}
\Crefname{beamer@scu@lemma@count}%
    {\beamer@scu@theonamelemma}%
    {\beamer@scu@theonamelemma}
\Crefname{beamer@scu@corollary@count}%
    {\beamer@scu@theonamecorollary}%
    {\beamer@scu@theonamecorollary}
\Crefname{beamer@scu@condition@count}%
    {\beamer@scu@theonamecondition}%
    {\beamer@scu@theonamecondition}
\Crefname{beamer@scu@conclusion@count}%
    {\beamer@scu@theonameconclusion}%
    {\beamer@scu@theonameconclusion}
\Crefname{beamer@scu@assumption@count}%
    {\beamer@scu@theonameassumption}%
    {\beamer@scu@theonameassumption}
% 定理区块参数设置.
% #1: 后缀 - 环境名称.
% #2: 前缀 - 样式类型.
% #3: 前缀 - 标签.
% ##1: <可选>附加参数.
% ##2: 标题.
% ##3: 后缀 - 标签.
\def\beamer@scu@theo#1#2#3{%
    \newtcolorbox[use counter=beamer@scu@#1@count,%
    number within=section]{scu#1}[3][]{%
        title={\csname beamer@scu@theoname#1\endcsname~%
            \thetcbcounter\ifstrempty{##2}{}{:~##2}},%
        IfValueT={##3}{label={#3:##3}},#2style,##1}%
}
\beamer@scu@theo{theorem}           {tcbtheo}   {theo}
\beamer@scu@theo{example}           {tcbexa}    {exam}
\beamer@scu@theo{algorithm}     {tcbexa}    {algo}
\beamer@scu@theo{definition}    {tcbdef}    {def}
\beamer@scu@theo{axiom}             {tcbtheo}   {axio}
\beamer@scu@theo{property}      {tcbdef}    {prope}
\beamer@scu@theo{proposition}   {tcbdef}    {propo}
\beamer@scu@theo{lemma}             {tcblem}    {lemm}
\beamer@scu@theo{corollary}     {tcblem}    {coro}
\beamer@scu@theo{condition}     {tcbcond}   {cond}
\beamer@scu@theo{conclusion}    {tcblem}    {conc}
\beamer@scu@theo{assumption}    {tcbcond}   {assu}

% scuremark 设置.
% 计数器定义.
\newcounter{beamer@scu@remark@count}
% 智能引用名称定义.
\Crefname{beamer@scu@remark@count}%
    {\beamer@scu@theonameremark}%
    {\beamer@scu@theonameremark}
% 定理区块参数设置.
\newtcolorbox[use counter=beamer@scu@remark@count,%
    no counter]{scuremark}[3][]{%
        title={\beamer@scu@theonameremark%
            \ifstrempty{#2}{}{:~#2}},%
        IfValueT={#3}{label={rema:#3}},%
        tcbexastyle,#1}

% scuproof 设置.
% 计数器定义.
\newcounter{beamer@scu@proof@count}
% 智能引用名称定义.
\Crefname{beamer@scu@proof@count}%
    {\beamer@scu@theonameproof}%
    {\beamer@scu@theonameproof}
% 定理区块参数设置.
\newtcolorbox[use counter=beamer@scu@proof@count,%
    no counter]{scuproof}[3][]{%
        title={% \@addpunct: Be intelligently omitted when punctuation is already present.
            \ifblank{#2}{\beamer@scu@theonameproof}{#2}\@addpunct{.}},%
        after upper={\par\hfill\qed},%
        IfValueT={#3}{label={proo:#3}},%
        tcbexastyle,#1}
\makeatother

\begin{document}

\section{定理区块示例}
\begin{scutheorem}{定理示例}{theorem}
    这是定理.
\end{scutheorem}
\begin{scuproof}{}{}
    这是证明.
\end{scuproof}
\begin{scuexample}{例子示例}{example}
    这是例子.
\end{scuexample}
\begin{scualgorithm}{算法示例}{algorithm}
    这是算法.
\end{scualgorithm}
\begin{scudefinition}{定义示例}{definition}
    这是定义.
\end{scudefinition}
\begin{scuaxiom}{公理示例}{axiom}
    这是公理.
\end{scuaxiom}
\begin{scuproperty}{性质示例}{property}
    这是性质.
\end{scuproperty}
\begin{scuproposition}{命题示例}{proposition}
    这是命题.
\end{scuproposition}
\begin{sculemma}{引理示例}{lemma}
    这是引理.
\end{sculemma}
\begin{scucorollary}{推论示例}{corollary}
    这是推论.
\end{scucorollary}
\begin{scuremark}{}{}
    这是注解.
\end{scuremark}
\begin{scucondition}{条件示例}{condition}
    这是条件.
\end{scucondition}
\begin{scuconclusion}{结论示例}{conclusion}
    这是结论.
\end{scuconclusion}
\begin{scuassumption}{假设示例}{assumption}
    这是假设.
\end{scuassumption}

\end{document}
muzimuzhi commented 2 years ago
FvNCCR228 commented 2 years ago
  • beamer 有自己的一套定理环境和 beamer theme,完全可以基于它进行定制
  • 用不着把颜色名储存在命令里,如 \csname beamer@scu@theoname#1\endcsname

理解错了,直接宏定义加选项就行了。

muzimuzhi commented 2 years ago

不是,以上两条是独立的,不是相互关联的。

根据 beamer 文档 sec. 12.4 "Theorem Environments",beamer 有一整套预定义的、可配置的定理类环境。要定义新的定理环境,也有 beamer 修改过的 \newtheorem 可以用。

tcolorbox 定义的定理环境,好处是在各种文档类里通用,不足是不支持 beamer 的 overlay action(见文档 sec. 9 "9 Creating Overlays")。

FvNCCR228 commented 2 years ago

不是,以上两条是独立的,不是相互关联的。

根据 beamer 文档 sec. 12.4 "Theorem Environments",beamer 有一整套预定义的、可配置的定理类环境。要定义新的定理环境,也有 beamer 修改过的 \newtheorem 可以用。

tcolorbox 定义的定理环境,好处是在各种文档类里通用,不足是不支持 beamer 的 overlay action(见文档 sec. 9 "9 Creating Overlays")。

我试了一下,应该是指不能直接在环境名后面加overlay吧

在前面用\pause等是可以的

FvNCCR228 commented 2 years ago

不是,以上两条是独立的,不是相互关联的。

根据 beamer 文档 sec. 12.4 "Theorem Environments",beamer 有一整套预定义的、可配置的定理类环境。要定义新的定理环境,也有 beamer 修改过的 \newtheorem 可以用。

tcolorbox 定义的定理环境,好处是在各种文档类里通用,不足是不支持 beamer 的 overlay action(见文档 sec. 9 "9 Creating Overlays")。

我重新修改了一下代码,给tcolorbox外面嵌套了一层beamer的action overlay环境,现在支持overlay了

\documentclass{beamer}

\usepackage{ctex}
\usepackage{xcolor}
\usepackage{tcolorbox}
\usepackage{xparse}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{cleveref}
\tcbuselibrary{most,xparse}

\definecolor{JXred}{cmyk}{0.12,0.92,0.95,0.20}
\definecolor{YYgrey}{cmyk}{0.47,0.37,0.37,0.00}
\definecolor{BSblue}{cmyk}{1.00,0.60,0.00,0.15}
\definecolor{HYgreen}{cmyk}{1.00,0.00,0.90,0.15}
\definecolor{YXyellow}{cmyk}{0.00,0.40,1.00,0.15}

\makeatletter

% 定理盒子基础样式定义.
% #1: 关键字 - 样式类型.
% #2: 颜色.
\def\beamer@scu@tcbstyletheo#1#2{%
    \tcbset{tcb#1style/.style=%
        {enhanced jigsaw,%
            drop fuzzy shadow southeast,%
            toprule=3mm,leftrule=1mm,%
            boxsep=-.5mm,arc=1.5mm,%
            left=1.8mm,right=2mm,top=2.5mm,%
            colback=#2!3!white,colframe=#2,%
            coltitle=black,opacityback=.95,%
            attach boxed title to top left={%
                yshift=-4mm,xshift=2mm},%
            boxed title style={%
                arc=2.5mm,top=-.5mm,bottom=-.5mm,%
                leftrule=1.5mm,rightrule=1.5mm,%
                colback=#2!8!white,colframe=#2},%
            fonttitle=\normalsize\bfseries,%
            breakable,break at=.785\textheight,%
            pad at break=.5ex}%
    }%
}

% 基础样式应用.
\beamer@scu@tcbstyletheo{theo}{JXred}
\beamer@scu@tcbstyletheo{exa} {YYgrey}
\beamer@scu@tcbstyletheo{def} {BSblue}
\beamer@scu@tcbstyletheo{lem} {HYgreen}
\beamer@scu@tcbstyletheo{cond}{YXyellow}

% 定理区块名称设置.
\def\beamer@scu@theonametheorem{定理}
\def\beamer@scu@theonameexample{例}
\def\beamer@scu@theonamealgorithm{算法}
\def\beamer@scu@theonamedefinition{定义}
\def\beamer@scu@theonameaxiom{公理}
\def\beamer@scu@theonameproperty{性质}
\def\beamer@scu@theonameproposition{命题}
\def\beamer@scu@theonamelemma{引理}
\def\beamer@scu@theonamecorollary{推论}
\def\beamer@scu@theonamecondition{条件}
\def\beamer@scu@theonameconclusion{结论}
\def\beamer@scu@theonameassumption{假设}
\def\beamer@scu@theonameremark{注}
\def\beamer@scu@theonameproof{证明}

% theorem, example, algorithm, definition, axiom, property, proposition, lemma, corollary, condition, conclusion, assumption 设置.
% 计数器定义.
\newcounter{beamer@scu@theorem@count}
\newcounter{beamer@scu@example@count}
\newcounter{beamer@scu@algorithm@count}
\newcounter{beamer@scu@definition@count}
\newcounter{beamer@scu@axiom@count}
\newcounter{beamer@scu@property@count}
\newcounter{beamer@scu@proposition@count}
\newcounter{beamer@scu@lemma@count}
\newcounter{beamer@scu@corollary@count}
\newcounter{beamer@scu@condition@count}
\newcounter{beamer@scu@conclusion@count}
\newcounter{beamer@scu@assumption@count}
% 智能引用名称定义.
\Crefname{beamer@scu@theorem@count}%
{\beamer@scu@theonametheorem}%
{\beamer@scu@theonametheorem}
\Crefname{beamer@scu@example@count}%
{\beamer@scu@theonameexample}%
{\beamer@scu@theonameexample}
\Crefname{beamer@scu@algorithm@count}%
{\beamer@scu@theonamealgorithm}%
{\beamer@scu@theonamealgorithm}
\Crefname{beamer@scu@definition@count}%
{\beamer@scu@theonamedefinition}%
{\beamer@scu@theonamedefinition}
\Crefname{beamer@scu@axiom@count}%
{\beamer@scu@theonameaxiom}%
{\beamer@scu@theonameaxiom}
\Crefname{beamer@scu@property@count}%
{\beamer@scu@theonameproperty}%
{\beamer@scu@theonameproperty}
\Crefname{beamer@scu@proposition@count}%
{\beamer@scu@theonameproposition}%
{\beamer@scu@theonameproposition}
\Crefname{beamer@scu@lemma@count}%
{\beamer@scu@theonamelemma}%
{\beamer@scu@theonamelemma}
\Crefname{beamer@scu@corollary@count}%
{\beamer@scu@theonamecorollary}%
{\beamer@scu@theonamecorollary}
\Crefname{beamer@scu@condition@count}%
{\beamer@scu@theonamecondition}%
{\beamer@scu@theonamecondition}
\Crefname{beamer@scu@conclusion@count}%
{\beamer@scu@theonameconclusion}%
{\beamer@scu@theonameconclusion}
\Crefname{beamer@scu@assumption@count}%
{\beamer@scu@theonameassumption}%
{\beamer@scu@theonameassumption}
% 定理区块参数设置.
% #1: 后缀 - 环境名称.
% #2: 前缀 - 样式类型.
% #3: 前缀 - 标签.
% ##1: <可选>附加参数.
% ##2: 标题.
% ##3: 后缀 - 标签.
\def\beamer@scu@theo#1#2#3{%
    \newtcolorbox[use counter=beamer@scu@#1@count,%
    number within=section]{beamer@scu@original#1}[3][]{%
        title={\csname beamer@scu@theoname#1\endcsname~%
            \thetcbcounter\ifstrempty{##2}{}{:~##2}},%
        IfValueT={##3}{label={#3:##3}},#2style,##1}%
    \newenvironment<>{scu#1}[3][]%
        {\begin{actionenv}##4\begin{beamer@scu@original#1}[##1]{##2}{##3}}%
        {\end{beamer@scu@original#1}\end{actionenv}}%
}

\beamer@scu@theo{theorem}           {tcbtheo}   {theo}
\beamer@scu@theo{example}           {tcbexa}    {exam}
\beamer@scu@theo{algorithm}     {tcbexa}    {algo}
\beamer@scu@theo{definition}    {tcbdef}    {def}
\beamer@scu@theo{axiom}             {tcbtheo}   {axio}
\beamer@scu@theo{property}      {tcbdef}    {prope}
\beamer@scu@theo{proposition}   {tcbdef}    {propo}
\beamer@scu@theo{lemma}             {tcblem}    {lemm}
\beamer@scu@theo{corollary}     {tcblem}    {coro}
\beamer@scu@theo{condition}     {tcbcond}   {cond}
\beamer@scu@theo{conclusion}    {tcblem}    {conc}
\beamer@scu@theo{assumption}    {tcbcond}   {assu}

% scuremark 设置.
% 计数器定义.
\newcounter{beamer@scu@remark@count}
% 智能引用名称定义.
\Crefname{beamer@scu@remark@count}%
{\beamer@scu@theonameremark}%
{\beamer@scu@theonameremark}
% 定理区块参数设置.
\newtcolorbox[use counter=beamer@scu@remark@count,%
no counter]{scuremark}[3][]{%
    title={\beamer@scu@theonameremark%
        \ifstrempty{#2}{}{:~#2}},%
    IfValueT={#3}{label={rema:#3}},%
    tcbexastyle,#1}

% scuproof 设置.
% 计数器定义.
\newcounter{beamer@scu@proof@count}
% 智能引用名称定义.
\Crefname{beamer@scu@proof@count}%
{\beamer@scu@theonameproof}%
{\beamer@scu@theonameproof}
% 定理区块参数设置.
\newtcolorbox[use counter=beamer@scu@proof@count,%
no counter]{scuproof}[3][]{%
    title={% \@addpunct: Be intelligently omitted when punctuation is already present.
        \ifblank{#2}{\beamer@scu@theonameproof}{#2}\@addpunct{.}},%
    after upper={\par\hfill\qed},%
    IfValueT={#3}{label={proo:#3}},%
    tcbexastyle,#1}
\makeatother

\begin{document}

    \section{定理区块示例}
    \begin{frame}{1}
        \begin{scutheorem}<1>{定理示例}{theorem}
            这是定理.
        \end{scutheorem}
        \begin{scuproof}{}{}
            这是证明.
        \end{scuproof}
    \end{frame}
    \begin{frame}{1}
        \begin{scuexample}<1->{例子示例}{example}
            这是例子.
        \end{scuexample}
        \begin{scualgorithm}<2->{算法示例}{algorithm}
            这是算法.
        \end{scualgorithm}
    \end{frame}
    \begin{frame}{1}
        \begin{scudefinition}{定义示例}{definition}<2->
            这是定义.
        \end{scudefinition}
        \begin{scuaxiom}{公理示例}{axiom}<1->
            这是公理.
        \end{scuaxiom}
    \end{frame}
    \begin{frame}{1}
        \begin{scuproperty}{性质示例}{property}
            这是性质.
        \end{scuproperty}
        \begin{scuproposition}{命题示例}{proposition}
            这是命题.
        \end{scuproposition}
    \end{frame}
    \begin{frame}{1}
        \begin{sculemma}{引理示例}{lemma}
            这是引理.
        \end{sculemma}
        \begin{scucorollary}{推论示例}{corollary}
            这是推论.
        \end{scucorollary}
    \end{frame}
    \begin{frame}{1}
        \begin{scuremark}{}{}
            这是注解.
        \end{scuremark}
        \begin{scucondition}{条件示例}{condition}
            这是条件.
        \end{scucondition}
    \end{frame}
    \begin{frame}{1}
        \begin{scuconclusion}{结论示例}{conclusion}
            这是结论.
        \end{scuconclusion}
        \begin{scuassumption}{假设示例}{assumption}
            这是假设.
        \end{scuassumption}
    \end{frame}

\end{document}