是否可以在 tikz 时间表中设置标题和标签?或者我必须以某种方式在 tikzpicture 中执行此操作?以下是代码片段:
\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}
答案1
如果要在浮动环境之外排版标题,可以使用(或) 包\captionof
提供的命令;该命令的第一个参数可以是或(或任何其他浮动用户定义对象),它用于决定将哪个名称放入标题标签中。这里有一个小例子:caption
capt-of
figure
table
\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}
另一个选择是将时间表包含在预定义浮动对象之一内figure
,或者table
使用标准\caption
命令(现在,当然,时间表将被视为浮动对象):
\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}
第三种可能性是为时序图定义一个新的浮动环境和标题类型;这可以借助一些包来完成:float
、floatrow
和。下面是使用包提供的命令的caption
示例(该示例还说明了如何创建一个新的“时序图列表”,类似于图列表和表格列表):\DeclareCaptionType
caption
\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}
编辑:考虑到马丁的评论,我在我的答案中添加了一些其他选项;使用哪一个取决于意图。