xtab 错误 \@sharp -> {\captionsize

xtab 错误 \@sharp -> {\captionsize

我开始学习xtab该软件包。为了尝试,我想尝试文档中给出的代码。但它会产生错误:

\@sharp ->{\captionsize \bfseries \tablename \ \thetable{} -- concluded fro....
 l.20 \begin{xtabular}{|l|p{0.5\textwidth}|}

 ?

以下是代码:

\documentclass[12pt]{article}
\usepackage{xtab}
\begin{document}
\topcaption{The principal xtab package commands} \label{tab:xtab}
\tablefirsthead{\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablehead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablelasthead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
concluded from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tabletail{\hline \multicolumn{2}{|r|}{{Continued on next page}} \\ \hline}
\tablelasttail{\hline \hline}
\begin{center}
\begin{xtabular}{|l|p{0.5\textwidth}|}
\verb|\begin{xtabular}{...}| & This is equivalent to the normal
\verb|\begin{tabular}{...}| environment.
You supply the specification of the columns
just as for the normal \Lenv{tabular} environment.
\\
&
All commands that can be used within a \Lenv{tabular}
environment can also be used within
the \Lenv{xtabular} environment.
\\
&
Unlike the \Lenv{tabular} environment which prevents page breaking
within the tabular, the \Lenv{xtabular} allows page breaking, so that
tabulars can extend automatically across several pages.
... ... ...
\verb|\tablelasttail{...}| & The contents of this command are inserted before
the final (internal) \verb|\end{tabular}| of the table.
\\
&
For example, you might want to note that this is where
the table ends.
\\
\end{xtabular}
\end{center}
\end{document} 

答案1

您在表中缺少caption包、的定义\Lenv和:\\

但我主要想评论一下你重新格式化了问题中的错误消息,使其变得难以理解;错误是

! Undefined control sequence.
\@sharp ->{\captionsize 
                        \bfseries \tablename \ \thetable {} -- concluded fro...
l.21 \begin{xtabular}{|l|p{0.5\textwidth}|}

? 

这表明未定义的命令(换行符之前的最后一个标记)是\captionsize 您已重新排列它,因此无法从您的问题中看出哪个是未定义的命令(但有帮助的是,您提供了一个 MWE,它提供了实际的错误消息)

\documentclass[12pt]{article}
\usepackage{xtab,caption}
\newcommand\Lenv{\textsf}
\begin{document}
\topcaption{The principal xtab package commands} \label{tab:xtab}
\tablefirsthead{\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablehead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablelasthead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
concluded from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tabletail{\hline \multicolumn{2}{|r|}{{Continued on next page}} \\ \hline}
\tablelasttail{\hline \hline}
\begin{center}
\begin{xtabular}{|l|p{0.5\textwidth}|}
\verb|\begin{xtabular}{...}| & This is equivalent to the normal
\verb|\begin{tabular}{...}| environment.
You supply the specification of the columns
just as for the normal \Lenv{tabular} environment.
\\
&
All commands that can be used within a \Lenv{tabular}
environment can also be used within
the \Lenv{xtabular} environment.
\\
&
Unlike the \Lenv{tabular} environment which prevents page breaking
within the tabular, the \Lenv{xtabular} allows page breaking, so that
tabulars can extend automatically across several pages.
... ... ...\\
\verb|\tablelasttail{...}| & The contents of this command are inserted before
the final (internal) \verb|\end{tabular}| of the table.
\\
&
For example, you might want to note that this is where
the table ends.
\\
\end{xtabular}
\end{center}
\end{document} 

相关内容