我想创建带有平行线的漂亮盒子。请参阅附图
我的最低限度的编码:
\documentclass[a4paper,8pt]{article}
\usepackage[left=1.0cm,right=0.3cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
%\usepackage{tikz}
\usepackage{adjustbox}
\tikzset{fancytitle/.style ={fill=red, text=white}}
\newtcolorbox{Mybox}[2][]{enhanced,
arc=4mm,
colframe=blue!80!red,colback=white,colbacktitle=blue!5!yellow!50!white,
fonttitle=\bfseries,coltitle=black,
title={#2},
#1}
\begin{document}
\begin{Mybox}[width=5.4cm,height=2.4cm]{Title}
\begin{center}
abc xyz
\end{center}
\end{Mybox}
\end{document}
答案1
这在很大程度上是从这里但\parshape
内容会自动插入before upper
。当然,您可以根据需要调整尺寸,并可以相应地更改行数\parshape
。
\documentclass[a4paper,8pt]{article}
\usepackage[left=1.0cm,right=0.3cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\newtcolorbox{Mybox}[2][]{%
enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
overlay unbroken and first={%
\draw[fill=yellow]
([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1,-2)
-- ++ (-0.5,0.3) -- ++ (-0.5,-0.3) -- cycle;
\node[anchor=north west,text width=1cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west)
{#2};
},
breakable,arc=4mm,
colframe=blue!80!red,colback=white,
width=\textwidth,
before upper ={\parshape 5
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
1.2cm \dimexpr \hsize-1.2cm\relax
0pt \hsize} ,#1}
\begin{document}
\begin{Mybox}[width=5.4cm]{abc xyz}
some text some text some text some text some text some text some text some text
some text some text some text some text some text some text some text some text
some text some text some text some text some text
\end{Mybox}
\end{document}
如果你想要水平线,你可以使用\hrulefill
。(但是,在这种情况下,你最好不要使用tcolorbox
,而只是用普通的 Ti 画出来钾Z.)
\documentclass[a4paper,8pt]{article}
\usepackage[left=1.0cm,right=0.3cm,top=0.5cm,bottom=0.5cm]{geometry}
\usepackage[most]{tcolorbox}
\newcounter{ic}
\newtcolorbox{Mybox}[2][]{%
enhanced,top=0mm,left=2pt,right=2pt,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
overlay unbroken and first={%
\draw[fill=yellow]
([xshift=6pt,yshift=12pt]frame.north west) -| ++ (1.6,-1.3)
-- ++ (-0.8,0.3) -- ++ (-0.8,-0.3) -- cycle;
\node[anchor=north west,text width=1.6cm-4pt,align=center] at ([xshift=6pt,yshift=12pt]frame.north west)
{#2};
},
breakable,arc=4mm,
colframe=blue!80!red,colback=white,
width=\textwidth,#1}
\begin{document}
\begin{Mybox}[width=5.4cm]{abc xyz}
\vphantom{X}\hspace{1.8cm}\hrulefill{}\par
\hspace{1.8cm}\hrulefill{}\par
\hrulefill{}\par
\hrulefill{}\par
\hrulefill{}
\end{Mybox}
\end{document}