我尝试在innerrightmargin
使用中插入标题mdframed
并发现如何在 mdframed 中插入标题?这个例子。但这仅适用于框架顶部。我的 MWE 是:
\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}
\newenvironment{myenv}[1]
{\mdfsetup{
frametitle={\colorbox{white}{\space#1\space}},
innertopmargin=10pt,
topline=false,
leftline=false,
frametitleaboveskip=-\ht\strutbox,
frametitlealignment=\center
}
\begin{mdframed}%
}
{\end{mdframed}}
\begin{document}
\begin{myenv}{The frame title}
\lipsum[2]
\end{myenv}
\end{document}
例子:
![在此处输入图片描述][1]
答案1
编辑问题后更新
两个选项;第一个选项中,垂直条用于标题,垂直条的长度将根据标题的长度而变化;第二个选项中,垂直条将与框架的高度一样长。
\documentclass{article}
\usepackage[tikz]{mdframed}
\usepackage{lipsum}
\definecolor{greentitle}{RGB}{165,224,168}
\newenvironment{myenvi}[1]
{\begin{mdframed}[
bottomline=false,
leftline=false,
linecolor=greentitle,
innerrightmargin=25pt,
singleextra={
\node[overlay,anchor=south east,fill=greentitle,rotate=90,font=\color{white}\scshape] at (P) {#1};
},
firstextra={
\node[overlay,anchor=south east,fill=greentitle,rotate=90,font=\color{white}\scshape] at (P) {#1};
},
]
}
{\end{mdframed}}
\newenvironment{myenvii}[1]
{\begin{mdframed}[
bottomline=false,
leftline=false,
linecolor=greentitle,
innerrightmargin=25pt,
singleextra={
\fill[greentitle] (P) rectangle ([xshift=-15pt]P|-O);
\node[overlay,anchor=south east,rotate=90,font=\color{white}\scshape] at (P) {#1};
},
firstextra={
\fill[greentitle] (P) rectangle ([xshift=-15pt]P|-O);
\node[overlay,anchor=south east,rotate=90,font=\color{white}\scshape] at (P) {#1};
},
]
}
{\end{mdframed}}
\begin{document}
\begin{myenvi}{the frame title}
\lipsum[2]
\end{myenvi}
\begin{myenvii}{the frame title}
\lipsum[2]
\end{myenvii}
\end{document}
结果:
初始版本
像这样?
代码:
\documentclass{article}
\usepackage[tikz]{mdframed}
\usepackage{lipsum}
\makeatletter
\protected\def\vvv#1{\leavevmode\bgroup\vbox\bgroup\xvvv#1\relax}
\def\xvvv{\afterassignment\xxvvv\let\tmp= }
\def\xxvvv{%
\ifx\tmp\@sptoken\egroup\ \vbox\bgroup\let\next\xvvv
\else\ifx\tmp\relax\egroup\egroup\let\next\relax
\else
%\hbox{\tmp}%original
\hbox to 1.1em{\hfill\tmp\hfill}% centred
\let\next\xvvv\fi\fi
\next}
\makeatother
\newenvironment{myenv}[1]
{\begin{mdframed}[
topline=false,
leftline=false,
innerrightmargin=40pt,
singleextra={
\node[overlay,anchor=north east] at (P) {\vvv{#1}};
},
firstextra={
\node[overlay,anchor=north east] at (P) {\vvv{#1}};
},
]
}
{\end{mdframed}}
\begin{document}
\begin{myenv}{The~frame title}
\lipsum[2]
\end{myenv}
\end{document}
我用了David Carlisle's answer
到垂直文本(不在表格中)垂直书写标题。