2

I'm looking for a way to have text flow across multiple TikZ nodes. I'm currently splitting text manually across nodes (each of them containing a minipage into which I put the text). However, it would be much more convenient if the text could flow automatically from one node to the next.

The most promising package I've found after a bunch of searching is flowfram, but after reading through its documentation I can't really see how it can be used for this problem.

Is there any package that can help me out here? Or is manually splitting text the only way to go here?

Edit: Here is an (obviously failing) MWE.

The idea is that the text flows from the top red block into the bottom red block.

In my actual use case:

  • There can be any number of such blocks on arbitrary locations on the page.
  • The number of blocks (and their locations and sizes) can be different for each page in the document.
\documentclass{article}[a4paper]

\usepackage{lipsum}

\usepackage{tikz}
\usetikzlibrary{calc}

\newlength{\textAHeight}
\setlength{\textAHeight}{3cm}

\newlength{\textAMaxWidth}
\setlength{\textAMaxWidth}{6cm}

\newlength{\textBHeight}
\setlength{\textBHeight}{8cm}

\newlength{\textBMaxWidth}
\setlength{\textBMaxWidth}{10cm}

\newlength{\textCHeight}
\setlength{\textCHeight}{4cm}

\newlength{\textCMaxWidth}
\setlength{\textCMaxWidth}{4cm}

\begin{document}
  \pagestyle{empty}

  \begin{tikzpicture}[overlay, remember picture]
    \node [draw=red, at=($(current page.north west)!0.2!(current page.south east)$), anchor=north west] (textA) {%
      \begin{minipage}[t][\textAHeight][t]{\textAMaxWidth}
        \lipsum[1]
      \end{minipage}
    };%
  \end{tikzpicture}

  \begin{tikzpicture}[overlay, remember picture]
    \node [draw=red, at=($(current page.north west)!0.6!(current page.south east)$), anchor=north east] (textB) {%
      \begin{minipage}[t][\textBHeight][t]{\textBMaxWidth}
        \hfill
      \end{minipage}
    };%
  \end{tikzpicture}

  \begin{tikzpicture}[overlay, remember picture]
    \node [draw=green, at={($(current page.west) + (15cm, 0cm)$)}, anchor=west] (textC) {%
      \begin{minipage}[t][\textCHeight][t]{\textCMaxWidth}
        Totally unrelated text.
      \end{minipage}
    };%
  \end{tikzpicture}
\end{document}

This generates the following document:

Failing MWE

3
  • 1
    Although I provided a possible solution, the answers could be more useful if you show an scheme of what you want to do.
    – Ignasi
    Mar 21, 2022 at 9:35
  • You can also split \vbox style saveboxes using \vsplit, then insert the resulting savebaxes (\usebox) into tikzpicture nodes. Mar 21, 2022 at 14:22
  • @hpekristiansen Added an MWE and screenshot of the result.
    – AVH
    Mar 21, 2022 at 17:58

1 Answer 1

13

magazine library (tcolorbox) allow to break a box in several fragments and place each one where you want. Following code shows an example. In this case all boxes have equal size and TiKZ is used to place them although you can insert them in your text just with \useboxarray command.

tcolorbox also offers poster library where text can flow into several bloks of a poster. But the poster is a closed and unbreakable environment. With magazine every fragment is independent.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usetikzlibrary{positioning}

\begin{document}
\begin{tcolorbox}[enhanced, size=fbox, width=4cm,
colback=yellow!10, colframe=yellow!10!black,
breakable, break at=4cm, height fixed for =all,
reset box array,
store to box array]
\lipsum[1-2]
\end{tcolorbox}

\begin{tikzpicture}
\node[inner sep=0pt] (a) {\useboxarray{1}};
\node[inner sep=0pt, below left=1cm of a] (b) {\useboxarray{2}};
\node[inner sep=0pt, below right=1cm of a] (c) {\useboxarray{3}};
\node[inner sep=0pt, below left=1cm of c] (d) {\useboxarray{4}};

\draw[ultra thick, opacity=.5, ->, red] (a)--(b)--(c)--(d);
\end{tikzpicture}

\end{document}

enter image description here

2
  • This might do the trick! Is there any way to have this support boxes of different widths? I searched but couldn't find anything.
    – AVH
    Mar 21, 2022 at 18:19
  • @AVH I don't know nothing able to fight with different widths boxes. I know shapepar package but it defines a complete non breakable paragraph form.
    – Ignasi
    Mar 22, 2022 at 8:17

You must log in to answer this question.

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