我想使用表格作为标题列和文本列,文本列将是枚举列表。但是,当我开始列表时,它似乎会自动为 \list 文本开始一条新的水平线。这可以与标题列文本对齐吗?以下是我尝试过的一些代码和编译结果...
\documentclass{article}
\usepackage{enumitem}
\usepackage[left=1in, right=1in, bottom=0.7in, top=0.7in]{geometry}
\begin{document}
\begin{tabular}{ p{1in} p{5in} }
Top left cell & \begin{enumerate}[itemindent=-20pt]
\item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
\item Thank you!
\end{enumerate} \\
\end{tabular}
\end{document}
答案1
欢迎来到 TeX.SE 社区!
一个可能的解决方案是将enumerate
列表括在 中minipage
。这可以通过使用enumitem
包选项before
和来完成after
:
\documentclass{article}
\usepackage[hmargin=1in, vmargin=0.7in]{geometry}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{tabular}{% this will have effect in each tabular
\setlist[enumerate]{before=\begin{minipage}[t]{\linewidth}, % <---
after =\end{minipage} % <---
} }
\begin{document}
\begin{tabular}{ p{1in} p{5in} }
Top left cell & \begin{enumerate}
\item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
\item Thank you!
\end{enumerate} \\
\end{tabular}
\end{document}
附录:
另一种可能性是使用小页面来扩展列规范p{...}
:
\documentclass{article}
\usepackage[hmargin=1in, vmargin=0.7in]{geometry}
\usepackage{array}
\usepackage{enumitem}
\begin{document}
\begin{tabular}{ p{1in} >{\csname @minipagetrue\endcsname}p{5in} } % <---
Top left cell & \begin{enumerate}
\item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
\item Thank you!
\end{enumerate}
\end{tabular}
\end{document}
编译结果和之前一样。
答案2
\documentclass{article}
\usepackage{enumitem}
\usepackage[left=1in, right=1in, bottom=0.7in, top=0.7in]{geometry}
\begin{document}
\begin{tabular}{ p{1in} p{5in} }
\begin{enumerate}[wide=0pt]\item[] Top left cell\end{enumerate} & \begin{enumerate}[]
\item Is it possible to get this text to line up horizontally with the top left cell when using enumerate?
\item Thank you!
\end{enumerate} \\
\end{tabular}
\end{document}