I would like to connect different LaTeX-table cells with dotted,
dashed lines according this example:
https://home.zhaw.ch/~grenasil/documents/PAX_Ansprueche.jpg
Could anyone give me a hint? Thanks a lot.
Best regards,
Tom
seems doable using tikz
> https://home.zhaw.ch/~grenasil/documents/PAX_Ansprueche.jpg
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, nodes in empty cells, row
sep={1cm,between origins}]
{ColumnA & ColumnB & ColumnC & ColumnD & ColumnF \\
RowA &&&&\\
RowB &&&&\\
RowC &&&&\\
RowD &&&&\\
};
\draw[thick,dotted] (A-2-2.center) -- (A-4-3.center) -- (A-3-4.center)
-- (A-3-5.center);
\draw[thick] (A-3-2.center) -- (A-2-3.center) -- (A-2-4.center) --
(A-4-5.center);
\end{tikzpicture}
\end{document}
etc.
Alan
Hi Alan
Thanks a lot for your help. That's a perfect template.
On the first view, I didn't find out, how to draw the vertical and
horizontal line between the colomns and rows.
Could you help me? Thanks a lot anyway.
Best regards
Tom
After I sent this, I realized that drawing the table lines would be
difficult. So here's a different approach, using a regular table, and
then overlaying the lines with \tikz commands. (You'll need to typeset
twice to get the lines positioned correctly.) -Alan
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{array}
% create a new column type with some extra height in each cell
\newcolumntype{C}{@{}>{\centering\arraybackslash}p{2cm}<{\rule[-1.5ex]{0p
t}{5ex}}@{}}
% create a command to place a tikz node (supply unique node name as the
argument)
\newcommand*{\tknode}[1]{\tikz[remember picture]\node (#1) {};}
\begin{document}
\begin{tabular}{|C|C|C|C|C|C|}
\hline
& ColumnA & ColumnB & ColumnC & ColumnD & ColumnF \\
\hline
RowA &\tknode{A} &\tknode{F}&\tknode{G}&&\\
\hline
RowB &\tknode{E}&&\tknode{C}&&\tknode{D}\\
\hline
RowC &&\tknode{B}&&&\\
\hline
RowD &&&&\tknode{H}&\\
\hline
\end{tabular}
% now connect up the nodes
\tikz[remember picture, overlay] \draw[thick,dotted] (A.center) --
(B.center) -- (C.center) -- (D.center);
\tikz[remember picture, overlay] \draw[thick] (E.center) -- (F.center)
-- (G.center) -- (H.center);
\end{document}
Hi Alan
Wow, this solution is exactly that I looked for. As I copied the code
here, the linebrake followed first to 31 erros, but now I recognised
this was the line break.
Anyway thanks a lot for your great help! By the way, would you draw
the legend below the table also with an TikZ overlay?
Best regards
Tom
You don't need to do an overlay for this, just put the tikz code in the
table like this: (assuming my example above, put this after the last
\hline)
\multicolumn{2}{C}{\tikz\draw[thick] (0,0) -- (1,0) node[pos=2.75,text
width=3cm] {Legend is here it will wrap};}&
\multicolumn{2}{C}{\tikz\draw[thick,dotted] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {Second legend};}&
\multicolumn{2}{C}{\tikz\draw[thick,dashed] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {Third legend};}
Alan
Wow, now can continue working with this example!
Thank you very much for your excellent help!
I've done the table so far, but now I have following problems:
-Text in the first line has an unequal space between the first and
second \hilne and not sufficient space between the vertical lines
-The numbers are not centered between the lines
-In the legend there is a strange line brake: "dringende
Geschäftsreise" works but the others not, althought I used the spacing
\-
Can you help me again? Thank you very much!
Best regards
Tom
Here is the code:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{array}
% create a new column type with some extra height in each cell
\newcolumntype{C}{@{}>{\centering\arraybackslash}m{1.5cm}<{\rule[-2ex]
{0pt}{0ex}\hspace{1cm}}@{}}%
\newcolumntype{S}{@{}>{\centering\arraybackslash}m{1cm}<{\rule[-2ex]
{0pt}{0ex}}@{}}
% create a command to place a tikz node (supply unique node name as
the argument)
\newcommand*{\tknode}[1]{\tikz[remember picture]\node (#1) {};}
\begin{document}
%\setlength{\extrarowheight}{2.5pt}
%\setlength{\tabcolsep}{5pt}
\begin{tabular}{|CC|C|C|C|C|C|C|C|}
\hline
\multicolumn{2}{|S|}{Kunden\-einschätzung} & Sitz\-ver\-füg\-bar\-
keit & Hohe Frequenz & Um\-buch\-ungs\-mög\-lich\-keit & Zwischen\-
stops & Service und Komfort & Schneller Check-In/Check-Out & günstiger
Preis \\
\hline
sehr wichtig & 5 & \tknode{Do1} & & \tknode{Do2} & \tknode{T4} &
\tknode{Do4} & \tknode{Do5} & \tknode{Dl5}\\
\hline
\hfill & 4 & & \tknode{T2} & \tknode{T3} & & \tknode{T5} &
\tknode{T6} & \tknode{Da6}\\
\hline
\hfill & 3 & \tknode{T1} \tknode{Da1} & & \tknode{Da2} & \tknode{Do3}
& \tknode{Da4} & &\\
\hline
\hfill & 2 & & \tknode{Dl2} & & \tknode{Da3} & & \tknode{Da5} &
\tknode{T7} \\
\hline
nicht wichtig & 1 & \tknode{Dl1} & & \tknode{Dl3} & & & \tknode{Dl4}
& \tknode{Do6}\\
\hline
\multicolumn{2}{C}{\tikz\draw[thick,dotted] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {dringende Geschäfts\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick] (0,0) -- (1,0) node[pos=2.75,text
width=3cm] {Geschäfts\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick,dashed] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {Wochen\-end\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick,dash pattern=on 10pt off 5pt]
(0,0) -- (1,0) node[pos=2.75,text width=3cm] {Ur\-laubs\-reise};}
\end{tabular}
% now connect up the nodes
\tikz[remember picture, overlay] \draw[thick,dotted] (Do1.center) --
(Do2.center) -- (Do3.center) -- (Do4.center) -- (Do5.center) --
(Do6.center);
\tikz[remember picture, overlay] \draw[thick] (T1.center) --
(T2.center)-- (T3.center) -- (T4.center) -- (T5.center) -- (T6.center)
-- (T7.center);
\tikz[remember picture, overlay] \draw[thick,dashed] (Da1.center) --
(Da2.center)-- (Da3.center) -- (Da4.center) -- (Da5.center) --
(Da6.center);
\tikz[remember picture, overlay] \draw[thick,dash pattern=on 10pt off
5pt] (Dl1.center) -- (Dl2.center)-- (Dl3.center) -- (Dl4.center) --
(Dl5.center);
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{array}
% create a new column type with some extra height in each cell
\newcolumntype{C}{@{}>{\centering\arraybackslash}m{1.5cm}<{\rule[-2ex]
{0pt}{0ex}\hspace{1cm}}@{}}%
\newcolumntype{S}{@{}>{\centering\arraybackslash}m{1cm}<{\rule[-2ex]
{0pt}{0ex}}@{}}
% create a command to place a tikz node (supply unique node name as
the argument)
\newcommand*{\tknode}[1]{\tikz[remember picture]\node (#1) {};}
\begin{document}
%\setlength{\extrarowheight}{2.5pt}
%\setlength{\tabcolsep}{5pt}
\begin{tabular}{|CC|C|C|C|C|C|C|C|}
\hline
\multicolumn{2}{|S|}{Kunden\-einschätzung} & Sitz\-ver\-füg\-bar\-
keit & Hohe Frequenz & Um\-buch\-ungs\-mög\-lich\-keit & Zwischen\-
stops & Service und Komfort & Schneller Check-In/Check-Out & günstiger
Preis \\
\hline
sehr wichtig & 5 & \tknode{Do1} & & \tknode{Do2} & \tknode{T4} &
\tknode{Do4} & \tknode{Do5} & \tknode{Dl5}\\
\hline
\hfill & 4 & & \tknode{T2} & \tknode{T3} & & \tknode{T5} &
\tknode{T6} & \tknode{Da6}\\
\hline
\hfill & 3 & \tknode{T1} \tknode{Da1} & & \tknode{Da2} & \tknode{Do3}
& \tknode{Da4} & &\\
\hline
\hfill & 2 & & \tknode{Dl2} & & \tknode{Da3} & & \tknode{Da5} &
\tknode{T7} \\
\hline
nicht wichtig & 1 & \tknode{Dl1} & & \tknode{Dl3} & & & \tknode{Dl4}
& \tknode{Do6}\\
\hline
\multicolumn{2}{C}{\tikz\draw[thick,dotted] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {dringende Geschäfts\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick] (0,0) -- (1,0) node[pos=2.75,text
width=3cm] {Geschäfts\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick,dashed] (0,0) -- (1,0)
node[pos=2.75,text width=3cm] {Wochen\-end\-reise};}&
\multicolumn{2}{C}{\tikz\draw[thick,dash pattern=on 10pt off 5pt]
(0,0) -- (1,0) node[pos=2.75,text width=3cm] {Ur\-laubs\-reise};}
\end{tabular}
% now connect up the nodes
\tikz[remember picture, overlay] \draw[thick,dotted] (Do1.center) --
(Do2.center) -- (Do3.center) -- (Do4.center) -- (Do5.center) --
(Do6.center);
\tikz[remember picture, overlay] \draw[thick] (T1.center) --
(T2.center)-- (T3.center) -- (T4.center) -- (T5.center) -- (T6.center)
-- (T7.center);
\tikz[remember picture, overlay] \draw[thick,dashed] (Da1.center) --
(Da2.center)-- (Da3.center) -- (Da4.center) -- (Da5.center) --
(Da6.center);
\tikz[remember picture, overlay] \draw[thick,dash pattern=on 10pt off
5pt] (Dl1.center) -- (Dl2.center)-- (Dl3.center) -- (Dl4.center) --
(Dl5.center);
\end{document}
Not necessarily; here's your example code with vertical and horizontal
lines:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (A) [%
matrix of nodes, nodes in empty cells,
row sep={1cm,between origins},
text width=2cm,text height=5mm
]
{ColumnA & ColumnB & ColumnC & ColumnD & ColumnF \\
RowA &&&&\\
RowB &&&&\\
RowC &&&&\\
RowD &&&&\\
RowE &&&&\\
};
\draw[thick,dotted] (A-2-2.center) -- (A-4-3.center) --
(A-3-4.center)
-- (A-3-5.center);
\draw[thick] (A-3-2.center) -- (A-2-3.center) -- (A-2-4.center) --
(A-4-5.center);
% horizontal lines of the table
\foreach \i in {1,2,3,4,5,6}
\draw[thin,black] (A-\i-1.north west) -- (A-\i-5.north east);
\draw[thin,black] (A-6-1.south west) -- (A-6-5.south east);
% vertical lines of the table
\foreach \j in {1,2,3,4,5}
\draw[thin,black] (A-1-\j.north west) -- (A-6-\j.south west);
\draw[thin,black] (A-1-5.north east) -- (A-6-5.south east);
\end{tikzpicture}
\end{document}