![长表中的几列垂直居中](https://linux22.com/image/296178/%E9%95%BF%E8%A1%A8%E4%B8%AD%E7%9A%84%E5%87%A0%E5%88%97%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD.png)
我想将此表中第二列(假设名称)的垂直对齐方式更改为居中,就像第一列一样。
我的最小示例:
\documentclass[a4paper,fontsize=12pt,a4paper,DIV=10,BCOR=10mm,twoside,titlepage=false,openany,pagesize]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{graphicx}
\usepackage[font=normalsize,labelfont=sc,singlelinecheck=false,justification=raggedright]{caption}
\usepackage[hyphens]{url}
\usepackage{setspace}
\usepackage{subfigure}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{feyn}
\usepackage[authoryear]{natbib}
\usepackage{chngcntr}
\usepackage{dcolumn}
\usepackage{amsmath}
\begin{document}
\fontsize{10pt}{11pt}\selectfont
\begin{longtable}[c]{l>{\centering\arraybackslash}p{0.2\textwidth}>{\centering\arraybackslash}p{0.4\textwidth}}
\captionsetup{justification=raggedright,width=.82\textwidth}
\caption{Hypotheses}
\label{tab:hypotheses}
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}}\\
\endhead
\midrule
\multirow{3}{*}{H1} & \textit{`lalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{7}{*}{H2} & \textit{`lalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{6}{*}{H2a} & \textit{`lalalalalalalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{6}{*}{H2b}& \textit{`lalalalalalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\bottomrule
\multicolumn{3}{l}{\small{\emph{Source: Author's depiction}}}\\
\end{longtable}
\normalsize
\end{document}
答案1
无论如何,你都在滥用\multirow
,因此再做一次吧;-)。
\documentclass[a4paper,fontsize=12pt,a4paper,DIV=10,BCOR=10mm,twoside,titlepage=false,openany,pagesize]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{graphicx}
\usepackage[font=normalsize,labelfont=sc,singlelinecheck=false,justification=raggedright]{caption}
\usepackage[hyphens]{url}
\usepackage{setspace}
\usepackage{subfigure}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{feyn}
\usepackage[authoryear]{natbib}
\usepackage{chngcntr}
\usepackage{dcolumn}
\usepackage{amsmath}
\newcommand{\level}[1]{%
\begin{tabular}{@{}>{\centering\arraybackslash}p{0.2\textwidth}@{}}
\strut#1\strut
\end{tabular}%
}
\begin{document}
\fontsize{10pt}{11pt}\selectfont
\begin{longtable}[c]{l>{\centering\arraybackslash}p{0.2\textwidth}>{\centering\arraybackslash}p{0.4\textwidth}}
\captionsetup{justification=raggedright,width=.82\textwidth}
\caption{Hypotheses}
\label{tab:hypotheses}
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}}\\
\endhead
\midrule
\multirow{3}{*}{H1} & \multirow{3}{*}{\level{\textit{`lalalala' hypothesis}}} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{7}{*}{H2} & \multirow{7}{*}{\level{\textit{`lalalala' hypothesis}}} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{6}{*}{H2a} & \multirow{6}{*}{\level{\textit{`lalalalalalalalala' hypothesis}}} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
\multirow{6}{*}{H2b}& \multirow{6}{*}{\level{\textit{`lalalalalalalala' hypothesis}}} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\bottomrule
\multicolumn{3}{l}{\small{\emph{Source: Author's depiction}}}\\
\end{longtable}
\normalsize
\end{document}
以下不滥用\multirow
。
\documentclass[a4paper,fontsize=12pt,a4paper,DIV=10,BCOR=10mm,twoside,titlepage=false,openany,pagesize]{scrbook}
\usepackage[T1]{fontenc}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage[font=normalsize,labelfont=sc,singlelinecheck=false,justification=raggedright]{caption}
\usepackage{setspace}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\usepackage{array}
\usepackage{booktabs}
\newcommand{\level}[1]{%
\begin{tabular}{@{}>{\centering\arraybackslash}p{0.4\textwidth}@{}}
\strut#1\strut
\end{tabular}%
}
\newcommand{\levell}[1]{%
\begin{tabular}{@{}>{\centering\arraybackslash}p{0.2\textwidth}@{}}
\strut#1\strut
\end{tabular}%
}
\begin{document}
\fontsize{10pt}{11pt}\selectfont
\begin{longtable}[c]{l>{\centering\arraybackslash}p{0.2\textwidth}>{\centering\arraybackslash}p{0.4\textwidth}}
\captionsetup{justification=raggedright,width=.82\textwidth}
\caption{Hypotheses}
\label{tab:hypotheses}
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}}\\
\endhead
\midrule
H1 & \levell{\textit{`lalalala' hypothesis}} & \level{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.} \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2 & \levell{\textit{`lalalala' hypothesis}} & \level{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec.} \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2a & \levell{\textit{`lalalalalalalalala' hypothesis}} & \level{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.} \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2b& \levell{\textit{`lalalalalalalala' hypothesis}} & \level{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.} \\
\bottomrule
\multicolumn{3}{l}{\small{\emph{Source: Author's depiction}}}\\
\end{longtable}
\normalsize
\end{document}
请注意\level
和\levell
不同。
答案2
表格m{}
对齐方式array
包(您已经加载)就是为此而制作的。将您的表规范更改为:
\begin{longtable}[c]{>{\centering\arraybackslash}m{0.1\textwidth}>{\centering\arraybackslash}m{0.2\textwidth}>{\centering\arraybackslash}m{0.4\textwidth}}
然后你可以删除全部你的\multirow
临时解决办法:
\documentclass[a4paper,fontsize=12pt,a4paper,DIV=10,BCOR=10mm,twoside,titlepage=false,openany,pagesize]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{graphicx}
\usepackage[font=normalsize,labelfont=sc,singlelinecheck=false,justification=raggedright]{caption}
\usepackage[hyphens]{url}
\usepackage{setspace}
\usepackage{subfigure}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\usepackage{array}
\usepackage{multirow}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{feyn}
\usepackage[authoryear]{natbib}
\usepackage{chngcntr}
\usepackage{dcolumn}
\usepackage{amsmath}
\begin{document}
\fontsize{10pt}{11pt}\selectfont
\begin{longtable}[c]{>{\centering\arraybackslash}m{0.1\textwidth}>{\centering\arraybackslash}m{0.2\textwidth}>{\centering\arraybackslash}m{0.4\textwidth}}
\captionsetup{justification=raggedright,width=.82\textwidth}
\caption{Hypotheses}
\label{tab:hypotheses}
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}}\\
\endhead
\midrule
H1 & \textit{`lalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2 & \textit{`lalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2a & \textit{`lalalalalalalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\cmidrule(lr){2-2}\cmidrule(l){3-3}
H2b & \textit{`lalalalalalalala' hypothesis} & Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. \\
\bottomrule
\multicolumn{3}{l}{\small{\emph{Source: Author's depiction}}}\\
\end{longtable}
\normalsize
\end{document}