2

In the following MWE (Minimal Working Example), an Itemize is placed outside of a Tcolorbox, which compiles fine:

\documentclass{article}
\usepackage[breakable]{tcolorbox}

\makeatletter
\newcommand{\quoted}[1]{%
\setbox0=\hbox{#1}%
\setlength{\@tempdima}{\dimexpr\wd0+0pt}%
\setlength{\parindent}{50pt}%
\begin{tcolorbox}[breakable]%
#1%
\end{tcolorbox}%
}

\begin{document}
\begin{itemize}
\item Item1
\item Item2
\end{itemize}
\quoted{Here is some text inside a tcolorbox-environment, called for with the arbitrary name `quoted'.}
\end{document}

In the following MFE (Minimal Frustrating Example), an Itemize is placed inside of a Tcolorbox, which doesn't compile:

\documentclass{article}
\usepackage[breakable]{tcolorbox}

\makeatletter
\newcommand{\quoted}[1]{%
\setbox0=\hbox{#1}%
\setlength{\@tempdima}{\dimexpr\wd0+0pt}%
\setlength{\parindent}{50pt}%
\begin{tcolorbox}[breakable]%
#1%
\end{tcolorbox}%
}

\begin{document}
\quoted{Here is some text inside a tcolorbox-environment, called for with the arbitrary name `quoted'.
\begin{itemize}
\item Item1
\item Item2
\end{itemize}}
\end{document}

How to make an Itemize placed inside of a Tcolorbox please?

  • Your second example is meant to typeset #1 twice? – jon Apr 17 '16 at 2:34
  • Can you explain more about that question @jon? You have a lot of knowledge from which I could learn. – Vincent Mia Edie Verheyen Apr 17 '16 at 2:38
  • 1
    In the second example, you have \newcommand{\quoted}[1]. This means that where you have #1 in the remainder of the definition, it will be replaced by what you include as the mandatory argument of the command \quoted. So, because you have #1 twice, the command (as used here) \quoted{this is the replacement text} tells TeX that you want to use this is the replacement text twice: once in your \hbox and once inside your tcolorbox environment. – jon Apr 17 '16 at 2:50
3

I am not certain if your extra code is because you want to do something really clever or because you are making it harder than it needs to be. I'm lumping for the second possibility right now.

\documentclass{article}
\usepackage{tcolorbox,lipsum}

\newcommand\zzz[1]{%
\begin{tcolorbox}
#1
\end{tcolorbox}
}

\newcommand\xxx[1]{%
\begin{tcolorbox}
  \begin{itemize}
 #1
  \end{itemize}
\end{tcolorbox}
}

\begin{document}

\zzz{\lipsum[1]}

\zzz{\lipsum[1]
  \begin{itemize}
  \item Lorem ipsum
  \end{itemize}
}

\xxx{%
\item One
\item Two
}

\end{document}
0

I have an additional problem with this. I want to replace the numbering with a bracketed word, but this makes the entire item out of the colorbox (I skipped the preamble in MWE below, as it is the same as shown below):

\begin{tcolorbox}
\begin{itemize}
\item{[blabla]} blablabla
\item{[blublu]} blublublu
\end{itemize}
\end{tcolorbox}

Do you have any idea how to do this?

  • I understand that this is another question, related with this, but another one. Then it's better that you ask a new question with a link to this one (if you want). This way you'll have a larger audience and more chances that someone answers it. – Ignasi Jan 30 '17 at 19:31

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.