关于这个代码,我想要类似的东西
\documentclass{book}
%\usepackage[italian]{babel}
\usepackage[english]{babel}
\usepackage[a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage[svgnames,x11names]{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}
\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}
\usepackage{imakeidx}
\usepackage[tight,english]{minitoc}
% (Re)newcommands
\renewcommand\qedsymbol{\ensuremath{\blacksquare}}
% New Theorems
\newtcbtheorem[number within=subsection] {goldtheorem}{Theorem}{nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---},#1,}{th}
% New Corollaries
\newtcbtheorem[number within=subsection, use counter from=goldtheorem] {goldcorolth}{Corollary of \Thref{th:#2} --- }{nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---},#1,}{th}
\newenvironment{statement}[1]{\textsc{Statement}$\:\:\blacktriangleright\:\:${#1}}
% New refs
\newcommand{\Thref}[1]{Theorem \ref{th:#1}}
\newcommand{\Propref}[1]{Proposition \ref{prop:#1}}
\newcommand{\Defref}[1]{Definition \ref{def:#1}}
\newcommand{\CorTref}[1]{Corollary \ref{th:#1}}
\newcommand{\CorLref}[1]{Corollary \ref{lem:#1}}
\newcommand{\CorPref}[1]{Corollary \ref{prop:#1}}
\newcommand{\Obsref}[1]{Observation \ref{obs:#1}}
\newcommand{\Lemref}[1]{Lemma \ref{lem:#1}}
\begin{document}
\title{\Huge\textcolor{red}{\textbf{Proof Book}}}
\author{\color{blue}{\Huge{\textbf{???}}}}
\maketitle
\dominitoc
\begin{tcolorbox}[enhanced,title=\Huge{Contents},colframe=orange,colback=Silver!75,colbacktitle=Gold1,fonttitle=\bfseries,coltitle=red,attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},boxed title style={boxrule=0.5mm, frame code={ \path[tcb fill frame]([xshift=-4mm]frame.west) -- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east) -- (frame.south east) -- (frame.south west) -- cycle; },interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west) -- (interior.north west) -- (interior.north east) -- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west) -- cycle;} }] %\csname @starttoc\endcsname{toc}
\makeatletter \@starttoc{toc} \makeatother
\end{tcolorbox}
%\tableofcontents
\part[First Example Part]{\Huge\textcolor{red}{First Example Part}}
\chapter[Goldboxed Theorems]{\huge Goldboxed Theorems}
\minitoc
\mtcskip
\section[Some theorem for proof]{\Large Some theorem for proof}
\section{Added of the Corollaries}
\begin{goldtheorem}{A Theorem}{T1}
\begin{statement}
\end{statement}
\end{goldtheorem}
\begin{proof}
Its Proof.
\end{proof}
\noindent\begin{goldcorolth}{A Corollary} {CorolT}{T1}
\end{goldcorolth}
But I'd like to have this:
\noindent\begin{tcolorbox}[title={Corollary of Theorem 1.2.0.1 --- 1.2.0.2 --- A Corollary}, nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---}]
\end{tcolorbox}
\end{document}
答案1
theorem ref=<label>
这里提供了一个新的 tcolorbox 选项。
- 定义:
\tcbset{theorem ref/.initial}
- 在环境声明中的用法
goldcorolth
:% before \newtcbtheorem[...]{goldcorolth}{Corollary of \Thref{th:#2} --- } % after \newtcbtheorem[...]{goldcorolth} {Corollary of \Thref{\pgfkeysvalueof{/tcb/theorem ref}} --- }
- env的使用方法
goldcorolth
:\begin{goldcorolth}[theorem ref=T1]{A Corollary}{CorolT} <body> \end{goldcorolth}
再说几句:
- 由于 是
\Thref
由 定义的\newcommand{\Thref}[1]{Theorem \ref{th:#1}}
,因此使用 时,其参数中不需要th:
。也就是说,使用\Thref{<label>}
而不是\Thref{th:<label>}
。 \newtheorem
总是定义一个采用一个可选参数和两个强制参数的新定理环境,因此尝试传递goldcorolth
第三个强制参数(\begin{goldcorolth}{A Corollary} {CorolT}{T1}
)是无效的。- 因此,我使用键值选项来接收和存储额外信息,并在标题中使用它。这里传递的值直接存储在键中
/tcb/theorem ref
。也可以将其存储在(显式)宏中,例如\makeatletter \tcbset{theorem ref/.store in=\tcb@theo@ref} \newtcbtheorem[...]{goldcorolth}{Corollary of \Thref{\tcb@theo@ref} --- }{...}{th} \makeatother
- 提供一个新的
\newtheorem
类似命令来定义接受两个以上强制参数的定理环境是可能的,但需要了解 tcolorbox 定理宏的内部结构。
完整示例
\documentclass{book}
%\usepackage[italian]{babel}
\usepackage[english]{babel}
\usepackage[a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage[svgnames,x11names]{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}
\usepackage{tcolorbox}
\tcbuselibrary{skins, theorems}
%\usepackage{imakeidx}
%\usepackage[tight,english]{minitoc}
% (Re)newcommands
\renewcommand\qedsymbol{\ensuremath{\blacksquare}}
% New Theorems
\newtcbtheorem[number within=subsection] {goldtheorem}{Theorem}{nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---},#1,}{th}
% New Corollaries
\tcbset{
theorem ref/.initial=,
}
\newtcbtheorem[number within=subsection, use counter from=goldtheorem] {goldcorolth}{Corollary of \Thref{\pgfkeysvalueof{/tcb/theorem ref}} --- }{nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---},theorem ref=,#1,}{th}
\newenvironment{statement}[1]{\textsc{Statement}$\:\:\blacktriangleright\:\:${#1}}
% New refs
\newcommand{\Thref}[1]{Theorem \ref{th:#1}}
\newcommand{\Propref}[1]{Proposition \ref{prop:#1}}
\newcommand{\Defref}[1]{Definition \ref{def:#1}}
\newcommand{\CorTref}[1]{Corollary \ref{th:#1}}
\newcommand{\CorLref}[1]{Corollary \ref{lem:#1}}
\newcommand{\CorPref}[1]{Corollary \ref{prop:#1}}
\newcommand{\Obsref}[1]{Observation \ref{obs:#1}}
\newcommand{\Lemref}[1]{Lemma \ref{lem:#1}}
\begin{document}
\chapter[Goldboxed Theorems]{\huge Goldboxed Theorems}
%\minitoc
%\mtcskip
\section[Some theorem for proof]{\Large Some theorem for proof}
\section{Added of the Corollaries}
\begin{goldtheorem}{A Theorem}{T1}
\begin{statement}
\end{statement}
\end{goldtheorem}
\begin{proof}
Its Proof.
\end{proof}
\noindent\begin{goldcorolth}[theorem ref=T1]{A Corollary}{CorolT}%{T1}
Corollary body
\end{goldcorolth}
But I'd like to have this:
\noindent\begin{tcolorbox}[title={Corollary of Theorem 1.2.0.1 --- 1.2.0.2 --- A Corollary}, nobeforeafter,tcbox raise base,enhanced,boxrule=0pt,interior style={top color=Gold1!10!white,bottom color=Gold1!10!white, middle color=Gold1!50!yellow,},colframe=red,fuzzy halo=1pt with Gold1,description color = black, coltitle=black,fonttitle=\bfseries,separator sign={\ ---}]
\end{tcolorbox}
\end{document}