9

How can I set the size of all the text that appears inside a tcolorbox to a different size? I have tried size=small in the options of the tcolorbox to no effect.

\begin{tcolorbox}[size=small]
some text
\end{tcolorbox}
2
  • 3
    This is clearly stated in the tcolorbox manual, looking for fontupper and fontlower, size=small has more effects than just the resizing of fonts -- it will influence the box separations etc. as well
    – user31729
    Commented Jan 7, 2018 at 10:50
  • I was a bit confused by the fontupper and fontlower aspects. Now I know that we can just have fontupper without fontlower text. initially I had thought both were required.
    – Damitr
    Commented Jan 7, 2018 at 11:20

1 Answer 1

9

It can be done by setting a hook at the beginning of the tcolorbox environment with the aid of etoolbox package. See the following:

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{etoolbox}
\AtBeginEnvironment{tcolorbox}{\small}

\begin{document}

\lipsum[2]
\begin{tcolorbox}%[size=small]
\lipsum[2]
\end{tcolorbox}

\end{document}

enter image description here

new solution based on comment

As you mentioned, previous solution makes all boxes' font size small, but with fontupper option you can set font size for upper part of tcolorbox and with fontlower for the lower part.

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{lipsum}

\newtcolorbox{mybox}{fontupper=\footnotesize}

\begin{document}
\begin{tcolorbox}[fontupper=\tiny, fontlower=\Large]
This is the upper part. 
\tcblower
This is the lower part.
\end{tcolorbox}

This is normal size font. 

\begin{mybox}
\lipsum[2]
\end{mybox}

\end{document}

enter image description here

3
  • Thanks. But this will set for all the boxes, is there any way to do it for individual boxes? I may want smaller text only for some boxes.
    – Damitr
    Commented Jan 7, 2018 at 7:50
  • @Damitr See revision of the solution.
    – javadr
    Commented Jan 7, 2018 at 8:25
  • Ok works perfectly.
    – Damitr
    Commented Jan 7, 2018 at 11:18

You must log in to answer this question.

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