5

Is it possible to set a caption and label within a tikz timing table? Or do I have to do that somehow within a tikzpicture? Here the codefragment:


\begin{minipage}{0.5\textwidth}
\begin{tikztimingtable}[xscale=1.5,yscale=1.5,timing/.cd,
        metachar={w}{z [black]},
        metachar={W}{Z [black]},
        slope=0]
      T1 & LLHLHHLH \\
      T2 & LLHHLHLH \\
      Summe & WWDDDDWD \\
      Daten & LLHHHHLH \ \extracode
   \begin{pgfonlayer}{background}
       \foreach [count=\x] \b in {0,0,1,0,1,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\x-.5,0) {\b};
       }
       \foreach [count=\y] \b in {0,0,1,1,0,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\y-.5,-2) {\b};
       }
       \foreach [count=\z] \b in {0,0,1,1,1,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\z-.5,-6) {\b};
       }
   \end{pgfonlayer}
\end{tikztimingtable}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tikztimingtable}[xscale=1.5,yscale=1.5,timing/.cd,
        c/dual arrows,c/arrow tip=latex,
        c/arrow pos=.7,
        metachar={v}{[timing/c/no arrows]c[timing/c/dual arrows]},
        metachar={w}{z [black]},
        metachar={W}{Z [black]},
        slope=0]
      T1 & ccv CCC cv CC c \\
      T2 & ccv CcvCCCCc \\
      Summe & wdwDwDDdWDw \\
      Daten & ccv Ccv HH 0c0h0l 0c CCc \ \extracode
   \begin{pgfonlayer}{background}
       \foreach [count=\x] \b in {0,0,1,0,1,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\x-.5,0) {\b};
       }
       \foreach [count=\y] \b in {0,0,1,1,0,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\y-.5,-2) {\b};
       }
       \foreach [count=\z] \b in {0,0,1,?,?,1,0,1} {
            \node [below,font=\sffamily\bfseries\tiny,inner ysep=2pt] at (\z-.5,-6) {\b};
       }
   \end{pgfonlayer}
\end{tikztimingtable}
\end{minipage}

3
  • Should the caption be a figure, table or custom caption? Should the tikztimingtable float or be displayed right where it is? Commented May 22, 2011 at 17:09
  • 1
    BTW: If you want the Z character (and z) in black you can change its style, e.g. globally using \tikzset{timing/z/.style={black}} or for a single tikztimingtable using [timing/z/.style={black}] as optional argument. Commented May 22, 2011 at 17:12
  • 1
    Could you please accept the answer (clicking the tick symbol below the voting arrows) or state what is still missing if the answer is not sufficient. Commented May 3, 2012 at 18:53

1 Answer 1

6

If you want to typeset the caption outside a floating environment, you can use the \captionof command provided by the caption (or the capt-of) package; the first argument of the command can be figure or table (or any other floating user-defined object), and it is used to decide which name to put into the caption label. Here's a little example:

\documentclass{article}
\usepackage{tikz-timing}
\usepackage{caption}

\begin{document}

\begin{minipage}{0.5\textwidth}
  ... (timing table code)
  \captionof{figure}{Here goes the caption}
  \label{fig:timetible}
\end{minipage}

\end{document}

Another option, would be to enclose the timing table inside one of the predefined float objects figure or table and to use the standard \caption command (now, of course, the timing table will be treated as a floating object):

\documentclass{article}
\usepackage{tikz-timing}

\begin{document}

\begin{figure}[!ht]
  ...(timing table code)...
  \caption{A test timing diagram}
  \label{fig:timtable}
\end{figure}

\end{document}

A third possibility will be to define a new floating environment and caption type for the timing diagrams; this can be done with the help of a number of packages: float, floatrow, and caption. Here's an example using the \DeclareCaptionType command provided by the caption package (the example also illustrates the creation of a new "list of timing diagrams" similar to the list of figures and list of tables):

\documentclass{article}
\usepackage{tikz-timing}
\usepackage{caption}

\DeclareCaptionType{timingdiag}[Timing diagram][List of Timing Diagrams]

\begin{document}
\listoftimingdiags

\begin{timingdiag}[!ht]
  \centering
  ... (timing table code)...
  \caption{A test timing diagram}
  \label{fig:timetible}
\end{timingdiag}

\end{document}

EDIT: taking into account Martin's comment, I've added some other options to my answer; which one to use will depend on the intent.

6
  • @Gonzalo Medina: Alright, thank you! That's what I was searching for
    – Lex88
    Commented May 22, 2011 at 16:22
  • Might be a good idea to put something like this in manual. (I'm the author of tikz-timing). Commented May 22, 2011 at 17:13
  • @Martin Scharrer: yes, it would be a good idea. Commented May 22, 2011 at 17:23
  • Nice update, but I would name it 'Timing Diagram' instead. Commented May 22, 2011 at 20:23
  • @Martin Scharrer: done. Commented May 22, 2011 at 20:30

You must log in to answer this question.

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