I have defined a float environment following this answer in the "optional caption" version:
\documentclass{article}
\usepackage{newfloat}
\usepackage{caption}
\DeclareFloatingEnvironment[fileext=frm,placement={!ht},name=Frame]{myfloat}
\captionsetup[myfloat]{labelfont=bf}
\usepackage{lipsum}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage[colorlinks=true]{hyperref}
\newenvironment{frameenv}[1][]
{\begin{myfloat}[tb]
\begin{mdframed}[roundcorner=10pt,backgroundcolor=blue!10]
\caption{#1}
}
{\end{mdframed}\end{myfloat}
}
\begin{document}
\lipsum[1]
\begin{frameenv}[Details for the caption]\label{frame1}
\lipsum[1]
\end{frameenv}
See frame \ref{frame1}.
\end{document}
Now I want to move the caption outside the box, so I tried moving the \caption{#1]
command in the {enddef}
argument of \newenvironment{}
between \end{mdframed}
and \end{myfloat}
, changing the definition of the frameenv
environment to the following:
\newenvironment{frameenv}[1][]
{\begin{myfloat}[tb]
\begin{mdframed}[roundcorner=10pt,backgroundcolor=blue!10]
}
{\end{mdframed}\caption{#1}\end{myfloat}
}
When I compile the document I get an error:
! Illegal parameter number in definition of \endframeenv.
1
l.16 }
and I can't figure out where is my mistake.
How can I move the caption outside the box?