文書内のすべての表のフォントを変更する

文書内のすべての表のフォントを変更する

ドキュメント内のすべての表のデフォルトのフォントを変更したいと思います。Computer Modern Roman フォントの代わりに、Bitstream Charter Mathdesign (同じファミリー) の「コンデンス」フォントを使用します。

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

次のコードを使用すると、ドキュメント全体に Mathdesign フォントが使用されます :-(

ご助力ありがとうございます。

答え1

おそらく、環境コマンドと別のニックネームを使用して、別の方法で解決されます。

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

たぶん、役に立つでしょう....

関連情報