Latex 错误:包数组错误:非法前置令牌(3.5cm):使用 c'

Latex 错误:包数组错误:非法前置令牌(3.5cm):使用 c'

我有一张包含此命令的表。

\begin{table}[ht]
  \centering
  \centering\caption{Table features}
\begin{tabular}{ r{3.5cm} p{5.50cm} p{5.50cm} }
\toprule
          & \multicolumn{1}{r}{} & \textbf{Income components } & \textbf{Determined in GETTSIM tax and transfer model?} \\
    \midrule
    \textbf{1} & \multicolumn{1}{r}{} & \textbf{Earned income} & No \\
          & +     & Self-employed income & No \\
          & +     & Capital income & No \\
          & +     & Rental income & No \\
          & +     & Other incomes (pensions)* & No \\
    \textbf{2} & - & \textbf{Social security contributions} & Yes \\
          & \multicolumn{1}{r}{} & \textbf{ (Old-age pensions+ employee unemployment insurance+ employee health insurance)} & \multicolumn{1}{r}{} \\
          & -     & Income tax & Yes \\
          & -     & Capital income tax & Yes \\
          & -     & Alimony advance payments & Yes \\
    \textbf{3} & +     & \textbf{Child benefit} & Yes \\
          & +     & Child-raising allowance (Child enhanced or additional Income) & Yes \\
          & +     & Unemployment benefits (no endogen. labor supply) & Yes \\
          & +     & Maternity allowance & Yes \\
    \textbf{4} & +     & \textbf{Housing allowance (HA)} & Yes \\
          & +     & Supplementary child allowance & Yes \\
          & +     & Social assistance for employable persons (SGB II) & Yes \\
          & +     & Social assistance for unemployable persons (SGB XII) & No \\
          & =     & \textbf{Net household income} & No \\
    \bottomrule
    \end{tabular}%

  {\raggedright \textit{Notes}:  \footnotesize \*{*}Nevertheless, the model predicts the (updated earning points for pension claims). This table refers to the latest features at the time of writing this paper, end of 2021. Supplementary child benefits (Kinderzuschlag) is also referred to as Child Enhanced or Additional Income.\par}
  \label{Tab:table1}
\end{table}%

我收到这个无法修复的 latex 错误,我需要让它消失

