带有项目符号列表的表格缺少 \endgroup 错误

带有项目符号列表的表格缺少 \endgroup 错误

我试图在 tabulary 类型的表中插入项目符号列表,但它总是引发以下错误!

 Missing \endgroup inserted.
 <inserted text> 
         \endgroup
       \end{tabulary}

使用的代码:

\usepackage{tabulary}
%%
\begin{center}
   \begin{tabulary}{0.7\textwidth}{|L|L|}
        \hline
     First Title & Second Title \\ 
     \hline
      Text  &  \begin{itemize}
                \item PointOne
                \item PointTwo
              \end{itemize} \\
    \hline
   \end{tabulary}
\end{center}

我已经用 关闭了每一个\begin\end并且我尝试对表格类型进行相同的操作tabular,并且它有效。

答案1

我确信这一定在tabulary文档的某处有记录......

\documentclass{article}
\usepackage{tabulary}
\makeatletter
\def\TY@tab{%
  \setbox\z@\hbox\bgroup
  \let\[$\let\]$%
  \let\equation$\let\endequation$%
\let\@itemdepth\count@
\let\itemize\endgraf
\let\enditemize\endgraf
\let\endenumerate\endgraf
\let\list\@gobbletwo\renewcommand\item[1][]{}%
\let\endlist\endgraf
\let\trivlist\endgraf
\let\endtrivlist\endgraf
    \col@sep\tabcolsep
    \let\d@llarbegin\begingroup\let\d@llarend\endgroup
    \let\@mkpream\TY@mkpream
      \def\multicolumn##1##2##3{\multispan##1\relax}%
    \CT@start\TY@tabarray}
\makeatother


\begin{document}
\begin{center}


   \begin{tabulary}{0.7\textwidth}{|L|J|}
        \hline
     First Title & Second Title \\ 
     \hline
      Text  &  \begin{itemize}
                \item PointOne
                \item PointTwo
              \end{itemize} \\
    \hline
   \end{tabulary}

   \begin{tabular}{|p{3cm}|p{5cm}|}
        \hline
     First Title & Second Title \\ 
     \hline
      Text  &  \begin{itemize}
                \item PointOne
                \item PointTwo
              \end{itemize} \\
    \hline
   \end{tabular}

\end{center}
\end{document}

答案2

也可以让它与环境一起工作varwidth。我添加了enumitem包来控制 itemize 参数,并cellspace确保给定列中单元格内容上方和下方的垂直间距最小:在说明符S之前添加预说明符L

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[debugshow]{tabulary}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{pbox, varwidth}
\usepackage{cellspace}
\usepackage{enumitem}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\addparagraphcolumntypes{L}
\usepackage{makecell}
\newcommand*{\topdblline}{\Xhline{0.15ex}\\[-2.6ex]\hline}
\newcommand*{\botdblline}{\hline\\[-2.6ex]\Xhline{0.15ex}}

\begin{document}

\centering
%%
\begin{tabulary}{0.7\textwidth}{|L|SL|}
    \hline
 First Title & Second Title \\
 \hline
  Text & \begin{varwidth}{0.7\textwidth}
  \begin{itemize}[wide, itemsep =0.25ex]
\item PointOne
\item PointTwo
\end{itemize}
\end{varwidth}
\\
\hline
\end{tabulary}
\end{document} 

在此处输入图片描述

相关内容