4

I have a commutative diagram written as a diagram environment defined using the package pb-diagram. I'm very satisfied with the appearance of the diagram.

However I need to change some arrows to dashed arrows.

In the pb-diagram manual it is stated that the option for the shaft of an arrow are:

 ..   |  dotted or dashed arrow shaft
 =    |  double line shaft* (“equals sign”)
 !    |  invisible arrow shaft

For instance the command \arrow{e,..} should draw a dotted or dashed arrow shaft.

My question is? How can I make sure that the arrow is dashed instead of dotted? In all examples I tried, the arrow becomes dotted.

I would appreciate any suggestions on how to solve this issue in pb-diagrams. A minimal example is the following.

\documentclass[12pt]{article}
\usepackage{pb-diagram}
\begin{document}
\begin{equation}
\begin{diagram}
\node{A} 
    \arrow{e,t,..}{a} 
    \arrow{s,l,..}{c} 
    \arrow{ese,b,1,..}{u}
\node{B}
    \arrow{e,t,..}{b}
\node{C}
    \arrow{s,r}{d} 
    \arrow{wsw,b,1}{v} \\
\node{D}
    \arrow[2]{e,b}{e} 
\node[2]{H}
\end{diagram}
\end{equation}
\end{document}

All dotted arrows should be dashed arrows.

OBS: I'm aware of the existence of a more advanced package called TikZ, which is more expressive and apparently allows one to have great control of the diagrams. But in this question I'm only interested in how to solve the problem with respect to the package pb-diagram, since the diagram, which is pretty large, is already coded and I just need to add some dashed arrows to finalize it. Additionally, I'm having some trouble to install TikZ on my computer.

7
  • 2
    Welcome to TeX.SX! Please show us a very minimal version of your document which is compilable. We do not want to set up the issue for you just in order to correct one arrow shaft. Thanks.
    – LaRiFaRi
    Aug 13, 2015 at 13:28
  • I tried to code this for you but I am not used to the picture environment which is used by this package. So I am sorry, but I am stuck here. Is your diagram really that big? Maybe it would be easier to post it here and I rewrite it in tikz-cd which can do this easily. If you want this in pb-diagram, please write a feature request to Paul Burchard
    – LaRiFaRi
    Aug 13, 2015 at 14:01
  • @LaRiFari thanks for your comments. I added a minimal example above. The diagram is compiling with dotted arrows, but they have to be dashed arrows.
    – verifying
    Aug 13, 2015 at 14:43
  • Contrary to what the manual says, I see no way to produce a dashed arrow with .., since it uses \circle.
    – egreg
    Aug 13, 2015 at 15:22
  • @egreg and verifying. No, it is not included for sure. I checked the whole code. Adding it was too complicated for me so as I said: I would go with a feature request. The author's address is written on top of his manual.
    – LaRiFaRi
    Aug 13, 2015 at 15:42

2 Answers 2

4

Here I found the routine in pb-diagram that placed dots, named \dg@dotvector and made several modifications to it. I replaced the \circle macro that placed each dot with a \rule. However, I needed to have the \rule tilted at the proper angle, so I used \FPdiv and \FParctan and \FPmul to calculate the angle tangent, take the arctangent, and convert to degrees. Then I used \rotatebox to angle the aforementioned \rule to that angle.

EDITED to take advantage of LaRiFaRi's excellent suggestion, thus allowing the simultaneous use of both dot .. and dash -- syntax. In the following MWE, I show both dot and dash lines (and solid lines) in the graph.

