La personalización del tamaño de fuente en un entorno tabular no funciona

La personalización del tamaño de fuente en un entorno tabular no funciona

Necesito aumentar el tamaño de fuente de las entradas de mi tabla. Según algunas preguntas anteriores sobre TEX.SE, una posible solución como agregar comandos de tamaño de fuente (como \large) antes de comenzar tabularel entorno debe funcionar. Pero en mi caso, esos comandos no cambian nada. ¿Cómo debería solucionarlo?

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

Respuesta1

No quieres \LARGE, pero \footnotesize. ¡Sí, en serio!

El problema es que creas una tabla grande y luego cambias su tamaño al ancho de columna: incluso si lo haces \HUMONGOUSLYHUGE, el resultado sería exactamente el mismo.

Recuerda: nunca lo hagas \resizeboxpor una mesa. Elaborelo según sea necesario.

En este caso, \footnotesizeparece razonable, junto con una reducción del espacio entre columnas y cambiar el gran “ocupado” por un símbolo que puedas explicar en el texto.

Para escribir la tabla, utilicé algunas taquigrafías locales: no sugiero usarlas \SThen lugar de en S^{h}(\theta^{h})todo el documento, pero solo para esta gran tabla las taquigrafías ayudan a facilitar la legibilidad del código.

¿Cómo determiné el valor de \addtolength? Compuse la mesa sin ella y obtuve un exceso de 73.22162 pt. Como hay 16 rellenos entre columnas, dividí la cantidad entre 16 y redondeé al primer decimal.

Además: \ttha sido un comando obsoleto durante más de veinte años. Utilice \ttfamilyo el “formulario 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}

lo que

Respuesta2

Intentar ampliar el tamaño de fuente con una directiva como esta \largees completamente contraproducente en su configuración debido a la presencia de la \resizeboxinstrucción.

Necesitas tomar otra ruta. Le sugiero que siga los siguientes pasos:

  • En lugar de "ocupado", escriba "occ.", para que el contenido de la celda ocupe menos espacio.

  • Escribe S^{h}(\theta^{h})y S^{v}(\theta^{v})ocupa mucho espacio. EN el código siguiente, le sugiero que escriba estos términos de forma mucho más compacta.

  • Reduzca la cantidad de espacios en blanco entre columnas. La cantidad predeterminada (2*6pt) es bastante generosa. En lugar de ajustar el parámetro \tabcolsepmediante prueba y error, le sugiero que lo configure 0ptde inmediato y utilice un tabular*entorno en lugar de un tabularentorno. De esa manera, LaTeX determinará la cantidad óptima (es decir, la máxima disponible) de espacio en blanco.

Una vez implementados estos ajustes, todo lo que necesita hacer es establecer el tamaño de fuente de la tabla en \small. La siguiente captura de pantalla proporciona una comparación del antes y el después; Confío en que la tabla "después" sea más o menos lo que esperabas lograr.

ingrese la descripción de la imagen aquí

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

información relacionada