LaTeX forum ⇒ GeneralHow 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.
User avatar
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

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

Postby Cham » Tue Jun 05, 2018 12:18 am

I'm having a problem in centering a title inside this simple mdframed code :
  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[12pt,letterpaper]{article}
  3. \usepackage{xcolor}
  4. \usepackage{mdframed}
  5. \mdfsetup{}
  6.  
  7. \begin{document}
  8.  
  9. Blablabla
  10.  
  11. \begin{mdframed}[
  12. frametitle={Some funky title},
  13. frametitlealignment=center, % <--- what's wrong here ? \center doesn't fix this.
  14. frametitlefont=\sffamily,
  15. frametitlerule=true,
  16. frametitlebackgroundcolor=gray!20,
  17. linecolor=black,
  18. backgroundcolor=white,
  19. linewidth=0.5pt,
  20. leftmargin=0cm,
  21. rightmargin=0cm,
  22. topline=true,
  23. bottomline=true,
  24. innertopmargin=1ex,
  25. shadow=true,
  26. shadowsize=1.5pt,
  27. shadowcolor=gray!30
  28. ]
  29.  
  30. Some braindead blabla in a cool box.
  31.  
  32. \end{mdframed}
  33.  
  34. \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 ?

User avatar
Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jun 05, 2018 6:21 am

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.

User avatar
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Jun 05, 2018 1:50 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 ?

User avatar
Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jun 05, 2018 1:52 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.

User avatar
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Jun 05, 2018 5:36 pm

Doh! :lol:

Apparently, the proper option to center the title in mdframed isn't center, or \center, it's \centering!
  1. 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. :roll:

The issue appears to be solved.

User avatar
Johannes_B
Site Moderator
Posts: 3883
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Jun 05, 2018 6:41 pm

\center is never correct use. center is an environment.

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

User avatar
Cham
Posts: 894
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Jun 05, 2018 7:00 pm

Yes, but we're talking about a package with options. Most of the options are simple words, not commands, like this :

  1. \begin{mdframed}[
  2. frametitle={Put a title in there},
  3. frametitlerule=true,
  4. linecolor=black,
  5. backgroundcolor=white,
  6. ...
  7. ]
  8.  
  9. Blabla
  10.  
  11. \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.


Return to “General”

Who is online

Users browsing this forum: No registered users and 9 guests