Alterar fonte em todas as tabelas do documento

Alterar fonte em todas as tabelas do documento

Gostaria de alterar a fonte padrão em todas as tabelas do meu documento. Em vez da fonte Computer Modern Roman prefiro Bitstream Charter Mathdesign (da mesma família), que é "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 o código a seguir, a fonte Mathdesign é usada para todo o documento :-(

Muito obrigado pela sua ajuda.

Responder1

Provavelmente resolvido de uma forma diferente, usando o comando de ambiente e um 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}

Talvez ajude....

informação relacionada