我有这个:
我希望第一个项目与其他单元格垂直对齐。我该怎么做?这里提供的答案建议使用topsep
和partopsep
:
但正如您在我的代码中看到的,它没有任何效果:
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{adjustbox}
\usepackage{enumitem}
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\begin{table}\small
\centering
\caption{Summary of proven determinants for falling}
\label{tab:FallPredictionVariables}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\begin{tabularx}{\textwidth}{lcY}
\textbf{Author} &\textbf{Subject count (M:F)} & \centering\arraybackslash\textbf{Determinants}\\
\firsthline\\
? &
311 (?) &
\begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Posture sway
\item Two or more falls in previous year
\item Low hand grip strength
\item Depressive state of mind
\end{itemize}\\\\
\lasthline\\
\end{tabularx}
\end{table}
\end{document}
正如过去的问题中提到的,我知道可以使用\setitemize
,但我不想全局设置它,只想为这个表在本地设置。
答案1
实际上,我会\setlength\extrarowheight{3pt}
在线条下方留出一点空间。
切勿使用\\
,否则\hline
将导致错误结果。
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{adjustbox}
\usepackage{enumitem}
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\begin{table}\small
\centering
\caption{Summary of proven determinants for falling}
\label{tab:FallPredictionVariables}
\newcolumntype{Y}{>{\raggedright\arraybackslash}X}
\begin{tabularx}{\textwidth}{lcY}
\textbf{Author} &\textbf{Subject count (M:F)} & \centering\arraybackslash\textbf{Determinants}\\
\firsthline
? &
311 (?) &\mbox{}\par\vspace{-\baselineskip}
\begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Posture sway
\item Two or more falls in previous year
\item Low hand grip strength
\item Depressive state of mind
\end{itemize}\\
\lasthline
\end{tabularx}
\end{table}
\end{document}
答案2
我发现有两个问题。一个是你不想使用 after \\
。\firsthline
这就是添加初始额外行的原因。但此外,itemize 环境想要添加初始空间,Stefan Kottwitz 展示了如何通过将 itemize 放入 minipage 中来避免这种情况(防止 itemize 环境插入初始垂直空间)。
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{adjustbox}
\usepackage{enumitem}
\usepackage{array}
\usepackage{tabularx}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\begin{table}\small
\centering
\caption{Summary of proven determinants for falling}
\label{tab:FallPredictionVariables}
\newcolumntype{Y}{>{\compress\raggedright\arraybackslash}X}
\begin{tabularx}{\textwidth}{lcY}
\textbf{Author} &\textbf{Subject count (M:F)} & \centering\arraybackslash\textbf{Determinants}\\
\firsthline
? &
311 (?) &
\begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Posture sway
\item Two or more falls in previous year
\item Low hand grip strength
\item Depressive state of mind
\end{itemize}\\\\
\lasthline\\
\end{tabularx}
\end{table}
\end{document}