Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.