This code draws sequence of words, each word in a separate block.
I want to manipulate it as one block. For example, how can I get next picture? (I want to add $\rho$ in front of it).
\documentclass[border=3pt]{article}
\usepackage{tikz}
\usepackage{xstring,calc}
\usetikzlibrary{calc}
\newlength{\NodeSize}
\tikzset{DNA Style/.style={minimum size=0.5cm, draw=gray, line width=1pt, inner sep = 2pt}}{}
\newcounter{ColumnCounter}% Prefix for node labels
\newlength{\CurrentXPos}
\newcommand*{\PreviousNode}{}%
\newcommand*{\DNASequence}[2][Mark]{%
% https://tex.stackexchange.com/questions/12091/tikz-foreach-loop-with-macro-defined-list
\def\Sequence{#2}%
\def\PreviousNode{}%
\foreach [count=\xi] \Label/\Color in \Sequence {%
\IfStrEq{\Color}{}{\def\Color{white}}{}
\edef\NodeName{#1-\arabic{ColumnCounter}}
\IfStrEq{\PreviousNode}{}{%
\node [DNA Style, fill=\Color, anchor=west] (\NodeName) {\Label};
\xdef\PreviousNode{\NodeName}%
}{
\node [DNA Style, fill=\Color, anchor=west, xshift=-\pgflinewidth] at (\PreviousNode.east)(\NodeName) {\Label};
\xdef\PreviousNode{\NodeName}%
}
\stepcounter{ColumnCounter}
}
}%
label=left:{$\rho$:}
in the options of the first node, maybe withlabel distance=.5cm
or something like that. – Qrrbrbirlbel May 6 '13 at 8:43\IfStrEq
. The correct syntax would be\DNASequence[mysec]{C/cyan, B/red}
. But the\DNASequence
doesn’t reset theColumnCounter
, so you might end-up withmysec-10
instead of-0
if the previous\DNASequence
had 10 nodes. – Qrrbrbirlbel May 6 '13 at 9:03\IfStrEq
but it does not draw two nodes. – ashim May 6 '13 at 9:16