我在本论坛中看到代码,有一个框“AAAA”。现在我想创建具有其他样式和相同曲线的框 BBBB 和 CCCC。BBBB 框:添加 B1/B2/B3 框 CCCC 框:旋转“标题”但不旋转文本请查看图片和原始代码。请帮助此代码:谢谢
\documentclass[a4paper]{book}
\usepackage{amsmath,amssymb}% pour les maths
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{MnSymbol,wasysym}
\usepackage[svgnames]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{framed}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
%\usepackage[utf8]{english}
\usepackage[english]{babel}
\usepackage[format=plain,
labelfont={bf,it},
textfont=it]{caption}
%\newcommand\captionof[2]{\def\@captype{#1}\caption}
\usepackage{tikzsymbols}
\newtcbtheorem{myLemma}{Long text here without counter }{lemmastyle}{thm}
\usetikzlibrary{calc, fit, backgrounds}
\usepackage{varwidth}
\newcommand{\mybox}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{%
\centering
\begin{tikzpicture}
\node[line width=0.5mm, inner ysep=10pt, text width=#1, outer sep=0] (text) {\begin{varwidth}{\textwidth}#4\end{varwidth}};
\node[text=white, above right, align=left] (title) at (text.north west) {#3};
\node[fit=(title) (text), line width=0.5mm, rounded corners, draw=#2, inner sep=0pt] (box){};
\begin{scope}[on background layer]
\fill[#2] (title.south west) -- (title.south east) to[out=0, in=180] ([xshift=1.5cm]title.east) -- (title.east-|box.north east) [rounded corners] -- (box.north east) -- (box.north west) [sharp corners] -- cycle;
\end{scope}
\end{tikzpicture}
}
\newcommand{\myboxa}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{%
\centering
\begin{tikzpicture}
\node[line width=0.5mm, inner ysep=10pt, text width=#1, outer sep=0] (text) {\begin{varwidth}{\textwidth}#4\end{varwidth}};
\node[text=white, above right, align=left] (title) at (text.west north) {#3};
\node[fit=(title) (text), line width=0.5mm, rounded corners, draw=#2, inner sep=0pt] (box){};
\begin{scope}[on background layer]
\fill[#2] (title.west south) -- (title.west south) to[out=0, in=180] ([xshift=1.5cm]title.east) -- (title.east-|box.east north) [rounded corners] -- (box.east north) -- (box.west north) [sharp corners] -- cycle;
\end{scope}
\end{tikzpicture}
}
\usepackage{pifont}
\begin{document}
\tcbset{sidebyside,
size=minimal,
colback=white,
lower separated=false,
halign upper=flush center,
halign lower=flush left,
lefthand width=2.5cm,
frame empty,
}
\mybox[10cm]{green!70!black}{AAAA }{
\begin{enumerate}
\item ....................................................\hspace*{1cm}..........................
\item ....................................................\hspace*{1cm}..........................
\end{enumerate}
}
\end{document}
答案1
这是一个可能的解决方案。它基于我自己的答案代码到灵感来自 Indesign 的精美盒子这些盒子的设计就是用这个tcolorbox
解决方案。使用这个解决方案,很容易定义一个盒子tcboxedraster
或tcboxeditemize
将三个盒子包含在另一个盒子中。
\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\makeatletter
\tcbset{
myhbox/.style 2 args={%
enhanced,
breakable,
colback=white,
colframe=blue!30!black,
attach boxed title to top left={yshift*=-\tcboxedtitleheight},
title={#2},
boxed title size=title,
boxed title style={%
sharp corners,
rounded corners=northwest,
colback=tcbcolframe,
boxrule=0pt,
},
underlay boxed title={%
\path[fill=tcbcolframe] (title.south west)--(title.south east)
to[out=0, in=180] ([xshift=5mm]title.east)--
(title.center-|frame.east)
[rounded corners=\kvtcb@arc] |-
(frame.north) -| cycle;
},
#1
},
myvbox/.style 2 args={%
enhanced,
colback=white,
colframe=blue!30!black,
left=8mm,
overlay={
\node[rotate=90, anchor=north west, inner sep=2mm, text=white] (title@aux) at (frame.south west) {#2};
\path[fill=tcbcolframe] ([email protected] west)--([email protected] east)
to[out=90, in=270] ([yshift=5mm][email protected])--
([email protected]|-frame.north)
[rounded corners=\kvtcb@arc] -|
(frame.west) |- ([email protected])[sharp corners] -- cycle;
\node[rotate=90, inner sep=2mm, text=white] at (title@aux) {#2};
},
#1
},
}
\makeatother
\newtcolorbox{myhbox}[2][]{%
myhbox={#1}{#2}
}
\newtcolorbox{myvbox}[2][]{%
myvbox={#1}{#2}
}
\begin{document}
\begin{myhbox}{Long fancy title}
\begin{enumerate}
\item Show that
\[D_2f(x,y) = \frac{\partial{}}{\partial{y}} \left ( \int_0^xg_1 (t,0)\ dt + \int_0^y g_2(x,s)\ ds \right)\]
\item Prove that
\[\left(\forall x\in\mathbb{R} \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y\]
\end{enumerate}
\end{myhbox}
\begin{myvbox}[colframe=red!80!black]{Long fancy title}
\begin{enumerate}
\item Show that
\[D_2f(x,y) = \frac{\partial{}}{\partial{y}} \left ( \int_0^xg_1 (t,0)\ dt + \int_0^y g_2(x,s)\ ds \right)\]
\item Prove that
\[\left(\forall x\in\mathbb{R} \right)\left(\forall y \in \mathbb{R} \right) x\neq y\, \text{and} \, x+y \neq 2 \implies x^{2}-2x \neq y^2-2y\]
\end{enumerate}
\end{myvbox}
\begin{tcboxeditemize}[raster columns=3, myhbox={colback=yellow!10, colframe=red!70!black}{Box \# \thetcbrasternum} ]{myhbox={colback=red!10}{External box}}
\tcbitem A
\tcbitem[notitle, myvbox={colback=green!70!black, height=4cm}{Box \# \thetcbrasternum}] B
\tcbitem C
\end{tcboxeditemize}
\end{document}
笔记先前的代码已更新,以兼容 tcolorbox v4.20。如果您使用的是先前版本,请将颜色形式重命名tcbcol...
为旧形式 tcbcol@...
。