当我在 savebox 环境中和主文档中使用 beamer 排版相同的方程式时,用于数学方程式的字体会有所不同。
下面是显示差异的 MWE。
\documentclass{beamer}
\newcommand{\delsq}[2]{
\frac{\partial^2 {#1}}{\partial {#2}^2}
}
\newcommand{\deldel}[2]{
\frac{\partial #1}{\partial #2}
}
\newcommand{\waveEqOneD}{\delsq{u}{t} = c^2\delsq{u}{x}}
\newsavebox{\waveEquationTest}
\savebox{\waveEquationTest}{
$\begin{array}{ll}
u(0,t)=0 & u(L,t)=0\\
u(x,0)=f(x) & \deldel{u}{t}(x,0)=g(x)\\
\end{array}$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Boundary conditions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usebox{\waveEquationTest}
$\begin{array}{ll}
u(0,t)=0 & u(L,t)=0\\
u(x,0)=f(x) & \deldel{u}{t}(x,0)=g(x)\\
\end{array}$
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
savebox环境内外使用相同的代码,但是呈现代码的字体不同。
我的问题是为什么这些排版不同?
其次,我其实更喜欢斜体字体里面savebox 环境。如何才能将其设为整个演示文稿中的默认数学字体?
答案1
该类beamer
重新定义了 中的部分字体\begin{document}
。这样它就可以支持在 之后的序言中加载的字体包\documentclass
。如果您将 移出\savebox
序言,它会看到beamer
数学字母已更改为无衬线斜体并使用与其他数学相同的字体。
\documentclass{beamer}
\newcommand{\delsq}[2]{
\frac{\partial^2 {#1}}{\partial {#2}^2}
}
\newcommand{\deldel}[2]{
\frac{\partial #1}{\partial #2}
}
\newcommand{\waveEqOneD}{\delsq{u}{t} = c^2\delsq{u}{x}}
\newsavebox{\waveEquationTest}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin document %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\savebox{\waveEquationTest}{
$\begin{array}{ll}
u(0,t)=0 & u(L,t)=0\\
u(x,0)=f(x) & \deldel{u}{t}(x,0)=g(x)\\
\end{array}$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Boundary conditions}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usebox{\waveEquationTest}
$\begin{array}{ll}
u(0,t)=0 & u(L,t)=0\\
u(x,0)=f(x) & \deldel{u}{t}(x,0)=g(x)\\
\end{array}$
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
如果您在序言中定义了 ,则将使用 中的\savebox
默认衬线字体 (Computer Modern Roman Italic)。我建议您beamer
通过添加以下行来设置字体
\usepackage{unicode-math}
并在 LuaLaTeX 中进行编译。如果beamer
看到unicode-math
,它会关闭对数学字体的重新定义并使用您选择的数学字体。如果您正在编写beamer
演示文稿,您的出版商不会强迫您使用 PDFTeX 和旧字体。然后,您可以设置您选择的任何 OpenType 字体,例如\usepackage{newcomputermodern}
默认 TeX 字体的稍暗克隆。
不过,与 PDFTeX 兼容的方法是添加
\usefonttheme{serif}