[Tex/LaTex] Styling tikz-timing signal lines

tikz-pgftikz-stylestikz-timing

I'm using the tikz-timing package and would like to apply either snakes type of styling, or say the double for double lines to signal lines. Consider the example below:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows,chains,matrix,positioning,scopes,snakes,decorations.markings}
\usepackage{tikz-timing}
\usetikztiminglibrary[rising arrows]{clockarrows} 
\usetikztiminglibrary{advnodes}

\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\newlength{\imagewidth}
\newlength{\imagescale}

\begin{document}

\begin{tikztimingtable}[timing/nodes/advanced,]
  %
  % start timing diagram
  %
  \textcolor{green}{ClockA} & [green] H N(ca01) 
    C N(ca02) C N(ca03) C N(ca04) C N(ca05) C N(ca06) C N(ca07) C N(ca08) \\ %
  \textcolor{orange}{ClockB} & [orange,snake=zigzag,double] L N(cb01) 
    C N(cb02) C N(cb03) C N(cb04) C N(cb05) C N(cb06) C N(cb07) C N(cb08)  \\ %
  %
  % end timing diagram
  %
  % there must NOT be an uncommented line before \extracode!
  %
\extracode
  \tablerules
  %\tablegrid
  \begin{background}[line width=0.35pt]
    \draw[snake=zigzag,double] (ca01) -- (cb01) ; 
  \end{background}
\end{tikztimingtable}

\end{document}

which results in the following timing diagram:

Sample image

Obviously, the snakes and double work for normal lines, but not for signals.

Is there a possibility to also 'style' the signal diagram lines in this way?

Best Answer

The support for the line decorations is very limited in tikz-timing. The reason is that the timing symbols are not drawn as one drawing path but using multiple ones. Therefore the previous style settings are getting lost most of the time a new timing character is used. The L and H characters are different here and are actually drawn in one path.

The first style options at the very beginning are global for the whole line, but unfortunately TikZ seems to require to put many of the decoration styles as local option to the actual \draw command. Therefore your code doesn't work as expected. A few styles, like the line width is explicitly copied from one drawing path to the next by tikz-timing but this doesn't help you with decorations.

You can however add certain styles to the style definitions of the timing characters. These are called /tikz/timing/<char> and can be modified like shown below. Note that there is not styles for H and L characters at the moment. I might change this in the future and maybe also add one style which is used by every character. This should simply things like that.

\documentclass{standalone}
\renewcommand{\PreviewBorder}{2mm}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{tikz-timing}
\tikzset{timing/c/.append style={snake=zigzag}}
\tikzset{timing/t/.append style={double}}
\tikzset{timing/d/.append style={snake=zigzag}}
\begin{document}
\begin{tikztimingtable}
    A &  5{hl} 5{C} 2D{A} \\
    B &  5{hl} 5{T} 2D{B} \\
\end{tikztimingtable}
\end{document}

Result


I now made some minor changes to tikz-timing to provide a timing/every char style which is used for every timing character. A second one timing/every bg is used for every background (like for U). The H and L character now also have an own style. However they do not start a new drawing path so HL combinations will be drawn with the last used style.

I have to test this further before I can publish it on CTAN. Feel free to download it from the SVN repository. Simply download the DTX and INS file and then run the INS file through latex in order to extract the package files. Do not hesitate to contact me by PM if you find any issue with this version.

The new styles can be used like that and should work with decorations:

\documentclass{standalone}
\renewcommand{\PreviewBorder}{2mm}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{tikz-timing}
\tikzset{timing/every char/.append style={double}}
\begin{document}
\begin{tikztimingtable}
    A &  5{hl} 5{C} 2D{A} Z \\
    B &[timing/every char/.style={snake=zigzag}]  5{hl} 5{T} 2D{B} Z \\
\end{tikztimingtable}
\end{document}

New Result