更改文件所有表格中的字體

更改文件所有表格中的字體

我想更改文件所有表格中的預設字體。與 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}

也許,它有幫助......

相關內容