表形式の環境でのフォントサイズのカスタマイズが機能しない

表形式の環境でのフォントサイズのカスタマイズが機能しない

テーブル内のエントリのフォント サイズを大きくする必要があります。 の以前の質問によるとTEX.SE、環境を開始する前にフォント サイズ コマンド (\large など) を追加するなどの潜在的な解決策がtabular機能するはずです。しかし、私の場合、そのようなコマンドでは何も変わりません。どうすれば修正できますか?

\documentclass[letterpaper, 10pt]{IEEEconf}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}

\title{My Title*}

\author{Guy$^{1}$
\thanks{*This work was not supported by any organization}% <-this % stops a space
\thanks{$^{1}$Guy is with Hell, {\tt\small [email protected]}}%
}

\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}

\begin{abstract}

ABSTRACT

\end{abstract}

\section{INTRODUCTION}

\begin{table}[h!]
    \centering
    \caption{Caption for the table.}
    \label{tab:table3}
    \resizebox{\columnwidth}{!}{%
    \LARGE  ------> It affects nothing
    \begin{tabular}{ccccccccc}
        \toprule
        $$      & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{v}(\theta^{v})$ & $^{v}(\theta^{v})$ & $S^{v}(\theta^{v})$ & $S^{v}(\theta^{v})$\\
        \midrule
        $S^{h}(\theta^{h})$ & occupied & & & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & occupied & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & occupied & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & & occupied\\
        \bottomrule
    \end{tabular}
    }
\end{table}

\end{document}

答え1

望んでいない\LARGEでしょうが、\footnotesize。はい、本当に!

問題は、大きなテーブルを作成してから、列幅に合わせてサイズを変更することです。たとえそうしたとしても\HUMONGOUSLYHUGE、結果はまったく同じになります。

覚えておいてください:\resizeboxテーブル用に作成しないでください。必要に応じて作成してください。

この場合、\footnotesize列間のスペースを減らし、大きな「占有」をテキストで説明できるシンボルに変更することが合理的と思われます。

表を入力するために、いくつかのローカルなショートカットを使用しました。ドキュメント全体\SThで の代わりに使用することをお勧めしているわけではありS^{h}(\theta^{h})ませんが、この大きな表の場合のみ、ショートカットを使用するとコードの読みやすさが向上します。

の値はどうやって決定したのでしょうか\addtolength? それを使わずに表をタイプセットしたところ、73.22162 ポイントのオーバーフルが発生しました。列間のパディングは 16 個あるため、その量を 16 で割り、小数点第 1 位に切り上げました。

余談ですが、\ttは 20 年以上前から非推奨のコマンドです。\ttfamilyまたは「コマンド形式」を使用してください\texttt

\documentclass[letterpaper, 10pt]{IEEEconf}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}

\usepackage{lipsum}

\title{My Title*}

\author{Guy$^{1}$
\thanks{*This work was not supported by any organization}% <-this % stops a space
\thanks{$^{1}$Guy is with Hell, {\ttfamily\small [email protected]}}%
}

\begin{document}

\maketitle
\thispagestyle{empty}
\pagestyle{empty}

\begin{abstract}

ABSTRACT

\end{abstract}

\section{INTRODUCTION}

\lipsum[2]

\begin{table}[htp]
\caption{Caption for the table.}
\label{tab:table3}

%%% Local shorthands
\newcommand{\STh}{$S^{h}(\theta^{h})$}
\newcommand{\STv}{$S^{v}(\theta^{v})$}
%%% The definition of \occ could be in the preamble,
%%% if you use it also in other tables
\newcommand{\occ}{$\times$} % <--- change to your liking

\centering\footnotesize

%%% do the computation only at the very last moment
\addtolength{\tabcolsep}{-4.7pt}

\begin{tabular}{@{}*{9}{c}@{}}
\toprule
  & \STh & \STh & \STh & \STh & \STv & \STv & \STv & \STv\\
