![合併表標題中的欄位出現問題](https://rvso.com/image/335486/%E5%90%88%E4%BD%B5%E8%A1%A8%E6%A8%99%E9%A1%8C%E4%B8%AD%E7%9A%84%E6%AC%84%E4%BD%8D%E5%87%BA%E7%8F%BE%E5%95%8F%E9%A1%8C.png)
我正在嘗試建立兩個表:一個有兩列,另一個有三列,在這兩種情況下,第一行應該是合併所有列的一個儲存格。此外,第一個儲存格的內容跨越多行。這是我目前的解決方案,但它僅適用於固定列號:
\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}
對於有兩列的情況:
\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}
對於三列的情況。
有誰知道如何編寫此標題命令,以便它適用於任何列號?
另外,我還有其他一些美學上的小問題:表格的內容在右側展開,尤其是灰線非常明顯,標題太寬。有沒有辦法解決這個問題?
有誰明白為什麼名字和姓氏之間的點在標題中可見,但在第一行中不可見(如 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}