# How to insert title in innerrightmargin using mdframed

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]

• 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

## 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:

## Initial version

Like this?

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.

• title should be place in right rule before but the styles are same \raggedleft. – Balaji Nov 19 '14 at 16:06
• @Balaji I don't understand. Please describe in more detail the desired positioning. – Gonzalo Medina Nov 19 '14 at 16:10
• @Balaji Ah, seeing your edit now I think I know what you want. In some minutes (if none else has provided an answer) I'll give you a possibility. – Gonzalo Medina Nov 19 '14 at 16:25
• I have updated my questions. – Balaji Nov 19 '14 at 16:25
• @Balaji Please see my updated answer. – Gonzalo Medina Nov 19 '14 at 17:03