\documentclass[12pt]{article}
\usepackage{pb-diagram,fp,graphicx}
\begin{document}
\makeatletter
\@namedef{dgo@--}{\let\dg@VECTOR=\dg@dashvector}% 
\def\dg@dashvector(#1,#2)#3{% 
   \begingroup
   \dg@XTEMP=#1\relax \dg@YTEMP=#2\relax
   \let\dg@NDOTS=\dg@XEND \let\dg@DOTDIAM=\dg@WEND
   % Find number of dots: make x-spacing be DOTSPACING for arrows
   % of |slope| <= 1, and make y-spacing be DOTSPACING otherwise.
   % Thus, true spacing is never more than 30% off from DOTSPACING.
   \dg@NDOTS=\unitlength \multiply\dg@NDOTS #3\relax
   \dg@ZTEMP=\dg@YTEMP \dg@changesign\dg@YTEMP\dg@ZTEMP
   \ifnum\dg@XTEMP>\z@
      \ifnum\dg@YTEMP>\dg@XTEMP
         \multiply\dg@NDOTS\dg@YTEMP \divide\dg@NDOTS\dg@XTEMP \fi
   \else\ifnum\dg@XTEMP<\z@
      \ifnum\dg@YTEMP>-\dg@XTEMP
         \multiply\dg@NDOTS\dg@YTEMP \divide\dg@NDOTS-\dg@XTEMP \fi
   \fi\fi
   \dg@YTEMP=\dg@ZTEMP
   \divide\dg@NDOTS\dgDOTSPACING
   \ifnum\dg@NDOTS>\z@\else \dg@NDOTS=\@ne \fi
   % Compute increment vector between dots; round to \unitlength's.
   % Use NDOTS not DOTSPACING, since DOTSPACING not exactly obeyed.
   \dg@ZTEMP=\unitlength \multiply\dg@ZTEMP #3\relax
   \divide\dg@ZTEMP\dg@NDOTS
   \ifnum\dg@XTEMP=\z@
      \dg@changesign\dg@ZTEMP\dg@YTEMP \dg@YTEMP=\dg@ZTEMP
   \else
      \dg@changesign\dg@ZTEMP\dg@XTEMP
      \multiply\dg@YTEMP\dg@ZTEMP \divide\dg@YTEMP\dg@XTEMP
      \dg@XTEMP=\dg@ZTEMP
   \fi
   \divide\dg@XTEMP\unitlength \divide\dg@YTEMP\unitlength
   % Draw dotted line with \multiput
   % and arrowhead as zero-length \vector
%%% CALCULATE THE ROTATE ANGLE OF THE DASHED LINE
\ifnum\the\dg@XTEMP>0%
  \FPdiv\arang{\the\dg@YTEMP}{\the\dg@XTEMP}%
  \FParctan\arang{\arang}%
  \FPmul\arang{\arang}{57.295}%
\else
  \def\arang{90}%
\fi
%%%%%
   \begin{picture}(0,0)%
      \dg@DOTDIAM=\dgDOTSIZE \divide\dg@DOTDIAM\unitlength
      \multiput(0,0)(\dg@XTEMP,\dg@YTEMP){\dg@NDOTS}{%
%         \circle*{\dg@DOTDIAM}}% REPLACE THIS LINE WITH THE NEXT
         \smash{\rotatebox{\arang}{\rule{2pt}{.5pt}}}}%
      \multiply\dg@XTEMP\dg@NDOTS \multiply\dg@YTEMP\dg@NDOTS
      \put(\dg@XTEMP,\dg@YTEMP){\vector(#1,#2){0}}%
   \end{picture}%
   \endgroup}%
\makeatother
\begin{equation}
\begin{diagram}
\node{A} 
    \arrow{e,t,..}{a} 
    \arrow{s,l,--}{c} 
    \arrow{ese,b,1,--}{u}
\node{B}
    \arrow{e,t,--}{b}
\node{C}
    \arrow{s,r}{d} 
    \arrow{wsw,b,1}{v} \\
\node{D}
    \arrow[2]{e,b}{e} 
\node[2]{H}
\end{diagram}
\end{equation}
\end{document}

enter image description here

For comparison, here is the default behavior of the routine, without modification:

enter image description here

4
  • Amazing. This worked perfectly with my file both when compiling it into pdf and into ps files. In the dvi version the diagonals get a bit weird, but again it gets great when converting from dvi to pdf or ps. Many thanks!
    – verifying
    Aug 13, 2015 at 19:11
  • Also thanks to LariFari for the suggestion of using Tikz. But my version of Tikz is old and I'm getting trouble using it with tikz-cd. When I have more time I will reinstall my texlive distribution.
    – verifying
    Aug 13, 2015 at 19:13
  • 1
    May I recommend to start your code with \makeatletter \@namedef{dgo@--}{\let\dg@VECTOR=\dg@dashvector}% \def\dg@dashvector(#1,#2)#3{% giving the possibility to do \node{A} \arrow{e,t,--}{a} \arrow{s,l,..}{c} .
    – LaRiFaRi
    Aug 14, 2015 at 9:55
  • 1
    @LaRiFaRi Thank you for the really nice extension. Aug 17, 2015 at 2:34
3

Just in case you change your mind :-)

% arara: pdflatex

\documentclass[12pt]{article}
\usepackage{tikz-cd}

\begin{document}
\begin{equation}
    \begin{tikzcd}[every arrow/.append style={-latex}]
        A
        \arrow[dashed]{r}{a} 
        \arrow[dashed]{d}[swap]{c} 
        \arrow[dashed]{drr}[near start,swap]{u}
        & B
        \arrow[dashed]{r}{b}
        & C
        \arrow{d}{d} 
        \arrow{dll}[near start]{v} \\
        D \arrow{rr}[swap]{e} 
        & 
        & 
        H 
    \end{tikzcd}
\end{equation}
\end{document}

enter image description here

You must log in to answer this question.

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