You can use stacked material inside D
by simply using \shortstack{$\mathbf0$\\a1}
. There is no need to use TeX lower-level primitives for that.
Also the node character N
also takes a content if used with { }
and also options using [ ]
, i.e. N[<options>]{<content>}
, so you can place text into the timing diagram directly, without extracode
. By default nodes are set using the coordinate
shape, you need to use the rectangle
option to allow for a visible content.
I personally use dotted or dashed lines (something like ;[dashed] <chars>;
) to draw discontinuities.
BTW, allowing text content for other characters as well is on my long-term TODO list.
Here a way you can implement such a diagram using dotted lines and direct node content. I'm moving the node position manually to get the correct vertical position.
\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}
![Result](https://i.stack.imgur.com/XGiZU.png)
I'm not sure if it's answering all your questions, but I think the following (although not perfect) shows some ways in which your code could be simplified. I think there will always be some manual adjustment involved though (e.g., setting appropriate inner sep
).
\documentclass[tikz,border=0.125cm]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\tikzset{%
set color/.style={
fill=#1,
draw=#1!50!black
},
every number/.style={
text=white,
rounded corners=0.125cm,
font=\fontfamily{pzc}\selectfont,
text width=3ex,
align=center,
scale=2
},
every prime number/.style={
shape=diamond,
set color=blue!70!black,
inner sep=0.25ex,
},
every even number/.style={
shape=circle,
set color=red!70!black,
inner sep=0.5ex
},
every odd number/.style={
shape=regular polygon,
regular polygon sides=3,
set color=green!70!black,
inner sep=-0.375ex
},
number 1/.style={
shape=star,
set color=green!50!blue,
inner sep=-.25ex
}
}%
\begin{tikzpicture}[x=2cm, y=2cm]
\foreach \n [evaluate={%
\x=mod(\n-1,10);
\y=floor((\n-1)/10);
\p=isprime(\n);
\e=mod(\n,2)==0;
\style=(\p || \n==2) ? "prime" : (\e ? "even" : "odd");}] in {1,...,100}
\node [every number/.try, every \style\space number/.try, number \n/.try]
at (\x,\y) {\n};
\end{tikzpicture}
\end{document}
![enter image description here](https://i.stack.imgur.com/ATWc3.png)
Best Answer
There's already code on the site for drawing ducks. Hence, only the turtle remains to be done. I hope turtles are sufficiently like tortoises for a tortoise to pass muster:
Adjust the colours to your taste.