我想创建一个\newtcbtheorem[number within=subsection]{definition}{Definition}{...}
这样的:
必须手动插入“定义的标题”和“定义的说明”。
请有人帮我解决代码问题。
(PS:也许我必须创建一个新的环境,但我不知道该怎么做)
下面的代码和谢谢:
\documentclass{book}
\usepackage[a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage[x11names]{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}
\usepackage[most]{tcolorbox}
\tcbuselibrary{theorems}
\title{TCBPOSTER}
\author{???}
\begin{document}
\maketitle
\chapter{Tcolorboxed Posters}
\section{Definition: \LaTeX--function}
\subsection{With Poster of Tcolorbox--package}
\begin{tcbposter}[
poster = {spacing=2mm,columns=1,rows=1},
coverage = {height=3cm,
interior style={top color=yellow,bottom color=yellow!50!red},
},
boxes = {sharp corners=downhill,arc=3mm,boxrule=1mm,
colback=white,colframe=cyan,
title style={left color=black,right color=cyan},
fonttitle=\bfseries}
]
\posterbox[adjusted title=Definition chapetr.section.subsection.definition\_number (Title of the definition)] {column=1,row=1,span=1}{The height of the box must be automatically calculated by LaTeX according to the length of the text inside. It's possible to do it?}
\end{tcbposter}
\end{document}
答案1
使用 a 时,tcbposter
您需要修复 a height
,否则它将使用 a default
。而且 atcbposter
是不可破坏的。
如果您想自动固定高度,可以使用tcbraster
或tcolorbox
在另一个框内使用。第二种选择如以下代码所示。
\newtcbtheorem
已为 定义A。Definitions
第一次使用仅显示此环境,第二次使用显示将其包含在提供黄色背景的外部环境中的效果tcolobox
。由于第二个示例由两个嵌套框组成,因此结果不会在页面之间中断。
\documentclass{book}
\usepackage[a4paper,top=3cm,bottom=3cm,left=1.5cm,right=1.5cm]{geometry}
\usepackage[x11names]{xcolor}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}
\usepackage[most]{tcolorbox}
\newtcolorbox{outerbox}{enhanced, sharp corners, boxrule=0pt, interior style={top color=yellow, bottom color=yellow!50!red}, notitle}
\newtcbtheorem[number within=subsection]{mydef}{Definition}{%
enhanced, sharp corners=downhill, arc=3mm,
boxrule=1mm, colback=white, colframe=cyan,
title style={left color=black, right color=cyan}, fonttitle=\bfseries,
separator sign none,
description delimiters parenthesis
}{def}
\begin{document}
\chapter{Tcolorboxed Posters}
\section{Definition: \LaTeX--function}
\subsection{With Poster of Tcolorbox--package}
\begin{mydef}{Title of the definition}{myfirstlabel}
The height of the box must be automatically calculated by LaTeX according to the length of the text inside. It's possible to do it?
\end{mydef}
\begin{outerbox}
\begin{mydef}{Title of the definition}{mysecondlabel}
The height of the box must be automatically calculated by LaTeX according to the length of the text inside. It's possible to do it?
\end{mydef}
\end{outerbox}
The definition~\ref{def:myfirstlabel} has no external box while the definition~\ref{def:mysecondlabel} although this one won't be breakable because they are nested boxes.
\end{document}