答案1
这取决于您希望解决方案的复杂程度和灵活性。
如果您只有两位二进制数(00、01、10、11),您可以使用chains
库进行自动连续放置和一些有用的样式。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[
2-bin helper/.code 2 args={#1 #2},
2-bin 00/.style={fill=cyan!50!green!50},
2-bin 10/.style={fill=green!50!yellow},
2-bin 01/.style={fill=red},
2-bin 11/.style={fill=black, text=white},
start chain=going right,
node distance=.1em, inner xsep=.1em, % A is the widest character:
every on chain/.append style={text width=width("A"), align=center}]
\sffamily
\node[every on chain] at (-5mm,0) {A B};
\foreach \binary in {10,01,10,01,10,01,10,01,00,00,00,00,00,00,00,11}
\node[on chain, 2-bin \binary] {\tikzset{2-bin helper/.expand once=\binary}};
\end{tikzpicture}
\end{document}