I want to add different positions within a company in a similar fashion to what LinkedIn uses, i.e. the vertical line connecting the dots of the bullet list. How can this be done?

Bulleted list with vertical line

Edit: now with a minimal working example after doing some research:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\linkedlist}[1]{
  \begin{tikzpicture}[remember picture]%
    \node (#1) [gray,circle,fill,inner sep=1.5pt]{};
  \end{tikzpicture}%
}
\begin{document}

\begin{itemize}
    \item[\linkedlist{a}] test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. 
    \item[\linkedlist{b}] test
    \item[\linkedlist{c}] test
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\draw[gray] ($(a)!0.1!(b)$) -- ($(a)!0.9!(b)$);
\draw[gray] ($(b)!0.2!(c)$) -- ($(b)!0.8!(c)$);
\end{tikzpicture}

\end{document}

The problem currently is that I need to add the lines manually in a second overlay picture and that I specify the "gap" between the dot and the start/end of the line using a percentage instead of a fixed value (e.g. 2pt). This causes the gaps to be of different size depending on the length of the paragraph.

  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – albert Oct 11 at 10:55
  • I've added an MWE. – Tom Oct 11 at 11:39
up vote 11 down vote accepted

Final solution (edit3)

Now, the code should work with page breaks in lists as well. Hope you like it :) If anything is unclear or you want some explanation about parts, just let me know!

\documentclass{article}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{refcount}

\newcounter{mylist} % new counter for amount of lists
\newcounter{mycnt}[mylist] % create new item counter
\newcounter{mytmp}[mylist] % tmp counter needed for checking before/after current item

\newcommand{\drawoptionsconn}{gray, shorten <= .5mm, shorten >= .5mm, thick}
\newcommand{\drawoptionsshort}{gray, shorten <= .5mm, shorten >= -1mm, thick}

\newcommand{\myitem}{% Modified `\item` to update counter and save nodes
  \stepcounter{mycnt}%
  \item[\linkedlist{%
    i\alph{mylist}\arabic{mycnt}}]%
  \label{item-\alph{mylist}\arabic{mycnt}}%
  \ifnum\value{mycnt}>1%
    \ifnum\getpagerefnumber{item-\alph{mylist}\arabic{mytmp}}<\getpagerefnumber{item-\alph{mylist}\arabic{mycnt}}%
      \begin{tikzpicture}[remember picture,overlay]%
        \expandafter\draw\expandafter[\drawoptionsshort] (i\alph{mylist}\arabic{mycnt}) --
          ++(0,3mm) --
          (i\alph{mylist}\arabic{mycnt} |- current page text area.north);% draw short line
      \end{tikzpicture}%
    \else%
      \begin{tikzpicture}[remember picture,overlay]%
        \expandafter\draw\expandafter[\drawoptionsconn] (i\alph{mylist}\arabic{mytmp}) -- (i\alph{mylist}\arabic{mycnt});% draw the connecting lines
      \end{tikzpicture}%
    \fi%
  \fi%
  \addtocounter{mytmp}{2}%
  \IfRefUndefinedExpandable{item-\alph{mylist}\arabic{mytmp}}{}{% defined
    \ifnum\getpagerefnumber{item-\alph{mylist}\arabic{mytmp}}>\getpagerefnumber{item-\alph{mylist}\arabic{mycnt}}%
      \begin{tikzpicture}[remember picture,overlay]%
      \expandafter\draw\expandafter[\drawoptionsshort] (i\alph{mylist}\arabic{mycnt}) --
        ++(0,-3mm) --
        (i\alph{mylist}\arabic{mycnt} |- current page text area.south);% draw short line
      \end{tikzpicture}%
    \fi%
  }%
  \addtocounter{mytmp}{-1}%
}

