I have the following code for a table


{\def\arraystretch{1.5}\tabcolsep=10pt \large
\multirow{2}{*}{\scalebox{1.5}{$\square$ Modul 1}}& Exercise 1\\
&Exercise 2\\
\multirow{4}{*}{\scalebox{1.5}{$\square$ Modul 2}}& Exercise 3\\
&Exercise 4\\
&Exercise 5\\
&Exercise 6\\
\multirow{2}{*}{\scalebox{1.5}{$\square$ Modul 3}}& Exercise 7\\
&Exercise 8\\

The output: Table without lines

But I want to add some lines to let it look like this (I drew the lines by Gimp):

enter image description here

How can I achieve this?

  • 1
    You can use \tikzmarknode from the tikzmark TikZ library, then -| and |- drawing operations between the appropriate node anchors.
    – frougon
    Commented Jun 27, 2022 at 18:38

1 Answer 1


Here is a solution with {NiceTabular} of nicematrix. The lines are drawn with Tikz by using the PGF/Tikz nodes created by nicematrix under the cells, rows and columns of the array.



\Block[name=modul1]{2-1}{$\square$ Modul 1}
   && Exercise 1\\
   && Exercise 2\\
\Block[name=modul2]{4-1}{$\square$ Modul 2}
   && Exercise 3\\
   && Exercise 4\\
   && Exercise 5\\
   && Exercise 6\\
\Block[name=modul3]{2-1}{$\square$ Modul 3}
   && Exercise 7\\
   && Exercise 8\\
  \draw [dotted,thick] 
        (modul1.east) -- ++(3cm,0) |- (1-|last) 
        (modul1.east) -- ++(3cm,0) |- ([yshift=0.5mm]5-|last) ;
        (modul2.east) -- ++(1cm,0) |- (3-|last) 
        (modul2.east) -- ++(1cm,0) |- (7-|last) ;
  \draw [dashed]
        (modul3.east) -- ++(3cm,0) |- ([yshift=-0.5mm]5-|last) 
        (modul3.east) -- ++(3cm,0) |- (9-|last) ;


You need several compilations (because of the PGF/Tikz nodes).

Output of the above code

  • This looks like the very thing I searched for, but when I try to compile it (with PDFLatex) i get a nicematrix package error: "The key 'name' is unknown for the command \Block."
    – Falrach
    Commented Jun 28, 2022 at 12:11
  • You don't have the latest version of nicematrix. You should update your TeX installation. If you use Overleaf, please note that Overleaf has not the latest version of nicematrix. In that case, you should upload the latest version of the file nicematrix.sty in the repertory of your Overleaf project. You can find that file on the SVN server of TeXLive: www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty Commented Jun 28, 2022 at 12:26
  • Unfortunately, I have not the permission to install/update software. But I solved my problem now, by defining tikzmarknodes and used your code for the tikzpicture. The use of the nicematrix package becomes obsolete then.
    – Falrach
    Commented Jun 28, 2022 at 14:30

You must log in to answer this question.

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