Skip to content

Commit

Permalink
增加定理类环境功能
Browse files Browse the repository at this point in the history
  • Loading branch information
sikouhjw committed Jan 23, 2022
1 parent dd2b275 commit 330dadd
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gdutthesis.pdf
main.pdf
*.tec
example/*.pdf
test.*

## Intermediate documents:
*.dvi
Expand Down
20 changes: 20 additions & 0 deletions example/Qiuyun_Zou.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
fullwidth-stop = {false},
hyperlink = {none},
},
theorem = {
header-font = bf,
body-font = rm,
indent = en,
interval = dash,
punct = colon,
braces = paren,
qed = \qedsymbol,
},
info = {
title = {贝叶斯推论快速近似算法研究},
title* = {Research on Fast Approximate Algorithm based Bayesian Inference},
Expand Down Expand Up @@ -150,6 +159,17 @@
$\mbf \Lambda = \Diag ( \lambda_1, \lambda_2, \cdots, \lambda_r )$
并且 $\lambda_1 \geqslant \lambda_2 \geqslant \cdots \geqslant \lambda_r \geqslant 0$

\gdutsubsection{概率论}{Theory of Probability}
\begin{lemma}[标量高斯相乘引理]
假设 $\mscr N ( x | a, A )$$\mscr N ( x | b, B )$,则有
\begin{equation}
\mscr N ( x | a, A ) \mscr N ( x | b, B ) = \mscr N ( 0 | a - b, A + B ) \mscr N \left( x \middle| \frac{ \frac{a}{A} + \frac{b}{B} }{ \frac{1}{A} + \frac{1}{B} }, \frac{ 1 }{ \frac{1}{A} + \frac{1}{B} } \right)
\end{equation}
\end{lemma}
\begin{proof}
标量高斯相乘引理的证明分为两个部分,分别是指数部分和常数部分。
\end{proof}

\gdutsubsection{贝叶斯估计原理}{Principle of Bayesian Estimation}
\gdutsubsection{最小均方误差估计}{Minimum Mean Square Error Estimation}

Expand Down
119 changes: 117 additions & 2 deletions gdutthesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@
everypage-1x,
background,
fancyhdr,
amsthm,
thmtools,
graphicx,
longtable,
caption,
Expand Down Expand Up @@ -906,6 +908,111 @@
fixskip = true,
},
}
\tl_new:N \l__gdut_thm_header_font_tl
\tl_new:N \l__gdut_thm_body_font_tl
\tl_new:N \l__gdut_thm_qed_tl
\tl_new:N \l__gdut_thm_punct_tl
\tl_new:N \l__gdut_thm_left_braces_tl
\tl_new:N \l__gdut_thm_right_braces_tl
\tl_new:N \gdutinterval
\dim_new:N \l__gdut_indent_dim
\keys_define:nn { gdut / theorem }
{
header-font .choice:,
header-font .value_required:n = true,
header-font / bf .code:n =
{ \cs_set_eq:NN \l__gdut_thm_header_font_tl \bfseries },
header-font / sf .code:n =
{ \cs_set_eq:NN \l__gdut_thm_header_font_tl \sffamily },
body-font .choice:,
body-font .value_required:n = true,
body-font / rm .code:n =
{ \cs_set_eq:NN \l__gdut_thm_body_font_tl \normalfont },
body-font / kai .code:n =
{ \cs_set_eq:NN \l__gdut_thm_body_font_tl \gdut@kai },
indent .choice:,
indent .value_required:n = true,
indent / en .code:n =
{ \dim_set:Nn \l__gdut_indent_dim {0pt} },
indent / cn .code:n =
{ \dim_set:Nn \l__gdut_indent_dim {2\ccwd} },
interval .choice:,
interval .value_required:n = true,
interval / dot .code:n =
{ \cs_set_eq:NN \gdutinterval . },
interval / dash .code:n =
{ \cs_set_eq:NN \gdutinterval - },
punct .choice:,
punct .value_required:n = true,
punct / colon .code:n =
{ \cs_set_eq:NN \l__gdut_thm_punct_tl : },
punct / quad .code:n =
{ \cs_set_eq:NN \l__gdut_thm_punct_tl \quad },
braces .choice:,
braces .value_required:n = true,
braces / paren .code:n =
{
\cs_set_eq:NN \l__gdut_thm_left_braces_tl (
\cs_set_eq:NN \l__gdut_thm_right_braces_tl )
},
braces / bracket .code:n =
{
\cs_set_eq:NN \l__gdut_thm_left_braces_tl 【
\cs_set_eq:NN \l__gdut_thm_right_braces_tl 】
},
qed .tl_set:N = \l__gdut_thm_qed_tl,
}
\RenewDocumentCommand \newtheorem { s m m }
{
\IfBooleanTF {#1}
{
\declaretheorem[style=gdut-no-number,name=#3,refname={#3},Refname={#3}]{#2}
}
{
\declaretheorem[style=gdut-number,name=#3,refname={#3},Refname={#3}]{#2}
\tl_set:cn{the #2}{\thechapter \gdutinterval \arabic{#2}}
}
}
\ctex_at_end_preamble:n
{
\declaretheoremstyle[
spaceabove = 0pt,
spacebelow = 0pt,
postheadspace = 0pt,
numberwithin = chapter,
headpunct = {\l__gdut_thm_punct_tl},
headfont = \l__gdut_thm_header_font_tl,
notefont = \l__gdut_thm_header_font_tl,
notebraces = {\l__gdut_thm_left_braces_tl}{\l__gdut_thm_right_braces_tl},
bodyfont = \l__gdut_thm_body_font_tl,
qed = \l__gdut_thm_qed_tl,
headindent = \l__gdut_indent_dim,
numbered = no,
]{gdut-no-number}
\declaretheoremstyle[
spaceabove = 0pt,
spacebelow = 0pt,
postheadspace = 0pt,
numberwithin = chapter,
headpunct = {\l__gdut_thm_punct_tl},
headfont = \l__gdut_thm_header_font_tl,
notefont = \l__gdut_thm_header_font_tl,
notebraces = {\l__gdut_thm_left_braces_tl}{\l__gdut_thm_right_braces_tl},
bodyfont = \l__gdut_thm_body_font_tl,
qed = ,
headindent = \l__gdut_indent_dim,
]{gdut-number}
\cs_undefine:N \proof
\cs_undefine:N \endproof
\newtheorem { axiom } { 公理 }
\newtheorem { corollary } { 推论 }
\newtheorem { definition } { 定义 }
\newtheorem { example } { 例 }
\newtheorem { lemma } { 引理 }
\newtheorem { theorem } { 定理 }
\newtheorem*{ proof } { 证明 }
}

%% 设置图表格式
\DeclareCaptionLabelFormat{english}{#1#2}
\captionsetup{labelsep=space,labelformat=english,font=small}
Expand Down Expand Up @@ -1384,8 +1491,9 @@
}
\keys_define:nn { gdut }
{
info .meta:nn = { gdut / info } {#1},
style .meta:nn = { gdut / style } {#1}
info .meta:nn = { gdut / info } {#1},
style .meta:nn = { gdut / style } {#1},
theorem .meta:nn = { gdut / theorem } {#1}
}
\keys_set:nn { gdut }
{
Expand All @@ -1397,6 +1505,13 @@
style / bib-style = numerical,
info / secret-level = none,
info / date = { 2021/5/1 },
theorem / header-font = bf,
theorem / body-font = rm,
theorem / indent = en,
theorem / interval = dot,
theorem / punct = colon,
theorem / braces = paren,
theorem / qed = \qedsymbol,
}
\NewDocumentCommand \gdutsetup { m }
{ \keys_set:nn { gdut } {#1} }
Expand Down
16 changes: 16 additions & 0 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@
% hyperlink-color = {graylevel},
% hyperlink-color = {prl},
},
theorem = {
header-font = bf,
% header-font = sf,
body-font = rm,
% body-font = kai,
indent = cn,
% indent = en,
interval = dash,
% interval = dot,
braces = paren,
% braces = bracket,
punct = colon,
% punct = quad,
qed = \qedsymbol,
% qed = \QED,
},
info = {
title = {模板射流电解加工微沟槽关键技术研究},
title* = {Investigation on masked jet electrochemical machining of micro grooves},
Expand Down
99 changes: 99 additions & 0 deletions user-manual/gdutthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,72 @@ Copyright (C) 2017&ndash;2021 by Xiangdong Zeng <[email protected]>.
%^^A! \end{function}
%^^A!
%
% \subsubsection{数学环境} \label{subsubsec:数学环境}
%
% \begin{function}{theorem}
% \begin{fdusyntax}[emph={[1]theorem}]
% theorem = (*\marg{键值列表}*)
% theorem/(*\meta{key}*) = (*\meta{value}*)
% \end{fdusyntax}
% 该选项包含许多子项目,用于定制数学环境的风格。具体内容见下。
% \end{function}
%
% \begin{function}^^A
% {theorem/header-font}
% \begin{fdusyntax}[emph={[1]header-font}]
% header-font = (*<(bf)|sf>*)
% \end{fdusyntax}
% 设置定理头(即标题)的字体。选择 |bf| 即使用正文字体的粗体;选择 |sf| 即使用无衬线字体。
% \end{function}
%
% \begin{function}^^A
% {theorem/body-font}
% \begin{fdusyntax}[emph={[1]body-font}]
% body-font = (*<(rm)|kai>*)
% \end{fdusyntax}
% 设置定理内容的字体。选择 |rm| 即使用正文字体;选择 |kai| 即使用 |\gdut@kai| 楷体。
% \end{function}
%
% \begin{function}^^A
% {theorem/indent}
% \begin{fdusyntax}[emph={[1]indent}]
% indent = (*<(en)|cn>*)
% \end{fdusyntax}
% 设置定理头是否缩进。选择 |en| 即不缩进;选择 |cn| 即缩进。
% \end{function}
%
% \begin{function}^^A
% {theorem/interval}
% \begin{fdusyntax}[emph={[1]interval}]
% interval = (*<(dot)|dash>*)
% \end{fdusyntax}
% 设置定理编号的分割符。选择 |dot| 即使用“.”;选择 |dash| 即使用“-”。
% \end{function}
%
% \begin{function}^^A
% {theorem/braces}
% \begin{fdusyntax}[emph={[1]braces}]
% braces = (*<(paren)|bracket>*)
% \end{fdusyntax}
% 设置定理标题的括号类型。选择 |paren| 即使用“()”;选择 |bracket| 即使用“【】”。
% \end{function}
%
% \begin{function}^^A
% {theorem/punct}
% \begin{fdusyntax}[emph={[1]punct}]
% punct = (*<(colon)|quad>*)
% \end{fdusyntax}
% 设置定理头与内容之间的间隔符。选择 |colon| 即使用“:”;选择 |quad| 即空一字的距离。
% \end{function}
%
% \begin{function}^^A
% {theorem/qed}
% \begin{fdusyntax}[emph={[1]qed}]
% qed = (*\marg{符号}*)
% \end{fdusyntax}
% 设置定理结束标记(即证毕符号)。默认为 |\qedsymbol|。
% \end{function}
%
% \subsubsection{信息录入} \label{subsubsec:信息录入}
%^^A! \subsubsection{Personal information} \label{subsubsec:information}
%^^A!
Expand Down Expand Up @@ -1954,6 +2020,39 @@ Copyright (C) 2017&ndash;2021 by Xiangdong Zeng <[email protected]>.
% 生成章节标题。|\gdut...| 的章节命令是为了生成中英文目录。
% \end{function}
%
% \begin{function}{axiom,corollary,definition,example,lemma,proof,theorem}
% \begin{fdusyntax}[emph={[2]proof}]
% \begin{proof}(*\oarg{小标题}*)
% (*\meta{证明过程}*)
% \end{proof}
% \end{fdusyntax}
% 一系列预定义的数学环境。具体含义见表~\ref{tab:theorem}。
% \end{function}
%
% \begin{table}[ht]
% \caption{预定义的数学环境} \label{tab:theorem}
% \centering
% \begin{tabular}{cccccccc}
% \toprule
% \textbf{名称} &
% \env{axiom} & \env{corollary} & \env{definition} &
% \env{example} & \env{lemma} & \env{proof} &
% \env{theorem} \\
% \midrule
% \textbf{含义} &
% 公理 & 推论 & 定义 & 例 & 引理 & 证明 & 定理 \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% 证明环境(\env{proof})的最后会添加证毕符号。要确保
% 该符号在正确的位置显示,|\end{proof}| 前不能有空行。
%
% 数学环境是以 \pkg{amsthm} 为后端、\pkg{thmtools} 为前端定制的,
% 如果预定义的数学环境和选项不能满足您的需求,请自行阅读
% \pkg{thmtools} 宏包手册。注意,您自行定义的数学环境名称不能与
% 预定义数学环境的名称相同。
%
% \begin{function}{gdutenum,gdutenenum}
% \begin{fdusyntax}[emph={[2]gdutenum,gdutenenum}]
% \begin{gdutenum}
Expand Down

0 comments on commit 330dadd

Please sign in to comment.