I'm having some problems getting my node locations correct using tikz-timing. I'd like the double-arrow line to be at the center of the pulse on both sides, instead of from bottom to top. Also, I'd like to place the label "tw" below the center of that double arrow line.
\documentclass{article}
\usepackage{tikz-timing}
\begin{document}
\begin{tikztimingtable}[timing/slope=.005, yscale=2]
Comparator Out & 2L 0.8H8.2L 0.8H 11.2L\\
One-Shot Out & 2L N(A1) 4H N(A2) 5L4H 8L\\
\extracode
%\horlines[] {0,1,5}
\tableheader[]{}{Case3: Two input pulses, far apart}
\draw [<->] (A1.center) -- (A2.south);
\node[] at (A1) {tw};
\end{tikztimingtable}
\end{document}
Best Answer
There are some predefined anchors for a row in a
tikztimingtable
, see figure 2.1 in thetikz-timing
manual. You can use one of themid
anchors ofrow2
combined with the(a |- b)
coordinate specification of TikZ, and thus draw the double arrow asThe coordinate
(A1|-row2.mid)
is the point at the intersection of a vertical line throughA1
and a horizontal line throughrow2.mid
, i.e. it has the x-coordinate of the former and the y-coordinate of the latter.Old answer
I'm not that familiar with
tikz-timing
, so there might be better ways of doing it, but here is one using thecalc
library to calculate the midpoints of the vertical lines of the pulse.To quickly explain what
($(A1|-A2)!0.5!(A1)$)
does.($ ... $)
with thecalc
library loaded means that what is between the dollar signs is a calculation of sorts, as described in the manual.(A1|-A2)
is a coordinate specification, and it defines the coordinate that has the x-coordinate ofA1
, and the y-coordinate ofA2
, so the top left corner of the pulse. Finally the syntax$(<first coord>)!<fraction>!(<second coord>)$
means that the result of the calculation is the coordinate that is<fraction>
the way from the first to the second coordinate.And to place a node below a line, place
node[below]{..}
right after a--
in a path, as shown in the example below.