![表格的失控参数错误](https://linux22.com/image/339983/%E8%A1%A8%E6%A0%BC%E7%9A%84%E5%A4%B1%E6%8E%A7%E5%8F%82%E6%95%B0%E9%94%99%E8%AF%AF.png)
我正在使用 tabulary 并已像这样设置我的环境:
\usepackage{array,ltablex, makecell}%
\renewcommand\theadfont{\normalsize\bfseries}
\newenvironment{conditions}
{\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}}
{\end{tabular}\par\vspace{\belowdisplayskip}}%This is for descriptions of equations
\usepackage[]{multirow}
\usepackage[autostyle]{csquotes}% This is for quotes
\usepackage{tabulary}% This is for tables
\usepackage{ragged2e}
\usepackage{longtable,array}% This is formatting for long tables
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
然后,当我想制作一个带有换行文本的表格时,如从此示例中所示,我得到:
Runaway argument?
>{\raggedright \arraybackslash }p{L}\relax \NC@do D\NC@do d\NC@do V\@iwhilesw \
ETC.
Paragraph ended before \NC@find was complete.
<to be read again>
\par
l.96 \end{tabulary}
使用我从此链接获得的代码(获取换行文本):
\begin{center}
\begin{tabulary}{0.7\textwidth}{LCL}
Short sentences & \# & Long sentences \\
\hline
This is short. & 173 & This is much loooooooonger, because there are many more words. \\
This is not shorter. & 317 & This is still loooooooonger, because there are many more words. \\
\end{tabulary}
\end{center}
我的首要目标是制作一张如下所示的表格:
但现在看起来像:
答案1
您定义L
列类型来接受参数,即,
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
但你却把它当作不接受论点:
\begin{tabulary}{0.7\textwidth}{LCL}
出现失控参数错误是因为 LaTeX 正在查找 参数,但没有成功L
。此外,L
列类型已由环境定义tabulary
。
我认为您应该 (a) 使用tabularx
环境而不是tabulary
环境,并且 (b) 从列类型的定义中删除该参数L
。例如,
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\begin{document}
\begin{center}
\begin{tabularx}{0.7\textwidth}{LcL}
Short sentences & \# & Long sentences\\
\hline
This is short. & 173 & This is much loooooooonger, because there are many more words. \\
This is not shorter. & 317 & This is still loooooooonger, because there are many more words. \\
\end{tabularx}
\end{center}
\end{document}
附录:如果您的最终目的是使用longtable
环境,那么您也不应该加载tabulary
包。相反,我建议您按照以下示例代码进行操作。
\documentclass{article}
\usepackage{array,longtable}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\begin{longtable}{L{0.25\textwidth}cL{0.25\textwidth}}
Short sentences & \# & Long sentences\\
\hline
\endhead
This is short. & 173 & This is much loooooooonger, because there are many more words. \\
This is not shorter. & 317 & This is still loooooooonger, because there are many more words. \\
\end{longtable}
\end{document}
答案2
\begin{document}
\begin{tabular}{|p{6cm}|p{6cm}|}\hline\hline
Features&Example\\\hline\hline
Here & There\\\hline
Today&Tomorrow\\\hline
Good & Bad \\\hline
\multicolumn{2}{|l|} {I need to add full two columns}\\\hline
\end{tabular}
我添加了一个表格示例来生成您需要的表格。