如何生成类似这样的表格并适合页面

如何生成类似这样的表格并适合页面

在此处输入图片描述

我想知道如何生成类似于所显示的表格并使其适合页面。

答案1

为了更实用的 MWE,我添加了两个最长的单元格进行测试。我选择第一列为p{6em},也就是说,足够容纳两个单词,如power control和,使用tabularx和,ragged2e正如其他人所建议的那样。

\documentclass[a4paper]{article}
\usepackage{tabularx,ragged2e}
\usepackage{booktabs,array,times}
\usepackage[margin=1in]{geometry}
\begin{document}

\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}    

\begin{table}\centering
\caption{My caption}
\label{my-label}
\begin{tabularx}{\linewidth}{@{}p{6em}LL@{}}
\toprule
        & \multicolumn{1}{c}{Conventional Power Plant} & \multicolumn{1}{c}{Wind Power Plant}                                                                                                                                                 \\ \midrule
Topology                                               & One or a few large generating units, each unit could be rated at 40 to 1000 MW+ & Typically hundreds of small generators deployed over a large area, each unit could be rated at 1 to 5 MW Wind turbines                   \\
. . .                                                  & . . .                & . . .                                                                                                                                                                                \\
Reactive power control & Units are equipped with an automatic voltage regulator, typically set for voltage control & Reactive power is managed at the plant level, through coordinated control of wind turbine control and/or plant-level reactive compensation\\ \bottomrule
\end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

答案2

使用包tabularxbooktabs和作为选项,ragged2e您可以轻松实现所需的结果。

\documentclass{article}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ragged2e}

\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}

\begin{document}

\begin{flushleft}
\begin{tabularx}{\linewidth}{lLL}
\toprule
& 
\multicolumn{1}{c}{Conventional Power Plant} & 
\multicolumn{1}{c}{Wind Power Plant} \\
\midrule
Topology &
Once or a few large generating units, each unit could be rated \dots &
Typically hundreds of small generators deployed over a large area, each unit \dots \\
Prime mover &
\dots &
\dots \\
\bottomrule
\end{tabularx}
\end{flushleft}

\end{document}

MWE 的输出

答案3

加载tabularxbooktabs使用

\begin{tabularx}{\linewidth}{@{}l*{2}{>{\arraybackslash}X}@{}}
\toprule\midrule
.................................................... \\
\midrule
....................................................
....................................................
.................................................... \\
\midrule\bottomrule

您可以在规则之间添加一些填充

\\
\addlinespace

答案4

像所有前面的答案一样,我强烈建议您研究使用环境tabularx及其主要列类型,称为X,它允许自动换行并根据需要扩展宽度以填充可用(水平)空间。并且,像其他答案一样,我会加载包booktabs以生成间距良好的水平规则。

查看提供的模板,我认为缺少了一件事:自动悬挂缩进第一行以外的行。这个想法在下面实现。另外,我也不会将两个标题居中;左对齐同样有效(并且可以说甚至更好)。

在此处输入图片描述

\documentclass{article}
\usepackage[english]{babel}
\usepackage[letterpaper,margin=1in]{geometry} % set page size parameters

\usepackage{tabularx,booktabs,ragged2e,
            newtxtext,newtxmath}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash
     \hangafter1\hangindent1em}X}
\newcolumntype{q}[1]{>{\raggedright  
     \hangafter1\hangindent1em}p{#1}}

\newlength\mylen
\settowidth\mylen{Reactive power} % width of first column

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{} q{\mylen} YY @{}}
\toprule
& Conventional Power Plant
& Wind Power Plant \\
\midrule
Topology 
& One of a few large generating units. Each unit could be rated at 40 to 1000$+$~MW.
& Typically hundreds of small generators deployed over a large area. Each unit could be rated at 1 to 5~MW. \\
Prime Mover & 
\dots & 
\dots \\
Dispatch
& \dots
& \dots \\
Real power control 
& Units have speed governors and are typically capable of \dots 
& Real power follows the wind speed generation \\
Reactive power control
& Units are equipped with an automatic voltage regulator, typically set for voltage control
& Reactive power is managed at the plant level, through \dots\\
Location & 
\dots & 
\dots \\
Generator 
& Synchronous generators 
&  Type 1---Fixed speed, induction generator; \\
&& Type 2---Variable slip, induction generators with variable rotor resistance; \\
&& \dots \\
\bottomrule
\end{tabularx}
\end{document}

相关内容