我尝试更改模板,但遇到了问题。你看,似乎 {defn} 行下的第一行总是缺少第一个字符(中文)。(如下图所示)
这是我的代码:
\documentclass[twoside]{article}
\usepackage[paperwidth=210mm, paperheight=297mm, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
%==Theorems==
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,theorems}
\usepackage{changepage}
\newcounter{cnt}
\setcounter{cnt}{\thesection}
\makeatletter
\parindent 0in
\parskip 1pt
\geometry{margin=1in, headsep=0.25in}
\setlength{\headheight}{14.39996pt}
% Definition
\newtcbtheorem[use counter=cnt, number within=section]{defn}{Definition}
{theorem style=theorem wide name and number,breakable,enhanced,arc=0mm,outer arc=0mm,
boxrule=0pt,toprule=1pt,leftrule=0pt,bottomrule=1pt, rightrule=0pt,left=0.2cm,right=0.2cm,
titlerule=0.5em,toptitle=0.1cm,bottomtitle=-0.1cm,top=0.2cm,
colframe=white!10!coral,colback=white!75!pink,coltitle=white, coltext=bourguignon!80!coral,
title style={white!10!coral}, before skip=8pt, after skip=8pt,
fonttitle=\bfseries,fontupper=\normalsize}{defn}
答案1
我重新格式化了代码,注释掉了cnt
没有用处的业务,除非您需要定义与其他环境共享计数器。我还注释掉了颜色选择,因为我不想猜测它们。
theorem wide name and number
我不知道其风格,而且手册中也找不到相关痕迹tcolorbox
。
你忽略了defn
需要二参数:一个是标题,另一个是交叉引用的标签。
\documentclass[twoside]{article}
\usepackage[paperwidth=210mm, paperheight=297mm, margin=2cm]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,theorems}
%\newcounter{cnt}
% Definition
\newtcbtheorem[
% use counter=cnt,
number within=section
]{defn}{Definition}{
%theorem style=theorem wide name and number, % <-- ???
breakable,
enhanced,
arc=0mm,
outer arc=0mm,
boxrule=0pt,
toprule=1pt,
leftrule=0pt,
bottomrule=1pt,
rightrule=0pt,
left=0.2cm,
right=0.2cm,
titlerule=0.5em,
toptitle=0.1cm,
bottomtitle=-0.1cm,
top=0.2cm,
%colframe=white!10!coral,
%colback=white!75!pink,
coltitle=white,
%coltext=bourguignon!80!coral,
%title style={white!10!coral},
before skip=8pt,
after skip=8pt,
fonttitle=\bfseries,
fontupper=\normalsize
}{defn}
\begin{document}
\begin{defn}{Something}
XYZ
\end{defn}
\begin{defn}{Something}{}
XYZ
\end{defn}
\begin{defn}{Something}{AAAAAA}
XYZ
\end{defn}
\ref{defn:AAAAAA}
\end{document}
如您所见,第一个例子缺少第二个参数,因此采用第一个后续对象来代替它。