Wie kann ich eine FILE Struktur in einer Tabelle darstellen/anzeigen. Anbei ein Code (Netzfund) den ich teilweise adaptiert habe. Dieser Code zeigt eine File Tree Struktur. Jetzt zu meiner Frage kann ich diese Struktur in meiner Tabelle (siehe unten) anzeigen lassen? Zb: in der Spalte 1?

Vollständiges Minimalbeispiel:

Öffne in Overleaf
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture}
\end{document}

Anbei meine Tabelle (kein Standalone Code - sorry)

Öffne in Overleaf
\begin{longtable}{@{\extracolsep{\fill}}|C{3.2cm}|L{4.5cm}|L{8cm}|}
\caption{} \\
\hline
\textbf{a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\hline
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endhead

\multicolumn{3}{c}{(To be continued)}
\endfoot
\endlastfoot
01a & 01\_gws (a) & \\ \hline
02a & 02\_aws (a) & \\ \hline
aa & 14a  & \\\cline{2-3}
 & v & \\ \hline
... &... & ...\\ \hline
\end{longtable}

UPDATE: Anbei mein lauffähiges Beispiel! Leider werden keine hlines bzw | Striche dargestellt. Kann ich weiters das "aaa" nicht mittig sondern nach oben-linksbündig positionieren?

Öffne in Overleaf
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{longtable} %Large tables (longtable)
\usepackage{tikz,booktabs}
\usepackage{tabularx}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcommand{\ltab}{\raggedright\arraybackslash} % Tabellenabschnitt linksbündig
\newcommand{\ctab}{\centering\arraybackslash} % Tabellenabschnitt zentriert
\newcommand{\rtab}{\raggedleft\arraybackslash} % Tabellenabschnitt rechtsbündig
%\renewcommand*{\footfont}{\normalfont} 
%\renewcommand*{\headfont}{\normalfont} 
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]

\begin{longtable}{@{\extracolsep{\fill}}|C{3.2cm}|L{4.5cm}|L{8cm}|}
\caption{} \\
\hline

%\textbf{a} & \textbf{a a a} & \textbf{a a a} \\ <- ursprüngliche Zeile
%Einfügen in der 1 Zeile/ 1 Spalte diesen File-Tree
% % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture} & \textbf{a a a} & \textbf{a a a} \\
% % %ENDE % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

\hline \addlinespace[1pt] \hline
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\hline
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endhead

\multicolumn{3}{c}{(To be continued)}
\endfoot
\endlastfoot
01a & 01\_gws (a) & \\ \hline
02a & 02\_aws (a) & \\ \hline
aa & 14a  & \\\cline{2-3}
 & v & \\ \hline
... &... & ...\\ \hline
\end{longtable}

\end{document}

alt text

gefragt 10 Aug '18, 13:32

Questionmark's gravatar image

Questionmark
1212
Akzeptiert-Rate: 0%

bearbeitet 13 Aug '18, 09:54


Dein Beispiel ist leider noch immer nicht minimal. Darüber hinaus beachtet es nicht den wichtigen Hinweis aus saputellos Kommentar, dass man für ein Minimalbeispiel nicht die Klasse minimal verwenden sollte, sondern beispielsweise article. Dieser Hinweis findet sich übrigens auch in der Minimalbeispiel-Anleitung. Beachtet man das:

Öffne in Overleaf
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{longtable} %Large tables (longtable)
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]

\begin{longtable}{@{\extracolsep{\fill}}|C{3.2cm}|L{4.5cm}|L{8cm}|}
\caption{} \\
\hline
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture} & \textbf{a a a} & \textbf{a a a} \\
% % %ENDE % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

\hline \addlinespace[1pt] \hline
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\hline
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endhead

\multicolumn{3}{c}{(To be continued)}
\endfoot
\endlastfoot
01a & 01\_gws (a) & \\ \hline
02a & 02\_aws (a) & \\ \hline
aa & 14a  & \\\cline{2-3}
 & v & \\ \hline
... &... & ...\\ \hline
\end{longtable}

\end{document}

dann sind die bei dir fehlenden Linien zu sehen:

Tabelle mit Linien aber viel zu breit

Damit erübrigt sich die Frage nach den Linien also eigentlich bereits. Dass die Tabelle dabei über die Seite hinaus ragt (das ist die dicke Linie rechts in der Abbildung), sollte nicht verwundern 3.2cm + 4.5cm + 8cm + 6\tabcolsep sind nun einmal deutlich zu breit.

Auch die vertikale Zentrierung wurde von dir explizit angefordert. Du verwendest sowohl für die Definition der C- als auch der L-Spalten eine m-Spalte. Der Inhalt von m-Spalten wird per \vcenter zentriert (siehe dazu die Anleitung zum Paket array, das diesen Spaltentyp bereit stellt). Man müsste also m in den Definitionen min. durch p ersetzen und auch die Breitenangaben anpassen:

