[Tex/LaTex] Every \newtcbox{\FOO} with a certain text-color

colortcolorbox

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?

Best Answer

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.