A personalização do tamanho da fonte em ambiente tabular não funciona

A personalização do tamanho da fonte em ambiente tabular não funciona

Preciso aumentar o tamanho da fonte das entradas da minha tabela. De acordo com algumas perguntas anteriores no TEX.SE, uma solução potencial, como adicionar comandos de tamanho de fonte (como \large) antes de iniciar tabularo ambiente, deve funcionar. Mas no meu caso, esses comandos não mudam nada. Como devo consertar isso?

\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}

Responder1

Você não quer \LARGE, mas \footnotesize. Sim com certeza!

O problema é que você cria uma tabela grande e depois a redimensiona para a largura da coluna: mesmo que o faça \HUMONGOUSLYHUGE, o resultado seria exatamente o mesmo.

Lembre-se: nunca faça \resizeboxpor uma mesa. Crie conforme necessário.

Neste caso, \footnotesizeparece razoável, juntamente com uma redução do espaço entre colunas e a alteração do grande “ocupado” por um símbolo que você possa explicar no texto.

Para digitar a tabela, usei algumas abreviações locais: não estou sugerindo usar \SThno lugar de S^{h}(\theta^{h})em todo o documento, mas apenas para esta tabela grande as abreviações ajudam na legibilidade do código.

Como determinei o valor de \addtolength? Eu compus a mesa sem ela e obtive um excesso de 73,22162pt. Como existem 16 preenchimentos entre colunas, dividi o valor por 16 e arredondei para a primeira casa decimal.

Como um aparte: \tté um comando obsoleto há mais de vinte anos. Use \ttfamilyou o “formulário de comando” \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}

qualquer que seja

Responder2

Tentar aumentar o tamanho da fonte com uma diretiva como essa \largeé totalmente contraproducente em sua configuração devido à presença da \resizeboxinstrução.

Você precisa seguir outro caminho. Sugiro que você siga os seguintes passos:

  • Em vez de “ocupado”, escreva “occ.”, para que o conteúdo da célula ocupe menos espaço.

  • Escrever S^{h}(\theta^{h})e S^{v}(\theta^{v})ocupa muito espaço. NO código abaixo, sugiro que você digite esses termos de forma muito mais compacta.

  • Reduza a quantidade de espaços em branco entre colunas. O valor padrão (2*6pt) é bastante generoso. Em vez de ajustar o parâmetro \tabcolseppor tentativa e erro, sugiro que você o configure 0ptimediatamente e use um tabular*ambiente em vez de um tabularambiente. Dessa forma, o LaTeX descobrirá a quantidade ideal (ou seja, a máxima disponível) de espaços em branco.

Com esses ajustes feitos, tudo o que você precisa fazer é definir o tamanho da fonte da tabela para \small. A captura de tela a seguir fornece uma comparação antes e depois; Acredito que a tabela "depois" seja mais ou menos o que você esperava alcançar.

insira a descrição da imagem aqui

\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}

informação relacionada