在 longtable 中逐项列出

在 longtable 中逐项列出

我有以下(不起作用的)示例。

\renewcommand*{\arraystretch}{1.8}
\begin{longtable}{lcl}
    \caption{Summary of proven determinants for falling}\\ \toprule
    \label{tab:FallPredictionVariables}
    \textbf{Author} &\textbf{Subject count (M:F)} & \textbf{Determinants}\\
    \midrule

    \noindent Author 1 &
    1780 (?) & 
    \begin{itemize}%[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
        \item Recent falls (last 2 months)
        \item Agitation
        \item Frequent toileting
        \item Visual impairment
    \end{itemize}\\

    \noindent Author 2 &
    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}\\
        \bottomrule

\end{longtable}

但是,它在longtable环境之外可以正常工作:

\renewcommand*{\arraystretch}{1.8}
\begin{table}
\centering
    \caption{Summary of proven determinants for falling} 
    \label{tab:FallPredictionVariables}
    \begin{tabular}{lcp{60mm}}
    \toprule
    \textbf{Author} &\textbf{Subject count (M:F)} & \textbf{Determinants}\\
    \midrule

    \noindent Author 1 &
    1780 (?) & 
    \begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
        \item Recent falls (last 2 months)
        \item Agitation
        \item Frequent toileting
        \item Visual impairment
    \end{itemize}\\

    \noindent Author 2 &
    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}\\
        \bottomrule

        \end{tabular}

\end{table}

正如你在下图中看到的那样,它实现了我所期望的(除了我想要删除的第一个项目上有一些垂直空间,解决方案发布在如何减少表格内垂直空间逐项环境似乎只适用于tabularx环境)。

在此处输入图片描述

我无法让我的代码在里面工作longtable,但我确实需要它(完整的表格很长)。

对于这两件事有什么想法:

  1. 能够在longtable环境中拥有 itemize
  2. 消除第一项的多余空间

PS:这是两个例子的序言:

\documentclass[a4paper,twoside,11pt,openright]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}  
\usepackage[inline]{enumitem}   
\usepackage{booktabs}

\begin{document}
...
\end{document}

答案1

在没有完整的 MWE 的情况下,我从Przemysław Scherwentke 的回答

在此处输入图片描述

\documentclass{report}
\usepackage{longtable}% http://ctan.org/pkg/longtable
\usepackage{array,booktabs,enumitem}% http://ctan.org/pkg/{array,booktabs,enumitem}
\newcolumntype{P}[1]{>{\endgraf\vspace*{-\baselineskip}}p{#1}}

\begin{document}

\renewcommand*{\arraystretch}{1.8}
\begin{longtable}{p{4cm}p{4cm}P{6cm}}
  \caption{Summary of proven determinants for falling}\label{tab:FallPredictionVariables} \\
  \toprule
  \textbf{Author} &\textbf{Subject count (M:F)} & \multicolumn{1}{l}{\textbf{Determinants}} \\
  \midrule

  \noindent Author 1 &
  1780 (?) & 
  \begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
    \item Recent falls (last 2 months)
    \item Agitation
    \item Frequent toileting
    \item Visual impairment
  \end{itemize}\\

  \noindent Author 2 &
  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}\\
  \bottomrule
\end{longtable}

\end{document}

P{<len>}类型(得益于array) 插入“垂直取消跳过”,以便第一项与表格的其余部分正确对齐。

P当然,假设最后一列只包含列表。如果不是,\multicolumn则必须像标题一样发出单独的决定因素

答案2

以下是一个工作示例。由于lcr是针对单行条目的,因此itemize不应该与它们一起使用。将改进的第一部分与未更改的第二部分进行比较。

\documentclass[a4paper,twoside,11pt,openright]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}  
%\usepackage[inline]{enumitem}   
\usepackage{enumitem}   
\usepackage{booktabs}


\begin{document}

\renewcommand*{\arraystretch}{1.8}
%\begin{longtable}{lcl}
\begin{longtable}{p{4cm}p{4cm}p{6cm}}
    \caption{Summary of proven determinants for falling}\\ \toprule
    \label{tab:FallPredictionVariables}
    \textbf{Author} &\textbf{Subject count (M:F)} & \textbf{Determinants}\\
    \midrule

    \noindent Author 1 &
    1780 (?) & \vspace{-\baselineskip}
    \begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
        \item Recent falls (last 2 months)
        \item Agitation
        \item Frequent toileting
        \item Visual impairment
    \end{itemize}\\

    \noindent Author 2 &
    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}\\
        \bottomrule

\end{longtable}

\end{document}

在此处输入图片描述

答案3

我认为你可以实现这种效果而不需要破解itemize。只需使用表格的多行:

\documentclass{report}
\usepackage{longtable}% http://ctan.org/pkg/longtable
\usepackage{array,booktabs}

\begin{document}

\begin{longtable}{p{4cm}p{4cm}>{-- }p{6cm}}
  \caption{Summary of proven determinants for falling}\label{tab:FallPredictionVariables} \\
  \toprule
  \textbf{Author} &\textbf{Subject count (M:F)} & \multicolumn{1}{l}{\textbf{Determinants}} \\
  \midrule

  \noindent 
  Author 1 & 1780 (?) & Recent falls (last 2 months) \\
           &          & Agitation                    \\
           &          & Frequent toileting           \\ 
           &          & Visual impairment            \\[1.8\baselineskip]

  Author 2 & 311 (?)  & Posture sway                 \\
           &          & Two or more falls in previous year \\
           &          & Low hand grip strength \\
           &          & Depressive state of mind \\               
\end{longtable}
\end{document}

示例代码输出

相关内容