\midrule
\STh & \occ & & & & & &\\
\STh & & & & & & &\\
\STh & & & \occ & & & &\\
\STh & & & & & & &\\
\STv & & & & & & &\\
\STv & & & & & \occ & &\\
\STv & & & & & & &\\
\STv & & & & & & & \occ\\
\bottomrule
\end{tabular}

\end{table}

\lipsum

\end{document}

何でも

答え2

などの命令を使用してフォント サイズを拡大しようとすると、命令\largeの存在によりセットアップで完全に自滅的になります\resizebox

別の方法を取る必要があります。次の手順を実行することをお勧めします。

  • 「occupied」の代わりに「occ.」と記述すると、セルの内容が占めるスペースが少なくなります。

  • と を書くS^{h}(\theta^{h})と、S^{v}(\theta^{v})多くのスペースを占有します。以下のコードでは、これらの用語をもっとコンパクトにタイプセットすることをお勧めします。

  • 列間の空白の量を減らします。デフォルトの量 (2*6pt) はかなり多めです。\tabcolsep試行錯誤しながらパラメータを調整するよりも、0ptすぐに設定して、tabular*環境ではなく環境を使用することをお勧めしますtabular。そうすれば、LaTeX が最適な (つまり、利用可能な最大の) 空白の量を判断します。

これらの調整が完了したら、あとはテーブルのフォント サイズを に設定するだけです\small。次のスクリーンショットは、変更前と変更後の比較を示しています。変更後のテーブルは、ほぼ期待どおりの結果になっていると思います。

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

\documentclass[letterpaper,10pt]{IEEEconf}
\usepackage{booktabs,graphicx}
\usepackage[skip=0.333\baselineskip,font={bf,sf}]{caption}
\newcommand\Sth[1]{S^{#1}\mkern-3mu(\mkern-2.5mu\theta^{\mkern-1mu#1}\mkern-2mu)}
\begin{document}
\section{Introduction}
\hrule % just to illustrate width of textblock

%%%% First the "before" look
\begin{table}[h!]
    \centering
    \caption{Before}
    \label{tab:table3}
    \resizebox{\columnwidth}{!}{%
    \LARGE % ------> It affects nothing
    \begin{tabular}{ccccccccc}
        \toprule
        $$      & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{h}(\theta^{h})$ & $S^{v}(\theta^{v})$ & $^{v}(\theta^{v})$ & $S^{v}(\theta^{v})$ & $S^{v}(\theta^{v})$\\
        \midrule
        $S^{h}(\theta^{h})$ & occupied & & & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & occupied & & & &\\[0.5em]
        $S^{h}(\theta^{h})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & occupied & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & &\\[0.5em]
        $S^{v}(\theta^{v})$ & & & & & & & occupied\\
        \bottomrule
    \end{tabular}
    }
\end{table}

%%%% Now the "after" look
\begin{table}[h!]
\captionsetup{font={small,bf,sf}} % optional
\small
\caption{After} \label{tab:table3}
\setlength\tabcolsep{0pt} % make LaTeX calculate intercolumn whitespace
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} ccccccccc}
\toprule
& $\Sth{h}$ & $\Sth{h}$ & $\Sth{h}$ & $\Sth{h}$ & $\Sth{\nu}$ & $\Sth{\nu}$ & $\Sth{\nu}$ & $\Sth{\nu}$\\
\midrule
$\Sth{h}$ & occ. & & & & & &\\
$\Sth{h}$ & & & & & & &\\
$\Sth{h}$ & & & occ. & & & &\\
$\Sth{h}$ & & & & & & &\\
$\Sth{\nu}$ & & & & & & &\\
$\Sth{\nu}$ & & & & & occ. & &\\
$\Sth{\nu}$ & & & & & & &\\
$\Sth{\nu}$ & & & & & & & occ.\\
\bottomrule
\end{tabular*}
\end{table}

\end{document}

関連情報