3

This question in Drawing a diagram in LaTeX.

\documentclass[12pt,border=5pt]{standalone}
\usepackage{newcent,pstricks,amsmath,amssymb,pst-arrow} 
\usepackage{auto-pst-pdf}

\makeatletter
\newcommand\NCline[2]{\ncline{#1}{#2}\@ifnextchar\bgroup\NCline{}} %% :-))))
\makeatother
\begin{document}
\begin{pspicture}
\begin{psmatrix}[colsep=12mm,rowsep=10mm]
           & [name=A1] $000$ &     &  [name=A2] $111$  &      &   \\
        &     &  [name=A3] $111$ &     &    [name=A4] $110$  &   \\
     & [name=A5] $011$ &   &  [name=A6] $110$  &   & [name=A7] $100$ \\
[name=A8] $001$  &  &  [name=A9] $101$ &  &  [name=A10] $110$    &
\end{psmatrix}
\psset{nodesep=5pt , arrows=->, arrowsize=5pt, arrowlength=1}
\ncline{A1}{A3}{A3}{A2}{A2}{A4}     
\ncline{A5}{A3}{A3}{A6}{A6}{A4}{A4}{A7}     
\ncline{A8}{A5}{A5}{A9}{A9}{A6}{A6}{A10}{A10}{A7}
\end{pspicture}
\end{document}

The result of compiling:

enter image description here

Question:

I got an error. How to fix it? You can improve it if you have a shorter way.

  • please run first your examples by yourself! There is no package pstrick! – user2478 Dec 13 '18 at 15:09
  • @Herbert :((, I have just known I did not load \NCline. :((( If it is loaded, I would not have to ask one question ... – user173875 Dec 13 '18 at 15:12
  • @chishimotoji: running your examples gives first an error that package pstrick doesn't exists! – user2478 Dec 13 '18 at 15:20
  • @Herbert That is a typo ... :-)) – user173875 Dec 13 '18 at 15:21
  • It is no fun for the ones who want to help that they have first to fix your typos! Because you can see it by yourself if you run your example by yourself! – user2478 Dec 13 '18 at 15:24
2

\foreach \i/\j in {1/3,3/2,2/4,5/3,3/6,6/4,4/7,8/5,5/9,9/6,6/10,10/7}{\ncline{A\i}{A\j}} is more elegant, isn't ?

\documentclass[preview,12pt,border=5pt]{standalone}
\usepackage{pst-node}
\begin{document}
\begin{psmatrix}[colsep=12mm,rowsep=10mm]
    & [name=A1] $000$ &                             & [name=A2] $111$       &                               &   \\
  &                             & [name=A3] $111$ &                                     & [name=A4] $110$   &   \\
  & [name=A5] $011$ &                               & [name=A6] $110$       &                                   & [name=A7] $100$ \\
[name=A8] $001$         &                               & [name=A9] $101$       &                                   & [name=A10] $110$   
\end{psmatrix}
\psset{nodesep=5pt,arrows=->,arrowsize=5pt,arrowlength=1}
\foreach \i/\j  in {1/3,3/2,2/4,5/3,3/6,6/4,4/7,8/5,5/9,9/6,6/10,10/7}{\ncline{A\i}{A\j}}
\end{document}

enter image description here

| improve this answer | |
  • This is a short way. – user173875 Dec 13 '18 at 15:04
  • 1
    \foreach can remember values. \foreach \i [remember \i as \j (initially 1] in .... – user121799 Dec 13 '18 at 15:04
  • Why not? You draw e.g. 1->3->2->4 and so on. You have only 3 chains which you need to run through. – user121799 Dec 13 '18 at 15:59
1
\documentclass[12pt,border=5pt]{standalone}
\usepackage{pst-node} 
\usepackage{auto-pst-pdf}

\makeatletter
\let\NCline\ncline
\def\ncline#1#2{\NCline{#1}{#2}\@ifnextchar\bgroup{\ncline}{}}
\makeatother
\begin{document}
    \begin{pspicture}(5,5)
    \begin{psmatrix}[colsep=12mm,rowsep=10mm]
    & [name=A1] $000$ &     &  [name=A2] $111$  &      &   \\
    &     &  [name=A3] $111$ &     &    [name=A4] $110$  &   \\
    & [name=A5] $011$ &   &  [name=A6] $110$  &   & [name=A7] $100$ \\
    [name=A8] $001$  &  &  [name=A9] $101$ &  &  [name=A10] $110$    &
    \end{psmatrix}
    \psset{nodesep=5pt , arrows=->, arrowsize=5pt, arrowlength=1}
    \ncline{A1}{A3}{A3}{A2}{A2}{A4}     
    \ncline{A5}{A3}{A3}{A6}{A6}{A4}{A4}{A7}     
    \ncline{A8}{A5}{A5}{A9}{A9}{A6}{A6}{A10}{A10}{A7}
    \end{pspicture}
\end{document}
| improve this answer | |

Your Answer

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