Cambiar fuente en todas las tablas del documento.

Cambiar fuente en todas las tablas del documento.

Me gustaría cambiar la fuente predeterminada en todas las tablas de mi documento. En lugar de la fuente Computer Modern Roman, prefiero Bitstream Charter Mathdesign (la misma familia), que está "condensada":

\documentclass{article}
\usepackage[charter, uppercase=upright]{mathdesign}

\makeatletter
\renewcommand{\sfdefault}{cmr}

\g@addto@macro{\table}{\fontencoding{T1}\fontfamily{mdbch}\selectfont}
\makeatother

\begin{document}

\begin{table}
    \caption{My Table}\label{tab:table}
    \centering
    \begin{tabular}{cc}\hline
      X & Y \\ \hline
      x1 & y1 \\
      x2 & y2 \\ \hline
    \end{tabular}
\end{table}

Some short text outside a table in a current font.

\end{document}

Usando el siguiente código, la fuente Mathdesign se usa para todo el documento :-(

Muchas gracias por su ayuda.

Respuesta1

Probablemente resuelto de otra manera, usando el comando de entorno y un nick diferente:

\documentclass{article}

\makeatletter
\renewenvironment{table}
     {\renewcommand\familydefault{mdbch}
      \@float{table}}
     {\end@float}
\makeatother

\begin{document}

\begin{table}
    \caption{My Table}\label{tab:table}
    \centering
    \begin{tabular}{cc}\hline
      X & Y \\ \hline
      x1 & y1 \\
      x2 & y2 \\ \hline
    \end{tabular}
\end{table}

Some short text outside a table in a current font.

\end{document}

Tal vez ayude....

información relacionada