Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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

share|improve this answer
    
Fantastic, @Martin Scharrer - thank you for the explanation! The reason why I was asking for something like this, is that I have this (relatively) complicated diagram, where I'd like to indicate groups of signals; for my purposes, I color them differently and it works well. However, I get complaints when relying on color for publishing (grayscale is preffered) - but on this diagram I already used plenty of gray.. So I hoped that by using snake or double I could add another level of distinction/grouping. Thanks again - cheers! –  sdaau Feb 28 '11 at 15:30
    
Oh, and PS: forgot to say - thanks for a most awesome package ! :) :) (kinda going all too fast these days :) ) –  sdaau Feb 28 '11 at 16:18
    
@sdaau: Thanks for the nice feedback. I made some changes to the package. See my updated answer. I'm also very keen to see how people use this package, so I would be happy to get same source code of complicated diagrams. –  Martin Scharrer Feb 28 '11 at 16:55
    
thanks a lot for the update; it will be immensely useful for me! (however, as I'm still on texlive 2009, may take me a while 'til I get a look).. Just wanted to say - your latest example A (with double) is exactly what I had in mind :) For the snakes, looks like I prefer smaller segment amplitudes, as in \tikzset{timing/t/.append style={snake=zigzag,segment length=0.5mm,segment amplitude=0.25mm}} ... Well, when I get any luck to publish that paper, I'll make sure I post a link to the diagram source here! Thanks again - and cheers! :) –  sdaau Mar 1 '11 at 10:12
    
@sdaau: As I said you can install it manually. Simply download the above files to you document folder and run latex once over the INS file. I assumed you will select smaller amplitudes for the snakes, but didn't had time to look the required settings up for the example. –  Martin Scharrer Mar 1 '11 at 10:18
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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