
我需要在一列中建立一個表。它需要進行調整以適應。表格行適合在一列中。但文字超出了列寬。如何使表格文字擴展到下一行而不是超過列寬?這是最小的測試程式碼。
\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage{graphicx}
\usepackage{array,tabularx}
\usepackage{multirow,booktabs} %for the table
\usepackage{pifont}% cross and match marks. http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{array,tabularx}
\begin{document}
\begin{table*} [h!]
%\centering
\caption{Caption for the table.}
\label{tab:table1}
\resizebox{\columnwidth}{!}{
\begin{tabularx} {\columnwidth}{cccccc} %{\columnwidth}{cccccc}
\toprule
& & first col & second col & third col & forth col \\
first row & & \xmark & \xmark & \xmark \\
%\midrule
%prettifies & the & content \\
\bottomrule
\end{tabularx}
}
\end{table*}
\end{document}
答案1
您已指定table*
哪一個是跨兩列的表。這只能在頁面頂部設置,您應該改為使用參數[t]
,或至少包括t
.然後您指定了tabularx
尺寸\columnwidth
,這表示表格具有該寬度。這就是這些行是一列的原因。由於文字較寬,因此無法放入表格中。此外,由於您不使用X
中指定的列說明符,tabularx
我建議改為使用tabular
.在下面的範例中,我添加了一些唇語文本,以更清晰地顯示表格位置。
\documentclass[letterpaper,twocolumn,10pt]{article}
\usepackage{graphicx}
\usepackage{array,tabularx}
\usepackage{multirow,booktabs} %for the table
\usepackage{pifont}% cross and match marks. http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{array,tabularx}
%%
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
%%%
\begin{table*} [ht]
\centering
\caption{Caption for the table.}
\label{tab:table1}
% \resizebox{\columnwidth}{!}{
\begin{tabular}{cccccc} %{\columnwidth}{cccccc}
\toprule
& & first col & second col & third col & forth col \\
first row & & \xmark & \xmark & \xmark \\
% \midrule
% prettifies & the & content \\
\bottomrule
\end{tabular}
%}
\end{table*}
\lipsum[4-13]
\end{document}