2列のドキュメントで表の幅を1列に調整する方法

2列のドキュメントで表の幅を1列に調整する方法

1 列の表を作成する必要があります。収まるように調整する必要があります。たとえば、テキストは 2 行にすることができます。表の行は 1 列に収まりますが、テキストが列幅を超えています。表のテキストを列幅を超えるのではなく、次の行に拡張するにはどうすればよいでしょうか。これは最小限のテスト コードです。

\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

2 列にまたがるテーブルを指定しましたtable*。これはページの上部にのみ設定できます。[t]代わりに引数を使用するか、少なくとも を含むものを使用する必要がありますt。次に、tabularxサイズの を指定しました\columnwidthが、これはテーブルがその幅であることを意味します。これが、行が 1 列である理由です。テキストの幅が広いため、テーブルに収まりません。さらに、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}

ここに画像の説明を入力してください

関連情報