2

I'm trying to draw a list of items, not unline itemize, where the dots are all connected by a vertical line. In other words, what I'm aiming for is a kind of vertical timeline, but without dates. In fact, I have started by -stealing-, I mean, taking inspiration, from the TikZ answer in How can you create a vertical timeline?, but I have to major problems:

  1. list items go beyond page limit, while they should remain inside the page, like an actual itemize
  2. List items currently do not accept \par and \\, while I would need to support these

Here is what I have so far:

\documentclass{article}

\usepackage{environ,tikz} \usetikzlibrary{calc,matrix,backgrounds}

\makeatletter \let\matamp=& \catcode`&=13 \def&{% \iftikz@is@matrix% \pgfmatrixnextcell% \else% \matamp% \fi% } \makeatother

\newcounter{lines} \def\endlr{\stepcounter{lines}\}

\newcounter{vtml} \setcounter{vtml}{0}

\tikzset{ description/.style={column 2/.append style={#1}}, timeline color/.store in=\vtmlcolor, timeline color=red!80!black, timeline color st/.style={fill=orange,draw=green}, line offset/.store in=\lineoffset, line offset=4pt, }

\NewEnviron{vtimeline}[1][]{% \setcounter{lines}{1}% \stepcounter{vtml}% \begin{tikzpicture}[%column 1/.style={anchor=east}, column 1/.style={anchor=west}, text depth=0pt,text height=1ex, row sep=1ex, column sep=1em, #1 ] \matrix(vtimeline\thevtml)[matrix of nodes]{\BODY}; \pgfmathtruncatemacro\endmtx{\thelines-1}

\foreach \x in {1,...,\endmtx}{
  \node[circle,timeline color st, inner sep=0pt, minimum size=10pt, line width=.75mm]
  (vtimeline\thevtml-c-\x) at
  ($(vtimeline\thevtml-\x-1.west) + (-1ex, 0)$){};
}

\begin{scope}[on background layer]
  \draw[blue, line width=1mm] (vtimeline\thevtml-c-1.center) -- (vtimeline\thevtml-c-\endmtx.center);
\end{scope}

\end{tikzpicture} }

\begin{document}

\begin{vtimeline}%[row sep=4ex] This is a very long sentence, hopefully it will generate a new line, otherwise I will have to keep writing nonsense on and on and on and on\endlr Xerox Palo Alto Research Centre envisage the `Dynabook'\endlr Busicom 'Handy-LE' Calculator\endlr First mobile handset invented by Martin Cooper\endlr Parker Bros. Merlin Computer Toy\endlr Osborne 1 Portable Computer\endlr Grid Compass 1100 Clamshell Laptop\endlr TRS-80 Model 100 Portable PC\endlr Psion Organiser Handheld Computer\endlr Psion Series 3 Minicomputer\endlr \end{vtimeline}

\end{document}

my output

Do you have any suggestions on how to proceed? Thanks in advance!

P.S. I know that the colors I chose are ugly, in fact they are temporary and just for testing purposes. Moreover, I would really like to be able to make this work with TikZ because this is the first step of something a bit more complicated that I would not know how to do without TikZ.

Pier Paolo
  • 2,790
  • 1
    Sounds like you can use tikzmark to remember the positions of bullets and connect them after all texts are properly broken into lines and pages. – Symbol 1 Nov 21 '22 at 22:57

1 Answers1

3

enter image description here

I don't know if this idea might suffice. The problem is that the comma is a list separator; you cannot use it in an item as it is, but with curly brackets, i.e. {,} (see the example).

Note that the distance between the items is the same. You can control it through node distance values. Moreover, you can use \\ to break lines inside an item.

The code

\documentclass[11pt, margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math, arrows.meta}
\usetikzlibrary{positioning}
\begin{document}

\newcommand{\linedlist}[1]{\noindent% \begin{tikzpicture}[every node/.style={node distance = 6ex and 1.5ex}] \node[anchor=west] at (0, 0) (S-0) {}; \tikzmath{ integer \nbPoints; } \foreach \s [count=\i from 1, evaluate=\i as \j using {int(\i-1)}] in {#1}{% \node[below=of S-\j.south west, anchor=west, align=left] (S-\i) {\s}; \node[left=of S-\i, draw=red, circle, shade, ball color=red, outer sep=0, inner sep=.65ex] (N-\i) {}; \pgfextra{\xdef\nbPoints{\i}} } \foreach \i [parse=true, evaluate=\i as \j using {int(\i+1)}] in {1, ..., \nbPoints -1}{% \draw[thick] (N-\i) -- (N-\j); } \end{tikzpicture} }

\linedlist{ If you can't explain it to a six year old{,} you don't \ understand it yourself., The important thing is to not stop questioning., Look deep into nature{,} and then you will \ understand everything better., A happy man is too satisfied with the present \ to dwell too much on the future. } \end{document}

Daniel N
  • 5,687
  • 1
    Hi @Daniel N, this seems a very good answer! You showed me a smart way to use \foreach that I did not know and would have never thought of. As for the outcome, however, I will need to use commas in my text, and I need to have more control on the nodes, as they are central in what I'm trying to achieve – Pier Paolo Nov 22 '22 at 19:11
  • 1
    I modified the answer slightly. You can use commas, but they must appear as {,}, otherwise they represent separators in the loop list. As for the mode control on the nodes, you should be more specific. It's too vague. Anyway, in the code, the nodes have each a name. You can use them afterwards as you wish. But try to give an example of what you need. – Daniel N Nov 23 '22 at 07:40
  • 1
    A question: How do you intend to use the list, inside a tikzpicture environment or in paragraph mode? Accordingly, the definition of the list will be different... – Daniel N Nov 23 '22 at 09:49
  • Hi @Daniel N, I took so long to accept your answer because I had to find a workaround for parse=true that is not supported by my version of TikZ (and unfortunately I'm not able to update.) In any case, this solution does what I asked and leaves a lot of control on the item nodes, so it's good enough for me :) – Pier Paolo Nov 24 '22 at 18:05
  • 1
    Hi @Pier Paolo. I'm glad you will use it! parse=true is there for avoiding the computation \nbPoints -1. But it can be done inside a \tikzmath before the \foreach. – Daniel N Nov 24 '22 at 19:52