![Проблема с объединением столбцов в заголовке таблицы](https://rvso.com/image/335486/%D0%9F%D1%80%D0%BE%D0%B1%D0%BB%D0%B5%D0%BC%D0%B0%20%D1%81%20%D0%BE%D0%B1%D1%8A%D0%B5%D0%B4%D0%B8%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5%D0%BC%20%D1%81%D1%82%D0%BE%D0%BB%D0%B1%D1%86%D0%BE%D0%B2%20%D0%B2%20%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%B5%20%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%8B.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}
для случая с тремя колоннами.
Кто-нибудь знает, как запрограммировать эту команду заголовка так, чтобы она работала для любого номера столбца?
Также у меня есть другие мелкие эстетические проблемы: содержимое таблицы растекается по правой стороне, особенно серые линии очень заметны, но также заголовок слишком широкий. Есть ли способ это исправить?
Кто-нибудь понимает, почему точка между именем и фамилией видна в заголовке, но не в первой строке (как Имя М и Имя М)?
Наконец, я пока не удовлетворен решением с фиксированной шириной ячеек, столбцы оказываются слишком правыми. Может быть, у кого-то есть предложения, как сделать это красивее?
Буду очень благодарен за помощь, комментарии, предложения!
решение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}