Tabelle richtig formatieren Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


leo123
Forum-Newbie
Forum-Newbie
Beiträge: 2
Registriert: Di 11. Jun 2024, 22:30

Tabelle richtig formatieren

Beitrag von leo123 »

Dies hier ist mein Code:
\begin{longtable}{| p{2cm} | p{1cm} | p{1.5cm} | p{1.5cm} | p{1.5cm} | p{1.5cm} | p{1.5cm} |}
\caption{Variantenbewertung Sicherung/Verriegelung} \\
\hline
\textbf{Kriterien} & \textbf{GWF} & \multicolumn{2}{c|}{\textbf{Variante 1}} & \multicolumn{2}{c|}{\textbf{Variante 2}} & \multicolumn{1}{c|}{\textbf{Variante 3}} \\
\cline{3-7}
 &  & \textbf{fg} & \textbf{} & \textbf{} & \textbf{} & \textbf{} \\
\hline
\textbf{a} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\textbf{b} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\textbf{c} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\textbf{d} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\textbf{f} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\textbf{g} &  & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} &  \\
\hline
\end{longtable}

Ich will dass unter Variante 3 auch die 2 Spalten sind, wie bei Variante 1 und 3. Ich kriege es nicht hin und bin echt mit meiner Geduld am Ende. Und wie kann ich die Größen für die Zellen einstellen? Ich wäre wirklich sehr dankbar, wenn mir jemand helfen könnte.
Zuletzt geändert von Stefan Kottwitz am Mi 12. Jun 2024, 07:27, insgesamt 1-mal geändert.
Grund: Code markiert

Benutzeravatar
Stefan Kottwitz
Admin
Admin
Beiträge: 2759
Registriert: Di 8. Jul 2008, 00:39
Kontaktdaten:

Re: Tabelle richtig formatieren

Beitrag von Stefan Kottwitz »

Hallo Leo,

willkommen im Forum!

Du hast nur eine Spalte zuwenig oben im Code definiert. Hier mal etwas übersichtlicher mit \newcolumntype und dem *-Feature zum Vervielfachen vom Spaltentyp-Definitionen aus dem array-Paket:
\documentclass{article}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{B}[1]{>{\bfseries}p{#1}}
\begin{document}
\begin{longtable}{| B{2cm} | *7{P{1cm}|}}
\caption{Variantenbewertung Sicherung/Verriegelung} \\
\hline
\textbf{Kriterien} & \textbf{GWF} & \multicolumn{2}{c|}{\textbf{Variante 1}} & \multicolumn{2}{c|}{\textbf{Variante 2}} & \multicolumn{2}{c|}{\textbf{Variante 3}} \\
\cline{3-8}
 &  & \textbf{fg} & \textbf{} & \textbf{} & \textbf{} & \textbf{} & \textbf{}  \\
\hline
a &  &  &  &  &  & & \\
\hline
b &  &  &  &  &  & & \\
\hline
c &  &  &  &  &  & & \\
\hline
d &  &  &  &  &  & & \\
\hline
f &  &  &  &  &  & & \\
\hline
g &  &  &  &  &  & & \\
\hline
\end{longtable}
\end{document}
Stefan

leo123
Forum-Newbie
Forum-Newbie
Beiträge: 2
Registriert: Di 11. Jun 2024, 22:30

Re: Tabelle richtig formatieren

Beitrag von leo123 »

Vielen lieben Dank

Antworten