这在某种程度上是对关于自定义 Kaobook 环境的这个问题在那个问题中,我能够成功地为该类定义一些新的环境kaobook
并让它们共享编号:
目标
我想要发出命令::
\listofdefinitions
\listoftheorems
\listofexamples
\listofactivities
自动生成目录中的列表,类似于现有命令
\tableofcontents
\listoffigures
\listoftables
。
我尝试过的一些方法:
1.)关注这个答案, 我试过
\makeatletter
\renewcommand{\listofdefinitions}{%
\let\l@definition\l@figure
\chapter*{\listdefinitionname}%
\@starttoc{loa}%
}
\makeatother
但这不起作用并发出错误。
2.)关注这个答案,我也试过
\newcommand{\listdefinitionname}{My list of definitions}
\newlistof{definition}{def}{\listdefinitionname}
\newcommand{\definition}[1]{%
\refstepcounter{definition}%
\par\noindent\textbf{The Definition~\thedefinition. #1}%
\addcontentsline{def}{figure}
{\protect\numberline{\thechapter.\thedefinition}#1}\par%
}
\makeatletter
但这也发出了一个错误,说definition
已经定义。
3.) 我读到thmtools
包裹有一个\listoftheorems
命令,我试图使用它,但它将所有内容都列在同一个标题下:
如您所见,存在一些问题:
- 定义和定理被分组在一起 - 我希望为每种环境类型提供单独的列表
- 缺少活动和示例(?)
- 不显示每个定义、定理等的“标签”。
exercises
列表中显示了章节的结束部分。
有什么办法可以解决这些问题吗?如果有帮助,以下是Overleaf 项目。请随意试用一下代码。
main.tex
\documentclass[
fontsize=10pt, % Base font size
twoside=false, % Use different layouts for even and odd pages (in particular, if twoside=true, the margin column will be always on the outside)
%open=any, % If twoside=true, uncomment this to force new chapters to start on any page, not only on right (odd) pages
%chapterprefix=true, % Uncomment to use the word "Chapter" before chapter numbers everywhere they appear
%chapterentrydots=true, % Uncomment to output dots from the chapter name to the page number in the table of contents
numbers=noenddot, % Comment to output dots after chapter numbers; the most common values for this option are: enddot, noenddot and auto (see the KOMAScript documentation for an in-depth explanation)
%draft=true, % If uncommented, rulers will be added in the header and footer
%overfullrule=true, % If uncommented, overly long lines will be marked by a black box; useful for correcting spacing problems
]{kaobook}
% Set the language
\usepackage[english]{babel} % Load characters and hyphenation
\usepackage[english=british]{csquotes} % English quotes
% Load mathematical packages for theorems and related environments. NOTE: choose only one between 'mdftheorems' and 'plaintheorems'.
\usepackage{styles/mdftheorems}
%\usepackage{styles/plaintheorems}
%https://tex.stackexchange.com/questions/369265/math-book-how-to-write-exercise-and-answers
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{xcolor}
\colorlet{lightcyan}{cyan!40!white}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage[skins,hooks,xparse,breakable]{tcolorbox}
\usepackage{xcolor}
\usepackage{chngcntr}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\tableofcontents
\listoftheorems
\chapter{Chapter Name}
\section{Section}
\begin{activity}[Name of Activity 1][activity:activityname]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{activity}
\begin{definition}\labdef{Name of Definition 2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{definition}
\begin{theorem}\label{Name of Theorem 3}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{theorem}
\begin{bookexample}[Name of Example 3][ex:example_4]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{bookexample}
Referring to Example \ref{ex:example_4}.
\begin{solution}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{solution}
\begin{definition} \labdef{Name of Definition 5}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{definition}
\begin{theorem} \label{Name of Theorem 6}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{theorem}
\begin{bookexample}[Name of Example 7][ex:example_7]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{bookexample}
\begin{solution}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{solution}
\newpage
\begin{Exercise}\label{EX11}
\vspace{-\baselineskip}% <-- You don't need this line of code if there's some text here
\Question Multiple choice question
\settasks{label={(\Alph*)}}
\begin{tasks}(4)
\task Choice 1
\task Choice 2
\task Choice 3
\task\label{correctchoice_1.1.1} Choice 4
\end{tasks}
\Question Multiple choice question
\settasks{label={(\Alph*)}}
\begin{tasks}(4)
\task Choice 1
\task Choice 2
\task\label{correctchoice_1.1.2} Choice 3
\task Choice 4
\end{tasks}
\Question Multi-part question
\settasks{label={\roman*.}}
\begin{tasks}(1)
\task Part 1
\task Part 2
\task Part 3
\end{tasks}
\end{Exercise}
\begin{Answer}[ref={EX11}]
\Question This is a solution of Ex 1
\end{Answer}
\setboolean{firstanswerofthechapter}{false}
\end{document}
编辑7/24:
现在还包括environments.sty
和mdftheorems.sty
,其中定义了一些 kaobox 环境。(抱歉,我是新手Overleaf Kaobook 模板并且不知道这些依赖项分布在多个文件中。)我不知道这两个文件是如何工作的,所以我将按原样粘贴它们。
environments.sty
%% environments.sty
%% Copyright 2020 Federico Marotta
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% 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 Maintainer of this work is Federico Marotta
%
% This work consists of all the files listed in MANIFEST.md.
\ProvidesPackage{styles/environments}
%----------------------------------------------------------------------------------------
% ITEMS
%----------------------------------------------------------------------------------------
\RequirePackage{amssymb}
\renewcommand{\labelitemi}{\small$\blacktriangleright$}
\renewcommand{\labelitemii}{\textbullet}
\RequirePackage{enumitem}
\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\setlist[description]{noitemsep}
%----------------------------------------------------------------------------------------
% SIMPLE BOXED ENVIRONMENT
%----------------------------------------------------------------------------------------
% kaobox (while tcolorbox may be more rich, I find it too complicated so I prefer mdframed)
\RequirePackage{tikz}
\RequirePackage[framemethod=TikZ]{mdframed}
%\mdfsetup{skipabove=\topskip,skipbelow=0pt}
\mdfdefinestyle{kaoboxstyle}{
skipabove=1.5\topskip,
skipbelow=.5\topskip,
rightmargin=0pt,
leftmargin=0pt,
%innertopmargin=3pt,
%innerbottommargin=3pt,
innerrightmargin=7pt,
innerleftmargin=7pt,
topline=false,
bottomline=false,
rightline=false,
leftline=false,
%linewidth=1pt,
%roundcorner=0pt,
%font={},
%frametitlefont={},
frametitlerule=true,
linecolor=black,
%backgroundcolor=LightBlue,
fontcolor=black,
%frametitlebackgroundcolor=LightBlue,
}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=RoyalBlue!20!White,
frametitlebackgroundcolor=RoyalBlue!20!White,
]{kaobox}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=Cyan!15!White,
frametitlebackgroundcolor=Cyan!15!White,
]{objective}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=Green!15!White,
frametitlebackgroundcolor=Green!15!White,
frametitle=Solution,
]{solution}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=Gray!15!White,
frametitlebackgroundcolor=Gray!15!White,
frametitle=Proof,
]{kaoproof}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=Magenta!15!White,
frametitlebackgroundcolor=Magenta!15!White,
]{note}
\newmdenv[
style=kaoboxstyle,
backgroundcolor=Purple!15!White,
frametitlebackgroundcolor=Purple!15!White,
frametitle=Summary
]{summary}
%----------------------------------------------------------------------------------------
% ENVIRONMENT WITH A COUNTER
%----------------------------------------------------------------------------------------
\newenvironment{kaocounter}{
\refstepcounter{kaocounter}
\begin{kaobox}[frametitle=Comment~\thekaocounter\autodot]
}{
\end{kaobox}
}
\newcounter{kaocounter}
\numberwithin{kaocounter}{section}
\newcommand*{\kaocounterformat}{% Format for the caption
Comment~\thekaocounter\csname autodot\endcsname}
\newcommand*{\fnum@kaocounter}{\kaocounterformat}
%----------------------------------------------------------------------------------------
% FLOATING ENVIRONMENT WITH TOC ENTRIES
%----------------------------------------------------------------------------------------
\newenvironment{kaofloating}{%
\@float{kaofloating}%
}{%
\end@float%
}
\newcommand*{\fps@floatingbox}{tbph}
\newcommand*{\ftype@floatingbox}{5}
\newcommand*{\floatingboxformat}{%
Insight~\thefloatingbox\csname autodot\endcsname}
\newcommand*{\fnum@floatingbox}{\floatingboxformat}
\newcommand*{\ext@floatingbox}{loi}
\addtotoclist[float]{loi}
\newcommand*{\listofloiname}{List of Insights}
\newcommand*{\l@floatingbox}{\l@figure}
\newcommand*{\listofinsights}{\listoftoc{loi}}
%----------------------------------------------------------------------------------------
% https://tex.stackexchange.com/questions/603869/custom-example-environment-with-colorbox-and-vertical-line-for-kaobook-documen
%----------------------------------------------------------------------------------------
\usepackage[skins,hooks,xparse,breakable]{tcolorbox}
\usepackage[table]{xcolor}
\usepackage{chngcntr}
% comment this line during integration because kaocounter would have been declared
%\newcounter{kaocounter}
% you may not need the line below as well if it has already been configured using other approaches
\counterwithin{kaocounter}{section}
\definecolor{greentitle}{RGB}{61,170,61}
\definecolor{greentitleback}{RGB}{216,233,213}
\definecolor{drakgreentitle}{RGB}{24,131,80}
\DeclareTColorBox{bookexample}{O{}o}{
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colframe=white,
colback=white,
top=3em, % you can change the top spacing
overlay unbroken and first={
% draw box on the left
\node[fill=greentitleback,
font=\color{greentitle}\sffamily\bfseries\large,
anchor=south west,
inner sep=3pt,
left=2mm,
right=2mm,
xshift=1mm,
yshift=-2em, % you can change xshift and yshift to adjust the title placement
] (titlebox) at (frame.north west)
% notice the difference here, kaocounter is used instead
{Example \refstepcounter{theorem}\thetheorem
% add cross-referencing support
\IfValueT{#2}{\label{#2}}
};
% write title on the right
\node[font=\color{drakgreentitle}\sffamily\large,
anchor=west
] at ($(titlebox.east)+(2mm,0mm)$) {#1};
% draw the vertical line on the left
\draw[draw=greentitleback, line width=2pt]
(titlebox.north west-|frame.north west)--(frame.south west);
},
overlay middle and last={
\draw[draw=greentitleback, line width=2pt]
(frame.north west)--(frame.south west);
}
fonttitle=\color{greentitle}\sffamily\bfseries\large,
}
\DeclareTColorBox{genericbox}{m}{
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colback=white,
attach boxed title to top left,
boxed title style={
colback=white,
colframe=white,
},
title={#1},
fonttitle=\color{greentitle}\sffamily\bfseries\large
}
\DeclareTColorBox{activity}{O{}o}{
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colframe=white,
colback=white,
top=3em, % you can change the top spacing
overlay unbroken and first={
% draw box on the left
\node[fill=Cyan!15!White,
font=\color{Cyan}\sffamily\bfseries\large,
anchor=south west,
inner sep=3pt,
left=2mm,
right=2mm,
xshift=1mm,
yshift=-2em, % you can change xshift and yshift to adjust the title placement
] (titlebox) at (frame.north west)
% notice the difference here, kaocounter is used instead
{Activity \refstepcounter{theorem}\thetheorem
% add cross-referencing support
\IfValueT{#2}{\label{#2}}
};
% write title on the right
\node[font=\color{Cyan}\sffamily\large,
anchor=west
] at ($(titlebox.east)+(2mm,0mm)$) {#1};
% draw the vertical line on the left
\draw[draw=Cyan!15!White, line width=2pt]
(titlebox.north west-|frame.north west)--(frame.south west);
},
overlay middle and last={
\draw[draw=Cyan!15!White, line width=2pt]
(frame.north west)--(frame.south west);
}
fonttitle=\color{Cyan}\sffamily\bfseries\large,
}
\DeclareTColorBox{genericbox}{m}{
enhanced,
breakable,
arc=0pt,
boxrule=0pt,
colback=white,
attach boxed title to top left,
boxed title style={
colback=white,
colframe=white,
},
title={#1},
fonttitle=\color{greentitle}\sffamily\bfseries\large
}
%----------------------------------------------------------------------------------------
%https://tex.stackexchange.com/questions/369265/math-book-how-to-write-exercise-and-answers
%----------------------------------------------------------------------------------------
\usepackage{ifthen}
\newboolean{firstanswerofthechapter}
\usepackage{chngcntr}
\usepackage{stackengine}
\usepackage{tasks}
\newlength{\longestlabel}
\settowidth{\longestlabel}{\bfseries viii.}
\settasks{label={(\Alph*)}, label-format={\bfseries}, label-width=\longestlabel,
item-indent=20pt, label-offset=2pt, column-sep={10pt}}
\usepackage[lastexercise,answerdelayed]{exercise}
\counterwithin{Exercise}{chapter}
\counterwithin{Answer}{chapter}
\renewcounter{Exercise}[chapter]
\newcommand{\QuestionNB}{\bfseries\arabic{Question}.\ }
\renewcommand{\ExerciseName}{EXERCISES}
\renewcommand{\ExerciseHeader}{\noindent\def\stackalignment{l}% code from https://tex.stackexchange.com/a/195118/101651
\stackunder[0pt]{\colorbox{cyan}{\textcolor{white}{\textbf{\LARGE\ExerciseHeaderNB\;\large\ExerciseName}}}}{\textcolor{lightcyan}{\rule{\linewidth}{2pt}}}\medskip}
\renewcommand{\AnswerName}{Exercises}
\renewcommand{\AnswerHeader}{\ifthenelse{\boolean{firstanswerofthechapter}}%
{\bigskip\noindent\textcolor{cyan}{\textbf{CHAPTER \thechapter}}\newline\newline%
\noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page %
\pageref{\AnswerRef}}}\smallskip}
{\noindent\bfseries\emph{\textcolor{cyan}{\AnswerName\ \ExerciseHeaderNB, page \pageref{\AnswerRef}}}\smallskip}}
\setlength{\QuestionIndent}{16pt}
mdftheorems.sty
%% mdftheorems.sty
%% Copyright 2020 Federico Marotta
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% 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 Maintainer of this work is Federico Marotta
%
% This work consists of all the files listed in MANIFEST.md.
\ProvidesPackage{styles/mdftheorems}
% Use mdframed to shade the background of theorems
\let\openbox\relax
\usepackage{amsmath} % Improved mathematics
\usepackage{amsfonts} % Mathematical fonts
\usepackage{amssymb} % AMS symbols and environments
\usepackage{amsthm} % Mathematical environments
\usepackage{thmtools}
\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}
% Box style
\mdfsetup{skipabove=\topskip,skipbelow=0pt}%-.5\topskip}
\mdfdefinestyle{mdfkao}{
skipabove=\topskip,
skipbelow=\topskip, % Does not work :(
rightmargin=0pt,
leftmargin=0pt,
innertopmargin=7pt,
innerbottommargin=3pt,
innerrightmargin=5pt,
innerleftmargin=5pt,
topline=false,
bottomline=false,
rightline=false,
leftline=false,
%linewidth=1pt,
%roundcorner=0pt,
%font={},
%frametitlefont={},
frametitlerule=true,
%linecolor=black,
%backgroundcolor=LightBlue,
%fontcolor=black,
%frametitlebackgroundcolor=LightBlue,
}
% Theorem styles
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,%\scshape,
%notefont=\normalfont, notebraces={ (}{)},
bodyfont=\normalfont\itshape,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
%postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
]{kaoplain}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,%\scshape,
%notefont=\normalfont, notebraces={ (}{)},
bodyfont=\normalfont\itshape,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
]{kaodefinition}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,
%notefont=\normalfont, notebraces={ (}{)},
%bodyfont=\normalfont,
%headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%refname={theorem,theorems},
%Refname={Theorem,Theorems},
]{kaoremark}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,
%notefont=\normalfont, notebraces={ (}{)},
%bodyfont=\normalfont,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
%refname={theorem,theorems},
%Refname={Theorem,Theorems},
]{kaoexample}
\theoremstyle{kaoplain}
\declaretheorem[
name=Theorem,
style=kaoplain,
refname={theorem,theorems},
Refname={Theorem,Theorems},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{theorem}
\declaretheorem[
name=Proposition,
refname={proposition,propositions},
Refname={Proposition,Propositions},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{proposition}
\declaretheorem[
name=Lemma,
refname={lemma,lemmas},
Refname={Lemma,Lemmas},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{lemma}
\declaretheorem[
name=Corollary,
refname={corollary,corollaries},
Refname={Corollary,Corollaries},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{corollary}
\theoremstyle{kaodefinition}
\declaretheorem[
name=Definition,
refname={definition,definitions},
Refname={Definition,Definitions},
%numberwithin=section,
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{definition}
\theoremstyle{kaoremark}
\declaretheorem[
name=Remark,
refname={remark,remarks},
Refname={Remark,Remarks},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{remark}
\theoremstyle{kaoexample}
\declaretheorem[
name=Example,
refname={example,examples},
Refname={Example,Examples},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{example}
%\renewcommand{\thetheorem}{\arabic{chapter}.\arabic{section}.\arabic{theorem}}
%\renewcommand{\thetheorem}{\arabic{subsection}.\arabic{theorem}}
%\renewcommand{\qedsymbol}{$\blacksquare$}
编辑7/25:这里有一个链接到kaobook.cls
文件对于那些需要它的人(感谢@cmhughes!)和链接至 Overleaf 项目,希望有帮助。
答案1
kaobook
将此请求归类为用户定制。
因此基本上,你可以自己动手。
方法有很多种。
这里,KOMA 脚本版本作为概念验证,其中一项是注释。所有其他项将是此方法的克隆。
简单阅读一下手册,你就会发现 KOMA-script 有一个方便的命令,\DeclareNewTOC
它通过环境处理新目录列表的所有必要内容。在这个环境中,“\caption
为这个新内容列表创建条目”(手册,第 406 页)。
在这里,我们将定义一个非浮动浮点数,其目录标题为“备注列表”,其相关辅助文件的扩展名是.rmk
;相关命令和环境的基本名称是kremark
:
\DeclareNewTOC[listname={List of Remarks},
type=kremark,
types=kremarks,
nonfloat,
name=Remark]{rmk}
\setuptoc{rmk}{chapteratlist}
自动创建的非浮动环境将被称为kremark-
。
这个环境里面将有:(1) mdframed 环境及其所有格式(或多或少取自 OP)称为mdremark
;和 (2) 一个\caption{}
命令:
\begin{kremark-}%nonfloat float: KOMA
\begin{mdremark}%md
Text of remark
\caption{\emph{Text of caption}}
\end{mdremark}
\end{kremark-}
为了节省输入,可以将整个内容包装在里面其他环境(由于缺乏更好的名称而称为myremark
),它可以将标题文本作为参数,并将(多参数)备注文本作为其主体 - 在 expl3 语法中很容易:
\ExplSyntaxOn
\NewDocumentEnvironment{myremark}{ m +b }
{
\begin{kremark-}%nonfloat float: KOMA
\begin{mdremark}%md
#2
\caption{\emph{#1}}
\end{mdremark}
\end{kremark-}
}
{ }
\ExplSyntaxOff
(kaobook
已经加载xparse
,以及许多其他包)
用法:
\begin{myremark}{title of remark}
Lorem ipsum ... ullamco laboris\sidenote{Colour is from mdframed; inside a KOMA nonfloating float env; inside a wrapper env which supplies the caption, with caption in turn generating the TOC entry.}
\end{myremark}
制作:
如果没有包装器,您将不得不输入很多\begin...\end
s:
\begin{kremark-}
The \verb|kremark| environment, contains the following:
\begin{mdremark}
The \verb|mdremark| environment, with a caption.
\caption{\emph{A bare remark}}
\end{mdremark}
Note the mdframed's colour and other format settings above.
\end{kremark-}
输出:
平均能量损失
\documentclass[
fontsize=12pt,
twoside=false,
numbers=noenddot,
]{kaobook}
\DeclareNewTOC[listname={List of Remarks},
type=kremark,
types=kremarks,
nonfloat,
name=Remark]{rmk}
\setuptoc{rmk}{chapteratlist}
\usepackage{kaotheorems}
\usepackage{xcolor}
\colorlet{lightcyan}{cyan!40}
\usepackage[framemethod=TikZ]{mdframed}
% Box style
\mdfsetup{skipabove=\topskip,skipbelow=0pt}%-.5\topskip}
\mdfdefinestyle{mdfkao}{
skipabove=\topskip,
% skipbelow=\topskip, % Does not work
rightmargin=0pt,
leftmargin=0pt,
innertopmargin=7pt,
innerbottommargin=3pt,
innerrightmargin=5pt,
innerleftmargin=5pt,
%% topline=false,
%% bottomline=false,
%% rightline=false,
%% leftline=false,
%linewidth=1pt,
%roundcorner=0pt,
%% font=\myrfont,
%frametitlefont={},
frametitlerule=true,
%linecolor=black,
%backgroundcolor=LightBlue,
%fontcolor=black,
%frametitlebackgroundcolor=LightBlue,
middlelinecolor=red!15,
middlelinewidth=1.5pt,
backgroundcolor=red!2,
roundcorner=10pt,
}
% Theorem styles
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,%\scshape,
%notefont=\normalfont, notebraces={ (}{)},
bodyfont=\normalfont\itshape,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
%postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
]{kaoplain}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,%\scshape,
%notefont=\normalfont, notebraces={ (}{)},
bodyfont=\normalfont\itshape,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
]{kaodefinition}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,
%notefont=\normalfont, notebraces={ (}{)},
%bodyfont=\normalfont,
%headformat={\footnotesize$\triangleright$\space\normalsize\NAME\space\NUMBER\space\NOTE},
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%refname={theorem,theorems},
%Refname={Theorem,Theorems},
]{kaoremark}
\declaretheoremstyle[
%spaceabove=.5\thm@preskip,
%spacebelow=.5\thm@postskip,
%headfont=\normalfont\bfseries,
%notefont=\normalfont, notebraces={ (}{)},
%bodyfont=\normalfont,
%headformat={\NAME\space\NUMBER\space\NOTE},
headpunct={},
postheadspace={.5em plus .1em minus .1em},
%prefoothook={\hfill\qedsymbol}
%refname={theorem,theorems},
%Refname={Theorem,Theorems},
]{kaoexample}
\theoremstyle{kaoplain}
\declaretheorem[
name=xTheorem,
style=kaoplain,
refname={theorem,theorems},
Refname={Theorem,Theorems},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!32,
frametitlebackgroundcolor=Goldenrod!45,
},
]{xtheorem}
\declaretheorem[
name=Proposition,
refname={proposition,propositions},
Refname={Proposition,Propositions},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{xproposition}
\declaretheorem[
name=Lemma,
refname={lemma,lemmas},
Refname={Lemma,Lemmas},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{xlemma}
\declaretheorem[
name=Corollary,
refname={corollary,corollaries},
Refname={Corollary,Corollaries},
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{xcorollary}
\theoremstyle{kaodefinition}
\declaretheorem[
name=Definition,
refname={definition,definitions},
Refname={Definition,Definitions},
%numberwithin=section,
sibling=theorem,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!45!white,
frametitlebackgroundcolor=Goldenrod!45!white,
},
]{xdefinition}
\theoremstyle{kaoremark}
\declaretheorem[
name={R},
refname={remark,remarks},
Refname={Remark,Remarks},
numberwithin=section,
mdframed={
style=mdfkao,
backgroundcolor=Goldenrod!12,
frametitlebackgroundcolor=Goldenrod!45,
},
]{mdremark}
\ExplSyntaxOn
\NewDocumentEnvironment{myremark}{ m +b }
{
\begin{kremark-}%nonfloat float: KOMA
\begin{mdremark}%md
#2
\caption{\emph{#1}}
\end{mdremark}
\end{kremark-}
}
{ }
\ExplSyntaxOff
\begin{document}
\tableofcontents
\listofkremarks
\chapter{Chapter C}
\section{Section S}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\begin{myremark}{title of remark}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\sidenote{Colour is from mdframed; inside a KOMA nonfloating float env; inside a wrapper env which supplies the caption, with caption in turn generating the TOC entry.}
\end{myremark}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\begin{myremark}{another remark}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\sidenote{A second remark.}
\end{myremark}
\begin{kremark-}
The \verb|kremark| environment, contains the following:
\begin{mdremark}
The \verb|mdremark| environment, with a caption.
\caption{\emph{A bare remark}}
\end{mdremark}
Note the mdframed's colour and other format settings above.
\end{kremark-}
\end{document}