tabularx 中的 noalign

tabularx 中的 noalign
\begin{table}[H]
\center
\begin{tabularx}{\textwidth}{| l | X |}
    \hline
    \textbf{Daten} & \textbf{XXX}
    \hline
    \textit{Crawler} & 
        \begin{itemize}
            \item task
            \item crawl
        \end{itemize} \\
    \textit{Disk} & 
        \begin{itemize}
            \item flash
        \end{itemize} \\
    \hline
\end{tabularx}
\caption
[test2]
{test1}
\label{tab:test}
\end{table} 

这给了我以下错误:!放错 \noalign。 \hline ->\noalign

有人能帮我吗?我对 LaTeX 还不太熟悉

答案1

你错过了一个\\......(如上面的评论所述)。

离题:看看以下变化(基于添加的软件包)是否让您感兴趣:

\documentclass[12pt]{article}
\usepackage{tabularx}
\usepackage{enumitem} % added
\usepackage{etoolbox} % added
\AtBeginEnvironment{table}{%
         \setlist[itemize]{ nosep,     % <-- new list setup
                            topsep     = 0pt,
                            partopsep  = 0pt,
                            leftmargin = *,
                            before     = \vspace{-0.6\baselineskip},
                            after      = \vspace{-\baselineskip}
                            }}
\usepackage[labelfont=bf, textfont=bf]{caption}

\begin{document}
    \begin{table}[ht] % changed
\centering % changed/corrected
\begin{tabularx}{\textwidth}{| l | X |}
\hline
\textbf{Daten} & \textbf{XXX}       \\ % <--- missing \\
\hline
\textit{Crawler} &
    \begin{itemize}
        \item task
        \item crawl
    \end{itemize} \\
\textit{Disk} &
    \begin{itemize}
        \item flash
    \end{itemize} \\
\hline
\end{tabularx}
\caption
[test2]
{test1}
\label{tab:test}
    \end{table}
\end{document}

在此处输入图片描述

注意:表格的标题通常位于表格上方。要实现这一点,只需将标题移到前面即可tabularx

相关内容