Problem beim Zusammenführen von Spalten in der Tabellenüberschrift

Problem beim Zusammenführen von Spalten in der Tabellenüberschrift

Ich versuche, zwei Tabellen zu erstellen: eine mit zwei Spalten und die andere mit drei Spalten. In beiden Fällen sollte die erste Zeile eine Zelle sein, die über alle Spalten hinweg zusammengeführt wird. Außerdem erstreckt sich der Inhalt dieser ersten Zelle über mehr als eine Zeile. Hier ist meine derzeitige Lösung, die jedoch nur für eine feste Spaltenanzahl funktioniert:

\documentclass{scrreprt}

\usepackage{booktabs} 

\usepackage{tabularx} 
\newcolumntype{b}{X} %type big
\newcolumntype{s}{>{\hsize=0.99\hsize}X} %type small. Above 1 does not make any difference
\newcommand{\heading}[1]{\multicolumn{2}{p{\textwidth}}{#1}} %For the cases where I am main author
%\newcommand{\heading}[1]{\multicolumn{3}{p{\textwidth}}{#1}} %For the cases where I am not main author

\usepackage[table,xcdraw]{xcolor}
\renewcommand{\arraystretch}{1.2} %(or 1.3). based on the advice in https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf

\usepackage{csquotes} 

\usepackage{siunitx} 
\sisetup{detect-all} 

\usepackage{pifont} 
\newcommand{\xmark}{\ding{55}} 

\begin{document}
This is my template for tables: documentation of authorship for the cumulative thesis.
\begin{table}[h!]
\centering
%\caption{My caption}
%\label{my-label}
\begin{tabularx}{\textwidth}{bs}
\toprule %requires the booktabs package.
%\multicolumn{2}{p{\textwidth}}{[ref] M. Name and L. Author, \enquote{Long title of a nice article reporting cool but complicated research}, \textit{Fancy journal} \textbf{2016}, \textit{13}, 001--007}  \\
\heading{[ref] M. Name and L. Author, \enquote{Long title of a nice article     reporting cool but complicated research} \textbf{2016}, \textit{13}, 001--007}\\
\midrule
Author                          & M. Name \\
\midrule %requires the booktabs package
Development of the concept      & \xmark   \\
\rowcolor[HTML]{C0C0C0} 
Preparation of the figures      & \xmark  \\ 
Preparation of the manuscript   & \xmark  \\ %\cmark \xmark require the pifont package and newcommand thing: http://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark 
\rowcolor[HTML]{C0C0C0} 
Correction of the manuscript    & \xmark   \\
\midrule 
Proposed publication equivalent & \num{1}  \\
\bottomrule     
\end{tabularx}
\end{table}

\end{document}

Tabelle mit 2 Spalten

für den Fall mit zwei Spalten und:

\documentclass{scrreprt}

\usepackage{booktabs} 

\usepackage{tabularx} 
\newcolumntype{b}{X} %type big
\newcolumntype{s}{>{\hsize=0.99\hsize}X} %type small. Above 1 does not make any difference
%\newcommand{\heading}[1]{\multicolumn{2}{p{\textwidth}}{#1}} %For the cases where I am main author
\newcommand{\heading}[1]{\multicolumn{3}{p{\textwidth}}{#1}} % For the cases where I am not main author

\usepackage[table,xcdraw]{xcolor}
\renewcommand{\arraystretch}{1.2} %(or 1.3). based on the advice in https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf

\usepackage{csquotes}

\usepackage{siunitx} %possible package for units
\sisetup{detect-all} 

\usepackage{pifont} 
\newcommand{\xmark}{\ding{55}} 

\begin{document}

This is my template for tables: documentation of authorship for the cumulative thesis.

\begin{table}[h!]
\centering
%\caption{My caption}
%\label{my-label}
\begin{tabularx}{\textwidth}{bss}
\toprule 
%\multicolumn{3}{p{\textwidth}}{[ref] F. Author, M. Name and L. Author,         \enquote{Long title of a nice article reporting cool but complicated research}, \textit{Fancy journal} \textbf{2016}, \textit{13}, 001--007}  \\
\heading{[ref] F. Author, M. Name and L. Author, \enquote{Long title of a nice article reporting cool but complicated research}, \textit{Fancy journal}     \textbf{2016}, \textit{13}, 001--007}\\
\midrule
Author                          & F. Author & M. Name \\
\midrule 
Development of the concept      & \xmark  & \\
\rowcolor[HTML]{C0C0C0} 
Programmation of the algorithm  & \xmark & \xmark  \\ 
Data acquisition                & \xmark &  \\
\rowcolor[HTML]{C0C0C0} 
Data analysis                   & \xmark & \xmark \\ 
Preparation of the manuscript   & \xmark & \\ %\cmark \xmark require the pifont package and newcommand thing: http://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark 
\rowcolor[HTML]{C0C0C0} 
Correction of the manuscript    & \xmark  & \xmark  \\
\midrule 
Proposed publication equivalent & \num{1} & \num{0,5} \\
\bottomrule     
\end{tabularx}
\end{table}

\end{document}

Tabelle mit 3 Spalten

für den Fall mit drei Spalten.

Weiß jemand, wie man diesen Überschriftenbefehl so programmiert, dass er für jede beliebige Spaltennummer funktioniert?

Außerdem habe ich noch andere kleinere ästhetische Probleme: Der Inhalt der Tabelle breitet sich auf der rechten Seite aus, besonders die grauen Linien sind sehr deutlich, aber auch der Titel ist zu breit. Gibt es eine Möglichkeit, dies zu beheben?

Versteht jemand, warum der Punkt zwischen Vor- und Nachnamen in der Überschrift sichtbar ist, aber nicht in der ersten Zeile (wie bei M. Name und M Name)?

Abschließend möchte ich sagen, dass ich mit der Lösung mit der festen Zellenbreite noch nicht zufrieden bin, die Spalten landen zu weit rechts, vielleicht hat jemand einen Vorschlag, wie man das schöner gestalten kann?

Für Hilfe, Kommentare, Anregungen wäre ich super dankbar!

Antwort1

Ich bin mir nicht sicher, warum die Punkte verschwunden sind, da ich mit den verwendeten Paketen nicht so vertraut bin. Was auch immer der Grund war, die Verwendung von c statt s hat das Problem behoben.

\documentclass{scrreprt}

\usepackage{booktabs} 

\usepackage{tabularx} 
\newcolumntype{b}{X} %type big
%\newcolumntype{s}{>{\hsize=0.99\hsize}X} %type small. Above 1 does not make any difference
%\newcommand{\heading}[1]{\multicolumn{2}{p{\textwidth}}{#1}} %For the cases where I am main author
\newcommand{\heading}[1]{\multicolumn{3}{p{\dimexpr\textwidth-2\tabcolsep}}{#1}} % For the cases where I am not main author

\usepackage[table,xcdraw]{xcolor}
\renewcommand{\arraystretch}{1.2} %(or 1.3). based on the advice in https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf

\usepackage{csquotes}

\usepackage{siunitx} %possible package for units
\sisetup{detect-all} 

\usepackage{pifont} 
\newcommand{\xmark}{\ding{55}} 

\begin{document}

This is my template for tables: documentation of authorship for the cumulative thesis.

\begin{table}[h!]
\centering
%\caption{My caption}
%\label{my-label}
\begin{tabularx}{\textwidth}{bcc}
\toprule 
%\multicolumn{3}{p{\textwidth}}{[ref] F. Author, M. Name and L. Author,         \enquote{Long title of a nice article reporting cool but complicated research}, \textit{Fancy journal} \textbf{2016}, \textit{13}, 001--007}  \\
\heading{[ref] F. Author, M. Name and L. Author, \enquote{Long title of a nice article reporting cool but complicated research}, \textit{Fancy journal}     \textbf{2016}, \textit{13}, 001--007}\\
\midrule
Author                          & F. Author & M. Name \\
\midrule 
Development of the concept      & \xmark  & \\
\rowcolor[HTML]{C0C0C0} 
Programmation of the algorithm  & \xmark & \xmark  \\ 
Data acquisition                & \xmark &  \\
\rowcolor[HTML]{C0C0C0} 
Data analysis                   & \xmark & \xmark \\ 
Preparation of the manuscript   & \xmark & \\ %\cmark \xmark require the pifont package and newcommand thing: http://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark 
\rowcolor[HTML]{C0C0C0} 
Correction of the manuscript    & \xmark  & \xmark  \\
\midrule 
Proposed publication equivalent & \num{1} & \num{0,5} \\
\bottomrule     
\end{tabularx}
\end{table}

\end{document}

Demo

verwandte Informationen