Package array Error: Illegal pream-token (3.5cm): `c' used.

./main.tex, 881‬
See the array package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.881 ...{tabular}{ r{3.5cm} p{5.50cm} p{5.50cm} }
                                              
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

我的序言中有与数组相关的部分

\usepackage{array}
\newcolumntype{P}[1]{>{\raggedleft\arraybackslash}p{#1}}

答案1

r{3.5cm}是错误。它只是rp{3.5cm}。可能你想要的是

 \begin{tabular}{ rc p{5.50cm} p{5.50cm} }

我不知道你的页面布局,所以我不知道什么适合,但我建议尝试这样的事情

\documentclass{article}
\usepackage{array,booktabs,tabularx,threeparttablex}
\begin{document}
\begin{table}[ht]
  \centering
  \begin{threeparttable}
    \caption{Table features}
    \begin{tabularx}\linewidth{ >{\bfseries} rc XX }
      \toprule
      & & \textbf{Income components } & \textbf{Determined in GETTSIM tax and transfer model?} \\
      \midrule
      1 & & \textbf{Earned income} & No \\
      & +     & Self-employed income & No \\
      & +     & Capital income & No \\
      & +     & Rental income & No \\
      & +     & Other incomes (pensions)\tnote{*} & No \\
      2 & - & \textbf{Social security contributions} & Yes \\
      & & \textbf{ (Old-age pensions+ employee unemployment insurance+ employee health insurance)} & \\
      & -     & Income tax & Yes \\
      & -     & Capital income tax & Yes \\
      & -     & Alimony advance payments & Yes \\
      3 & +     & \textbf{Child benefit} & Yes \\
      & +     & Child-raising allowance (Child enhanced or additional Income) & Yes \\
      & +     & Unemployment benefits (no endogen. labor supply) & Yes \\
      & +     & Maternity allowance & Yes \\
      4 & +     & \textbf{Housing allowance (HA)} & Yes \\
      & +     & Supplementary child allowance & Yes \\
      & +     & Social assistance for employable persons (SGB II) & Yes \\
      & +     & Social assistance for unemployable persons (SGB XII) & No \\
      & =     & \textbf{Net household income} & No \\
      \bottomrule
    \end{tabularx}
    
    \footnotesize
    \begin{tablenotes}[para]
      \item[] \textit{Notes}
      \item[*] Nevertheless, the model predicts the (updated earning points for pension claims). This table refers to the latest features at the time of writing this paper, end of 2021. Supplementary child benefits (Kinderzuschlag) is also referred to as Child Enhanced or Additional Income.
    \end{tablenotes}
    \label{Tab:table1}
  \end{threeparttable}
\end{table}
\end{document}

每列X将设置为可用宽度的一半,其中总宽度\linewidth包括前两列(r)和(c)以及后两X列。

该软件包tabularx可以实现此功能。

为了帮助做笔记,我会使用 或threeparttablethreeparttablex这可以提供更好的间距,并且更容易正确排版标记。

最后,>{\bfseries}r使用包>中的array选项将该列中的每个单元格格式化为粗体,这样,如果您改变主意,事情会变得更容易,并且源代码也不会那么混乱。

[不幸的是,由于 Okular-on-X 错误,图像不可用,所以如果您想查看结果,我要求您编译或想象输出。]

答案2

\begin{tabular}{ r{3.5cm} p{5.50cm} p{5.50cm} } rrightp表示paragraph的长度,由 的参数给出。您还可以使用 和。pc您的代码中,之后是语法错误,因为只有一个段落可以有一个参数。centerlleft{3.5cm}r

答案3

我建议你采用基于的设置,表格的tabularx整体目标宽度为,自动\textwidth大胆的\addlinespace在第 1 列中,在第 2 列中为自动数学模式。此外,在主要信息组之间提供一些垂直空白(通过指令)。

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx,booktabs}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}
\begin{table}[ht]

\caption{Table features} \label{Tab:table1}

\smallskip
\begin{tabularx}{\textwidth}{@{}
    >{\bfseries}l %% automatic **bold-facing**
    >{$}c<{$}     %% automatic math mode
    P{7cm} % allow automatic line-breaking
    >{\raggedright\arraybackslash}X @{}}

\toprule
& & \textbf{Income components} & \textbf{Determined in GETTSIM tax and transfer model?} \\
\midrule
1 &   & \textbf{Earned income} & No \\
  & + & Self-employed income & No \\
  & + & Capital income & No \\
  & + & Rental income & No \\
  & + & Other incomes (pensions)* & No \\
\addlinespace

2 & - & \textbf{Social security contributions} & Yes \\
  &   & (Old-age pensions + employee unemployment insurance + employee health insurance) &  \\
  & - & Income tax & Yes \\
  & - & Capital income tax & Yes \\
  & - & Alimony advance payments & Yes \\
\addlinespace

3 & + & \textbf{Child benefit} & Yes \\
  & + & Child-raising allowance (Child enhanced or additional Income) & Yes \\
  & + & Unemployment benefits (no endogen. labor supply) & Yes \\
  & + & Maternity allowance & Yes \\
\addlinespace

4 & + & \textbf{Housing allowance (HA)} & Yes \\
  & + & Supplementary child allowance & Yes \\
  & + & Social assistance for employable persons (SGB II) & Yes \\
  & + & Social assistance for unemployable persons (SGB XII) & No \\
\addlinespace

  & = & \textbf{Net household income} & No \\
\bottomrule
\end{tabularx}

\smallskip
\raggedright 
\footnotesize
* Nevertheless, the model predicts the (updated earning points for pension claims). 

\textit{Notes}: This table refers to the latest features at the time of writing this paper, end of 2021. Supplementary child benefits (Kinderzuschlag) is also referred to as Child Enhanced or Additional Income.
  
\end{table}%

\end{document}

相关内容