I'd like to parse an optional variable from a custom \newenvironment{example} to an mdframed environment \mytextbox nested in the example environment.
What I'd like to achieve is something like
Example 1.1 [Optional example title]
and the rest of the text in the framed box.
So far, I have the desired mdframed formatting I'd like, (spacing, "Example X.X", etc.) but I cant figure out how to put in the optional title correctly. It's being printed into the mdframed test area instead of the title area.
This is possibly a simple oversight and I'm being stupid with the limited knowledge I have on macros and environments, it's my first time using them, which is why I'm here :)
Below is a MWE and a sample output.
\documentclass[12pt,oneside]{report} \usepackage[a4paper,width=170mm,top=25mm,bottom=25mm]{geometry} \usepackage{lipsum} \usepackage{tikz} \usepackage{mdframed} \newcounter{exampleCounter}[section] \newmdenv[ linewidth=1pt,% frametitlerule=true,% backgroundcolor=black!3,% innerleftmargin=10mm,% innerrightmargin=10mm,% innerbottommargin=10mm,% ] {mytextbox} \newenvironment{example} [1][] {\refstepcounter{exampleCounter} \begin{mytextbox}[frametitle={Example~\thechapter.\theexampleCounter.~##1}] } {\end{mytextbox}} \usepackage{setspace} \setlength{\parindent}{0mm} \setlength{\parskip}{1em} \begin{document} \chapter{First Chapter} \lipsum[1] \begin{example}{\textit{Optional example title}} \lipsum[2] \end{example} \lipsum[3] \end{document} 
