2

i have this array. I need to write over each cell. For example, i have to write "S" and "E" over the array and not inside. Can anyone help me?

\begin{tikzpicture}[>=latex,font=\sffamily,every node/.style={minimum width=1cm,minimum height=1.5em,outer sep=0pt,draw=black,semithick}]
\node []at (0,0) (A) {};
\node [anchor=west] at (A.east) (B) {};
\node [anchor=west,fill=black!20] at (B.east) (C) {S};
\node [anchor=west,fill=black!20] at (C.east) (D) {};
\node [anchor=west] at (D.east) (E) {E};
\node [anchor=west] at (E.east) (F) {};
\node [anchor=west] at (F.east) (G) {};
\draw [->,shorten >=2pt,shorten <=2pt,semithick] (G.south) -- +(0,-1em) -| (A);
\end{tikzpicture}

enter image description here

  • Try with a label option: \node [anchor=west,fill=black!20, label=S] at (B.east) (C) {}; – Ignasi Dec 2 '15 at 10:05
2

Do you mean something like that?

\begin{tikzpicture}[>=latex,font=\sffamily,every node/.style={minimum width=1cm,minimum height=1.5em,outer sep=0pt,draw=black,semithick}]
\node []at (0,0) (A) {};
\node [anchor=west] at (A.east) (B) {};
\node [anchor=west,fill=black!20] at (B.east) (C) {S};
\node [anchor=west,fill=black!20] at (C.east) (D) {};
\node [anchor=west] at (D.east) (E) {E};

\node [draw=none,above] at (E.north) {Test};

\node [anchor=west] at (E.east) (F) {};
\node [anchor=west] at (F.east) (G) {};
\draw [->,shorten >=2pt,shorten <=2pt,semithick] (G.south) -- +(0,-1em) -| (A);
\end{tikzpicture}

enter image description here

  • Yes! Thank you! Can you explain me your line \node [draw=none,above] at (E.north) {Test}; ? – Simon Dec 2 '15 at 9:46
  • You already used almost everything that is necessary. I added nothing special, just one line. You want to write above the "E" node, therefore I used the above keyword which lets the base coordinate of the "Test" node be its "south" anchor. Therefore it appears above the "E" node's north anchor that I defined as absolute base coordinate for the "Test" node with (E.north). – Chris Dec 2 '15 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.