还没有账号去注册
SITE:zTeX
The main commands of this module are:
% 1. create new theorem/proof-like envs
\zlatexThmCreate{theorem}{Zaxiom, Ztheorem=Thm|green, Zproposition=Prop|orange}
\zlatexThmCreate{proof}{Zproof, Zexample=Example|red, Zsolution=Solution|}
% 2. set the title format of theorem-like envs
% NOTE: This command will overwrite the existing environments
\zlatexThmTitle % thm title content
\zlatexThmTitleSwitch % thm title inline or not
\zlatexThmTitleFormat{⟨format⟩, ⟨content, such as:\zlatexThmNumber, \zlatexThmName, \zlatexThmNote⟩}
\zlatexThmTitleFormat*{⟨format⟩, ⟨content, such as:\zlatexThmNumber, \zlatexThmName, \zlatexThmNote⟩}
\zlatexThmCnt{share, parent=⟨counter name:section, subsection, ...⟩}
% 3. change the style of theorem-like envs
\zlatexThmStyle{elegant}
\zlatexThmColorSetup{⟨theorem/proof-like envs' name⟩=⟨color⟩}
% 4. custom the warper of each theorem-like envs
\zlatexThmStyleNew{⟨style⟩={begin=⟨.⟩, end=⟨.⟩, option=⟨.⟩}}
% 5. thm envs names setup interface of different languages
\zlatexThmLang{fr}
\zlatex_math_env_name_set:nn {fr}{
axiom = Axiome,
definition = Définition,
theorem = Théorème,
lemma = Lemme,
corollary = Corollaire,
proposition = Proposition,
remark = Remarque,
proof = Preuve,
exercise = Exercice,
example = Exemple,
solution = Solution,
problem = Problème,
}
% 6. thm hooks
\zlatexThmHook{⟨next hook⟩}
\zlatexThmHook*{⟨next all hook⟩}
\zlatexThmBefore{⟨code⟩}
% 7. list of theorems
\zlatexThmToc[
title-vspace=⟨dim⟩,
title=⟨title⟩,
after-vspace=⟨dim⟩,
stretch=⟨float⟩
]
\zlatexThmTocPrefix{⟨prefix⟩}
\zlatexThmTocSymbol{
lemma=⟨lemma symbol⟩,
definition=⟨definition symbol⟩,
....
}
% clear all predefined thm toc symbol
\zlatexThmTocSymbolClear
\zlatexThmSecAdd[name=⟨toc name⟩]{⟨toc level:chapter, section, etc.⟩}
Fixed bug: optional braces, brackets around \zlatexThmNote
when it is empty. Now the syntax is:
\zlatexThmNote{⟨before⟩}{⟨end⟩}
% --> output:
% ⟨before⟩⟨Thm-Note⟩⟨end⟩
To define a complex Thm title format, users may use command \zlatexThmNoteEmptyTF
, which is provided by thm
module in zlatex, to check whether it's empty or not, definition of this command as below:
\NewDocumentCommand{\zlatexThmNoteEmptyTF}{mm}
{
\tl_if_empty:eTF {\zlatexThmNote{}{}}
{#1}
{#2}
}
The corresponding format in List of Theorem command \zlatexThmToc
fixed as well.
color spec is very simple now, see below:
% way 1
\zlatexThmCreate{theorem}{Ztheorem=THM|{HTML}{8e44ad}, Zproposition}
% way 2
\zlatexColorSetup{
definition=blue,
theorem={HTML}{007175},
Ztheorem={RGB}{219,48,122}
}
Command \zlatexColorSetup
is only available in preamble. Though, I do NOT recommend using too much color in your script, you can change color temporarily using command such as the following:
% users' interface
\zlatexThmColorSetup{
definition={HTML}{22b8cf},
}
% the implementation of the above command
\ExplSyntaxOn
\zlatex_keys_set:nn {color}{
definition = {RGB}{219,48,122},
}
\ExplSyntaxOff
Now the thm
module provides 4 hooks for users to custom the theorem-like envs. The places of these hooks are:
(zlatex/thm/before) --> (warper begin)
--> (thm-title) --> (zlatex/thm/begin) --> (thm-content) --> (zlatex/thm/end) -->
(warper end) --> (zlatex/thm/after)
The implementation as below:
\NewDocumentEnvironment{#1}{O{}}{
\refstepcounter{#1}
\UseHook{zlatex/thm/before}
\__zlatex_thm_warp_start:nnnn {#1}{##1}{\bfseries}{\ }
\__zlatex_thm_title:
\UseHook{zlatex/thm/begin}
}{
\UseHook{zlatex/thm/end}
\__zlatex_thm_warp_end:
\UseHook{zlatex/thm/after}
}
Command \zlatexThmHook
is used to add your own code chunks to these places, syntax:
% only add to the next one
\zlatexThmHook{
before=⟨BEFORE code⟩,
begin=⟨BEGIN code⟩,
end=⟨END code⟩,
after=⟨AFTER code⟩
}
% add to all thm ebv below
\zlatexThmHook*{
before=⟨BEFORE code⟩,
begin=⟨BEGIN code⟩,
end=⟨END code⟩,
after=⟨AFTER code⟩
}
Remark:
\zlatexThmStyleNew
(this function can be only used in preamble) are based on these hooks.\zlatexThmTitle
and \zlatexThmTitleSwitch
may be useful for you to custom the title format of theorem-like envs.zlatex/thm/end
and zlatex/thm/after
are reverse hook.zlatex/thm/before
is \par
.For that the original HOOK
thm style is removed, thus the original definition of \zlatexThmStyleNew
:
% dependency of this command:
\DeclareDocumentEnvironment{zlatexTheoremWarper}{O{axiom}}{{
...
{HOOK}{\UseHook{zlatex/math/envstyle/begin}}
...
}{
...
{HOOK}{\UseHook{zlatex/math/envstyle/end}}
...
}
}
% definition
\NewDocumentCommand{\zlatexThmStyleNew}{mm}{
\AddToHook{zlatex/thm/begin}{#1}
\AddToHook{zlatex/thm/end}{#2}
\ActivateGenericHook{zlatex/thm/begin}
\ActivateGenericHook{zlatex/thm/end}
\tl_gset:Nn \g__zlatex_thm_style_tl {HOOK}
}
\@onlypreamble\zlatexThmStyleNew
Now the implementation is:
\NewDocumentCommand{\zlatexThmStyleNew}{smm}{
\IfBooleanTF{#1}
{\zlatexThmHook*{#2}{#3}}
{\zlatexThmHook{#2}{#3}}
}
- In the future, this function maybe be changed, i will use this function to add more
thm
style like the\_zslide_theme_create:nn
function inslide
library plays on.- please use this command with
*
in the preamble, or some unexpected error may occur.
To change the default before code chunk in hook zlatex/thm/before
, you can use command \zlatexThmBefore
, an simple example maybe:
\zlatexThmBefore{\par\noindent\dotfill\par}
Implementation of this command is:
\hook_gput_code:nnn {zlatex/thm/before}{thm-before-par}{\par}
\NewDocumentCommand{\zlatexThmBefore}{+m}
{
\hook_gremove_code:nn {zlatex/thm/before}{thm-before-par}
\hook_gput_code:nnn {zlatex/thm/before}{thm-before-par}{#1}
}
Now the command \zlatexThmStyleNew
is implemented by l3keys
, then you could add your own thm style freely. The Syntax of this function as follows:
\zlatexThmStyleNew {
⟨thm style name⟩ = {
begin = ⟨env begin code⟩,
end = ⟨env end code⟩,
option = ⟨env begin option⟩
},
}
What you need pay attention to is ⟨env begin option⟩
, in this part, you can specify whether to display thm title
inline or hang on the top like in tcolorbox. Use function:
\__zlatex_thm_title_inline:n {T}
% T: inline
% F: on the top
Or you can set the thm envs colors, see the elegant
thm-style for reference:
\zlatexThmStyleNew {
elegant = {
begin = {
\begin{tcolorbox}[
enhanced, breakable,
top=8pt, bottom=1.5pt,
left=3pt, right=3pt,
arc=3pt, boxrule=0.5pt,
before~upper*={\setlength{\parindent}{1em}},
fontupper=\rmfamily, fonttitle=\bfseries,
lower~separated=false, separator~sign={.},
attach~ boxed~ title~ to~ top~ left={yshift=-0.11in, xshift=0.15in},
boxed~ title~ style={boxrule=0pt, colframe=white, arc=0pt, outer~arc=0pt},
title=\zlatexThmTitle,
colback = \thm@temp@color!5, colframe = \thm@temp@color,
coltitle = white, colbacktitle = \thm@temp@color,
]
},
end = {\end{tcolorbox}},
option = {
\__zlatex_thm_title_inline:n {F}
\__zlatex_thm_tcolorbox_warning:
\zlatex_keys_set:nn {color}{
axiom = {HTML}{2c3e50},
definition = {RGB}{0, 166, 82},
theorem = {RGB}{255, 134, 23},
lemma = {RGB}{255, 134, 23},
corollary = {RGB}{255, 134, 23},
proposition = {RGB}{0, 173, 247},
}
}
},
}
A simple analysis of the mechanism of this module:
% For command:
\zlatexThmCreate{theorem}{Ztheorem=THM|orange}
% ANALYSIS
\__zlatex_math_env_create__:nnn {theorem}{Ztheorem}{THM|orange}
\zlatex_math_env_create:ne {theorem}{Ztheorem}
% the theorem-like clist add a new item "Ztheorem"
\__zlatex_color_keyval_add:n {Ztheorem}
% created a key named "Ztheorem"
\__zlatex_math_env_color_set:w {Ztheorem}\q_stop THM|orange\q_stop
% create a new tl "\l__zlatex_Ztheorem_color_tl" and set it to "orange"
\prop_gput:cee {g__zlatex_math_env_name_prop}
{#2}{\exp_last_unbraced:Ne \__zlatex_mid_first:w #3\q_stop}
% add a new key-value pair to the prop for thm title, in this case it is "Ztheorem=THM"
The key command is \__zlatex_color_set:n
, see below:
% ==> color setup
\regex_new:N \l__zlatex_color_mode_regex
\regex_set:Nn \l__zlatex_color_mode_regex {(\cB..{1,}\cE.){2}}
\cs_new:Npn \__zlatex_color_set:n #1 {
\regex_match:NnTF \l__zlatex_color_mode_regex {#1}{
\definecolor{zlatex@color@\l_keys_key_str}#1
\tl_set:ce {l__zlatex_\l_keys_key_str _color_tl}{zlatex@color@\l_keys_key_str}
}{
\@ifundefined{\string\color@#1}{
\msg_new:nnn {color} {undefined} {--->~Color~`#1'~undefined}
\msg_error:nn {color} {undefined}
}{
\tl_set:cn {l__zlatex_\l_keys_key_str _color_tl}{#1}
}
}
}
This function will check your color spec is valid or not, if not, it will throw an error message. If so, it will create a color and set the color tl to the color name dynamiclly.
Remark: In fancy
math EnvStyle, you can use command:
\setlength{\fboxsep}{0pt}
to cancle the color box padding.
elegant
thm style page break issue in slide mode, warning message:
Package tcolorbox Warning: Using nobreak failed. Try to enlarge `lines before break' or set page breaks manually on input line 216.
Now you can use command \zlatexThmToc
to create a table of the previous theorem-like env. You can use it for proof-like environments. Once this command is invoke in your source, there will be a file named \jobname.thlist
occurs in your working dir. This command takes 1 option argument, in form of key-value, syntax as follows:
\zlatexThmToc[vspace=⟨dim⟩, title=⟨title⟩]
Additionally, you can use command \zlatexThmTocLevel
to change the default thm entry level, a simple example:
\zlatexThmTocLevel{section}
This table of theorems shares the same format as the main table of contents.
Now the syntax is as follows, a simple example:
\zlatexThmToc[
title={\textsc{List of Theorems}},
stretch=1.5,
title-vspace=-10pt,
after-vspace=20pt
]
Update: when there is no \tableofcontents
before, stretch for thm toc will lose. The new implement is:
\zlatex_keys_define:nn {thm/toc}
{
title .tl_gset:N = \g__zlatex_thm_toc_title_tl,
title .initial:n = { \Large\bfseries List\ of\ Theorems },
title-vspace .dim_gset:N = \g__zlatex_thm_toc_title_vspace_dim,
title-vspace .initial:n = { 0pt },
after-vspace .dim_gset:N = \g__zlatex_thm_toc_after_vspace_dim,
after-vspace .initial:n = { 0pt },
stretch .fp_gset:N = \g__zlatex_thm_toc_stretch_fp,
stretch .initial:n = { 1 },
}
\NewDocumentCommand{\zlatexThmToc}{o}
{
\bool_gset_true:N \g__zlatex_thm_toc_bool
\group_begin:
\IfValueT {#1}{\zlatex_keys_set:nn {thm/toc}{#1}}
\legacy_if_set_false:n { @filesw }
{\par\noindent\tl_use:c {g__zlatex_thm_toc_title_tl}}
\addvspace{\g__zlatex_thm_toc_title_vspace_dim}
\addvspace{-\fp_to_dim:n {\g__zlatex_thm_toc_stretch_fp*\baselineskip}+\baselineskip}
{
\renewcommand{\baselinestretch}{\fp_use:N \g__zlatex_thm_toc_stretch_fp}\normalsize
\@input{\jobname.thlist}
}
\addvspace{\g__zlatex_thm_toc_after_vspace_dim}
\group_end:
}
But this new implementation still has been deprecated. I remove title
part. This part will be controled be the users.
zlatex thm
module and theme
library contains many predefined thm themes that can be used out of box. List of predefined themes in thm
module are:
To use these themes, an example is:
\zlatexThmStyle{fancy}
themes in theme
library are:
To use these them , the syntax is simple:
\zlatexloadlibrary{theme}
\zlatexThmStyle{lapsis}
In thm them
lapsis
, there is a new feature, the command --\tcblower
, which is used to split current thm env into 2 parts, each of which has a different style. Have a try immediately to see how it actually looks like.
When you load theme
library, tikz
and tcolorbox
will be loaded, so do these many libraries belong to them. Up to now, the optioanl preamble commands are:
\RequirePackage[many]{tcolorbox}
\RequirePackage{adjustbox}
\RequirePackage{tikz}
\RequirePackage{etoolbox}
\patchcmd{\pgfutil@InputIfFileExists}{\input #1}{
\@pushfilename
\xdef\@currname{#1}
\input #1
\@popfilename
}{}{}
\usetikzlibrary{fadings, calc}
\RequirePackage{pifont}
Users can create new thm themes easily based on the interface thm module provides.
To create a new theme, you can use the commands decribed in section thm:main commands
. What need to be decribed here are two internal macros:
\thm@temp@color
: temp name for each thm env, such as red, blue, zlatex@thm@theorem
, etc\thm@temp@name
: temp name for each thm, such as theorem, definition, axiom
, etc.These 2 macros will NOT be exposed to normal users, for advanced users, you can use theme. Besides, original definitions of these 2 comamnds are:
% \cs_new:Npn \__zlatex_thm_warp_start:nnnn #1#2#3#4 {
...
\def\thm@temp@color{\tl_use:c {l__zlatex_#1_color_tl}}
\def\thm@temp@name{#1}
..
% }
An simple example of creating a new them(also the implementation of lapsis
theme):
\zlatexThmStyleNew{
% lapsis theme from: Foundation Mathematics for the Physical Sciences
lapsis = {
begin = {
\begin{tcolorbox}[
enhanced, breakable,
top=1.5pt, bottom=1.5pt,
left=2pt, leftlower=-3pt,
right=3pt, arc=0pt, frame~hidden,
bicolor, colback=\thm@temp@color!60,
opacitybacklower=0,
frame~code~app={
\draw[color=\thm@temp@color, thick]
(frame.north~west)++(-5cm, -1pt)--($(frame.north~east)+(5cm, 0pt)$);
\draw[color=\thm@temp@color, thick]
(frame.south~west)++(-5cm, -1pt)--($(frame.south~east)+(5cm, 0pt)$);
\fill[color=\thm@temp@color!50, path~fading=east]
(frame.north~west)++(-5cm, -1pt) rectangle ($(frame.south~east)+(5cm, 0pt)$);
},
]\zlatex@llapnote{\zlatexThmTitle}
},
end = {\hfill$\mathcolor{\thm@temp@color}{\blacktriangleleft}$\end{tcolorbox}},
option = {
\__zlatex_thm_title_inline:n {F}
\__zlatex_thm_tcolorbox_warning:
},
preamble = {
\DeclareMathSymbol{\blacktriangleleft}{\mathrel}{AMSa}{"4A}
\zlatexThmTitleFormat*{\sffamily\bfseries
\zlatexThmName\ \zlatexThmNumber
\zlatexThmNoteEmptyTF{}{\\}
\zlatexThmNote{}{}
}
\newcommand{\zlatex@llapnote}[1]{
\mbox{}\llap{
\adjustbox{set~height=0pt, set~depth=0pt}{
\parbox[t]{2.85cm}{\raggedleft #1}}\hspace*{.75em}}
}
}
},
}
暂无评论