7

I have this:

enter image description here

I want for the first item to be vertically aligned with my other cells. How can I do it? The answers provided here suggested to play with topsep and partopsep:

How can I change behaviour of enumitem?

How to get rid of vertical space before and behind the lists

How to reduce space after the end of a tabbing environment

But as you can see in my code, it has no effect:

\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}

As mentioned in the past questions, I know it is possible to use \setitemize, but I don't want to set this globally, just locally for this table.

10

enter image description here

In practice I would add \setlength\extrarowheight{3pt} to give a bit of space under the lines.

Never use \\ after \hline it will do the wrong thing.

\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}
3
  • Where would you write the \setlength\extrarowheight{3pt}? Is this definition just local? – Mario S. E. May 15 '13 at 12:27
  • 1
    \setlength is always a local definition so set in in the preamble to affect all tables in the document or after \begin{table} and before \begin{tabular} to affect just this one. – David Carlisle May 15 '13 at 12:36
  • Will this affect just the first space between \firsthline and the first data row or will it affect all spaces between rows, like arraystrech does? – Mario S. E. May 15 '13 at 12:50
7

There were two problems I found. One is that you don't want to use a \\ after \firsthline. That's what added the initial extra row. But also, the itemize environment wants to add that initial space, which Stefan Kottwitz shows how to avoid by putting the itemize into a minipage (Preventing itemize environment to insert initial vertical space).

\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}

enter image description here

2
  • Any ideas on how to give a little extra room after the \firsthline? – Mario S. E. May 15 '13 at 12:40
  • @MarioS.E. \setlength\extrarowheight{2pt} after the \begin{table} will do it. This is what David Carlisle also mentioned in his solution. – Steven B. Segletes May 15 '13 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.