![额外的对齐标签已更改为 \cr,并且看不到任何额外的对齐标签 - 输出是错误的](https://linux22.com/image/452831/%E9%A2%9D%E5%A4%96%E7%9A%84%E5%AF%B9%E9%BD%90%E6%A0%87%E7%AD%BE%E5%B7%B2%E6%9B%B4%E6%94%B9%E4%B8%BA%20%5Ccr%EF%BC%8C%E5%B9%B6%E4%B8%94%E7%9C%8B%E4%B8%8D%E5%88%B0%E4%BB%BB%E4%BD%95%E9%A2%9D%E5%A4%96%E7%9A%84%E5%AF%B9%E9%BD%90%E6%A0%87%E7%AD%BE%20-%20%E8%BE%93%E5%87%BA%E6%98%AF%E9%94%99%E8%AF%AF%E7%9A%84.png)
我在横向环境中使用换行文本制作这个长表。表中的第一个数据行一切正常,但一旦我开始添加第二行,我就会收到错误“额外的对齐标签已更改为 \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
自动应用。我建议你加载array
和ragged2e
包,然后运行
\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}