如何使用 itemize 环境功能绘制表格

如何使用 itemize 环境功能绘制表格

我想在单元格内绘制带有逐项列举功能的下表为了做到这一点,我认为如果我添加此代码它就会起作用,但事实并非如此

\setlist[itemize]{nosep,
              topsep= 0pt,
              partopsep=0pt,
              leftmargin= *,
              label=\textendash,
              before=\vspace{-0.6\baselineskip},
              after=\vspace{-\baselineskip}
              }

下面是绘制表格的代码,我想在该表格的单元格内添加项目化环境

   \begin{center}
\bfseries
\settowidth\rotheadsize{Title 1}
\begin{tabularx}{\linewidth}{|c|>{\centering\arraybackslash}X|}
    %\hline
%\multicolumn{3}{|>{\centering\arraybackslash}%
                 %p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}{\cellcolor{gray!30}
    %Title 2}    \\
    \hline
\cellcolor{gray!30} Cell 1 & \cellcolor{gray!30} Cell 2     \\
    \hline
\multirow[b]{3}{*}{Info 2}   
            & very long text but centered
 \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
   & very long text but centered
   \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
    &  very long text but centered   \rule[-1em]{0pt}{2.5em} \\
    \hline
        \multirow[b]{3}{*}{Info 2}   
            & very long text but centered
 \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
   & \begin{itemize}
    -     \item very long text 
          \item very long text 
    \end{itemize}
   \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
    &     \rule[-1em]{0pt}{2.5em} \\
    \hline
\end{tabularx}
    \end{center}

答案1

这是你想要的吗?

     \documentclass{article}
    \usepackage{tabularx}
    \usepackage{amsmath}
    \usepackage[table]{xcolor}
    \usepackage{tabularx, multirow, makecell, rotating} %
    \usepackage{enumitem}
    \makeatletter
    \newcommand*{\compress}{\@minipagetrue}
    \makeatother

    \begin{document}

     \begin{center}
    \bfseries\setlength{\extrarowheight}{3pt}
    \settowidth\rotheadsize{Title 1}
    \setlist[itemize]{nosep,
                  topsep= 0pt,
                  partopsep=0pt,
                  leftmargin= *,
                  label=\textendash,
                  after=\vspace{-\baselineskip}
                  }
    \begin{tabularx}{\linewidth}{|c|>{\centering\arraybackslash\compress}X|}
        \hline
    \rowcolor{gray!30} Cell 1 & Cell 2 \\
        \hline
    \multirow[b]{3}{*}{Info 2}
                & very long text but centered
     \rule[-1em]{0pt}{2.5em} \\
        \cline{2-2}
       & very long text but centered
      \rule[-1em]{0pt}{2.5em} \\
        \cline{2-2}
        & very long text but centered \rule[-1em]{0pt}{2.5em} \\
        \hline
            \multirow[b]{3}{*}{Info 2}
                & very long text but centered
     \rule[-1em]{0pt}{2.5em} \\
        \cline{2-2}
       & \begin{itemize}
      \item very long text
     \item very long text
     \end{itemize}
     \rule[-1em]{0pt}{2.5em}
      \\
        \cline{2-2}
        & \rule[-1em]{0pt}{2.5em} \\
        \hline
    \end{tabularx}
    \end{center}

    \end{document} 

在此处输入图片描述

相关内容