这个表可以正常工作。但是,
\begin{tabularx}{\textwidth}{lllX}
\toprule
A & B & C & D\\
\midrule
A & B & C & aaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaa \\
\hline
\end{tabularx}
当我改变字体大小时,如下表所示,
\begin{tabularx}{\textwidth}{lllX}
\toprule
A & B & C & D\\
\midrule
\footnosize
A & B & C & aaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaa \\
\hline
\end{tabularx}
我收到错误信息:
Undefined control sequence. \end{tabularx}.
另外,我无法添加标题;如果我加了,
\begin{tabularx}{\textwidth}{lllX}
\toprule
A & B & C & D\\
\midrule
\caption{ABC}
A & B & C & aaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaa \\
\hline
\end{tabularx}
我收到一串错误消息:
! You can't use `\hrule' here except with leaders.
\caption@hrule ->\hrule
\@height \z@
l.167 \end{tabularx}
To put a horizontal rule in an hbox or an alignment,
you should use \leaders or \hrulefill (see The TeXbook).
! Missing number, treated as zero.
<to be read again>
\vskip
l.167 \end{tabularx}
A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)
! Illegal unit of measure (pt inserted).
<to be read again>
\vskip
l.167 \end{tabularx}
...
\captionof{table}{\textbf{Inflation categories}}
我已经通过添加之前的行解决了标题问题
\begin{tabularx}
,但缺点是标题和表格最终可能会出现在不同的页面中。
我该如何解决这个问题?
编辑1 收到以下消息后,这是一个可行的解决方案:
\begin{table}
\caption{ABC}
\footnotesize
\begin{tabularx}{\textwidth}{lllX}
\toprule
A & B & C & D\\
\midrule
A & B & C & aaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaa \\
\hline
\end{tabularx}
\end{table}
我有一个拼写错误\footnotesize
,tabularx
需要用 来封装table
。
答案1
当我编译以下文档时,
\documentclass{article}
\usepackage{tabularx,booktabs}
\begin{document}
\begin{tabularx}{\textwidth}{lllX}
\toprule
A & B & C & D\\
\midrule
\footnosize
A & B & C & aaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaaaaaa aaaaa aaaaa \\
\hline
\end{tabularx}
\end{document}
我收到以下错误消息:
! Undefined control sequence.
<recently read> \footnosize
l.11 \end{tabularx}
因此,投诉的主题是\footnosize
,而不是\end{tabularx}
。该怎么办?以防万一它不是很明显:将其更改\footnosize
为\footnotesize
。
我假设您知道该\footnotesize
指令不会影响整行,而只会影响相关行的第一个单元格。
要将应用\caption
到该表,必须将tabularx
环境嵌入到环境中table
,如下所示:
\begin{table}
\caption{Stuff} \label{tab:stuff}
\begin{tabularx}{\textwidth}{lllX}
...
\end{tabularx}
\end{table}