6

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?

9

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.

  • 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. – Vincent Mia Edie Verheyen Apr 27 '15 at 12:05
  • 1
    shouldn't it be coltext (or colupper) rather than fontupper ? – David Carlisle Apr 27 '15 at 12:06
  • @DavidCarlisle: Those are possiblities. I was still writing up. :-) – user11232 Apr 27 '15 at 12:10
  • fontupper=\color{green} doesn't appear to survive page break, when used with option breakable...? – PatrickT Dec 7 '17 at 22:24

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.