合并表格标题中的列时出现的问题

合并表格标题中的列时出现的问题

我正在尝试创建两个表格:一个有两列,另一个有三列,在这两种情况下,第一行都应该是一个单元格合并到所有列中。此外,第一个单元格的内容跨越多行。这是我目前的解决方案,但它仅适用于固定列号:

\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}

有 2 列的表格

对于有两列的情况:

\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}

有 3 列的表格

对于有三列的情况。

有人知道如何编程这个标题命令以使其适用于任何列号吗?

另外,我还有其他一些小的美观问题:表格的内容在右侧蔓延,尤其是灰线非常明显,而且标题也太宽了。有办法解决这个问题吗?

有人明白为什么名字和姓氏之间的点在标题中可见但在第一行中不可见(如 M. Name 和 M Name)吗?

最后,我对这里的固定单元格宽度解决方案还不满意,列在右侧太多了,也许有人可以建议如何使它更漂亮?

我将非常感谢您的帮助、评论和建议!

答案1

我不确定是什么原因导致句号消失,因为我对所有正在使用的包都不太熟悉。无论原因是什么,使用 c 而不是 s 都可以解决这个问题。

\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}

演示

相关内容