\newcommand{\linkedlist}[1]{
  \raisebox{0pt}[0pt][0pt]{\begin{tikzpicture}[remember picture]%
  \node (#1) [gray,circle,fill,inner sep=1.5pt]{};
  \end{tikzpicture}}%
}

\newenvironment{myitemize}{%
% Create new `myitemize` environment to keep track of the counters
  \stepcounter{mylist}% increment list counter
  \begin{itemize}
}{\end{itemize}%
  }

\begin{document}

\rule[-32\baselineskip]{2pt}{32\baselineskip}
\begin{myitemize}
  \myitem test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph.
  \myitem test
  \myitem test
\end{myitemize}

And a new list:
\begin{myitemize}
\myitem test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph.
\myitem test
\end{myitemize}

\end{document}

new MWE result


edit2: I managed to solve the problems @Tom mentioned by using \pgfmathsetmacro\result{int(\x-1)} and \result rather than \pgfmathparse{int(\x-1)} and \pgfmathresult. It looks like tikz uses \pgfmathparse for internal calculations that crashed the code. Using a name for it (\result), solves this issue. Also, I used the easier shorten syntax by @Ignasi.

TL;DR: Now thick works as it should, as well as the other options.

edit: Made the code work with many lists on many pages.

I used a list counter mylist and iterate over each node to plot the connecting line in the end of the newly created environment myitemize. This supports multiple lists on multiple pages.

Original solution: works as long as you have a single list. If you need multiple lists, page breaking, etc., you need to expand the code.

I used a new counter to name and save the nodes automatically and iterate over them in the end.

  • I want to replace the \draw command with the one provided by Ignasi but \draw[gray, shorten >=1mm, shorten <=1mm] (i\pgfmathresult) -- (i\x); gives me a dimension too large error. What am I doing wrong? – Tom Oct 11 at 13:31
  • Also, simple adding thick to the draw options results in an error: No shape named i0 is known. – Tom Oct 11 at 13:54
  • Hm, sorry @Tom - I don't know why, I'll investigate. – nox Oct 11 at 14:02
  • @Tom I fixed the issue =) – nox Oct 11 at 14:22
  • @marmot Have you read the edits? The new code works with as many pages and as many lists as you want, as long as there is no page break between two items in the same list. I currently have a solution that takes care of page breaks as well, but want to give it a final touch. I will post it soon. – nox Oct 11 at 15:53

You can use shorten option to fix a certain distance between node's border and end of line. There's no nees for calc:

\documentclass{article}
\usepackage{tikz}
%\usetikzlibrary{calc}

\newcommand{\linkedlist}[1]{
  \begin{tikzpicture}[remember picture]%
    \node (#1) [gray,circle,fill,inner sep=1.5pt]{};
  \end{tikzpicture}%
}
\begin{document}

\begin{itemize}
    \item[\linkedlist{a}] test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. 
    \item[\linkedlist{b}] test
    \item[\linkedlist{c}] test
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\draw[gray, shorten >=1mm, shorten <=1mm] (a)-- (b);
\draw[gray, shorten >=1mm, shorten <=1mm] (b)-- (c);
\end{tikzpicture}

\end{document}

enter image description here

Update

If itemize list is replaced by an enumerate list, it's possible to declare a new linkedlist environment which does all the work and uses regular \items.

It works with only for one level lists and it doesn't break between pages.

\documentclass{article}
\usepackage{tikz}

\newcommand{\linkeditem}[1]{
  \begin{tikzpicture}[remember picture]%
  \node (#1) [gray,circle,fill,inner sep=1.5pt]{};
  \end{tikzpicture}%
}

\newenvironment{linkedlist}{%
    \renewcommand{\theenumi}{\protect\linkeditem{\arabic{enumi}}}
    \renewcommand{\labelenumi}{\theenumi}
    \begin{enumerate}
}{ \end{enumerate} \begin{tikzpicture}[remember picture,overlay]
  \ifnum\value{enumi}>1% Only if there are at least 2 bullet points
  \foreach \x [remember=\x as \lastx (initially 1)] 
    in {2,...,\value{enumi}}{% iterate over them
    \draw[gray, shorten >=1mm, shorten <=1mm] (\lastx) -- (\x);}% and draw the connecting lines
  \fi
  \end{tikzpicture}
}

\begin{document}

\begin{linkedlist}
  \item test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph. test with a very long paragraph.
  \item test
  \item test
\end{linkedlist}

\end{document}
  • I once knew about this shorten command and was searching for it but could not find it. Thanks for the input! – Tom Oct 11 at 13:17
  • 1
    @Tom It appears in examples in pgfmanual but I could not find any comment about it. It seems it desappeared in some update. – Ignasi Oct 11 at 13:22
  • 1
    Indeed I used to read through the pgfmanual a long time ago and I was pretty sure I encountered it there, but could not find it very quickly when searching for it to create my MWE. – Tom Oct 11 at 13:32
  • @Tom I've updated my answer with a new linkedlist environment. – Ignasi Oct 12 at 7:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.