我想这是一个常见问题,我可以使用 tabularx 包将表格调整到适合文本宽度。但表格内的文本却放不进去。我想我忽略了一个小细节?感谢您的帮助。
以下是 MWE:
\documentclass[11pt,a4paper]{article}
\usepackage{verbatim}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{tabularx}
\begin{document}
\begin{table}[h!]
\small
\captionsetup{font=small}
\centering
\caption{Description of the features employed in this project.}
\label{table:1}
\begin{tabularx}{1.0\textwidth}{l||l}
\toprule
\textbf{Feature} & \textbf{Description}\\ \hline
Zero Crossing Rate & The rate of sign-changes of the signal during the duration of a particular frame. \\ \hline
Energy & The sum of squares of the signal values, normalized by the respective frame length. \\ \hline
Entropy of Energy & The entropy of sub-frames' normalized energies. It can be interpreted as a measure of abrupt changes. \\ \hline
Spectral Centroid & The center of gravity of the spectrum.\\ \hline
Spectral Spread & The second central moment of the spectrum.\\ \hline
Spectral Entropy & Entropy of the normalized spectral energies for a set of sub-frames.\\ \hline
Spectral Flux & The squared difference between the normalized magnitudes of the spectra of the two successive frames.\\ \hline
Spectral Rolloff & The frequency below which 90\% of the magnitude distribution of the spectrum is concentrated.\\ \hline
Mel-frequency coefficients (1-13) & Mel Frequency Cepstral Coefficients form a cepstral representation where the frequency bands are not linear but distributed according to the mel-scale.\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案1
至少有一列必须是环境X
中的类型tabularx
。
此外:
tabu
尽量避免;booktabs
如果您使用或想要美观的表格,请避免使用垂直规则;- 始终如一地使用规则:例如,
booktabs
不要\hline
与混合;\toprule
- 永远不要将
h
其用作浮动的唯一放置选项:它的意思是“如果有空间,就在这里”,那么如果没有空间,LaTeX 应该怎么做?
代码:
\documentclass[11pt,a4paper]{article}
\usepackage{verbatim}
% \usepackage{tabu}% avoid like the plague
\usepackage{booktabs}
\usepackage{caption}
\usepackage{tabularx}
\begin{document}
\begin{table}[ht!]% never use h as the sole specifier
\small
\captionsetup{font=small}
\centering
\caption{Description of the features employed in this project.}
\label{table:1}
\begin{tabularx}{1.0\textwidth}{lX}% avoid vertical rules with booktabs
\toprule
\textbf{Feature} & \textbf{Description}\\ \midrule
Zero Crossing Rate & The rate of sign-changes of the signal during the duration of a particular frame. \\ \cmidrule(lr){1-2}
Energy & The sum of squares of the signal values, normalized by the respective frame length. \\ \cmidrule(lr){1-2}
Entropy of Energy & The entropy of sub-frames' normalized energies. It can be interpreted as a measure of abrupt changes. \\ \cmidrule(lr){1-2}
Spectral Centroid & The center of gravity of the spectrum.\\ \cmidrule(lr){1-2}
Spectral Spread & The second central moment of the spectrum.\\ \cmidrule(lr){1-2}
Spectral Entropy & Entropy of the normalized spectral energies for a set of sub-frames.\\ \cmidrule(lr){1-2}
Spectral Flux & The squared difference between the normalized magnitudes of the spectra of the two successive frames.\\ \cmidrule(lr){1-2}
Spectral Rolloff & The frequency below which 90\% of the magnitude distribution of the spectrum is concentrated.\\ \cmidrule(lr){1-2}
Mel-frequency coefficients (1-13) & Mel Frequency Cepstral Coefficients form a cepstral representation where the frequency bands are not linear but distributed according to the mel-scale.\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}