4

Minimal example:

\documentclass{report}
\usepackage{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{tcolorbox}
\lipsum[1-2]
\end{tcolorbox}

\end{document}

I want the paragraphs in the tcolorbox to be formatted like body text. (I'm using tcolorboxes as subsections.)

2 Answers 2

5

This is a consequence of the fact that LaTeX clears the paragraph indentation in a minipage or \parbox. But it's possible to tell tcolorbox to reapply it.

\documentclass{report}
\usepackage{tcolorbox}
\usepackage{lipsum}

\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
\tcbset{before upper={\setlength{\parindent}{\normalparindent}}}

\begin{document}

\lipsum[1-2]

\begin{tcolorbox}
\lipsum[1-2]
\end{tcolorbox}

\end{document}

enter image description here

3

Store the current value of parindent and apply it in the tcolorbox.

randyrandersonTcolorboxParagraphs

\documentclass{report}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage{showframe}
\newlength{\saveparindent}
\begin{document}
\setlength{\saveparindent}{\parindent}
    \lipsum[1-2]

\begin{tcolorbox}
    \setlength{\parindent}{\saveparindent}
    \lipsum[1-2]
\end{tcolorbox}

\end{document}

To do this globally, you can missuse the setting for the font. But i rather suggest to make a feature request to the author.

\tcbset{fontupper={\setlength{\parindent}{\saveparindent}}}
3
  • How can you apply it simultaneously to all tcolorboxes in the document, i.e., using tcbset? Jun 14, 2015 at 8:56
  • @RandyRanderson Please see the update.
    – Johannes_B
    Jun 14, 2015 at 9:06
  • before upper seems to be the better hook to change.
    – Johannes_B
    Jun 14, 2015 at 9:08

You must log in to answer this question.

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