4

I wonder how I can vertically centre the argument of \Title inside the frame in the following MWE.

\documentclass[12pt]{report}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{MyFrame}{%
    outerlinewidth=0pt,
    roundcorner=10pt,
    innerbottommargin=0.5\baselineskip,
    innertopmargin=0.5\baselineskip,
    font=\Huge,
    backgroundcolor=blue}

\newcommand{\Title}[1]{
\begin{mdframed}[style=MyFrame, frametitle={\color{white}#1}, frametitlealignment=\center]
\end{mdframed}
}


\begin{document}

\Title{Title of the text}

\end{document}

1 Answer 1

3

You can fake it by using the option frametitleaboveskip which sets the vertical skip from the top rule of the frame title.

%http://tex.stackexchange.com/questions/89775/vertically-centre-the-title-in-mdframed
\documentclass[12pt]{report}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{MyFrame}{%
    outerlinewidth=0pt,
    roundcorner=10pt,
    innerbottommargin=0.5\baselineskip,
    innertopmargin=0.5\baselineskip,
    font=\Huge,
    backgroundcolor=blue,
    splittopskip=0.5\baselineskip,
    frametitleaboveskip=\baselineskip% \baselineskip distance from top rule
    }

\newcommand{\Title}[1]{
\begin{mdframed}[style=MyFrame, frametitle={\color{white}#1},frametitlealignment=\center,]
\end{mdframed}
}


\begin{document}

\Title{Title of the text}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .