我有一段用于定制 tcolorbox 的代码(我使用 XeTeX 进行字体管理):
\documentclass[10pt, oneside]{book}
\usepackage[skins]{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{fontspec}
\setmainfont[Path=../../FONTES/,
Variant=1,
BoldItalicFont=cambriaz.ttc,
BoldFont =cambriab.ttc,
ItalicFont =cambriai.ttc]
{cambria.ttc}
\newfontfamily\fonteverdana[Path=../../FONTES/,
BoldItalicFont=verdanaz.ttf,
BoldFont =verdanab.ttf,
ItalicFont =verdanai.ttf]
{verdana.ttf}
\usepackage{setspace}
\newenvironment{completa}[1][]{\fonteverdana\normalsize\par\addvspace{12pt plus1pt minus1pt}%
\begin{tcolorbox}[enhanced,
breakable,
code={\onehalfspacing},
center title,
title = \fontsize{11}{13}\fonteverdana\textbf{SOLUTION}\vspace{-10pt},
colback=yellow,
colframe=black,
boxrule=.7pt,
arc=0mm,
titlerule=0mm,
colbacktitle=yellow,
coltitle=black,
]{#1\par\vskip8pt}
}{\end{tcolorbox}%
\par\addvspace{9pt plus1pt minus1pt}}
\begin{document}
\begin{completa}
Here I have a number, $2$. As it can be seen it's smaller than it should be. Here's another example:
$$2\times 4 = 8$$
I think that's probably happening because the font is big. But I can't find anyway of changing it.
\end{completa}
\end{document}
当我编译它时,我注意到数学字体与正文相比变得太小了。有什么想法吗?我尝试以fontsize
某种方式输入一些命令,但无法弄清楚。请参见下面的框:
答案1
这是使用软件包执行此操作的一种方法unicode-math
。这需要使用 OpenType 数学字体,这会在一定程度上限制您的选择。但由于您使用 Cambria 作为主要字体,因此我在此示例中使用了 Cambria Math。该unicode-math
软件包允许您创建不同的数学版本,因此我们创建一个缩放以匹配 Verdana 的版本并在框中使用它。
\documentclass[10pt, oneside]{book}
\usepackage[skins]{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage[math-style=TeX]{unicode-math}
\setmathfont{Cambria Math}[version=main]
\setmathfont{Cambria Math}[version=box,Scale=1.2]
%\setmainfont[Path=../../FONTES/,
% Variant=1,
% BoldItalicFont=cambriaz.ttc,
% BoldFont ˚=cambriab.ttc,
% ItalicFont =cambriai.ttc]
% {cambria.ttc}
%
\setmainfont{Cambria}
\newfontfamily\fonteverdana[]{Verdana}
%\newfontfamily\fonteverdana[Path=../../FONTES/,
% BoldItalicFont=verdanaz.ttf,
% BoldFont =verdanab.ttf,
% ItalicFont =verdanai.ttf]
% {verdana.ttf}
\usepackage{setspace}
\newenvironment{completa}[1][]{\fonteverdana\normalsize\par\addvspace{12pt plus1pt minus1pt}%
\begin{tcolorbox}[enhanced,
breakable,
code={\onehalfspacing\mathversion{box}},
center title,
title = \fontsize{11}{13}\fonteverdana\textbf{SOLUTION}\vspace{-10pt},
colback=yellow,
colframe=black,
boxrule=.7pt,
arc=0mm,
titlerule=0mm,
colbacktitle=yellow,
coltitle=black,
]{#1\par\vskip8pt}
}{\end{tcolorbox}%
\par\addvspace{9pt plus1pt minus1pt}}
\mathversion{main}
\begin{document}
Regular text:
\[2\times 4 = 8\]
Example text:
\begin{completa}
Here I have a number, $2$. As it can be seen it's \index{smaller} than it should be. Here's another example:
\[
2\times 4 = 8
\]
I think that's probably happening because the font is big. But I can't find anyway of changing it.
\end{completa}
\end{document}