如何在 Tablularx 中垂直和水平对齐左列?

如何在 Tablularx 中垂直和水平对齐左列?

我使用包创建了一个表格tabularx,并尝试垂直和水平对齐左列的内容。我该怎么做?

\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell}
\usepackage{booktabs}

\begin{document}
\begin{tabularx}{\linewidth}{l X}
    {\small\textbf{Column 1}}
    & {\small \textbf{Column 2}}\\
    \midrule
    \makecell{5} & \begin{itemize}
    \itemindent=-13pt
        \item Item 1
        \item Item 2
        \item Item 3
    \end{itemize}\\
  \end{tabularx}
\end{document}

当前输出如下所示:

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}
\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}   % <-- defined new list
\setlist[tabitem]{nosep,        % <-- new list setup
                  leftmargin=*,
                  label=$\bullet$,
                  after=\vspace{-\baselineskip},
                  before=\vspace{-0.5\baselineskip}
                  }

\usepackage{booktabs}

\begin{document}
\begin{tabularx}{\linewidth}{l X}
    \small\textbf{Column 1}
    & \small \textbf{Column 2}  \\
    \midrule
5   &   \begin{tabitem}
            \item Item 1
            \item Item 2
            \item Item 3
        \end{tabitem}\\
    \midrule
  \end{tabularx}
  
\end{document}

或者

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}
\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}   % <-- defined new list
\setlist[tabitem]{nosep,        % <-- new list setup
                  leftmargin=*,
                  label=$\bullet$,
                  after=\vspace{-\baselineskip},
                  }
\usepackage{booktabs}

\begin{document}
  
\begingroup
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{tabularx}{\linewidth}{l X}
    \small\textbf{Column 1}
    & \small \textbf{Column 2}  \\
    \midrule
5   &   \begin{tabitem}
            \item Item 1
            \item Item 2
            \item Item 3
        \end{tabitem}\\
    \midrule
  \end{tabularx}
\endgroup
  
\end{document}

相关内容