我制作了一个表格,将其插入到论文中,然后将其移动到我的论文中。由于某些原因,它给出了一系列我无法理解的错误,你能帮助我吗?我尝试复制我在论文 tex 中拥有的各种包和表格代码
\ifsetCustomMargin
\RequirePackage[left=37mm,right=30mm,top=35mm,bottom=30mm]{geometry}
\setFancyHdr
\RequirePackage[labelsep=space,tableposition=top]{caption}
\renewcommand{\figurename}{Fig.}
\usepackage{float}
\restylefloat{figure}
\usepackage{subcaption}
\usepackage{booktabs} % For professional looking tables
\usepackage{multirow}
\usepackage{multicol}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage[utf8]{inputenc}
\usepackage{makecell}
\usepackage{longtable}
\usepackage{ltablex}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\usepackage{siunitx}
\ifuseCustomBib
\RequirePackage{natbib}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\begin{table}
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}
\setcellgapes{5pt}
\makegapedcells
\centering
\begin{tabularx}{\linewidth}{*{6}{>{\raggedright\arraybackslash}X}}
\hline
\textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
\cline{2-6}
& Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
\hline
\textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cline{2-6}
& \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
& \multicolumn{5}{l}{Antoinette had given her great-grandfather}
\hline
\end{tabularx}
\end{table}
答案1
正如@Zarko 在评论中所述,\hline
a 中的所有stabular
都应以 a 开头。我还将第一列的对齐方式更改为,因为它比所有其他列都短。\\
l
\begin{table}
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}
\setcellgapes{5pt}
\makegapedcells
\centering
\begin{tabularx}{\linewidth}{@{}l*{5}{>{\raggedright\arraybackslash}X}@{}}
\hline
\textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
\cline{2-6}
& Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
\hline
\textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cline{2-6}
& \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
& \multicolumn{5}{l}{Antoinette had given her great-grandfather} \\
\hline
\end{tabularx}
\end{table}
答案2
你忘记了\\
之前的内容\hline
。另一方面,你可以对代码进行一些改进,例如如何更好地处理\multicolumn
B 部分中的跨列。
\documentclass{article}
\usepackage{microtype}
\usepackage{tabularx,booktabs}
\begin{document}
\begin{table}
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}
\centering
\begin{tabularx}{\linewidth}{
@{}
l
*{5}{>{\raggedright\arraybackslash}X}
@{}
}
\toprule
\textbf{Part A}
& \textit{Sally speaking}
& \textit{Narrator}
& \textit{Sally speaking}
& \textit{Narrator}
& \textit{Sally speaking} \\
\cmidrule(l){2-6}
& Oh yes,
& Sally remembered;
& she had it still, a ruby ring which Marie Antoinette
had given her great-grandfather.
& She never had a penny to her name in those days
& and going to Bourton always meant some frightful pinch.\\
\midrule
\textbf{Part B}
& \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cmidrule(l){2-6}
& \multicolumn{5}{>{\raggedright\arraybackslash\hsize=\dimexpr5\hsize+8\tabcolsep}X@{}}{%
Oh yes, Sally remembered; she had it still, a ruby ring which
Marie Antoinette had given her great-grandfather} \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案3
让我详细说明一下我的评论……
为了重现您的问题,以下最小工作示例就足够了(姆韦):
\documentclass{article}
\usepackage{makecell, tabularx}
\begin{document}
\begin{table}
\setcellgapes{5pt}
\makegapedcells
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}
\centering
\begin{tabularx}{\linewidth}{*{6}{>{\raggedright\arraybackslash}X}}
\hline
\textbf{Part A} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} & \textit{Narrator} & \textit{Sally speaking} \\
\cline{2-6}
& Oh yes, & Sally remembered; & she had it still, a ruby ring which Marie Antoinette had given her great-grandfather. & She never had a penny to her name in those days & and going to Bourton always meant some frightful pinch.\\
\hline
\textbf{Part B} & \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cline{2-6}
& \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
& \multicolumn{5}{l}{Antoinette had given her great-grandfather}
\hline
\end{tabularx}
\end{table}
\end{document}
最后一行以 结尾\\
。当行后有任何规则( 、 等)时,这是必要\hline
的\cline
。
修正并略有改善姆韦可以如下:
因为您的代码是booktabs
包,所以使用它是明智的,正如 AboAmmar 的回答中所示。
\documentclass{article}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage{ragged2e}
\usepackage{makecell, tabularx}
% \renewcommand\theadfont{\itshape}
\newcolumntype{L}{>{\RaggedRight}X}
\begin{document}
\begin{table}
\setcellgapes{5pt}
\makegapedcells
\setlength\tabcolsep{3pt}
\caption{Example of different attributions by three representative participants (A, B and C)}
\label{table3}
\centering
\begin{tabularx}{\linewidth}{@{}
>{\bfseries}l
*{5}{L}
@{} }
\hline
Part A
& \textit{Sally speaking}
& \textit{Narrator}
& \textit{Sally speaking}
& \textit{Narrator}
& \textit{Sally speaking} \\
\cline{2-6}
& Oh yes,
& Sally remembered;
& she had it still, a ruby ring which Marie Antoinette had given her great-grandfather.
& She never had a penny to her name in those days
& and going to Bourton always meant some frightful pinch. \\
\hline
Part B
& \multicolumn{5}{l}{\textit{Sally thinking}} \\
\cline{2-6}
& \multicolumn{5}{l}{Oh yes, Sally remembered; she had it still, a ruby ring which Marie} \\
& \multicolumn{5}{l}{Antoinette had given her great-grandfather} \\
\hline
\end{tabularx}
\end{table}
\end{document}