# Environment with mdframed

The following mwe showcases the environment I am currently working with:

\documentclass{article}
\usepackage[tikz]{mdframed}

\definecolor{greentitle}{RGB}{165,224,168}

\newenvironment{notation}[1]
{\begin{mdframed}[
bottomline=true,
leftline=true,
linecolor=greentitle,
innerrightmargin=25pt,
singleextra={
\node[overlay,anchor=east,fill=greentitle,rotate=90,font=\footnotesize\scshape] at ([yshift=0.4pt]O|-P) {#1};
},
firstextra={
\node[overlay,anchor=east,fill=greentitle,rotate=90,font=\footnotesize\scshape] at ([yshift=0.4pt]O|-P) {#1};
},
]
}
{\end{mdframed}}
\begin{document}
\begin{notation}{Notation}
Sample Text
\end{notation}
\begin{notation}{Notation}
\begin{enumerate}
\item sample
\item sample
\item sample
\item sample
\item sample
\item sample
\end{enumerate}
\end{notation}
\begin{notation}{Notation}
\begin{enumerate}
\item sample
\item sample
\end{enumerate}
\end{notation}
\begin{notation}{Notation}
\begin{enumerate}
\item sample
\item sample
\end{enumerate}
\end{notation}
\end{document}


The issue I have is that I would like the environment to expand to the height of any word, in this case, notation by default. Therefore, the minimum height of the framed environment should be the height of the boxed word "notation." In the last examples you can see that the bottom line is not aligned with the boxed word.

Also I would like the boxed word to anchored outside of the framed box at the top right corner, not as is.

Note also that there is not enough space after each environment and as the first and second example show, they overlap.

• Is a solution with tcolorbox acceptable to you? – CarLaTeX Jul 16 '19 at 4:34
• @CarLaTeX Sure. If that is another way of doing it yes. I would like to compare both ways if that is the case; tcolorbox and mdframed. – azetina Jul 16 '19 at 4:44

This is what I managed to do with tcolorbox:

\documentclass{article}
\usepackage{graphicx}
\usepackage[most]{tcolorbox}
\definecolor{greentitle}{RGB}{165,224,168}
\newcommand{\mytitle}[1]{\rotatebox[origin=c]{90}{#1}}
\newtcolorbox{notation}{
sharp corners,
bicolor,
sidebyside,
colback=greentitle,
colframe=greentitle,
colbacklower=white,
lefthand width=.2cm,
sidebyside align=top seam,
left=0pt,
middle=0pt,
sidebyside gap=10pt,
fontupper=\footnotesize\scshape,
}

\begin{document}
\begin{notation}
\mytitle{Notation}
\tcblower
Sample Text
\end{notation}
\begin{notation}
\mytitle{Notation}
\tcblower
\begin{enumerate}
\item sample
\item sample
\item sample
\item sample
\item sample
\item sample
\end{enumerate}
\end{notation}
\begin{notation}
\mytitle{Notation}
\tcblower
\begin{enumerate}
\item sample
\item sample
\end{enumerate}
\end{notation}
\begin{notation}
\mytitle{Notation}
\tcblower
\begin{enumerate}
\item sample
\item sample
\end{enumerate}
\end{notation}
\end{document}