TikZ - Blöcke an der linken Kante ausrichten

Tabellen und Grafiken erstellen und anordnen


finsch
Forum-Newbie
Forum-Newbie
Beiträge: 3
Registriert: Di 5. Apr 2011, 21:34

TikZ - Blöcke an der linken Kante ausrichten

Beitrag 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

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag 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

Antworten