我有一个包含beamer
该metropolis
主题的演示文稿。所有表格的所有内容都应使用 mono/typewriter 字体书写。理想情况下,我更愿意在序言内进行全局更改。
一个解决方法是更改环境中的字体,这种方法有点用,但必须为每个表进行本地设置table
。请参见注释掉的两行。
\documentclass{beamer}
\usetheme{metropolis}
%\setmonofont{Courier Prime} % (optional) more distinct typewriter font
\usepackage{booktabs}
\begin{document}
\begin{frame}{Typewriter table}
This text should have the default Beamer font.
\begin{table}
\caption{Default text font}
%{\ttfamily % workaround start: until the closed curly bracket, should be typewriter font
\begin{tabular}{cr}
\toprule
Begin \textbf{typewriter} & \textit{mono} \textit{\textbf{font}} \\
\midrule
A & 0.1 \\
Bc & 1 \\
Cde & 23.45 \\
Defg & 3.456 \\
\bottomrule
\end{tabular}
%} % workaround end
\caption{Default text font} % added to check both, top and bottom, description variants
\end{table}
This text should have the default Beamer font.
\end{frame}
\end{document}
答案1
像这样:
编辑:
读完下面的评论后,你的问题并不完全清楚,你遇到的问题都是什么。无论如何,请每个问题提出一个问题。现在我为使用 LuaLaTeX 进行编译的选项添加一个可能的解决方案,其中使用的是FiraSans
第一个版本并进行了更正,现在使用的是默认的 Beamer 字体。
关于etoolbox
:旧版 LaTeX 需要它。最新版本\AtBeginEnvironment
中已集成了一个定义(现在我假设您已安装最新版本的 LaTeX)。
编译示例pdfLaTeX
:
\documentclass{beamer}
\usetheme{metropolis}
\usepackage{booktabs}
\AtBeginEnvironment{tabular}{\ttfamily} % global setting for tabular
\begin{document}
\begin{frame}
\frametitle{Typewriter table}
This text should have the default Beamer.
\begin{table}
\caption{Default text font}
\begin{tabular}{cr}
\toprule
Begin \textbf{typewriter} & \textit{mono \textbf{font}} \\
\midrule
A & 0.1 \\
Bc & 1 \\
Cde & 23.45 \\
Defg & 3.456 \\
\bottomrule
\end{tabular}
\caption{Default text font} % added to check both, top and bottom, description variants
\end{table}
This text should have the default Beamer font.
\end{frame}
\begin{frame}
\frametitle{Typewriter table}
This text should have the default Beamer.
\begin{table}
\caption{Default text font}
\begin{tabular}{cr}
\toprule
Begin typewriter & mono font \\
\midrule
A & 0.1 \\
Bc & 1 \\
Cde & 23.45 \\
Defg & 3.456 \\
\bottomrule
\end{tabular}
\end{table}
This text should have the default Beamer font.
\end{frame}
\end{document}
LuadfLaTeX
使用字体编译的示例FiraSans
:
\documentclass{beamer}
\usetheme{metropolis}
\usepackage{booktabs}
\usepackage[sfdefault]{FiraSans}
\AtBeginEnvironment{tabular}{\ttfamily} % global setting for tabular
\begin{document}
\begin{frame}
\frametitle{Typewriter table}
This text is in the FiraSans sans Serif fonts.
\begin{table}
\caption{Default text font}
\begin{tabular}{cr} % in tabular are use \ttfamily as defined in FiraSans
\toprule
Begin \textbf{typewriter} & \textit{mono \textbf{font}} \\
\midrule
A & 0.1 \\
Bc & 1 \\
Cde & 23.45 \\
Defg & 3.456 \\
\bottomrule
\end{tabular}
\caption{Default text font} % added to check both, top and bottom, description variants
\end{table}
This text should have the default Beamer font.
\end{frame}
\begin{frame}
\frametitle{Typewriter table}
This text should have the default Beamer.
\begin{table}
\caption{Default text font}
\begin{tabular}{cr}
\toprule
Begin typewriter & mono font \\
\midrule
A & 0.1 \\
Bc & 1 \\
Cde & 23.45 \\
Defg & 3.456 \\
\bottomrule
\end{tabular}
\end{table}
This text should have the default Beamer font.
\end{frame}
\end{document}
为了定义仅使用 FiraSans 字体,\ttfamily
请提出新问题。