如何在表格和正文中设置不同的行距?

如何在表格和正文中设置不同的行距?

我希望正文的行距为 1.5 倍,而tabular环境应使用默认(即较小的)行距。但是,以下代码为整个文档(包括表格)提供了 1.5 倍的行距:

\documentclass[12pt, a4paper] {report}
\parindent = 0cm \parskip = 0cm
\renewcommand\baselinestretch{1.5}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce accumsan congue leo, at 
convallis diam pulvinar nec. In venenatis neque mi, pellentesque dictum turpis ultrices 
quis. \bigskip

\centering
\begin{tabular} { p{2cm} p{6cm} }
    Hello World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce 
    accumsan congue leo, at convallis diam pulvinar nec. \\ \hline
    Goodbye World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
\end{tabular}
\end{document}

答案是tex.stackexchange.com/a/79155对我来说不起作用。特别是,我尝试更换

  • \renewcommand\baselinestretch{1.5}\usepackage{setspace} \setstretch{1.5}
  • \centering\begin{center}

注意:\renewcommand\arraystretch{0.8}没有帮助,因为我关心的是表格中文本行之间的间距,而不是表格行之间的间距。

答案1

解决方案是setspace。我必须用 from 替换,\hline以便\midrulebooktabs水平规则周围留出一些填充:

\documentclass[12pt, a4paper] {report}
\parindent = 0cm \parskip = 0cm
\usepackage{booktabs}
\usepackage{setspace}
\renewcommand\baselinestretch{1.5}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce accumsan congue leo, at
convallis diam pulvinar nec. In venenatis neque mi, pellentesque dictum turpis ultrices
quis. \bigskip

\begin{spacing}{0.8}\centering
\begin{tabular} { p{2cm} p{6cm} }
    Hello World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
    accumsan congue leo, at convallis diam pulvinar nec. \\
    \midrule
    Goodbye World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
\end{tabular}
\end{spacing}

\end{document} 

在此处输入图片描述

答案2

似乎放入tabular里面table会给出默认的行距。 Bernard 的答案有效,但我不愿意booktabs不必要地导入包(即)。

\documentclass[12pt, a4paper] {report}
\parindent = 0cm \parskip = 0cm
\usepackage{setspace} \setstretch{1.5}
\renewcommand\arraystretch{1.3}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce accumsan congue leo, at
convallis diam pulvinar nec. In venenatis neque mi, pellentesque dictum turpis ultrices
quis.

\begin{table} [h!]
\centering
\begin{tabular} { p{2cm} p{6cm} }
    Hello World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
    accumsan congue leo, at convallis diam pulvinar nec. \\ \hline
    Goodbye World & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
\end{tabular}
\end{table}
\end{document}

相关内容