PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tikz Problem (zeichnen von einem pfeil)



corsair
04-05-2009, 15:12
Hallo,

ich habe folgenden code:



\begin{figure}[h]
\begin{center}
\begin{tikzpicture}
\def\blockdist{1.1}
\def\edgedist{0.3}
\tikzstyle{byte}=[draw, fill=yellow!20, text centered]
\node (byte1) [byte] {byte};
\path (byte1)+(\blockdist,0) node (byte2) [byte] {byte};
\path (byte2)+(\blockdist,0) node (byte3) [byte] {byte};
\path (byte3)+(\blockdist,0) node (byte4) [byte] {byte};
\draw [->] (byte1.north)+(0,\edgedist) -- (byte1.north) {};
\draw [-] (byte1.north west)+(0,\edgedist) -- node [above] {1.}
(byte1.north)+(0,\edgedist);
\end{tikzpicture}
\end{center}
\end{figure}


Das Ergebnis seht ihr im Anhang. Wie ihr seht tut es nicht das, was ich will: ich will dass es eine wagerechte linie von überhalb "north west" zu überhalb von "north" gibt. und dann eine senkrechte von überhalb von north zu north. leider ist der erste strich schief. was mache ich falsch?

-corsair

corsair
04-05-2009, 18:23
so funktioniert es nun:



\begin{figure}[h]
\begin{center}
\begin{tikzpicture}
\def\blockdist{1.1}
\def\edgedist{0.3}
\tikzstyle{byte}=[draw, fill=yellow!20, text centered]
\node (byte1) [byte] {byte};
\path (byte1)+(\blockdist,0) node (byte2) [byte] {byte};
\path (byte2)+(\blockdist,0) node (byte3) [byte] {byte};
\path (byte3)+(\blockdist,0) node (byte4) [byte] {byte};
\draw [->] (byte1.north west)+(0,\edgedist) -| node [above] {1.}
(byte1.north);
\draw [->] (byte2.north west)+(0,\edgedist) -| node [above] {2.}
(byte2.north);
\draw [->] (byte3.north west)+(0,\edgedist) -| node [above] {3.}
(byte3.north);
\draw [->] (byte4.north west)+(0,\edgedist) -| node [above] {4.}
(byte4.north);
\draw [<-] (byte1.south east)+(0,-\edgedist) -| node [below] {4.}
(byte1.south);
\draw [<-] (byte2.south east)+(0,-\edgedist) -| node [below] {3.}
(byte2.south);
\draw [<-] (byte3.south east)+(0,-\edgedist) -| node [below] {2.}
(byte3.south);
\draw [<-] (byte4.south east)+(0,-\edgedist) -| node [below] {1.}
(byte4.south);
\end{tikzpicture}
\end{center}
\caption{Gluecode byte reordering}
\label{fig:byte_reordering}
\end{figure}

Stefan_K
04-05-2009, 18:34
Hallo corsair,

innerhalb von figure-Umgebungen würde ich \centering statt \begin{center} ... \end{center} verwenden, letzteres erzeugt zusätzlichen Abstand, siehe center vs. \centering (http://texblog.net/latex-archive/layout/center-centering/).

Beim eigentlichen Problem könntest Du die calc-library verwenden:

\usetikzlibrary{calc}
...
\draw [-] ($(byte1.north west)+(0,\edgedist)$) -- node [above] {1.}
($(byte1.north)+(0,\edgedist)$);

Viele Grüße,

Stefan

--
TeXblog.net (http://texblog.net)