0

In a document with indented text, I want text inside a tcolorbox to have the same indentation, including lack of indentation in the first paragraph.

I followed this post: https://tex.stackexchange.com/a/492402/91605

While it works in the simple case, if the first thing in the box is a list, then extra unwanted space is inserted. MWE follows.

\documentclass{article}
\usepackage[skins,breakable]{tcolorbox}
\usepackage{enumitem}
\setlist{noitemsep}

\tcbset{
  boxrule=1pt,
  left=.3em, right=.3em, top=.3em, bottom=.3em,
  beforeafter skip balanced=.5\baselineskip plus 2pt,
  before upper={\parindent5mm\noindent},
  rounded corners=all,
  colframe=gray,
  colback=white,
}

\begin{document}

\begin{tcolorbox}
Text in a box.

New paragraph.

\begin{itemize}
\item a
\item list
\end{itemize}
\end{tcolorbox}

\begin{tcolorbox}
    \begin{itemize}
        \item list
        \item in
        \item a
        \item box
    \end{itemize}
\end{tcolorbox}
\end{document}

Output:

enter image description here

Is there a fix for this?

1 Answer 1

1

Does this answer your question? I put [leftmargin=10pt] after the second \begin{itemize}, in this code:


\documentclass{article}
\usepackage[skins,breakable]{tcolorbox}
\usepackage{enumitem}
\setlist{noitemsep}

\tcbset{
  boxrule=1pt,
  left=.3em, right=.3em, top=.3em, bottom=.3em,
  beforeafter skip balanced=.5\baselineskip plus 2pt,
  before upper={\parindent5mm\noindent},
  rounded corners=all,
  colframe=gray,
  colback=white,
}

\begin{document}

\begin{tcolorbox}
Text in a box.

New paragraph.
\begin{itemize}
\item a
\item list
\end{itemize}
\end{tcolorbox}

\begin{tcolorbox}
    \begin{itemize}[leftmargin=10pt]
        \item list
        \item in
        \item a
        \item box
    \end{itemize}
\end{tcolorbox}
\end{document}

,which gave me the output: enter image description here

The “10pt” is the width of a single space bar in font size 10pt, which is the default latex font size (since you didn’t specify one in your preamble.) If you also want the extra space between the first item of the list and the top of the box to be gone, then you can add [topsep=0pt] which gives: enter image description here

You must log in to answer this question.

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