8

Imagine having a certain tcolorbox (manual) named FOO, called for via:

\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbox{\FOO}{colback=red,colframe=blue}

\begin{document}
\FOO{Something}
\FOO{Something else}
\end{document}

Now, is it possible to include something in the Preamble (i.e. before \begin{document}) such that every FOO will have e.g. green text?

1 Answer 1

14

You can use fontupper like

\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbox{\FOO}{colback=red,colframe=blue,fontupper=\color{green}}
\begin{document}
\FOO{Something}
\FOO{Something else}
\end{document}

enter image description here

If you are using \tcblower then there is also \fontlower which will apply to the lower part. Here you can use font changing commands (like \sffamily) too in addition to colour commands.

Equivalently you can use colupper=green and collower=green. There is also coltext which should be used as

\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbox{\FOO}{colback=red,colframe=blue,coltext=green}
\begin{document}
\FOO{Something}
\FOO{Something else}
\end{document}

coltext is a short hand for using both colupper and collower.

4
  • You have answered perfectly, faster then SE allows me to accept your answer. Congratulations with your answer, which will be accepted in ±9 minutes. =) Your answer is as fast as a PING.
    – O0123
    Apr 27, 2015 at 12:05
  • 1
    shouldn't it be coltext (or colupper) rather than fontupper ? Apr 27, 2015 at 12:06
  • @DavidCarlisle: Those are possiblities. I was still writing up. :-)
    – user11232
    Apr 27, 2015 at 12:10
  • fontupper=\color{green} doesn't appear to survive page break, when used with option breakable...?
    – PatrickT
    Dec 7, 2017 at 22:24

You must log in to answer this question.

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