# How to mix titling and mdframed packages

Through a tip on this site, I have used package mdframed to get a nice rounded box. But I would like to include it with the titling package.

The following minimum example shows mdframed working correctly later in the document. It also shows titling working, as the \thedate and \thetitle are available after \maketitle, which is one of its helpful features. And I've included the flushright environment which works with titling. But the mdframed environment causes errors.

\documentclass{scrartcl}

\usepackage{lipsum}
\usepackage{titling}
\usepackage[framemethod=TikZ]{mdframed}

\title{My document's title}
\author{Jonathan Clark}
\date{10 May 2014}

% \pretitle{\begin{mdframed}[roundcorner=10pt]\LARGE\bfseries}  % doesn't work
\pretitle{\LARGE\bfseries}    % but without mdframed it works
\posttitle{}
\preauthor{\begin{flushright}\scshape}
\postauthor{\end{flushright}}
\predate{\large}
% \postdate{\end{mdframed}}   % doesn't work
\postdate{\end{mdframed}}     % but without mdframed it worsk

\begin{document}
\maketitle
\begin{mdframed}[roundcorner=10pt]
Date: \thedate. Title: \thetitle.
\end{mdframed}

\lipsum{1}

\end{document}


I believe I'm running the latest version of all packages via TeX Live on OS X.

I suuppose it's something like the following you want. I used the etoolbox package, and more specifically, \pretocmd and \apptocmd towrap \maketitle into the mdframed environment:

\documentclass[x11names]{scrartcl}

\usepackage{lipsum}
\usepackage{titling}
\usepackage{fourier}
\usepackage{heuristica}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{etoolbox}
\title{My document's title}
\author{Jonathan Clark}
\date{10 May 2014}

\pretitle{\LARGE\bfseries}
\posttitle{}
\preauthor{\begin{flushright}\scshape}
\postauthor{\end{flushright}}
\predate{\large}
\postdate{}
\pretocmd{\maketitle}{\mdfsetup{roundcorner = 10pt,linewidth = 2pt, linecolor = Red3}\begin{mdframed}}{}{}
\apptocmd{\maketitle}{\end{mdframed}\bigskip}{}{}

\begin{document}
\maketitle

\lipsum{1}

\end{document}


• Thank you; that looks a good answer.But any idea why the mdframed environment seems to be acting in a special way? – JGC May 10 '14 at 21:26
• I think (not sure, though) it is rather maketitle that acts in a special way. – Bernard May 10 '14 at 21:28