我想写定理和定义(编号应按章节进行,如 2.1、2.2 等)以附加 jpg 文件的形式。
编辑:
上面的框中只会出现标题,框内会出现定理/定义编号。该怎么办?
我在网上收到一个代码。我不知道如何修改它。请帮忙。
\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage[most]{tcolorbox}
\newtcbtheorem{Theorem}{Theorem}{
enhanced,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}{thm}
\newtcbtheorem[no counter]{Proof}{Proof}{
enhanced,
sharp corners,
attach boxed title to top left={
yshifttext=-1mm
},
colback=white,
colframe=blue!25,
fonttitle=\bfseries,
coltitle=black,
boxed title style={
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,
}
}{prf}
\begin{document}
\begin{Theorem}{}{fermat}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n}
+ b^{n} = c^{n}\) for any integer greater than two.
\end{Theorem}
\begin{Proof}{Theorem \ref{thm:fermat}}{}
The proof is easy, but too large to fit in this box.
\end{Proof}
\end{document}
编辑 2:问题只在于设置计数器。定理应为 1.1、1.2... 并且定义应与 1.1、1.2 相同...
\documentclass{book}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}
\tcbset{theostyle/.style={
enhanced,
sharp corners,
attach boxed title to top left={
xshift=-1mm,
yshift=-4mm,
yshifttext=-1mm
},
top=1.5ex,
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}}
\newtcbtheorem[number within=chapter]{Theorem}{Theorem}{%
theostyle
}{thm}
\newtcbtheorem[number within=chapter]{Definition}{Definition}{%
theostyle
}{def}
\newenvironment{myTheorem}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2}
\textbf{Theorem \thetcbcounter.} }{\end{Theorem}}
\newenvironment{myDefinition}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2}
\textbf{Definition \thetcbcounter.} }{\end{Theorem}}
\begin{document}
\chapter{Foo chapter}
\begin{myDefinition}{ggggggggg}{ReadingTheManual}
Reading the manual helps ;-)
\end{myDefinition}
\begin{myTheorem}{fffff}{fermat}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n}
+ b^{n} = c^{n}\) for any integer greater than two.
\end{myTheorem}
\end{document}
答案1
\documentclass{book}
\usepackage{amsmath}
\usepackage{cleveref}
\usepackage[most]{tcolorbox}
\newtcbtheorem[number within=chapter]{Theorem}{}{
enhanced,
sharp corners,
attach boxed title to top left={
xshift=-1mm,
yshift=-5mm,
yshifttext=-1mm
},
top=1.5em,
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}{thm}
\newtcbtheorem[number within=chapter]{Definition}{}{
enhanced,
sharp corners,
attach boxed title to top left={
xshift=-1mm,
yshift=-5mm,
yshifttext=-1mm
},
top=1.5em,
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}{def}
\newenvironment{myTheorem}[2]{ \begin{Theorem}[adjusted title=#1]{}{#2}
\textbf{Theorem \thetcbcounter.} }{\end{Theorem}}
\newenvironment{myDefinition}[2]{ \begin{Definition}[adjusted title=#1]{}{#2}
\textbf{Definition \thetcbcounter.} }{\end{Definition}}
\begin{document}
\chapter{Foo}
\begin{myTheorem}{Fermats Last Theorem}{thm:FermatsLastTheorem}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n} + b^{n} = c^{n}\) for any integer greater than two.
\end{myTheorem}
\begin{myDefinition}{Reading the Manual}{def:ReadingTheManual}
Reading the manual helps ;-)
\end{myDefinition}
\begin{myDefinition}{Definition}{def:Definition}
A statement of the meaning of a word, phrase, or term, as in a dictionary entry.
\end{myDefinition}
\begin{myTheorem}{Pythagoras Theorem}{thm:PythagorasTheorem}
In a right angled triangle: the square of the hypotenuse is equal to the sum of the squares of the other two sides.
\end{myTheorem}
\end{document}
答案2
使用宏number within=chapter
的“init”选项\newtcbtheorem
来应用用chapter-wise
该宏定义的定理计数。(tcolorbox
有关的更多信息,请参阅手册的第 5 和 16 节init option
。)
xshift
可以使用和yshift
键来更改框样式attach boxed title to top left
。
\documentclass{book}
\usepackage{amsmath}
\usepackage[most]{tcolorbox}
\usepackage{cleveref}
\tcbset{theostyle/.style={
enhanced,
sharp corners,
attach boxed title to top left={
xshift=-1mm,
yshift=-4mm,
yshifttext=-1mm
},
top=1.5ex,
colback=white,
colframe=blue!75!black,
fonttitle=\bfseries,
boxed title style={
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,
}
}}
\newtcbtheorem[number within=chapter]{Theorem}{Theorem}{%
theostyle
}{thm}
\newtcbtheorem[number within=chapter]{Definition}{Definition}{%
theostyle
}{def}
\begin{document}
\chapter{Foo chapter}
\begin{Definition}{}{ReadingTheManual}
Reading the manual helps ;-)
\end{Definition}
\begin{Theorem}{}{fermat}
No three positive integers \(a\), \(b\) and \(c\) satisfy the equation \(a^{n}
+ b^{n} = c^{n}\) for any integer greater than two.
\end{Theorem}
\end{document}