tikz-timing:除 D 以外的符号中的文本标签以及时间轴不连续性

tikz-timing:除 D 以外的符号中的文本标签以及时间轴不连续性

这是两个(或多个)问题合二为一的问题 - 无论如何相关;所以我会尝试在一篇文章中涵盖所有内容。我心中有一个特定的时序图布局,我快完成了:

图像由 sigdisc_tikz 提供。

该示例的完整代码如下。简而言之,这就是我想要实现的目标:

  1. 我希望能够在LH逻辑字符/符号内显示多行(两行)文本标签:第一行是信号的值(0 或 1) - 第二行是某种索引标签(可以是简单的数字‘ 1’,也可以是字母数字‘ a1’ - 作为参数传递,例如h{a1}
  2. 我希望能够显示时间轴上的不连续性;示例显示了以下变体:
    1. 根据D性格(用低和高平行线;大写字母名称BV或者基于Z字符(中间的线;小写字母名称bv
    2. 使用省略号(...,即\cdots;Bb或者使用“弯曲的小部件”(此处$\iint$)作为分隔符(Vv元字符宏)
      • (有点)题外话:我相信省略是时间图中表示“不连续性”的适当字符/符号,因为它也表示“遗漏”;这与“曲线小部件”是我从(高中)时代(上个世纪)就拥有的东西。有人知道这种“弯曲小部件”符号的名称吗?它在图形/图表意义上表示不连续/跳过/遗漏? 我使用了双重积分符号,$\iint$只是因为我找不到更合适的符号;我只需要两个平行的“ S”形状,但我不喜欢谱号类似于“点衬线”(在排版中如何称呼它们?)积分符号有;我能找到的最接近的是Unicode 符号 U+2240' ' 为了花环产品- 但是,我需要将“花环”符号旋转 180 度,以便其方向正确(向右)

 

...以下是问题概述:

  1. 只能D接受“内部”的文本字符/标签 - 但这并不是真正的问题,因为在元字符宏中,我可以先D用细虚线绘制一个(这也对我的视觉有帮助 - 所以图片中的虚线是故意的)和文本标签,然后“重新启动”宏绘图,并绘制一个LH符号......但是,然后:
    1. D无法接受段落内容(带换行符) - 所以我不得不用 TeX 原语(\raise/\lower \hbox\kern)来“作弊”以模拟两行;结果里面的这些文本行是不是居中对齐
  2. 我必须应用相同的 TeX 基元(\raise/\lower \hbox\kern)方法,才能将“时间不连续性”符号与D- 派生逻辑符号(BV)的低线和高线对齐;由于对齐是“手动”完成的,因此这些符号同样是不是正确居中对齐(相对于逻辑符号的整个宽度)
    1. 我无法在视觉上“中断”线条D(如果我尝试在代码中“中断”,我会得到一个 D 转换,这是我不想要的) - 所以我必须使用\colorbox{white}{...}来指定白色背景;但是,这个背景“溢出”了网格,这也是我不希望的 - 我只想要一个与线条高度相同的白色“中断”
      • 我还希望信号线能够准确接触“曲线小部件”符号
    2. 对于Z派生符号 - 我无法在其中“写入”文本标签,因此我必须指定一个“命名节点”(N(b)N(v));然后在部分中绘制一个与这些“命名节点”对齐的 TikZ 文本节点\extracode- 但是,我不想要这个,因为我不想手动跟踪“命名节点”引用,这取决于我想在任意数量的给定信号中显示多少个时间不连续性
      • 在这种情况下,省略号也没有正确居中
      • TikZ 节点的白色背景不如本例那么宽\colorbox,但我仍然想让它的高度与信号线的 strokewidth 一样高
      • 另外,我希望信号线接触“曲线小部件”符号

 

所以,基本上,这些就是我遇到的问题。我知道这些问题可能没有一个简单的答案 - 但是,问题是我(有点)“破解”了我的方法来获取此图像;所以,我希望也许有一种更合适的方法来处理上述问题 - 我可能错过了......

非常感谢您的任何回答,
干杯!

 

代码:

% sigdisc_tikz.tex
% pdflatex sigdisc_tikz.tex                                   # to obtain sigdisc_tikz.pdf
% convert -density 300x sigdisc_tikz.pdf sigdisc_tikz.png   # to obtain sigdisc_tikz.png

% \documentclass[border=0]{standalone} % incorrectly crops image - use minimal + preview
\documentclass{minimal}

% minimal doesn't have \scriptsize, \tiny:
% see also http://wiki.lyx.org/FAQ/ChangeFontUsingLatex ;
% copied from IEEEtran.cls (for 12 pt doc)
\makeatletter
\def\ttiny{\@setfontsize{\ttiny}{4}{5pt}}
%
\def\tiny{\@setfontsize{\tiny}{6}{7pt}}
\def\scriptsize{\@setfontsize{\scriptsize}{8}{9pt}}
\def\footnotesize{\@setfontsize{\footnotesize}{9}{10.5pt}}
\def\small{\@setfontsize{\small}{10}{12pt}}
%
\def\normalsize{\@setfontsize{\normalsize}{12}{13.92pt}}%
%
\def\large{\@setfontsize{\large}{14}{17pt}}
\def\Large{\@setfontsize{\Large}{17}{20pt}}
\def\LARGE{\@setfontsize{\LARGE}{20}{24pt}}
\def\huge{\@setfontsize{\huge}{22}{26pt}}
\def\Huge{\@setfontsize{\Huge}{24}{28pt}}

% \let\tthtext\tikztiming@handletext % ! Undefined control sequence.
% \def\tthtext{\tikztiming@handletext} % ! Improper alphabetic constant.
\makeatother



\usepackage{tikz}
% \usetikzlibrary{arrows,chains,matrix,positioning,scopes,snakes,decorations.markings} % Package tikz Warning: Snakes have been superseded by decorations.
\usetikzlibrary{arrows,chains,matrix,positioning,scopes,decorations}
\usepackage{tikz-timing}
\usetikztiminglibrary[rising arrows]{clockarrows}
\usetikztiminglibrary{advnodes}
\usetikztiminglibrary{overlays}

\usetikztiminglibrary{nicetabs} % a bit strange with \Huge; use belowrulesep to adjust
% \typeout{\the\abovetopsep} % no - belowrulesep
% \typeout{\the\belowrulesep} % yes
%% \belowrulesep=10pt % ok; but not anymore? Not with ex (1ex)?!
%% \setlength{\belowrulesep}{10ex} % ok, but not with ex/em anymore?
% use current font size in \f@size (note, it's in pt, but "without the unit"); works only for normalsize
% for others, use a new def (let):
\let\mainsize\Large
\makeatletter
{\mainsize\global\let\myfontsize\f@size}
\makeatother
\newlength{\myfontsizelen}
\setlength{\myfontsizelen}{\myfontsize pt}

\setlength{\belowrulesep}{0.4\myfontsizelen} % ok, but not with ex/em anymore?

\usepackage{amsmath}
\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\newlength{\imagewidth}
\newlength{\imagescale}

\usepackage{type1cm} % to avoid "LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <2> not available"; tlmgr install type1cm
\usepackage{helvet}

\begin{document}

% have a D with bleak color to allow text;
% then restart, and in overlay, draw a H
% \tikztimingmetachar{h}{H; O{$1$}} % nothing happens
% \tikztimingmetachar{h}{ [gray] D{1}; [black] O{H} } % all is gray
% \tikztimingmetachar{h}{ [[timing/.style={dotted,gray}]] D{1}; [black] O{H} } % all is black
% \tikztimingmetachar{h}{ [timing/.style={dotted,gray}] D{1}; [black] O{H} } % all is black
% \tikztimingmetachar{h}{ ; [dotted,gray] D{1}; [black] O{H} ; } % late?
% NOTE: `before` - O{background} - foreground - `after`
% \tikztimingmetachar{h}{ ; O{ [dotted,gray] D{1} } [solid,black] H ; } % ok
% \tikztimingmetachar{h}{ O{ [dotted,gray] D{1} } [solid,black] H  } % not ok
% \tikztimingmetachar{h}{ O{ [dotted,gray] D{1} } [solid,black] H ; } % not ok
% \tikztimingmtachar{h}{ ; O{ [dotted,gray] D{1} } [solid,black] H } % ok
% \tikztimingmetachar{h}{ ; O{ [dotted,black!10] D{1} } [solid,black] H } % ok
% \tikztimingmetachar{h}{ ; O{ [dotted,black!10,line width=1pt] D{[black]1} } [solid,black] H } % line width don't reset; default def: line width=0.15ex
% \tikztimingmetachar{h}{ ; O{ [dotted,black!10,line width=1pt] D{[black]1} } ; H } % line width, solid, black restored with the `;` before `H`

% these were OK:
% \tikztimingmetachar{h}{ ; O{ [dotted,black!40,line width=0.07ex,timing/dslope=0] D{[black]$1$} } ; H }
% \tikztimingmetachar{l}{ ; O{ [dotted,black!40,line width=0.07ex,timing/dslope=0] D{[black]$0$} } ; L }


% \linebreak inside D char has no effect;
% cannot have parbox, minipage inside D char: "Runaway argument? Paragraph ended before \tikztiming@metachar was complete."
% \parbox, \node next to D: "! Improper alphabetic constant."
% \vspace inside D passes, but no effect
% \lower1.1em\hbox{\kern-0.5em{b}} works (tex approach, as in \LaTeX logo)
% '\hbox to' does not really work there; \parbox neither ("! A <box> was supposed to be here.")
% note: #1 is always width of metacharacter
% also used: A, W, E, Q, I

% comments (code must be otherwise in one line!):
% \tikztimingmetachar{h}[2]{
%   ; % RESTART
%   O{                % start overlay
%   [dotted,black!40,line width=0.07ex,timing/dslope=0] % overlay options
%     D{                    % start D; `inside` text:
%       [black]             % option for D `inside` text
%       \parbox{2em}{       % start parbox, 2em width
%         \centering        % make stuff inside parbox centered (refers to first line)
%         $1$               % write out the value (text character) "1" in math mode
%         \lower1.1em\hbox{ % now \lower, and start a hbox
%           \kern-1.0em{    % pull the lowered content left a bit (so its almost centered with first line
%             (#2)          % write out string "(arg)"
%           }             % close \kern
%         }
%       }
%     }                 % close (insides of) D
%   }                 % close overlay
%   ; % RESTART
%   H % draw H logic character
% }

\tikztimingmetachar{h}[2]{ ; O{ [dotted,black!40,line width=0.07ex,timing/dslope=0] D{ [black] \parbox{2em}{\centering$\mathbf1$\lower1.1em\hbox{\kern-1.0em{(#2)}}}} } ; H }

\tikztimingmetachar{l}[2]{ ; O{ [dotted,black!40,line width=0.07ex,timing/dslope=0] D{ [black] \parbox{2em}{\centering$\mathbf0$\lower1.1em\hbox{\kern-1.0em{(#2)}}}} } ; L }

% "The new ‘$’ modifier can be used to calculate the width of the group characters:"
% use phantom to give an 'anchor' to \lower
% \raisebox: "! Improper alphabetic constant."
% debug with fbox:
% \tikztimingmetachar{B}[1]{ [black!40] $#1$D{\phantom{X}{\raise1.8em\hbox{\kern-1em\fbox{$\cdots$}}}{\lower1.8em\hbox{\kern-3.5em\fbox{$\cdots$}}} }  }
% with white background - colorbox
% first semicolon prevents "leak" of B's gray to the previous (say, h or l) character
% note - [red] is placed there, to show there's no effect on the color of the dots (in other position, it is simply rendered as text)
% B - based on D (...)
\tikztimingmetachar{B}[1]{ ; [black!40]$#1$D{ [red] \phantom{X}{\raise1.8em\hbox{\kern-1.3em\colorbox{white}{$\cdots$}}}{\lower1.8em\hbox{\kern-3.4em\colorbox{white}{$\cdots$}}} } }

% b - based on Z (...)
% for Z, color spec needs to be *after* the characters, to change stroke color!
% N(b) named node is to add a \node with the \cdots afterwards
\tikztimingmetachar{b}[1]{ ; $#1/2$Z[black!40] N(b) $#1/2$Z[black!40] }

% V - based on D (≀≀ / ∬ )
\tikztimingmetachar{V}[1]{ ; [black!40]$#1$D{ [red] \phantom{X}{\raise1.8em\hbox{\kern-1.3em\colorbox{white}{$\iint$}}}{\lower1.8em\hbox{\kern-3.4em\colorbox{white}{$\iint$}}} } }

% v - based on Z (≀≀ / ∬ )
\tikztimingmetachar{v}[1]{ ; $#1/2$Z[black!40] N(v) $#1/2$Z[black!40] }





%% --------------------------------

\mainsize % this one to make timing symbols (as default font) big!

\begin{tikztimingtable}[%
    timing/nodes/advanced,
    timing/dslope=0.1,
    timing/name/.style={font=\sffamily\scriptsize},
    timing/d/text/.style={font=\sffamily\ttiny},
  ]
  %
  % start timing diagram
  %
  \textcolor{black}{Sig1} & [black]
    Z H l{a1} l{2} h{3} 3B h{$N_{a}$} Z \\ %
  \textcolor{black}{Sig2} & [black]
    Z H h{1}  h{2} l{3} 3b l{$N_{b}$} Z \\ %
  \textcolor{black}{Sig3} & [black]
    Z H l{a1} l{2} h{3} 3V h{$N_{a}$} Z \\ %
  \textcolor{black}{Sig4} & [black]
    Z H h{1}  h{2} l{3} 3v l{$N_{b}$} Z \\ %
  %
  % end timing diagram
  %
  % there must NOT be an uncommented line before \extracode!
  %
\extracode
  % foreground:
  \tablerules
  \tablegrid
  \node[%
    rectangle,inner sep=0pt,align=center,draw=none,fill=white%
  ] at (b) {%x
    \normalsize $\cdots$%
  };
  \node[%
    rectangle,inner sep=0pt,align=center,draw=none,fill=white%
  ] at (v) {%x
    \tiny $\iint$%
  };
  % background:
  \begin{pgfonlayer}{background}
  \end{pgfonlayer}
\end{tikztimingtable}

\end{document}

答案1

D只需使用即可在内部使用堆叠材料\shortstack{$\mathbf0$\\a1}。无需为此使用 TeX 低级原语。

此外,如果与 一起使用,节点字符N也会带有内容,{ }并且还可以使用 选项[ ],即N[<options>]{<content>},因此您可以直接将文本放入时序图中,而无需extracode。默认情况下,节点使用形状设置coordinate,您需要使用rectangle选项来允许可见内容。

我个人使用虚线或虚线(类似于;[dashed] <chars>;)来绘制不连续之处。

顺便说一句,允许其他角色使用文本内容也在我的长期待办事项清单上。


这里有一种方法,您可以使用虚线和直接节点内容来实现这样的图表。我正在手动移动节点位置以获得正确的垂直位置。

\documentclass[convert=png]{standalone}

\usepackage{tikz-timing}
\usetikztiminglibrary{nicetabs} % a bit strange with \Huge; use belowrulesep to adjust

\usepackage{amsmath}
\usepackage{type1cm} % to avoid "LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <2> not available"; tlmgr install type1cm
\usepackage{helvet}

\begin{document}
\begin{tikztimingtable}[%
    timing/dslope=0.1,
    timing/name/.style={font=\sffamily\scriptsize},
    timing/d/text/.style={font=\sffamily\tiny},
    grayz/.style={timing/z/.append style={gray}},
    timing/n/.style={rectangle},
    timing/metachar={{K}[2]{#1l !{++(0,+.5\yunit)} N[rectangle,scale=.3]{\shortstack{$\mathbf 0$\\(#2)}} !{++(0,-.5\yunit)} #1l}},
    timing/metachar={{J}[2]{#1h !{++(0,-.5\yunit)} N[rectangle,scale=.3]{\shortstack{$\mathbf 1$\\(#2)}} !{++(0,+.5\yunit)} #1h}},
  ]
  Sig1 & Z H K{a1} K{2} J{3} ;[gray] D;[dotted,gray] D;[gray] D; J{$N_a$} Z \\
  Sig2 & Z H J{1} J{1} K{3} ;[grayz] Z;[dotted,grayz] Z;[grayz] Z; K{$N_b$} Z \\
\extracode
  % foreground:
  \tablerules
  \tablegrid[black!25]
\end{tikztimingtable}
\end{document}

结果

相关内容