所以我不想重复,但显然我无法在之前的帖子中知道答案......
所以最初的问题是:tcolorbox 用于定理
现在我已经完成了:
它解决了我的问题。我可以问你如何修改代码的一部分吗?
因此对于这个问题:如何在 beamer 中制作框架块 我已经创建了方框定理。但我想在上面的小方框中写下定理的名称。我该如何添加它 :)?
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[most]{tcolorbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{xcolor}
\definecolor{vert}{RGB}{0,181,0}
\definecolor{oran}{RGB}{223,74,0}
\definecolor{viol}{RGB}{134,0,175}
\definecolor{roug}{RGB}{215,15,0}
\newtcolorbox[auto counter]{theoreme}[1]{%
colback=white,
colframe=roug,
colbacktitle=white!90!roug,
coltitle=black,
fonttitle=\bfseries,
title=Théorème~\thetcbcounter .,
enhanced,
attach boxed title to top left={yshift=-2mm, xshift=0.5cm}
}
\tcbset{
thmbox/.style={
enhanced,
breakable,
sharp corners=all,
fonttitle=\bfseries\normalsize,
fontupper=\normalsize\itshape,
top=0mm,
bottom=0mm,
right=0mm,
colback=white,
colframe=white,
colbacktitle=white,
%coltitle=red,
attach boxed title to top left,
boxed title style={empty, size=minimal, bottom=1.5mm},
overlay unbroken ={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
overlay first={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay middle={
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay last={
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
},
SV/.style={thmbox, coltitle=vert,
overlay unbroken ={
\draw[vert][thick] (title.south west)--(title.south east);
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay first={
\draw[vert][thick] (title.south west)--(title.south east);
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
},
SO/.style={thmbox, coltitle=oran,
overlay unbroken ={
\draw[oran][thick] (title.south west)--(title.south east);
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay first={
\draw[oran][thick] (title.south west)--(title.south east);
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
},
LQ/.style={thmbox, coltitle=viol,
overlay unbroken ={
\draw[viol][thick] (title.south west)--(title.south east);
\draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
\node[anchor=east] at (frame.south east) {$\square$};},
overlay first={
\draw[viol][thick] (title.south west)--(title.south east);
\draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
\node[anchor=east] at (frame.south east) {$\square$};},
},
}
\newtcbtheorem[]{ajoutationV}{Exemple}{thmbox,SV}{theo}
\newtcbtheorem[]{ajoutationO}{Exercice}{thmbox,SO}{theo}
\newtcbtheorem[]{demo}{Démonstration}{thmbox,LQ}{theo}
\begin{document}
\begin{ajoutationV}{}{}
\lipsum[2]
\end{ajoutationV}
\begin{ajoutationO}{}{}
\lipsum[2]
\end{ajoutationO}
\begin{demo}{}{}
\lipsum[1]
\end{demo}
\begin{theoreme}
WOW
\end{theoreme}
\end{document}
我还有另一个问题。我想定义一个计数器,但我不知道如何在每章结束时重置它。有什么想法吗?
答案1
定理的名称已经写在附加的小框中,但是定义了tcolorbox
theoreme
一个强制参数,因此它需要一个参数——如果没有给出这个参数,它将吞噬环境中的第一个标记,然后WOW
变成OW
。
我建议写
\newtcolorbox[auto counter]{theoreme}[2][]{%
相反,在这种情况下,第一个参数是可选的,可用于更改框的选项。如果省略,则不会造成任何损害,第二个参数是必需的,用于标题:
\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath,amssymb}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[most]{tcolorbox}
\usepackage{lmodern}
\usepackage{xcolor}
\definecolor{vert}{RGB}{0,181,0}
\definecolor{oran}{RGB}{223,74,0}
\definecolor{viol}{RGB}{134,0,175}
\definecolor{roug}{RGB}{215,15,0}
\newtcolorbox[auto counter]{theoreme}[2][]{%
colback=white,
colframe=roug,
colbacktitle=white!90!roug,
coltitle=black,
fonttitle=\bfseries,
title=Théorème~\thetcbcounter.\ #2,
enhanced,
attach boxed title to top left={yshift=-2mm, xshift=0.5cm},%
#1% For possible options
}
\tcbset{
thmbox/.style={
enhanced,
breakable,
sharp corners=all,
fonttitle=\bfseries\normalsize,
fontupper=\normalsize\itshape,
top=0mm,
bottom=0mm,
right=0mm,
colback=white,
colframe=white,
colbacktitle=white,
%coltitle=red,
attach boxed title to top left,
boxed title style={empty, size=minimal, bottom=1.5mm},
overlay unbroken ={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
overlay first={
\draw (title.south west)--(title.south east);
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay middle={
\draw ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);
\draw (frame.north east)--(frame.south east);},
overlay last={
\draw ([xshift=3.5mm]frame.north west)|-%
(frame.south east)--(frame.north east);},
},
SV/.style={thmbox, coltitle=vert,
overlay unbroken ={
\draw[vert][thick] (title.south west)--(title.south east);
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay first={
\draw[vert][thick] (title.south west)--(title.south east);
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[vert][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
},
SO/.style={thmbox, coltitle=oran,
overlay unbroken ={
\draw[oran][thick] (title.south west)--(title.south east);
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay first={
\draw[oran][thick] (title.south west)--(title.south east);
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[oran][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
},
LQ/.style={thmbox, coltitle=viol,
overlay unbroken ={
\draw[viol][thick] (title.south west)--(title.south east);
\draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
\node[anchor=east] at (frame.south east) {$\square$};},
overlay first={
\draw[viol][thick] (title.south west)--(title.south east);
\draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay middle={
\draw[viol][thick] ([xshift=3.5mm]frame.north west)--([xshift=3.5mm]frame.south west);},
overlay last={
\draw[viol][thick] ([xshift=3.5mm]frame.north west)|-([xshift=15mm]frame.south west);
\node[anchor=east] at (frame.south east) {$\square$};},
},
}
\newtcbtheorem[]{ajoutationV}{Exemple}{thmbox,SV}{theo}
\newtcbtheorem[]{ajoutationO}{Exercice}{thmbox,SO}{theo}
\newtcbtheorem[]{demo}{Démonstration}{thmbox,LQ}{theo}
\begin{document}
\begin{ajoutationV}{}{}
\lipsum[2]
\end{ajoutationV}
\begin{ajoutationO}{}{}
\lipsum[2]
\end{ajoutationO}
\begin{demo}{}{}
\lipsum[1]
\end{demo}
\begin{theoreme}{A nice theorem}
WOW
\end{theoreme}
\end{document}