1

Why does this code need the tcolorbox package to compile?

\documentclass[]{article}

\usepackage[most]{tcolorbox}

\def\Image{\includegraphics[scale=0.2]{example-image.jpg}}

\begin{document}

\foreach \i in {1,...,2}{
\Image
\newpage
}

\end{document}
1
  • 5
    well you need pgffor for the \foreach, and graphicx for the graphic. Side remark: don't use only \def, you don't know if you redefine an important command with it. Use \newcommand, either instead or before the \def. Sep 6, 2020 at 12:38

1 Answer 1

2

As Ulrike Fischer told, what you need is pgffor and graphicx packages. This is the minimal code.

\documentclass[]{article}

\usepackage{pgffor}
\usepackage{graphicx}

\def\Image{\includegraphics[scale=0.2]{example-image.jpg}}

\begin{document}

\foreach \i in {1,...,2}{
\Image
\newpage
}

\end{document}

But tcolorbox loads pgf package which loads graphicx and pgffor and allows to compile your code. If you want to work with tcolorbox your code is correct, but it will load too much code for your example.

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.