Öffne in Overleaf
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{longtable} %Large tables (longtable)
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]

\begin{longtable}{@{\extracolsep{\fill}}|C{3.2cm}|L{4cm}|L{4cm}|}
\caption{} \\
\hline
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\hline
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endhead

\multicolumn{3}{c}{(To be continued)}
\endfoot

\endlastfoot

01a & 01\_gws (a) & \\ \hline
02a & 02\_aws (a) & \\ \hline
aa & 14a  & \\\cline{2-3}
 & v & \\ \hline
... &... & ...\\ \hline
\end{longtable}

\end{document}

Hässliche Tabelle mit korrekter Breite und Ausrichtung

Allerdings scheint es so, dass die Tabellenzellen überhaupt nicht umbrochen werden müssen. Daher wäre es einfacher, c- und l-Spalten an Stelle von selbst definierten C- und L-Spalten zu verwenden, oder auch nur drei l-Spalten:

Öffne in Overleaf
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{longtable} %Large tables (longtable)
\usepackage{booktabs}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]

\begin{longtable}{|*3{l|}}
\caption{} \\
\hline
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\hline
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\hline \addlinespace[1pt] \hline
\endhead

\multicolumn{3}{c}{(To be continued)}
\endfoot

\endlastfoot

01a & 01\_gws (a) & \\ \hline
02a & 02\_aws (a) & \\ \hline
aa & 14a  & \\\cline{2-3}
 & v & \\ \hline
... &... & ...\\ \hline
\end{longtable}

\end{document}

In der Tat schließe ich mich aber der booktabs-Anleitung an und empfehle, auf vertikale Linien ganz zu verzichten und horizontale Linien auf ein Minimum zu reduzieren:

Öffne in Overleaf
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{longtable} %Large tables (longtable)
\usepackage{booktabs}
\begin{document}
\tikzstyle{every node}=[draw=black,thick,anchor=west]
\tikzstyle{selected}=[draw=red,fill=red!30]
\tikzstyle{optional}=[dashed,fill=gray!50]

\begin{longtable}{*3l}
\caption{} \\
\toprule
\begin{tikzpicture}[%
  grow via three points={one child at (0.5,-0.7) and
  two children at (0.5,-0.7) and (0.5,-1.4)},
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
  \node {texmf}
    child { node {S1*1}}        
    child { node {S2*3}}
    child { node {S2*3}}
    child { node [selected] {S*ALL}
      child { node [optional] {latex}}
      child { node {plain}}
    }
    child [missing] {}              
    child [missing] {}              
    child [missing] {}              
    child { node {S END}};
\end{tikzpicture} & \textbf{a a a} & \textbf{a a a} \\
\midrule
\endfirsthead

\multicolumn{3}{c}{(a of a)} \\
\textbf{a a} & \textbf{a a a} & \textbf{a a a} \\
\midrule
\endhead

\midrule
\multicolumn{3}{c}{(To be continued)}
\endfoot

\bottomrule
\endlastfoot

01a & 01\_gws (a) & \\
02a & 02\_aws (a) & \\
aa & 14a  & \\
 & v & \\
... &... & ...\\
\end{longtable}

\end{document}

bessere Tabelle

Permanenter link

beantwortet 13 Aug '18, 11:50

gast3's gravatar image

gast3
(ausgesetzt)
Akzeptiert-Rate: 53%

bearbeitet 13 Aug '18, 12:05

Danke. Habe es verstanden :)

(13 Aug '18, 14:06) Questionmark
-1

Alternativ -> einfacher (funktioniert auch in meiner Tabellenumgebung)

Öffne in Overleaf
\documentclass[border=5pt]{standalone}
\usepackage{forest}

\begin{document}

\begin{forest}
  for tree={
    font=\ttfamily,
    grow'=0,
    child anchor=west,
    parent anchor=south,
    anchor=west,
    calign=first,
    edge path={
      \noexpand\path [draw, \forestoption{edge}]
      (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label};
    },
    before typesetting nodes={
      if n=1
        {insert before={[,phantom]}}
        {}
    },
    fit=band,
    before computing xy={l=15pt},
  }
[text1
  [text1.1
    [text1.1.1]
    [text1.1.2]
    [text1.1.3]
  ]
  [text1.2
    [text1.2.1]
    [text1.2.2]
  ]
]
\end{forest}

\end{document}
Permanenter link

beantwortet 13 Aug '18, 14:06

Questionmark's gravatar image

Questionmark
1212
Akzeptiert-Rate: 0%

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×728
×254
×7

gestellte Frage: 10 Aug '18, 13:32

Frage wurde gesehen: 5,034 Mal

zuletzt geändert: 13 Aug '18, 15:11