为什么我不能将单元格垂直对齐到顶部?

为什么我不能将单元格垂直对齐到顶部?

使用此代码有效

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\singlespacing
\begin{longtable}{ L{3cm} L{4cm} L{4cm} L{4cm} L{4cm} }

\caption{Determination of whether studies' outcomes were concordant with any theoretical framework invoked} \label{tab:long} \\

\hline 
\multicolumn{1}{c}{\textbf{Study}} & \multicolumn{1}{c}{\textbf{Outcome 1}} & \multicolumn{1}{c}{\textbf{Outcome 2}} &
\multicolumn{1}{c}{\textbf{Theory invoked}} &
\multicolumn{1}{c}{\textbf{Determination}} \\ \hline 
\endfirsthead

\hline \multicolumn{1}{r}{{Continued on next page}} \\ \hline
\endfoot

\hline 
\multicolumn{1}{c}{\textbf{Study}} & \multicolumn{1}{c}{\textbf{Outcome 1}} & \multicolumn{1}{c}{\textbf{Outcome 2}}&
\multicolumn{1}{c}{\textbf{Theory invoked}}&
\multicolumn{1}{c}{\textbf{Determination}} \\ \hline 
\endhead

\hline \multicolumn{5}{r}{{Continued on next page}} \\ \hline
\endfoot

\hline \hline
\endlastfoot

Cassidy & Marijuana vaping with ENDS or otherwise in the past 30 days vs. none & X & X & X \\
Lozano & Past 12-month marijuana use vs. none & X & X & X \\
Dai & Past 12-month marijuana use vs. none & Weekly or more often use of marijuana, hash, THC, grass, pot, or weed vs. none & X & X \\ 
Audrain-McGovern & Past 30-day combustible marijuana use vs. not, marijuana vaping vs. not, and edible marijuana use vs. not & Ever combustible marijuana use vs. none, marijuana vaping vs. none, and edible marijuana use vs. none & X & X \\
Unger & Marijuana use in the past month & X & X & X \\
Park & Marijuana use in the last 6 months vs. none  & X & X & X \\
Wong & Past-month marijuana use at Wave 3 vs. none  & X & X & X \\
Rogers & Any marijuana use in the past 30 days vs. none  & X & X & X \\
Pokhrel & Past 12-month marijuana use vs. not  & X & X & X \\
Evans-Polce & Past 30-day nonmedical prescription tranquilizer, sedative, stimulant, or opioid use use  & X & X & X \\
Lee & Ever marijuana vaping in Wave 4 vs. none  & X & X & X \\
Butler & Cannabis use (at least monthly in the last 12 months) at T2  & X & X & X \\
Bentivegna & Past 12-month use of marijuana in Wave 2 or Wave 3  & X & X & X \\
Ksinan & Never cannabis use vs. cannabis use 1-5 times in the past 12 months vs. 6 or more times in the past 12 months  & X & X & X \\
Ortega & Ever use of marijuana vs. not at each of two follow-up years  & X & X & X \\
Seidel & Cannabis use: not at all vs. only a few puffs vs. 1-19 times vs. 20-100 times vs. more than 100 times  & X & X & X \\

\end{longtable}
\end{landscape}

如果我将 改为\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}并将\newcolumntype{P}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}中的 L 改为 P \begin{longtable}{ L{3cm} L{4cm} L{4cm} L{4cm} L{4cm} },则会出现错误。

答案1

L从列类型更改为P不会引发错误,但您的代码片段存在其他问题:在表序中您有两个定义foot

我会稍微重新设计一下你的桌子。我会:

  • 而不是使用包\hline 中定义的规则booktabs
  • 在行之间插入\addlinespace也在booktabs包中定义
  • 定义标题宽度等于文本宽度
  • 对于列标题,使用包\thead中定义的宏makecell
\documentclass{article}
\usepackage{booktabs, longtable, makecell}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{P}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\renewcommand\theadfont{\bfseries}
\usepackage{pdflscape}

\begin{document}
\begin{landscape}
\setlength\LTleft{0pt}
\setlength\LTcapwidth\linewidth

%\begin{longtable}{ L{3cm} *{4}{L{4cm}} }
\begin{longtable}{ P{3cm} *{4}{P{4cm}} }

\caption{Determination of whether studies' outcomes were concordant with any theoretical framework invoked} 
\label{tab:long}                            \\
    \toprule
\thead{Study}   & \thead{Outcome 1}         & \thead{Outcome 2} 
                & \thead{Theory invoked}    & \thead{Determination} \\ 
    \midrule
\endfirsthead
\caption[]{Determination of whether studies' outcomes were concordant with any theoretical framework invoked (cont.)}      \\
    \toprule
\thead{Study}   & \thead{Outcome 1}         & \thead{Outcome 2}
                & \thead{Theory invoked}    & \thead{Determination} \\
    \midrule
\endhead
    \midrule
\multicolumn{5}{r}{\footnotesize\textit{Continued on next page}}    \\ 
\endfoot
    \bottomrule
\endlastfoot

Cassidy     & Marijuana vaping with ENDS or otherwise in the past 30 days vs. none 
                & X & X & X     \\  \addlinespace
Lozano      & Past 12-month marijuana use vs. none 
                & X & X & X     \\  \addlinespace
Dai         & Past 12-month marijuana use vs. none 
                & Weekly or more often use of marijuana, hash, THC, grass, pot, or weed vs. none 
                    & X & X     \\  \addlinespace
Audrain-McGovern 
            & Past 30-day combustible marijuana use vs. not, marijuana vaping vs. not, and edible marijuana use vs. not 
                & Ever combustible marijuana use vs. none, marijuana vaping vs. none, and edible marijuana use vs. none 
                    & X & X     \\  \addlinespace
Unger       & Marijuana use in the past month 
                & X & X & X     \\  \addlinespace
Park        & Marijuana use in the last 6 months vs. none  
                & X & X & X     \\  \addlinespace
Wong        & Past-month marijuana use at Wave 3 vs. none  
                & X & X & X     \\  \addlinespace
Rogers      & Any marijuana use in the past 30 days vs. none  
                & X & X & X     \\  \addlinespace
Pokhrel     & Past 12-month marijuana use vs. not  
                & X & X & X     \\  \addlinespace
Evans-Polce & Past 30-day nonmedical prescription tranquilizer, sedative, stimulant, or opioid use
                & X & X & X     \\  \addlinespace
Lee         & Ever marijuana vaping in Wave 4 vs. none  
                & X & X & X     \\  \addlinespace
Butler      & Cannabis use (at least monthly in the last 12 months) at T2  
                & X & X & X     \\  \addlinespace
Bentivegna  & Past 12-month use of marijuana in Wave 2 or Wave 3  
                & X & X & X     \\  \addlinespace
Ksinan      & Never cannabis use vs. cannabis use 1-5 times in the past 12 months vs. 6 or more times in the past 12 months  
                & X & X & X     \\  \addlinespace
Ortega      & Ever use of marijuana vs. not at each of two follow-up years  
                & X & X & X     \\  \addlinespace
Seidel      & Cannabis use: not at all vs. only a few puffs vs. 1-19 times vs. 20-100 times vs. more than 100 times  
                & X & X & X     \\
\end{longtable}
\end{landscape}
\end{document}

在此处输入图片描述

所以我无法说出你的文档出了什么问题。

相关内容