\documentclass{book}
\usepackage{amsmath,amssymb}
\usepackage{nccmath}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcolorbox[auto counter,
number within=chapter,
list inside=myexercise
]{myexercise}[1][]{%
enhanced,
title={{\begin{minipage}{0.99\linewidth}\textbf{Ejercicio}~\thetcbcounter.~\textit{#1}\end{minipage}}},
,
halign title=left,
sharp corners,
colback=white,
coltitle=black,
colbacktitle=white,
boxrule=0pt,frame hidden,
overlay unbroken={%
\draw[black,double] (interior.north west)--(interior.south west);%
},
boxed title style={%
colframe=white,
boxrule=0pt,
colback=white,
left=0pt,
right=0pt},
attach boxed title to top left={xshift={-5pt}},
}
\begin{document}
\begin{myexercise}[This is an example of how this box works, and this is all I got and I want to write a little bit more]{}
Just text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just textJust text Just text Just text Just text Just text Just text
\end{myexercise}
\end{document}
代码的作用如下:
这就是我要的:
我想用 tcolorbox 创建一个新环境或一个框,这样我就可以做你在图片中看到的事情。这个数学问题环境将有一个部分来解释问题陈述(可能长于一行),然后放一张问题的图片,或者添加额外的信息,最后是解决方案的一部分,其中有一些方形帮助行(如笔记本)来写解决方案。还想知道你是否可以用 pgfplot 制作一个具有透明背景的图形。抱歉我的英语不好,谢谢大家。
如果环境可以被打破,那么如果问题大于一页,那就太棒了
答案1
不完全符合您的图像,但可能是进行进一步调整的起点:
\documentclass{book}
\usepackage{amsmath,amssymb}
\usepackage{nccmath}
\usepackage{tcolorbox}
\tcbuselibrary{most}
\newtcolorbox[auto counter,
number within=chapter,
list inside=myexercise
]{myexercise}[1][]{%
enhanced,
title={{\begin{minipage}{\linewidth}\textbf{Ejercicio}~\thetcbcounter.~\textit{#1}\end{minipage}}},
halign title=left,
sharp corners,
colback=white,
coltitle=black,
colbacktitle=white,
boxrule=0pt,frame hidden,
overlay unbroken={\draw[black,double] (interior.north west)--(segmentation.west);},
boxed title style={%
colframe=white,
boxrule=0pt,
colback=white,
left=0pt,
right=0pt},
attach boxed title to top left={xshift={-5pt}},
underlay unbroken={\draw[help lines,step=5mm,black!20!white](interior.south west) grid (segmentation.east);},
lower separated=false,
before lower = {\tcbsubtitle[colback=white, colframe=black, boxrule=1pt, height=1cm, width=2.55cm, valign=center]{Solution:}}
}
\begin{document}
\begin{myexercise}[This is an example of how this box works, and this is all I got and I want to write a little bit more]{}
\vspace{4cm}
\tcblower
\vspace{1cm}
\end{myexercise}
\begin{myexercise}[This is an example of how this box works, and this is all I got and I want to write a little bit more]{}
\vspace{1cm}
\tcblower
\vspace{5cm}
\end{myexercise}
\end{document}