4

In my document I have several tikz pictures (in different sizes) with explanation next to the tikz picture. To put some text at the side of the picture I use a \parbox{}.

My document looks like this

enter image description here

There are two things I don't know how to fix

  • [see RED LINE:] I want some space between the picture and the text (let's say 1cm)
  • [see RED BOX:] I want that the text goes until the end of the line (the parbox should have a relative size, e.g. parboxwidth = \textwidth - picture width - space between picture and text)

MWE

\documentclass[parskip=full]{scrartcl}

\usepackage{blindtext}

\usepackage{tikz}

\begin{document}

\Blindtext[1]

\begin{tikzpicture}[scale=\linewidth/20cm,baseline=(current bounding box.north)]
  \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
  \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}
\parbox[t]{0.45\textwidth}{\vskip0pt
   Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
}

\Blindtext[1]

\begin{tikzpicture}[scale=\linewidth/30cm,baseline=(current bounding box.north)]
  \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
  \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}
\parbox[t]{0.45\textwidth}{\vskip0pt
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
}

\end{document}

1 Answer 1

5

You can try with a sidebyside box from tcolorbox. Option sidebyside adapt= ... defines which part fixes proportions between left and right parts and the other one takes the rest of the line.

\documentclass[parskip=full]{scrartcl}

\usepackage{blindtext}

\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}

\Blindtext[1]

\tcbsidebyside[sidebyside adapt=left, blanker, sidebyside gap=1cm, 
               sidebyside align=top seam]{%
\begin{tikzpicture}[scale=\linewidth/20cm, baseline=(current bounding box.north)]
  \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
  \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}{Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}

\Blindtext[1]

\tcbsidebyside[sidebyside adapt=left, blanker, sidebyside gap=1cm, 
               sidebyside align=top seam]{%
\begin{tikzpicture}[scale=\linewidth/30cm,baseline=(current bounding box.north)]
  \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
  \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}{
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
}

\end{document}

enter image description here

You must log in to answer this question.

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