Latex 使用环境生成表-“;错位对齐选项卡字符;错误

Latex 使用环境生成表-“;错位对齐选项卡字符;错误,latex,Latex,我正在尝试创建一组简单的环境,以使表的创建更加容易和一致。 环境\observation生成空表。通过命令\subobbservation引入观测行。它使用一个\subobbservation命令,但我不知道如何插入多行。 在下面的代码示例中,我得到了一个“错位对齐选项卡字符”错误 我从这里得到了一些灵感来解决我的问题 \documentclass[11pt,a4paper]{article} \usepackage{lipsum} \newenvironment{observationta

我正在尝试创建一组简单的环境,以使表的创建更加容易和一致。 环境
\observation
生成空表。通过命令
\subobbservation
引入观测行。它使用一个
\subobbservation
命令,但我不知道如何插入多行。 在下面的代码示例中,我得到了一个“错位对齐选项卡字符”错误


我从这里得到了一些灵感来解决我的问题

\documentclass[11pt,a4paper]{article}
\usepackage{lipsum}

\newenvironment{observationtable}{
    \begin{center}
    \begin{tabular}{p{0.2\textwidth}p{0.6\textwidth}p{0.2\textwidth}}
    \hline\\
    }
    { 
    \end{tabular} 
    \end{center}
}

\newcommand{\subobservation}[3]{
    \textbf{#1} & #2 & \textbf{#3} \\
    \hline\\
    }

\newenvironment{observation}[1]{
    \textbf{#1}
    \begin{observationtable}
        1st Col & 2nd Col & 3rd Col \\
        \hline\\
    }{
    \end{observationtable}
    }

\begin{document}

\begin{observation}
    {An interesting collection of observation}
   \begin{subobservation}
        {some information}
        {\lipsum[1]}
        {another something}
    \end{subobservation}

    \begin{subobservation}
        {some 2nd information}
        {\lipsum[2]}
        {another 2nd something}
    \end{subobservation}

\end{observation}

\end{document}
\documentclass{article}

\usepackage{etoolbox}
\usepackage{booktabs}
\usepackage{lipsum}


\newbool{firstline}
\newenvironment{observation}[1]
    {%
    \subsection*{#1}
    \booltrue{firstline}%
    \begin{tabular}{p{0.15\textwidth}p{0.6\textwidth}p{0.15\textwidth}}
        \toprule\\
        \textbf{1st Col} & \textbf{2nd Col} & \textbf{3rd Col} \\ \\
        \toprule
        }
    {\\ \bottomrule\end{tabular}}

\newcommand{\subobservation}[3]{%
    \ifbool{firstline}{}{\\\midrule}%
    \global\boolfalse{firstline}\\
    #1
    &#2
    &#3
}

\begin{document}
    \begin{observation}
        {An interesting collection of observation}
        \subobservation
            {some information}
            {\lipsum[1]}
            {another something}
        \subobservation
            {some 2nd information}
            {\lipsum[2]}
            {another 2nd something}
    \end{observation}

\end{document}