Seite 1 von 1

TikZ - Blöcke an der linken Kante ausrichten

Verfasst: Do 7. Apr 2011, 19:53
von finsch
Hallo Leute,

ich habe ein Problem mit TikZ. Ich möchte ein Blockschaltbild erzeugen und dabei zwei Blöcke an der linken Seite vertikal ausrichten, wenn Sie unterschiedliche Breite besitzen.

Kann mir jemand sagen wie das geht?

Am Besten ohne eine matrix zu benutzen, weil ich noch deutlich mehr blöcke haben will.

Hier ein Beispiel:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{tikz} 
\usetikzlibrary{%
  positioning,% wg. " of " für Blockschaltbild
  shadows,% für Blockschaltbild
  circuits.ee.IEC,% für Stromlaufplan
  arrows,%
  shapes,% für Shapes (Namen an Knoten von Objekten
  shapes.geometric,% für Shapes (Namen an Knoten von Objekten
  shapes.misc,% wg. rounded rectangle
  calc,% für koordinaten berechnungen
  matrix,%
}

\begin{document}
  
	\begin{tikzpicture}[node distance=1.5cm]
    \tikzstyle {block} = [rectangle, minimum size = 1cm, very thick, draw=black, fill=gray!20, font=\ttfamily]
	  
    \node (1)  [block]                 {text};
    \node (2)  [block, below of = 1]   {längerer text};
    
	\end{tikzpicture}
\end{document}

Ich bin dankbar für jede Hilfe.

Gruß
Finn

Verfasst: Do 7. Apr 2011, 21:51
von esdd
Hallo,

hier sind zwei Vorschläge:
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document} 
  
\begin{tikzpicture}%
  \tikzset{block/.style= {minimum size = 1cm,draw,very thick,fill=gray!20,font=\ttfamily,%
           anchor=north west,yshift=-1.5cm}}
  \node[block](1){text}; 
  \node[block](2)at(1.south west){längerer text}; 
\end{tikzpicture}
%
\hspace{2cm}
%
\begin{tikzpicture}
  \tikzset{block/.style= {minimum size = 1cm,draw,very thick,fill=gray!20,font=\ttfamily,%
           inner sep=0.3333em,anchor=west}}
  \matrix(M)[matrix of nodes,inner sep=0pt,row sep=1.5cm,nodes={block}]{%
      text\\
      längerer text\\
    };
\end{tikzpicture}

\end{document}
Gruß
Elke