如何获取1-3
和3(1/2)
中的顶部框值mdframed
。请参阅以下屏幕截图:
![在此处输入图片描述][1]
我的 MWE 是:
\documentclass{article}
\usepackage[tikz]{mdframed}
\usepackage{lipsum}
\definecolor{greentitle}{cmyk}{.3,.02,.4,0}
\makeatletter
\newenvironment{understanding}[1][]%
{\begin{mdframed}[
bottomline=false,
leftline=false,
linecolor=greentitle,
backgroundcolor=white,
roundcorner=0pt,
linewidth=1pt,
innerrightmargin=25pt,
singleextra={
\fill[greentitle] (P) rectangle ([xshift=-13pt]P|-O);
\node[overlay,anchor=south east,rotate=90,font=\color{white}\scshape] at (P) {\fontsize{10} {12}\selectfont{UNDERSTANDING}};
},
]
}
{\end{mdframed}}
\makeatother
\begin{document}
\begin{understanding}
\lipsum[2-3]
\end{understanding}
\end{document}
请提出好的基本建议tikz basic user guide
。
答案1
您可以在singleextra
\documentclass{article}
\usepackage[tikz]{mdframed}
\usepackage{lipsum}
\definecolor{greentitle}{cmyk}{.3,.02,.4,0}
\makeatletter
\newenvironment{understanding}[1][]%
{\begin{mdframed}[
bottomline=false,
leftline=false,
rightline=false,
linecolor=greentitle,
backgroundcolor=white,
roundcorner=0pt,
linewidth=1pt,
innerrightmargin=25pt,
singleextra={
\fill[greentitle] ([yshift=3ex]P) rectangle ([xshift=-13pt]P|-O);
\node[overlay,anchor=south east,rotate=90,text=white,font=\scshape] at (P) {\fontsize{10} {12}\selectfont{UNDERSTANDING}};
\node[overlay,fill=gray!30,minimum width=0.75in,text depth = 0pt,text height=1.4ex,anchor=south east,text=white] at ([xshift=-13pt]P) {3(1/2)};
\node[overlay,fill=gray,minimum width=0.75in,anchor=south east,text depth = 0pt,text height=1.4ex,text=white] at ([xshift=-13pt-0.75in]P) {1--3};
},
]
}
{\end{mdframed}}
\makeatother
\begin{document}
\begin{understanding}
\lipsum[2-3]
\end{understanding}
\end{document}
正如所承诺的,这里有一个tcolorbox
可以帮助您入门的版本。
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\definecolor{greentitle}{cmyk}{.3,.02,.4,0}
\makeatletter
\newtcolorbox[auto counter]{understanding}[2][]{
enhanced jigsaw,
left=0pt,
boxrule=0pt,
toprule=1pt,
arc=0pt,
after=\par\noindent\vspace{2em},
colback= white ,
colframe=greentitle,
overlay={
\node[anchor=south west,text width=1.5in,fill=greentitle,text=white]
(a) at ([xshift=-1pt]frame.north west) {\strut \Large\sffamily Exercise~\thetcbcounter: \space
\normalsize#2};
\draw[line width=2pt,rounded corners=1ex,white] (a.south west) |- (a.north east) -- (a.south east);
\node[anchor=south east,text width=0.5in,text depth=0pt,text height=1.55ex,outer sep=0pt,align=center,fill=gray!30,text=white]
(b) at (frame.north east) {3(1/2)};
\node[anchor=east,text width=0.5in,text depth=0pt,text height=1.55ex,outer sep=0pt,align=center,fill=gray,text=white]
(c) at (b.west) {1--3};
\node[anchor=north east,text width=\tcb@height+1.55ex,outer sep=0pt,align=right,fill=greentitle,rotate=90,text=white,font=\sffamily\Large]
(d) at ([yshift=3.1ex]frame.north east) {Understanding\hspace{1.6ex}\null};
},
#1}
\makeatother
\begin{document}
\begin{understanding}{Revision}
\lipsum[2-3]
\end{understanding}
\end{document}