3

I want to set up a customised tcolorbox where the title of the box is automatically formatted as a section heading. Here's a MWE with my current set up:

\documentclass[a0]{a0poster}
\usepackage{lipsum}
\usepackage[margin=4cm]{geometry}
\usepackage{multicol}
\columnsep=3cm
\columnseprule=0pt
\usepackage{xcolor}
\definecolor{grey}{RGB}{240,240,240}
\usepackage{tcolorbox}
\newtcolorbox{info}[1]{boxrule=1.5mm,sharp corners,colback=grey,colframe=black,title=#1,fontupper=\color{black},fonttitle={\color{white}\bf\section{#1}}}
\begin{document}
\begin{multicols}{3}
\begin{info}{Introduction}
\lipsum[1]
\end{info}
\lipsum[2-30]
\end{multicols}
\end{document}

The problem is that this creates this:

enter image description here

Rather than, as desired, this:

enter image description here

A solution would be welcome.

  • Well, you're typesetting the title twice, effectively. \bf is deprecated – user31729 Apr 24 '17 at 13:33
8

The \section should go into title=..., not again in fonttitle=, which is meant for font settings, not for structure levels.

(Well, 'again' is the wrong term: fonttitle settings are done first, so \section will come first then as well, which is clearly visible in the O.P.'s screenshot)

\documentclass[a0]{a0poster}
\usepackage{lipsum}
\usepackage[margin=4cm]{geometry}
\usepackage{multicol}
\columnsep=3cm
\columnseprule=0pt
\usepackage{xcolor}
\definecolor{grey}{RGB}{240,240,240}
\usepackage{tcolorbox}
\newtcolorbox{info}[1]{boxrule=1.5mm,sharp corners,colback=grey,colframe=black,title=\protect\section{#1},fontupper=\color{black},fonttitle={\color{white}}}
\begin{document}
\begin{multicols}{3}
\begin{info}{Introduction}
\lipsum[1]
\end{info}
\lipsum[2-30]
\end{multicols}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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