在 Latex 的 \textwidth 内放置一个 table

Fit a table within \textwidth in Latex

我有一个 table 比我文档的 \textwidth 还宽。 (我不想改变 \textwidth。) 我想通过包装最后一列(最右边的列)的文本来强制将 table 安装在 \textwidth 中。 这是我的代码 table:

\begin{table*}[!t]
\caption{Extracted Features used in Meta-Learning} \label{sample-features}
\label{tbl:features}
\begin{center}
\begin{tabular*}{0.95\textwidth,center}{|l||l|}
{\textbf{FEATURE}}  &{\textbf{DESCRIPTION}} \
\hline \
n.examples & Number of examples \
n.attrs & Number of attributes \
prop.symbolic.attrs & Proportion of symbolic attributes \
prop.missing.values & Proportion of missing values \
class.entropy & Class entropy \
avg.mutual.information & Average mutual information \
prop.h.outlier & Proportion of continuous attributes with outliers \
avg.attr.entropy & Average attribute entropy \
avg.symb.pair.mutual.infor & Average mutual information between pairs of symbolic attributes \
avg.abs.attr.correlation & Average absolute correlation between continuous attributes \
avg.skewness & Mean skewness of attributes \
avg.abs.skewness & Mean absolute skewness of attributes \
avg.kurtosis & Mean kurtosis of attributes \
canonical.correlation.best.linear.combination & Canonical correlation of the best linear combination of attributes to distinguish between classes \
relative.prop.best.linear.combination & Proportion of the total discrimination power explained by the best linear combination \
\end{tabular*}
\end{center}
\end{table*}

这段代码的结果是以下文档:

红线右边的部分(自己加的)要换行

有什么帮助吗?

这是一个答案。希望对您有所帮助:

使用包 tabularx 如下:

\usepackage{tabularx,booktabs}
.
.
.
\begin{table*}[!t]
\caption{Caption}
\label{tbl:tbl}
\centering
\begin{tabularx}{\textwidth}{X X}
\toprule
Item 1 & Item 2 \
\midrule
Item 1 description & Item 2 description \
.
.
.
\bottomrule
\end{tabularx}
\end{table*}

在我的例子中,解决方案如下:

\begin{table*}[!t]
\caption{Extracted Features used in Meta-Learning} \label{sample-features}
\label{tbl:features}
\centering
\begin{tabularx}{0.95\textwidth}{|X||X|}
\toprule
{\textbf{FEATURE}}  &{\textbf{DESCRIPTION}} \
\midrule
n.examples & Number of examples \
n.attrs & Number of attributes \
prop.symbolic.attrs & Proportion of symbolic attributes \
prop.missing.values & Proportion of missing values \
class.entropy & Class entropy \
avg.mutual.information & Average mutual information \
prop.h.outlier & Proportion of continuous attributes with outliers \
avg.attr.entropy & Average attribute entropy \
avg.symb.pair.mutual.infor & Average mutual information between pairs of symbolic attributes \
avg.abs.attr.correlation & Average absolute correlation between continuous attributes \
avg.skewness & Mean skewness of attributes \
avg.abs.skewness & Mean absolute skewness of attributes \
avg.kurtosis & Mean kurtosis of attributes \
canonical.correlation.best.linear.combination & Canonical correlation of the best linear combination of attributes to distinguish between classes \
relative.prop.best.linear.combination & Proportion of the total discrimination power explained by the best linear combination \
\bottomrule
\end{tabularx}
\end{table*}