# Taylor's diagrams package : set color of individual elements

In Paul Taylor's diagrams package, is it possible to set the color of specific elements in a diagram? If so, how?

I have tried using \color{a_color}. It changes the color of part of the diagram, but I never succeed in coloring specific elements of the graph.

For instance, in the following diagram,

    \begin{diagram}
\bullet     &                       &   \bullet \\
\bullet     &                       &   \bullet
\end{diagram}


I would like to color only the diagonal link \rdlink in red. I have tried

\begin{diagram}
\bullet     &                                     &   \bullet \\
\bullet     &                                     & \bullet
\end{diagram}


but this leaves the graph uncolored. I have also tried

\begin{diagram}
\bullet     &                                     &   \bullet \\
\bullet     &                                     & \bullet
\end{diagram}


which yields

beside making all the following diagram red too. Other combination of \color{red} and \color{black} yields similar somewhat erratic outcomes.

It looks like using \color{a_color} sets the color of the whole line, as well as the color of the later lines (in further diagrams too).

Any idea how I could color a single element (say a link) of a single line?

• Have you considered one of the TikZ-based packages for drawing these kinds of diagrams? (Or PSTricks probably has packages, too.) – cfr Jun 27 '15 at 16:30
• I don't think the package supports color; since the code is obfuscated, it's impossible to try and make it honor color choices. – egreg Jun 27 '15 at 21:46
• Using a package with obfuscated code "maintained" by someone who expressly claims he has little to no time to devote to (La)TeX seems unwise.... – jon Jun 28 '15 at 4:44

I'd suggest you to switch to the powerful tikz-cd package which was built upon TikZ specifically for commutative diagrams. You can easily control the attributes for every element of yout diagrams:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}
\bullet\ar[d,dash]\ar[dr,red,dash] & \bullet \\
\bullet & \bullet
\end{tikzcd}

\end{document}


The result:

• Given the above comments on why I should try alternatives to "diagrams", I'll accept this answer. – Martin Van der Linden Jun 28 '15 at 6:56

The package file diagrams.sty, found on the webpage, does not define \*Link commands, therefore I have used \*Line instead (\dLine and \rdLine).

Analyzing the package is a very time consuming task, because the author obfuscated the internal macros.

But it seems that the approach of package luacolor works here. It does not insert specials, but sets the color via LuaTeX's attributes. Therefore the package requires LuaLaTeX:

\documentclass{article}
\usepackage{diagrams}
\usepackage{luacolor}

\begin{document}
\begin{diagram}
\bullet     &                       &   \bullet \\
\dLine      &  \color{red}\rdLine   &           \\
\bullet     &                       &   \bullet
\end{diagram}
\end{document}


For those who do not want to use tikz-cd, psmatrix from the pst-node package works fine.

An example :

\documentclass{article}
\usepackage{pst-node}
\usepackage{wasysym}

\begin{document}

$$\begin{psmatrix}[nodesep = 10pt, colsep=3cm, rowsep=3cm] % % % % \CIRCLE & \CIRCLE\\ \CIRCLE & \CIRCLE % % % % \psset{linecolor = red} \ncline{-}{1,1}{2,2} \psset{linecolor = black} \ncline{-}{1,1}{2,1} \end{psmatrix}$$

\end{document}


The result :