
저는 tcolorbox 패키지를 사용하여 제목이 붙은 상자를 생성합니다. 상자의 오른쪽 모서리에 제목 노드를 배치했지만 이는 예제의 텍스트와 겹쳐졌습니다. 오른쪽 모서리에 title- 노드가 있고 그 주위에 텍스트가 "감겨" 있는 상자를 만들려면 어떻게 해야 합니까? 그러면 예제의 텍스트가 노드에 도착하고 개행 문자에 들어갈 때 중지됩니다. 나는 최소한의 예를 든다.
\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}
\usepackage{array}
\tikzstyle{titlenode} =
[draw=black, thick, scale=.7, fill=red,%
line width=0.1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]
\newtcolorbox{boxexample}[2][]{%
enhanced,
%oversize,
colback=white,
boxrule=.5pt,
colframe=black,
top=6mm,
bottom=6mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
overlay unbroken and first={%
\node[titlenode] (B)
at ([xshift=0cm,yshift=-.7cm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c}
\hline
\rule{0pt}{2ex}
\mbox{Example}
\\
\mbox{#2}
\rule{0pt}{1.5ex}
\end{array}$}};},
breakable,
arc=0pt,outer arc=0pt,
#1}%
\begin{document}
\begin{boxexample}{One}
The text of the example is overlayed by the node of the title in the right-corner...
The text of the example is overlayed by the node of the title in the right-corner
\end{boxexample}
\end{document}
xelatex 컴파일러로 얻은 결과
업데이트
Thanks to @David Carlisle, I obtain boxed examples, with text wrapped around the title node,
with the command "0pt \dimexpr \hsize-3cm\relax", which is not very far from my aim. Clearly,
I doesn'nt want to write the commands...
"\parshape 4
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize"
at every beginning of example.
How can I write a macro which inserts automatically the command \parshape 4,
and 3 lines with the command "0pt \dimexpr \hsize-3cm\relax" at the beginning of each
example ?...
I give the tex file I use
\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}
\usepackage{array}
\tikzstyle{titlenode} =
[draw=blue, thick, scale=.7, fill=red,%
line width=1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]
\newcounter{example}
\newtcolorbox[auto counter,
number within=section,
number freestyle={\noexpand\arabic{section}\noexpand\alph{\tcbcounter}}]{example}[1][]{%
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={%
at ([xshift=-6pt,yshift=-27pt]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}}
\hline
\rule{0pt}{2ex}
\mbox{Example}
\\
\mbox{\Large\thetcbcounter}
\rule{0pt}{1.5ex}
\end{array}$}};
},
breakable,before=\par\smallskip\vspace{-10pt}\centering,arc=0pt,
outer arc=0pt,colframe=green,colback=white,
width=\textwidth,
#1}
\begin{document}
\setcounter{section}{1}
\begin{example}
\parshape 4
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize
The text of the example is not overlayed by the node of the title in the right-corner...
The text of the example is not overlayed by the node of the title in the right-corner...
The text of the example is not overlayed by the node of the title in the right-corner
\end{example}
\end{document}
xelatex로 컴파일한 것입니다.
답변1
귀하의 예제를 실행하면 최상위 라인이 표시되지 않지만 컷아웃이 추가됩니다.
\documentclass[14pt]{extbook}%
\usepackage[most]{tcolorbox}
\usepackage{array}
\tikzstyle{titlenode} =
[draw=black, thick, scale=.7, fill=red,%
line width=0.1pt, text=black, rectangle,
font=\Large,
left, minimum height=1cm]
\newtcolorbox{boxexample}[2][]{%
enhanced,
%oversize,
colback=white,
boxrule=.5pt,
colframe=black,
top=6mm,
bottom=6mm,
enlarge top by=\baselineskip/2+1mm,
enlarge top at break by=0mm,pad at break=2mm,
fontupper=\normalsize,
overlay unbroken and first={%
\node[titlenode] (B)
at ([xshift=0cm,yshift=-.7cm]frame.north east)
{\strut\setlength{\extrarowheight}{-30.5pt}\textbf{$\begin{array}{c}
\hline
\rule{0pt}{2ex}
\mbox{Example}
\\
\mbox{#2}
\rule{0pt}{1.5ex}
\end{array}$}};},
breakable,
arc=0pt,outer arc=0pt,
#1}%
\begin{document}
\begin{boxexample}{One}
\parshape 3
0pt \dimexpr \hsize-3cm\relax
0pt \dimexpr \hsize-3cm\relax
0pt \hsize
The text of the example is overlayed by the node of the title in the right-corner...
The text of the example is overlayed by the node of the title in the right-corner
\end{boxexample}
\end{document}