bin Latex-Neuling, gerade dabei eine Grundstruktur für meine Masterthesis zu basteln und habe ein Problem mit dem Tabellenkopf.
Als Tabellenvorlage finde ich die Vorlage von Matthias Pospiech sehr gut. Diese habe ich etwas angepasst:
% Präambel wie zuvor
\documentclass[a4paper, 11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage[table]{xcolor}
\pagestyle{empty}
% --- Definition der Tabellenstile ---
%--Definition der Farben ----------
\colorlet{tablesubheadcolor}{gray!40}
\colorlet{tableheadcolor}{gray!25}
\colorlet{tableblackheadcolor}{black!60}
\colorlet{tablerowcolor}{gray!15.0}
\newcommand\tablealtcolored{%
\rowcolors{1}{tablerowcolor}{white!100}%
}
\newcommand\tableheadcolor{
\rowcolor{tableblackheadcolor}
}
% -- Schriftgrößen
\newcommand{\tablefontsize}{ \footnotesize}
\newcommand{\tableheadfontsize}{\footnotesize}
% --- Allgemein ---
% Layout der Tabelle: Ausrichtung, Schrift, Zeilenabstand
\newcommand\tablestylecommon{%
\renewcommand{\arraystretch}{1.4} % Groessere Abstaende zwischen Zeilen
\normalfont\normalsize %
\sffamily\tablefontsize % Serifenlose und kleine Schrift
\centering% % Tabelle zentrieren
}
\newcommand{\tablestyle}{
\tablestylecommon
%\tablealtcolored
}
% --- Kopf --------
% Stil für den Tabellenkopf
\newcommand\tablehead{%
\tableheadfontsize
\sffamily\bfseries
\color{white}
}
\newcommand\tablebegin{%
\hline
}
% --- Zwischenkopf --
% --- Inhalt --------
% Text Zentriert, automatischer Zeilenumbruch:
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcommand\tablebody{%
\tablefontsize
\sffamily
\upshape%
}
% Fuss
\newcommand\tableend{%
\hline
}
\begin{document}
%- Tabelle --------------------------------------
%
\begin{table}[H]
% Stil der Tabelle
\tablestyle
%
\tablealtcolored % Alternierende Farbe der Tabellenzeilen
%
\begin{tabular}{|C{2cm}||C{2cm} C{2cm}|}
\tablebegin % Linie oberhalb des Kopfes
\tableheadcolor % Farbe für den Tabellenkopf
% Tabellenkopf
\tablehead Tabellenkopf & \tablehead Tabellenkopf & \tablehead Tabellenkopf \tabularnewline
\hline
\hline
%
% Stil des Tabelleninhaltes
\tablebody
% Tabelleninhalt
Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt \tabularnewline
% Linie am Ende der Tabelle
\tableend
\end{tabular}
\end{table}
\end{document}
Mein Tabellenkopf sollte so aussehen, wie in dem Link (es geht nur um das Prinzip des Tabellenkopfes). Mit multirow und multicolumn habe ich es nicht geschafft und bin echt am verzweifeln. Kann mir jemand helfen?
Danke und Gruß
Danke schonmal. Dein Vorschlag sieht auch gut aus. Wenn die Gestaltung des Tabellenkopfes wie eigentlich gedacht nicht möglich ist, werde ich deinen Vorschlag übernehmen.
Ich habe auch nochmal nochmal selber mein Glück versucht. Leider mit folgendem Ergebnis (Die Änderungen sind mit !!!! markiert):
% Präambel wie zuvor
\documentclass[a4paper, 11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage[table]{xcolor}
\pagestyle{empty}
\usepackage{multirow} %!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% --- Definition der Tabellenstile ---
%--Definition der Farben ----------
\colorlet{tablesubheadcolor}{gray!40}
\colorlet{tableheadcolor}{gray!25}
\colorlet{tableblackheadcolor}{black!60}
\colorlet{tablerowcolor}{gray!15.0}
\newcommand\tablealtcolored{%
\rowcolors{1}{tablerowcolor}{white!100}%
}
\newcommand\tableheadcolor{
\rowcolor{tableblackheadcolor}
}
% -- Schriftgrößen
\newcommand{\tablefontsize}{ \footnotesize}
\newcommand{\tableheadfontsize}{\footnotesize}
% --- Allgemein ---
% Layout der Tabelle: Ausrichtung, Schrift, Zeilenabstand
\newcommand\tablestylecommon{%
\renewcommand{\arraystretch}{1.4} % Groessere Abstaende zwischen Zeilen
\normalfont\normalsize %
\sffamily\tablefontsize % Serifenlose und kleine Schrift
\centering% % Tabelle zentrieren
}
\newcommand{\tablestyle}{
\tablestylecommon
%\tablealtcolored
}
% --- Kopf --------
% Stil für den Tabellenkopf
\newcommand\tablehead{%
\tableheadfontsize
\sffamily\bfseries
\color{white}
}
\newcommand\tablebegin{%
\hline
}
% --- Zwischenkopf --
% --- Inhalt --------
% Text Zentriert, automatischer Zeilenumbruch:
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcommand\tablebody{%
\tablefontsize
\sffamily
\upshape%
}
% Fuss
\newcommand\tableend{%
\hline
}
\begin{document}
%- Tabelle --------------------------------------
%
\begin{table}[H]
% Stil der Tabelle
\tablestyle
%
\tablealtcolored % Alternierende Farbe der Tabellenzeilen
%
\begin{tabular}{|C{2cm}||C{2cm} C{2cm} C{2cm}|}
\tablebegin % Linie oberhalb des Kopfes
\tableheadcolor % Farbe für den Tabellenkopf
% Tabellenkopf
\tablehead & \multirow{2}{*}{\tablehead Tabellenkopf} & \multicolumn{2}{c|}{\tablehead Gemeinsamer Tabellenkopf} \tabularnewline %!!!!!!!!!!!!!!!!!!!!!
\tablehead & \tablehead & \tablehead & \tablehead \tabularnewline %!!!!!!!!!!!!!!!!!!!!!
\hline
\hline
%
% Stil des Tabelleninhaltes
\tablebody
% Tabelleninhalt
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
Inhalt & Inhalt & Inhalt & Inhalt \tabularnewline
% Linie am Ende der Tabelle
\tableend
\end{tabular}
\end{table}
\end{document}