2

Right now I am struggling with getting a box around some text with a figure. The idea is that I have a small picture on the lefthand-side with some text right next to it. And then draw a box around the whole thing.

I tried messing around with tikzpicture. But my tikz-solution needs the text to be only one line long otherwise I have to set manual line-breaks every time. Since this will be a recurring element I need to use, I would much rather have an elegant solution (if there is one).

How it looks without the box:

\begin{wrapfigure}{l}{0.05\textwidth}
    \centering
    \includegraphics[width=0.05\textwidth]{Icon}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
1
  • Should the text be able to flow around the image if the text is longer than the place needed by the picture?
    – Skillmon
    May 21 at 10:13

2 Answers 2

5

If I understood your question correctly, you are after the following:

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage[skins]{tcolorbox}
\tcbset{boxrule=1pt, colframe=red,
        colback=white,
        left=3pt, right=3pt, sidebyside gap=8pt,
        sidebyside, lefthand width=0.1\linewidth,
        lower separated=false
        }

\begin{document}
    \begin{tcolorbox}
\includegraphics[width=\linewidth]{goldshade}%
    \tcblower
\lipsum[66]
    \end{tcolorbox}
\end{document}

Or more likely to @Tom answer (+1). It can be (slightly) modified as follows:

\documentclass{article}
\usepackage{wrapfig}
\usepackage[skins]{tcolorbox}
\tcbset{boxrule=1pt, colframe=red,
        colback=white,
        left=3pt, right=3pt
        }
\usepackage{lipsum}

\begin{document}
    \begin{tcolorbox}
\begin{wrapfigure}[3]{l}{0.1\textwidth}
\vspace{-\baselineskip}
\includegraphics[width=\linewidth]{goldshade}%
\end{wrapfigure}
\lipsum[66]
    \end{tcolorbox}
\end{document}

enter image description here

2
  • This is perfect. Thanks alot! What really is the upside of the part you wrote after "It can be (slightly) modified"? I do not see a dfference in the result.
    – Tom Göbel
    May 25 at 10:08
  • @TomGöbel, I do not understand you. Differences in results are very obvious to me. Please clarify! BTW, you receive two answers on your question. It is time to select one of them, which on the best ways solve problem and accept it (by clicking on check mark at top left side of answer). SO far you not accept any of answer got on your questions. Are no one of them fulfil your expectations?
    – Zarko
    May 25 at 10:25
3

This may be what you want:

Enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{tcolorbox}

\begin{document}
\begin{tcolorbox}[standard jigsaw,opacityback=0,colframe=red]
\begin{wrapfigure}{l}{0.05\textwidth} 
    \centering
    \includegraphics[width=0.05\textwidth]{example-image}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{tcolorbox}

\end{document}

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.