问:如何将所有表格的宽度调整为文本文档的边距?

问:如何将所有表格的宽度调整为文本文档的边距?

@LaTeX-class-文件

文件名 = “harvard-thesis.cls”

版本 = “0.4”,

日期 = “2012 年 4 月 4 日”,

代码表 = “ISO/ASCII”

如您在此示例中所见,我的表格超出了文本文档的宽度。我的目的是将表格宽度调整为整个文档中的文本列。

\documentclass{harvard-thesis}
\captionsetup{labelfont=\rmdefault, textfont=\rmdefault }

\begin{document}

\begin{table}
\centering
\begin{tabular}{@{}lll@{}}\toprule[1.5pt]
\bf Periodista & \bf Medio & \bf Cargo \\\midrule

Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 
Sample name surname &  Sample medium & Other text. Responsable de Participación, redes y Comunidad \\ 

\bottomrule[1.25pt]
\end {tabular}\par
\captionof{table}{Periodistas participantes}
\label{tab:periodistas}
\end{table}

\end{document}

以上示例

答案1

使用该tabularx包。

您可以将列宽定义为百分比\textwidth,这样文本将被格式化为段落并带有换行符。为此,只需p{<width>}使用l...

两列:

\begin{tabularx}{\textwidth}{|p{0.5\textwidth}|p{0.5\textwidth}|}

三列:

\begin{tabularx}{\textwidth}{|p{0.33\textwidth}|p{0.33\textwidth}|p{0.33\textwidth}|}

表格示例:

\begin{center}
\begin{tabularx}{\textwidth}{|p{0.33\textwidth}|p{0.33\textwidth}|p{0.33\textwidth}|}
\hline
Label Sample                                               & Label Sample                                               & Label Sample                                               \\ \hline
a & b & c \\ \hline
Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell \\ \hline
Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell & Protoctista wave equations telegrapher's equations Maxwell \\ \hline
a & bbbbbb bbbbbbbb bbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbl &  c \\ \hline
\end{tabularx}
\end{center}

相关内容