我试图将一些列表放入一个表格中,这似乎比我想象的要难。
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{calc}
\usepackage{array}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1\textwidth-2\tabcolsep}}
\renewcommand{\arraystretch}{1.3}
\usepackage{enumitem}
\begin{document}
\begin{table}[t]
\centering
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{label=\textbullet,
nosep,
after=\strut,
align=parleft,
leftmargin=*,
after=\vspace{-\baselineskip},
before=\vspace{-0.75\baselineskip}}
\newcommand*{\listone}{\begin{tabitemize}
\item \textit{a}
\item \textit{b}
\item \textit{c}
\end{tabitemize}}
\newcommand*{\listtwo}{\begin{tabitemize}
\item \textit{d}
\item \textit{e}
\item \textit{f}
\end{tabitemize}}
\newcommand*{\listthree}{\begin{tabitemize}
\item \textit{g}
\end{tabitemize}}
\newcommand*{\mergedlist}{\begin{tabitemize}
\item \textit{1}
\item \textit{2}
\item \textit{3}
\item \textit{4}
\end{tabitemize}}
\begin{tabular}{{P{0.25}P{0.36}P{0.35}}}
\toprule
\textbf{Row A} & \textbf{Row B} & \textbf{Row C} \\ \midrule
\listone & \listtwo & \listthree \\ \midrule
& \mergedlist & \\
\bottomrule\hline
\end{tabular}
\caption{Lorem Ipsum.}
\label{tab:some_table}
\end{table}
\end{document}
现在我想让列表居中,让数字位于其所在行。我该如何实现呢?
答案1
与您的原始代码相比,我在类型列的定义中用\raggedright
替换了。此外,我还更改了列表的和键,以便在列表周围放置 。如果小页面的宽度刚好足以容纳其内容,则列表将显示在列的中央。必须手动确定适当的宽度。\centering
P
before
after
tabitemize
minipage
\documentclass[12pt, a4paper, twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{calc}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1\textwidth-2\tabcolsep}}
\renewcommand{\arraystretch}{1.3}
\usepackage{enumitem}
\begin{document}
\begin{table}[t]
\centering
\newlist{tabitemize}{itemize}{1}
\setlist[tabitemize]{label=\textbullet,
nosep,
after=\strut,
align=parleft,
leftmargin=*,
after=\end{minipage},
before=\begin{minipage}[t]{2em}}
\newcommand*{\listone}{\begin{tabitemize}
\item \textit{a}
\item \textit{b}
\item \textit{c}
\end{tabitemize}}
\newcommand*{\listtwo}{\begin{tabitemize}
\item \textit{d}
\item \textit{e}
\item \textit{f}
\end{tabitemize}}
\newcommand*{\listthree}{\begin{tabitemize}
\item \textit{g}
\end{tabitemize}}
\newcommand*{\mergedlist}{\begin{tabitemize}
\item \textit{1}
\item \textit{2}
\item \textit{3}
\item \textit{4}
\end{tabitemize}}
\begin{tabular}{{P{0.25}P{0.36}P{0.35}}}
\toprule
\textbf{Row A} & \textbf{Row B} & \textbf{Row C} \\ \midrule
\listone & \listtwo & \listthree \\ \midrule
& \mergedlist & \\
\bottomrule\hline
\end{tabular}
\caption{Lorem Ipsum.}
\label{tab:some_table}
\end{table}
\end{document}