Seite 1 von 1
Tabelle in Treppen- bzw. Dreiecksform
Verfasst: Mo 7. Apr 2014, 02:13
von TeHaiX
Hallo liebe Gemeinde,
ich habe bereits die Suchfunktion und Google genutzt, jedoch habe ich bis jetzt nichts Passendes gefunden. Ich würde gerne eine Tabelle erstellen, welche die Form eines Dreiecks bzw. eine Treppe besitzt. Ich hoffe ihr könnt mir helfen. Anbei ein Bild zum Verständnis.

Verfasst: Mo 7. Apr 2014, 02:33
von esdd
Du könntest die Tabelle als Matrix mit TikZ darstellen:
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}
\matrix(M)[
matrix of nodes,
row sep=-\pgflinewidth,column sep=-\pgflinewidth,
nodes={draw,text width=1cm,minimum height=2em}
]
{
{}\\
{}&{}\\
{}&{}&{}\\
{}&{}&{}&{}\\
};
\foreach[count=\j] \i in {2,...,5}\node[left=0pt of M-\j-1,font=\tiny]{\i};
\foreach[count=\j] \i in {1,...,4}\node[below=0pt of M-4-\j,font=\tiny]{\i};
\end{tikzpicture}
\end{document}
Gruß
Elke
Verfasst: Mo 7. Apr 2014, 08:50
von Felix
Noch ein Beispiel, was mit TikZ möglich ist - mehr als nur Dreiecksform -
Tabelle in Pfeilform.
Felix
Verfasst: Mo 7. Apr 2014, 18:49
von TeHaiX
Hi Leute,
die erste Variante war perfekt. Doch wenn ich das Dreieck umdrehen möchte, funktionieren die Abstände nicht mehr richtig. Es sieht bei mir jetzt wie folgt aus.
\begin{figure}[H]
\centering
\begin{tikzpicture}
\matrix(M)[matrix of nodes,row sep=-\pgflinewidth,column sep=-\pgflinewidth,
nodes={draw,minimum width=4em,minimum height=4em}]
{
$ A,B $ & $ A,B $ & $ B $ & $ B $ & $ B $ \\
$ A,S $ & $ S $ & - & - \\
$ A,S,C $ & $ C $ & - \\
$ S,C $ & - \\
$ C $ \\
};
\foreach[count=\j] \i in {$ a $,$ a $,$ b $, $ b $, $ b $}\node[above=0pt of M-1-\j]{\i};
\end{tikzpicture}
\caption{CYK-Algorithmus}
\end{figure}
Verfasst: Mo 7. Apr 2014, 21:36
von esdd
Die Verschiebungen kommen von den unterschiedlichen Unterlängen in den einzelnen Zellen. Das kann man beseitigen, in dem man bei den Optionen für die nodes noch font=\strut ergänzt. (
Was macht der Befehl \strut?)
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{center}
\begin{minipage}{\linewidth}
\centering
\begin{tikzpicture}
\matrix(M)[matrix of math nodes,row sep=-\pgflinewidth,column sep=-\pgflinewidth,
nodes={draw,minimum width=4em,minimum height=4em,font=\strut}]
{
A,B & A,B & B & B & B \\
A,S & S & - & - \\
A,S,C & C & - \\
S,C & - \\
C \\
};
\foreach[count=\j] \i in {a,a,b,b,b}\node[above=0pt of M-1-\j]{$\i$};
\end{tikzpicture}
\captionof{figure}{CYK-Algorithmus}
\end{minipage}
\end{center}
\end{document}
Gruß
Elke