LaTeX forum ⇒ General ⇒ How to center a title in a mdframed box? Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm

How to center a title in a mdframed box?  Topic is solved

I'm having a problem in centering a title inside this simple mdframed code :
\RequirePackage[l2tabu,orthodox]{nag}\documentclass[12pt,letterpaper]{article}\usepackage{xcolor}\usepackage{mdframed}\mdfsetup{} \begin{document} Blablabla \begin{mdframed}[	frametitle={Some funky title},	frametitlealignment=center, % <--- what's wrong here ?  \center doesn't fix this.	frametitlefont=\sffamily,	frametitlerule=true,	frametitlebackgroundcolor=gray!20,	linecolor=black,	backgroundcolor=white,	linewidth=0.5pt,	leftmargin=0cm,	rightmargin=0cm,	topline=true,	bottomline=true,	innertopmargin=1ex,	shadow=true,	shadowsize=1.5pt,	shadowcolor=gray!30] Some braindead blabla in a cool box. \end{mdframed} \end{document}

The mdframed package documentation doesn't give the options to be used for the frametitlealignment command, except default=\raggedleft.

nag gives an error message about the centering command.

What should be the proper solution to center the title ?

Johannes_B
Site Moderator
Posts: 3763
Joined: Thu Nov 01, 2012 4:08 pm
Why not using tcolorbox?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
You mean replacing mdframed with tcolorbox ? mdframed is working very well, there's just this title centering which causes a nag problem. Is this a bug ?

Johannes_B
Site Moderator
Posts: 3763
Joined: Thu Nov 01, 2012 4:08 pm
No idea, probably not a big.
I'll have a look later.

tcolorbox is more powerful these days.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Doh!

Apparently, the proper option to center the title in mdframed isn't center, or \center, it's \centering!
frametitlealignment=\centering,

No more nag warnings.

Why haven't I tried this before? And why it isn't shown in the documentation? Such is LaTeX, I guess.

The issue appears to be solved.

Johannes_B
Site Moderator
Posts: 3763
Joined: Thu Nov 01, 2012 4:08 pm
\center is never correct use. center is an environment.

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm
Yes, but we're talking about a package with options. Most of the options are simple words, not commands, like this :

\begin{mdframed}[	frametitle={Put a title in there},	frametitlerule=true,	linecolor=black,	backgroundcolor=white,	...] Blabla \end{mdframed}

So for the frametitlealignment option, I was expecting a simple word like "center" or "centered", not a command.
But it's working great anyway. The issue is solved.

Who is online

Users browsing this forum: No registered users and 9 guests