0

I'm trying to make a space of a given width, e.g. 10cm, in a tikzpicture environment where i can input text either with style-1 or style-2. Style-1 is for example [text width=6cm, align=left] and style-2 is [text width=6cm, align=right]. As usually \node needs coordinates, i used 'chains', but I've not yet found how to set the width of the whole text block. I tried to nest a node with style-1 or style-2 within a \node at (0,0) [text width=10] but that doesn't work.

Here is an illustration done with a wysiwyg program.

enter image description here

here is my mwe:

\documentclass[a4paper]{article}

\usepackage{lipsum} \usepackage{tikz} \usetikzlibrary{positioning,chains} \setlength{\parindent}{0pt}

\begin{document} \begin{tikzpicture} [start chain=going below]{ \node [on chain, text width=6cm] {\lipsum[1][1]}; \ \node [on chain, text width=6cm] {\lipsum[1][2]}; \ \node [on chain, text width=6cm] {\lipsum[1][3]}; \ \node [on chain, text width=6cm] {\lipsum[1][4]}; \ }; \end{tikzpicture} \end{document}

EDIT: here's my own solution, but i'm still expecting a better one

\begin{document}
\begin{tikzpicture}
[start chain=going below, node distance=.2cm]
  \node [on chain, align=left, text width=6cm] {\lipsum[1][1]};
  \node [on chain, align=right, text width=6cm, xshift=4cm] {\lipsum[1][2]};
  \node [on chain, align=left, text width=6cm, xshift=-4cm] {\lipsum[1][3-8]};
  \node [on chain, align=right, text width=6cm, xshift=4cm] {\lipsum[1][9]};
\end{tikzpicture}
\end{document}
muzimuzhi Z
  • 26,474
  • 2
    You don't need tcolorbox for that. But you need to define two node styles, one for each chatter. And maybe using chain would be better thant a matrix of nodes. – SebGlav Feb 01 '22 at 15:18
  • 2
    There is also https://tex.stackexchange.com/questions/266713/resemble-popular-messenger-with-latex-macros – Marijn Feb 01 '22 at 16:53
  • 2
    But I was actually looking for https://tex.stackexchange.com/questions/405132/how-to-make-every-line-in-a-bubble-like-chat-conversations – Marijn Feb 01 '22 at 16:54
  • 2
    Or https://tex.stackexchange.com/questions/624775/chat-bubbles-with-picture-and-name-attached – Marijn Feb 01 '22 at 16:56

0 Answers0