# Arrow within a signal (timing diagram)

I want to draw a Manchester code and need arrows to better show the falling and rising flag within the signal, something like that:

In LaTeX, it is possible to use the package timing. Is it possible to draw an arrow within a timing diagram using the package timing? If not, how else is it possible?

-

## migrated from stackoverflow.comMay 22 '11 at 11:04

This question came from our site for professional and enthusiast programmers.

Hi, could you accept one of the answers now. I think simply forgot to do this. – Martin Scharrer May 3 '12 at 18:51

There is a tikz-based package for drawing timing diagram called tikz-timing. With it logic levels can be given as letters like H for high and L for low. For your case I recommend the clock character C together with the clockarrows library. I aware that you signal isn't a clock, but other signals don't have arrows in this package. The C letter changes its logic level every time it is used. In lowercase its length its only half the width. You signal can be written simply as cCCccCccCCc, beside some start position issue I just discovered.

\documentclass{article}

\usepackage{tikz-timing}
\usetikztiminglibrary{clockarrows}

\begin{document}

\begin{tikztimingtable}[scale=2,timing/.cd,
c/dual arrows,c/arrow tip=latex,
c/arrow pos=.7,
metachar={v}{[timing/c/no arrows]c[timing/c/dual arrows]},
slope=0]
\shortstack[l]{Manchester-Codierung:\\(bi-phase)}
&h 0c0h0l 0c CCcvCcvCCc \\
\extracode
\begin{pgfonlayer}{background}
\vertlines[help lines,brown]{}
\foreach [count=\x] \b in {1,0,1,1,0,0,1,0} {
\node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\x-.5,0) {\b};
}
\end{pgfonlayer}
\end{tikztimingtable}

\end{document}


-

You can do what you want using tikz. I drew a rough picture like the one in your example using the following code

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
%red vertical lines
\foreach \x in {0,1,...,8} {
\draw[color=red] (\x,0.5) -- +(0,3);  };

%black lines with arrows
\draw[very thick,->] (0,2.5) -- +(0.5,0) -- +(0.5,-0.5);
\draw[very thick,->] (0.5,2) -- +(0,-0.5) -- +(1,-0.5) -- +(1,0);
\draw[very thick,->] (1.5,2) -- +(0,0.5) -- +(1,0.5) -- +(1,0);
\draw[very thick,->] (2.5,2) -- +(0,-0.5) -- +(0.5,-0.5) -- +(0.5,0.5) -- +(1,0.5) --+(1,0);
\draw[very thick,->] (3.5,2) -- +(0,-0.5) -- +(1,-0.5) -- +(1,0);
\draw[very thick,->] (4.5,2) -- +(0,0.5) -- +(0.5,0.5) -- +(0.5,-0.5) -- +(1,-0.5) -- +(1,0);
\draw[very thick,->] (5.5,2) -- +(0,0.5) -- +(1,0.5) -- +(1,0);
\draw[very thick,->] (6.5,2) -- +(0,-0.5) -- +(1,-0.5) -- +(1,0);
\draw[very thick] (7.5,2) -- +(0,0.5) -- +(0.5,0.5);

%numbers
\path (0.5,1) node{1};
\path (1.5,1) node{0};
\path (2.5,1) node{1};
\path (3.5,1) node{1};
\path (4.5,1) node{0};
\path (5.5,1) node{0};
\path (6.5,1) node{1};
\path (7.5,1) node{0};
\end{tikzpicture}
\end{document}


Which produces

Of course, the code above is inefficient and can be improved, but this will give you an idea of how TiKz works so that if you can't find a solution with timing, this will do.

-