额外的对齐标签已更改为 \cr,并且看不到任何额外的对齐标签 - 输出是错误的

额外的对齐标签已更改为 \cr,并且看不到任何额外的对齐标签 - 输出是错误的

我在横向环境中使用换行文本制作这个长表。表中的第一个数据行一切正常,但一旦我开始添加第二行,我就会收到错误“额外的对齐标签已更改为 \cr”。我从正确的行复制并仅更改了内容,即我看不到如何存在额外的对齐,并且进行了检查但找不到问题所在。任何帮助都将不胜感激。

\documentclass[landscape,12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[]{graphicx}
\usepackage{array}
\usepackage{longtable}
\usepackage[]{anysize}
\marginsize{.8in}{0.8in}{0.8in}{0.8in} % mine

% \makeatletter
% \newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt\par}}
% \makeatother

\begin{document}
\begin{longtable}[]{p{0.75in}p{0.5in}p{0.5in}p{1in}p{1.5in}p{1.5in}p{2.5in}}
\caption[My table-optional caption in list of tables]{Table-caption\label{longtable}} \\
\hline\hline
\multicolumn{7}{c}{Optional at the top of the table, simply remove line if not needed} \\
Paper & 
Country & 
Idea & 
Topic &
Data &
Methodology &
Results                                                                                 \\
\hline
\endfirsthead
\caption[]{(continued)}                                                                  \\
\hline\hline
\multicolumn{7}{c}{Optional at the top of every other page, simply remove line if not needed} \\
Paper & 
Country & 
Idea & 
Topic &
Data &
Methodology &
Results                                                                                 \\
\hline
\endhead
\hline
\raggedright A &
\raggedright Be or not to be that is a problem &
\raggedright Cool to see you today man &
\raggedright Do it your self I don't care &
\raggedright Eat all your food, otherwise we are not going the park &
\raggedright Furious at me why? did I do something wrong to you &
\raggedright Gurious at me why? did I something wrong to youGFurious at me why? did I do something wrong to youGGGFurious at me why? did I do something wrong to youGG Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG OKay Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG ok \\
\raggedright A &
\raggedright Be or not to be that is a problem &
\raggedright Cool to see you today man &
\raggedright Do it your self I don't care &
\raggedright Eat all your food, otherwise we are not going the park &
\raggedright Furious at me why? did I do something wrong to you &
\raggedright Gurious at me why? did I something wrong to youGFurious at me why? did I do something wrong to youGGGFurious at me why? did I do something wrong to youGG Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG OKay Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG ok \\
\end{longtable}
\end{document}

答案1

既然你希望应用于\raggedright所有单元格的内容,你不妨修改p列类型以便\raggedright自动应用。我建议你加载arrayragged2e包,然后运行

\newcolumntype{P}[1]{>{\RaggedRight}p{#1}}

在序言中。如果你这样做不是想要允许单元格中的长单词连字符,你可以运行

\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

然后,您可以通过执行以下命令摆脱所有后续\raggedright指令(并大大简化代码)

\begin{longtable}{P{0.75in}P{0.5in}P{0.5in}P{1in}P{1.5in}P{1.5in}PO{2.5in}}

完整的 MWE(最小工作示例),它还使用了包的线条绘制宏booktabs

在此处输入图片描述

\documentclass[12pt]{report}
%%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[landscape,letterpaper,margin=0.8in]{geometry}
\usepackage{array,     % for \newcolumntype macro
            ragged2e,  % for \RaggedRight macro
            booktabs,  % for well-spaced horizontal rules
            longtable} % for longtable environment
\newcolumntype{P}[1]{>{\RaggedRight}p{#1}} % disable full justification

\begin{document}

\begin{longtable}{@{} l *{2}{P{0.75in}} P{1in} *{2}{P{1.5in}} P{2.5in} @{}}

%% headers and footers

\caption[My table-optional caption in list of tables]{Table-caption\label{longtable}} \\
\toprule
\multicolumn{7}{c}{Optional at the top of the table, simply remove line if not needed} \\[0.5ex]
Paper & 
Country & 
Idea & 
Topic &
Data &
Methodology &
Results \\
\midrule
\endfirsthead

\multicolumn{7}{@{}l}{Table \thetable, continued}\\ \addlinespace
\toprule
\multicolumn{7}{c}{Optional at the top of every other page, simply remove line if not needed} \\[0.5ex]
Paper & 
Country & 
Idea & 
Topic &
Data &
Methodology &
Results \\
\midrule
\endhead

\midrule
\multicolumn{7}{r@{}}{\small (continued on next page)} \\
\endfoot

\bottomrule
\endlastfoot

%% body of table

A &
Be or not to be that is a problem &
Cool to see you today man &
Do it your self I don't care &
Eat all your food, otherwise we are not going the park &
Furious at me why? did I do something wrong to you &
Gurious at me why? did I something wrong to youGFurious at me why? did I do something wrong to youGGGFurious at me why? did I do something wrong to youGG Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG OKay Furious at me why? did I do something wrong to youGGFurious at me why? \\
\addlinespace
B &
Be or not to be that is a problem &
Cool to see you today man &
Do it your self I don't care &
Eat all your food, otherwise we are not going the park &
Furious at me why? did I do something wrong to you &
Gurious at me why? did I something wrong to youGFurious at me why? did I do something wrong to youGGGFurious at me why? did I do something wrong to youGG Furious at me why? did I do something wrong to youGGFurious at me why? did I do something wrong to youGG OKay Furious at me why? did I do something wrong to youGGFurious at me why? \\

\end{longtable}

\end{document}

相关内容