Probleme mit Tabellenkopf Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


Latex-Neuling

Probleme mit Tabellenkopf

Beitrag von Latex-Neuling »

Moin,

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ß

http://www.luk-korbmacher.de/Schule/Text/din5008_12.htm

skater
Forum-Guru
Forum-Guru
Beiträge: 356
Registriert: Do 12. Mär 2009, 14:34
Wohnort: Berlin

Beitrag von skater »

Ich werde mir zwar mal wieder Mecker einfangen, aber ich finde trotzdem diese Kästchen und diese Farbspielereien voll krass Osterei.

Ohne den Anspruch, perfekt zu sein:
\documentclass[paper=a4,fontsize=12pt]{scrartcl}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
 
\begin{document}

\begin{table}
\caption{Beispieltabelle ohne voll blöde Kästchen und doofe Farbe}
\begin{tabular}{@{}lccc@{}}
\toprule
& \multirow{2}{*}{\small\em \vspace*{-\aboverulesep}\vspace*{-\belowrulesep}Spaltenüberschrift} & \multicolumn{2}{c@{}}{\small\em Gemeinsame Spaltenüberschrift} \\
\cmidrule(l){3-4}
& & \small\em Spaltenüberschrift & \small\em Spaltenüberschrift \\
\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(l){4-4}
Zeilenbezeichnung & Zelle & Zelle & Zelle \\
Zeilenbezeichnung & Zelle & Zelle & Zelle \\
Zeilenbezeichnung & Zelle & Zelle & Zelle \\
Zeilenbezeichnung & Zelle & Zelle & Zelle \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

Latex-Neuling

Beitrag von Latex-Neuling »

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}
Noch jemand eine Idee?

Antworten