我制作了一张长表格,但不知何故,它在内容很短的行(ShoL &
Shoulder Left\)显示了一个错误。
我在这个论坛上查看了类似的问题。我不能在 longtable 环境下使用 tabularx,是真的吗?如果是,我应该放在哪里\begin{tabularx}
?我试过放在\begin{tabularx}
之后\begin{longtable}
之前\caption
,\usepackage:tabularx
当然是在 前言 中,但结果只是出现了更多错误。
我也尝试过用 解决方案\begin{sloppypar} \end{sloppypar}
,但是没有效果。
当前错误消息是:
! Undefined control sequence.
<argument> ...ibnameprefix {of}\isdot \ifprefchar
{} {} {\ifuseprefix {\bibn...
l.168
The control sequence at the end of the top line
of your error message was never `\def`'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Overfull `\hbox` (81.02432pt too wide) in paragraph at lines 168--168
\T1/lmr/m/n/12 (-20) [Ac-cessed on Septem-ber 20, 2016], Avail-able on : http:/
/www.sunyem.com/simulation/overview/.
我的脚本如下,为了呈现一个简短的脚本,我从表中删除了很多行,所以现在它不是那么长:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{array, booktabs, caption}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{longtable}
\setlength{\tabcolsep}{10pt}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begin{longtable}{ll}
\caption{List}
\label{tab:Ch2VCOB}\\
\hline
\multicolumn{2}{l}{Components:}
\endfirsthead
\multicolumn{2}{c}%
{{\tablename\ \thetable{} continued from previous page}} \\
\hline \multicolumn{1}{l}{}
\endhead
\hline \hline
\endlastfoot
\multicolumn{1}{l}{Joints <joi>}
\tabularnewline
Free & free - joint beween inertial and midhip\\
Navl & navel - joint between lower and middle\\& trunk\\
Subs & substernal - joint between middle and upper \\
& trunk\\
Cerv & cervicular - joint between neck and upper \\&trunk\\
Atls & atlas - joint between head and neck\\
ShoR & shoulder right\\
ElbR & elbow right\\
WriR & wrist right\\
ShoL & shoulder left\\
ElbL & elbow left\\
WriL & wrist left\\
HipR & hip right\\
KneR & knee right\\
AnkR & ankle right\\
HipL & hip left\\
KneL & knee left\\
AnkL & ankle left\\
\end{longtable}
\end{document}
先感谢您
答案1
尝试
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{caption}
\usepackage{multicol}
\usepackage{array, booktabs, multirow, longtable}
\usepackage{ltablex} % <-- added (as suggested by Bernard in his comment)
\keepXColumns
\setlength{\tabcolsep}{10pt}
\renewcommand{\arraystretch}{1.5}
\usepackage{lipsum} % <-- added for dummy text
\begin{document}
\begin{tabularx}{\textwidth}{lX} % <-- changed from \begin{longtable}
\caption{List}
\label{tab:Ch2VCOB}\\
\toprule
\multicolumn{2}{l}{Components:}
\endfirsthead
\caption{continued from previous page} \\
\toprule
\endhead
\bottomrule
\endlastfoot
\multicolumn{1}{l}{Joints <joi>}
\tabularnewline
Free & free - joint beween inertial and midhip\\
Navl & navel - joint between lower and middle trunk\\
Subs & substernal - joint between middle and upper trunk\\
Cerv & cervicular - joint between neck and upper trunk\\
Atls & atlas - joint between head and neck\\
ShoR & shoulder right\\
test & \lipsum[1] \\ % added for test if long table works
ElbR & elbow right\\
WriR & wrist right\\
ShoL & shoulder left\\
ElbL & elbow left\\
WriL & wrist left\\
HipR & hip right\\
KneR & knee right\\
AnkR & ankle right\\
HipL & hip left\\
KneL & knee left\\
AnkL & ankle left\\
\end{tabularx} % <-- changed
\end{document}
为了得到最终的表格形式,您需要编译两次表格。
编辑:
许多人更喜欢ltxtable
而不是ltablex
因为后者将所有tabularx
表环境转换为longtable
。 有关 的使用,ltablex
请参阅 David Carlisle 的回答这里。