I have to draw some timing diagrams with annotations. The timing shall be annoated as shown in the example:

        \timing at(1,3) {3H 20U 4H 13U 6H};
        \timing at(1,2.5) {23D{2} 4X 19D{2} };
        \draw (1.75,4) -- +(0,-.6);         
        \draw (6.58,4) -- +(0,-.6); 
        \draw (7.58,4) -- +(0,-.6); 
        \draw (10.68,4) -- +(0,-.6);    
        \draw[<->] (1.75,3.8) -- (6.58,3.8);
        \draw[<->] (6.58,3.8) -- (7.58,3.8);
        \draw[<->] (7.58,3.8) -- (10.68,3.8);
        \node at (4.3,4) {Transmit};
        \node at (7.05,4) {Idle};
        \node at (9.0,4) {Receive};


Edit: The \timing line shows the signal at a wire. The signal level is 'High' at the beginning. There are two burts of high/low level signals containing the information. The actual information is not important. That's why it's shown here as 'X' don't care, but not stable 'High'.

The picture shall describe the phases of these bursts. The details are in the text that comes with the diagram.

This works but is cumbersome and error prone. The X positions (1.75, 6.58, 7.58, 10.68) are only detected visually. And the values must be entered repeated. If you need to change the timing to \timing at(1,3) {3H 10U 4H 13U 6H}; nearly everything has to be changed.

Further the complete construct is affected, if you want to use the TikZ picture with KOMA script. This inhibits to place the tikz-timing code in a reusable TeX include file.

  • How can the annotations be drawn more efficiently?
  • How can the position of the annotations be calculated from the timing diagram positions?
  • How can the TikZ drawing be made robust for use with or without KOMA script?
  • Hello, maybe I'm asking something obvious, but what is the graph supposed to represent? The reason I ask is that your objective might change the approach to give you an improved or alternative solution. So, what is the aim, how often you need to use it, is it going to appear as a figure in a document, etc.
    – Alenanno
    Oct 10, 2020 at 10:48
  • I extended the question.
    – harper
    Oct 10, 2020 at 11:04
  • @Alenanno Yes, this picture and some similar pictures showing a bit different timing is part of a LaTeX document. The upper line shows where the data can be seen. The second line shows a state that will be annotated in the text. I thought it is impossible to create a TikZ drawing outside a TeX or LaTeX document. Am I right?
    – harper
    Dec 30, 2020 at 17:53

2 Answers 2


So your question essentially boils down to: How can I get the coordinate of a certain transition in a timing diagram in order to draw annotations to it.

The tikz-timing package sets a few anchors to a timing diagram, but sadly too few for your needs. But you can define coordinates that are shifted from the .high start anchor which denotes the upper left corner of a timing diagram. You need to give the timing diagram you wish to refer to a name and then you can use this name in combination with the anchor.

The tikz-timing package sets the default unit to 1.6 ex. Using this default unit, you can easily calculate the distances between the transitiosn. For example, for the first coordinate that you would wish to place where the first transition from H to U takes place, you know that is is three units from the left (because you define 3H in the timing function). Thus, if you name the timing diagram with a, you can refer to this coordinate with ([xshift=3*1.6ex]a.high start).

Finally, you can use these coordinates to draw the lines, arrows and also place the labels on the arrows (which I would suggest you to do instead of using nodes that are placed using explicit coordinates).

Now, if you change the timing diagram, you still need to change the coordinates, but you once you changed them, all the other things are changed automatically at least.

This should work regardless of whether you use a KOMA class or another document class.


        \timing[name=a] at(1,3) {3H 20U 4H 13U 6H};
        \timing at(1,2.5) {23D{2} 4X 19D{2} };
        \coordinate (a1) at ([yshift=5pt, xshift=3*1.6ex]a.high start);
        \coordinate (a2) at ([yshift=5pt, xshift=23*1.6ex]a.high start);
        \coordinate (a3) at ([yshift=5pt, xshift=27*1.6ex]a.high start);
        \coordinate (a4) at ([yshift=5pt, xshift=40*1.6ex]a.high start);
        \draw (a1) -- +(0,.6);         
        \draw (a2) -- +(0,.6);         
        \draw (a3) -- +(0,.6);         
        \draw (a4) -- +(0,.6);         

        \draw[<->] ([yshift=10pt]a1) -- ([yshift=10pt]a2) node[midway, above] {Transmit};
        \draw[<->] ([yshift=10pt]a2) -- ([yshift=10pt]a3) node[midway, above] {Idle};
        \draw[<->] ([yshift=10pt]a3) -- ([yshift=10pt]a4) node[midway, above] {Receive};

enter image description here


I have found a partial solution. This allows to avoid repeating the numbers. Additionally the location of the texts are calculated.

    \timing at(1,3) {3H 20U 4H 13U 6H}; 
    \timing at(1,2.5) {23D{2} 4X 19D{2} };
    % change the X values only at these lines
    % calculate the mid values between pairs
    \pgfmathdivide{\a+\b}{2}        \let\mab\pgfmathresult
    \pgfmathdivide{\b+\c}{2}        \let\mbc\pgfmathresult
    \pgfmathdivide{\c+\d}{2}        \let\mcd\pgfmathresult
    % now don't use any magic number anmyore.
    \draw (\a,4) -- +(0,-.6);           
    \draw (\b,4) -- +(0,-.6);   
    \draw (\c,4) -- +(0,-.6);   
    \draw (\d,4) -- +(0,-.6);   
    \draw[<->] (\a,3.8) -- (\b,3.8);
    \draw[<->] (\b,3.8) -- (\c,3.8);
    \draw[<->] (\c,3.8) -- (\d,3.8);
    \node at (\mab,4) {Transmit};
    \node at (\mbc,4) {Idle};
    \node at (\mcd,4) {Receive};

This approach is only partial because the actual X position of the level changes are still entered manually. But at least the X position is entered at a single location.

The problem with the KOMA script environment is still open.

You must log in to answer this question.

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