4

I have tried to insert title in innerrightmargin using mdframed and found How to insert title in mdframed? this example. But this is only for top of the frame. My MWE is:

\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}

Example:

![enter image description here][1]

Balaji
  • 2,282
  • Your question is not completely clear, at least for me. Where exactly do you want the title to appear? – Gonzalo Medina Nov 19 '14 at 16:00
  • @Gonzalo: Inside frame with vertical right alignment (like end of every line (Morbi, ul-, ligula, hendrerit etc..) – Balaji Nov 19 '14 at 16:02

1 Answers1

5

Update after the edit to the question

Two options; in the first one, a vertical strip is used for the title and the vertical strip's length will vary according to the title's length ; in the second option, the vertical strip will be as long as the frame's height.

\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}

The result:

enter image description here

Initial version

Like this?

enter image description here

The code:

\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}

I used David Carlisle's answer to Vertical text (not in table) to write the title vertically.

Gonzalo Medina
  • 505,128