不能使用方括号

不能使用方括号
\begin{table}[ht]
\label{tab:intro}
\caption{Anonymized data - output example}
\begin{tabular}{llll}
\toprule    
      Age & SEX & ETHNIC & STUDIES \\
\midrule
    * &   * &      * &       * \\
   42 &   1 &      1 &       7 \\
   40 &   1 &      1 &       7 \\
   45 &   1 &      1 &       7 \\
 [48, 51[ &   2 &      1 &     <=3 \\
 [48, 51[ &   1 &      1 &     <=3 \\
    * &   * &      * &       * \\
 [60, 63[ &   2 &      6 &     <=6 \\
   58 &   1 &      1 &       5 \\
    * &   * &      * &       * \\
\bottomrule
\end{tabular}
\end{table}

如果我删除 [,一切都会正常工作,但我需要放置它们。

这是错误:

! Paragraph ended before \@argarraycr was complete.

答案1

正如在回答中已经解释的那样表格错误\relax\\以 开头的行之前添加[,可以解决问题:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[ht]
\label{tab:intro}
\caption{Anonymized data - output example}
\begin{tabular}{llll}
\toprule    
      Age & SEX & ETHNIC & STUDIES \\
\midrule
    * &   * &      * &       * \\
   42 &   1 &      1 &       7 \\
   40 &   1 &      1 &       7 \\
   45 &   1 &      1 &       7 \\\relax
 [48, 51[ &   2 &      1 &     <=3 \\\relax
 [48, 51[ &   1 &      1 &     <=3 \\
    * &   * &      * &       * \\\relax
 [60, 63[ &   2 &      6 &     <=6 \\
   58 &   1 &      1 &       5 \\
    * &   * &      * &       * \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

顺便说一句:如示例所示,<在文本模式下不会导致 <。您应该使用\textless

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[ht]
\label{tab:intro}
\caption{Anonymized data - output example}
\begin{tabular}{llll}
\toprule    
      Age & SEX & ETHNIC & STUDIES \\
\midrule
    * &   * &      * &       * \\
   42 &   1 &      1 &       7 \\
   40 &   1 &      1 &       7 \\
   45 &   1 &      1 &       7 \\\relax
 [48, 51[ &   2 &      1 &     \textless=3 \\\relax
 [48, 51[ &   1 &      1 &     \textless=3 \\
    * &   * &      * &       * \\\relax
 [60, 63[ &   2 &      6 &     \textless=6 \\
   58 &   1 &      1 &       5 \\
    * &   * &      * &       * \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

或数学模式:

\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath}
\begin{document}
\begin{table}[ht]
\label{tab:intro}
\caption{Anonymized data - output example}
\[
\begin{array}{llll}
\toprule    
      \text{Age} & \text{SEX} & \text{ETHNIC} & \text{STUDIES} \\
\midrule
    * &   * &      * &       * \\
   42 &   1 &      1 &       7 \\
   40 &   1 &      1 &       7 \\
   45 &   1 &      1 &       7 \\\relax
 [48, 51[ &   2 &      1 &     \leq 3 \\\relax
 [48, 51[ &   1 &      1 &     \leq 3 \\
    * &   * &      * &       * \\\relax
 [60, 63[ &   2 &      6 &     \leq 6 \\
   58 &   1 &      1 &       5 \\
    * &   * &      * &       * \\
\bottomrule
\end{array}\]
\end{table}
\end{document}

答案2

感谢用户124577:

\begin{table}[ht]
\label{tab:intro}
\caption{Anonymized data - output example}
\begin{tabular}{llll}
\toprule
  Age & SEX & ETHNIC & STUDIES \\
\midrule
    * &   * &      * &       * \\
   42 &   1 &      1 &       7 \\
   40 &   1 &      1 &       7 \\
   45 &   1 &      1 &       7 \\[0pt]
 [48, 51[ &   2 &      1 &     <=3 \\[0pt]
[48, 51[ &   1 &      1 &     <=3 \\
    * &   * &      * &       * \\[0pt]
[60, 63[ &   2 &      6 &     <=6 \\
   58 &   1 &      1 &       5 \\
    * &   * &      * &       * \\
\bottomrule
\end{tabular}
\end{table}

相关内容