2

I am using pstricks to connect entries of 4x4-matrices with lines, more precisely, I use \ncline{}{}to connect two elements of a given matrix, that I initiated with \Rnode{}{}.

I iniated a 4x4-matrix with entries 1 to 16, I want to connect 1 and 6, as well as 1 and 11, but the line between 1 and 11 overlays the line between 1 and 6, such that only the line between 1 and 11 appears on the output.

\begin{pspicture}
\begin{pmatrix}
\Rnode{1}{1} & \Rnode{2}{2} & \Rnode{3}{3} & \Rnode{4}{4} \\ 
\Rnode{5}{5} & \Rnode{6}{6} & \Rnode{7}{7} & \Rnode{8}{8} \\ 
\Rnode{9}{9} & \Rnode{10}{10} & \Rnode{11}{11} & \Rnode{12}{12} \\ 
\Rnode{13}{13} & \Rnode{14}{14} & \Rnode{15}{15} & \Rnode{16}{16}
\end{pmatrix} 
\psset{linewidth=0.5pt, nodesep=0.5pt}
\ncline{1}{6} \ncline{1}{11}
\end{pspicture}

Picture of the matrix with the overlaying lines

How can I shift one of the lines, such that two lines are visible? How can I manage the case, if three lines are overlaying in this manner?

Thanks a lot!

1

Here you are: you have to use the offset = key. I would do it with 3 lines, personally:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, array}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

\begin{document}

\[ \begin{pspicture}
\begin{pmatrix}
\Rnode{1}{1} & \Rnode{2}{2} & \Rnode{3}{3} & \Rnode{4}{4} \\
\Rnode{5}{5} & \Rnode{6}{6} & \Rnode{7}{7} & \Rnode{8}{8} \\
\Rnode{9}{9} & \Rnode{10}{10} & \Rnode{11}{11} & \Rnode{12}{12} \\
\Rnode{13}{13} & \Rnode{14}{14} & \Rnode{15}{15} & \Rnode{16}{16}
\end{pmatrix}
\psset{linewidth=0.4pt}
\ncline{1}{6}\ncline{6}{11}
\psset{nodesep=0.5pt, offset = 2.5pt}
\ncline{6}{1}
\psset{nodesepA =-1.5pt}
\ncline{1}{6}
\psset{nodesepB =-1pt}
 \ncline{6}{11}\ncline{11}{16}
\end{pspicture} \]

\end{document} 

enter image description here

  • Thanks, but this way I coud still not draw three lines from 1 to 6,11 and 16 (at least I don't see how). Do you know a solution? – user153906 Feb 2 '18 at 17:45
  • I've updated my answer. Is it closer to what you want? – Bernard Feb 2 '18 at 18:06
  • Thanks again, but I interpret your updated picture now as one line connecting 1 and 6 plus a second line connecting 1 and 16. The third line, connecting 1 and 11 is missing. In the area between 1 and 6, there would have to be 3 parallel lines. – user153906 Feb 2 '18 at 23:02
  • I think I've finally understood. Please see the second update. – Bernard Feb 2 '18 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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