0

I want to insert a figure as a item of tcbitemize enviroment in tcolorbox. The following code does work:

\newcommand{\ff}[2][]{%
  \tcbitem[#1]\includegraphics[width=1.0\textwidth]{#2}
}

usage example: \ff[colback=red]{myfigure.jpg}

But, the figure document name has to be enclosed in a pair of braces. Is there a better way to use \ff like this:

\ff[colback=red] myfigure.jpg

MWE below:

\documentclass{article}

\usepackage[most]{tcolorbox}

\begin{document}

\begin{tcbitemize}
  \tcbitem some text
  \ff[colback=red] myfigure.jpg % directly document name without braces
  \tcbitem some text
  \tcbitem some text  
\end{tcbitemize}

\end{document}
lyl
  • 2,727
  • arguments should be in braces in latex. Trying to avoid this will only lead to confusing code. Don't do it. – Ulrike Fischer Oct 27 '18 at 11:00
  • The argument of \tcbitem, or the content of \tecbitem need not braces. So I'd like to add figures as the argument of \tcbitem without braces. Is it possible? – lyl Oct 27 '18 at 12:16
  • \tcbitem does internally \end{tcolorbox}\begin{tcolorbox}, it doesn't grab the following text as argument. And yes it is possible. But don't do it. – Ulrike Fischer Oct 27 '18 at 12:48
  • Can you show me an example? – lyl Oct 27 '18 at 14:03
  • You could start with the code in the answers here https://tex.stackexchange.com/questions/150909/how-can-i-parse-the-first-word-in-a-token-stream-token-by-token. And no, I won't adapt the code for you. Imho your idea is not sensible. If you want to do it, you will have to figure it out without my help. – Ulrike Fischer Oct 27 '18 at 14:58

0 Answers0