我正在使用\documentclass{book}
。我想创建如下图所示的定理样式,但没有\tcolorbox
。出于某种原因\tcolorbox
,它对我来说不起作用。有什么想法吗?提前谢谢!!这是我目前使用的 MWE,但看起来并不像我想要的完美。
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{tabularx,booktabs}
\usepackage{blindtext}
\definecolor{myblue}{RGB}{32,92,195}
\newenvironment{mybox}[1]
{\par\medskip\noindent\arrayrulewidth=2pt\arrayrulecolor{myblue}%
\hfill\tabularx{0.8\linewidth}{!{\color{myblue}\vrule width 2pt} X @{}}
\multicolumn{1}{@{}l}{\tabular{@{}l}\kern\tabcolsep\textbf{#1}\\\hline\endtabular}\\}
{\endtabularx\par\medskip}
\begin{document}
\begin{mybox}{The title with some more text in the title}
Onyl some text here
\end{mybox}
\blindtext
\begin{mybox}{The title}
\blindtext
\end{mybox}
\blindtext
\end{document}
答案1
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{tabularx,booktabs}
\usepackage{blindtext}
\def\myindent{1.5ex}
\def\rulethk{1.0pt}
\definecolor{myblue}{RGB}{32,92,195}
\newenvironment{mybox}[1]
{\par\medskip\noindent\arrayrulewidth=2pt\arrayrulecolor{myblue}%
\tabularx{\linewidth}{!{\color{myblue}\hspace{\myindent}\vrule width \rulethk} X @{}}
\multicolumn{1}{@{}l}{\tabular{@{}l@{}}\textbf{#1}\\\hline\endtabular}\\}
{\\\color{myblue}\hspace{\myindent}\smash{\rule[.5pt]{10ex}{\rulethk}}\endtabularx\par\smallskip}
\begin{document}
\begin{mybox}{The title with some more text in the title}
Only some text here
\end{mybox}
\blindtext
\begin{mybox}{The title}
\blindtext
\end{mybox}
\blindtext
\end{document}
答案2
您还可以使用“thmbox”包,这是一个定义定理环境的包。这会在定理周围形成您想要的相同“框”。如果您看一下这里,您将获得一个额外的选项来更改周围框的颜色。