在下面的代码中,当字体缩小时,数字上标和下标无法正确缩放或看起来“不好看”。有没有办法让上标和下标很好地缩放或这样可以呈现?:
这是我正在测试的代码:
代码
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{amssymb,amsthm}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother
\DeclareMathOperator{\di}{d\!}
\newcommand*\Eval[3]{\left.#1\right\rvert_{#2}^{#3}}
%======================================================================================
% FONTS
%======================================================================================
\usepackage{unicode-math} % loads 'fontspec' automatically
\setmainfont{Fira Sans Light}[
Numbers = OldStyle,
BoldFont = Fira Sans Medium,
ItalicFont = Fira Sans Light Italic,
BoldItalicFont= Fira Sans Medium Italic]
\setsansfont{Fira Sans Light}[
Numbers = OldStyle,
BoldFont = Fira Sans Medium,
ItalicFont = Fira Sans Light Italic,
BoldItalicFont= Fira Sans Medium Italic]
% For source code
\setmonofont{Source Code Pro Light}[
BoldFont=Source Code Pro]
%% Math font
\setmathfont{Asana Math} % or some other suitable font
\advance\topmargin-1in
\advance\textheight3in
\advance\textwidth3in
\advance\oddsidemargin-1.5in
\advance\evensidemargin-1.5in
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
\begin{document}
\begin{multicols*}{3}
\newtcolorbox{mybox}[2][]{text width=0.97\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
title=#2,colback=white}
%%------------ AM: Double Sideband Large Carrier ---------------
\hspace*{0.07cm}
\begin{minipage}{0.30\textwidth}
\begin{mybox}{AM: Double Sideband Large Carrier [DSB-LC\text{]}}
\hspace*{-0.5cm}\tiny{Pwr Eff:} $\eta=\frac{\text{Pwr in DSB-SC Side Bands}}{\text{Total Pwr in AM Signal}}=\dfrac{\frac{1}{2}K^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}{\frac{1}{2}A^{2}_{c}+\frac{1}{2}%
k^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}=\dfrac{\overline{m^{2}(t)}}{1/k^{2}_{a}+\overline{m^{2}(t)}}\quad
=\frac{\overline{m^{2}(t)}}{A^{2}+\overline{m^{2}(t)}}=\fbox{$\frac{\mu^{2}}{2+\mu^{2}}$}$
\end{mybox}
\end{minipage}
\end{multicols*}
\end{document}
答案1
看起来数学只是\tiny
由于标记错误而导致的
{\tiny Pwr Eff:}
但是,如果您确实想要那么小的字体,请使用声明下标和下标大小\DeclareMathSize
,如下面的第二个版本所示。
\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{amssymb,amsthm}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother
\DeclareMathOperator{\di}{d\!}
\newcommand*\Eval[3]{\left.#1\right\rvert_{#2}^{#3}}
%======================================================================================
% FONTS
%======================================================================================
\usepackage{unicode-math} % loads 'fontspec' automatically
\parindent0pt
\parskip2pt
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
\DeclareMathSizes{5}{5}{3}{2.5}% really?
\begin{document}
\begin{multicols*}{3}
\newtcolorbox{mybox}[2][]{text width=0.97\textwidth,fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize, colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},top=3pt,bottom=2pt,
title=#2,colback=white}
%%------------ AM: Double Sideband Large Carrier ---------------
\begin{minipage}{0.30\textwidth}
\begin{mybox}{AM: Double Sideband Large Carrier [DSB-LC\text{]}}
\hspace*{-0.5cm}{\tiny Pwr Eff:}
$\eta=\frac{\text{Pwr in DSB-SC Side Bands}}{\text{Total Pwr in AM Signal}}=
\dfrac{\frac{1}{2}K^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}{\frac{1}{2}A^{2}_{c}+\frac{1}{2}%
k^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}=\dfrac{\overline{m^{2}(t)}}{1/k^{2}_{a}+\overline{m^{2}(t)}}\quad
=\frac{\overline{m^{2}(t)}}{A^{2}+\overline{m^{2}(t)}}=\fbox{$\frac{\mu^{2}}{2+\mu^{2}}$}$
\end{mybox}
\end{minipage}
\begin{minipage}{0.30\textwidth}
\begin{mybox}{AM: Double Sideband Large Carrier [DSB-LC\text{]}}
\hspace*{-0.5cm}\tiny Pwr Eff:
$\eta=\frac{\text{Pwr in DSB-SC Side Bands}}{\text{Total Pwr in AM Signal}}=
\dfrac{\frac{1}{2}K^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}{\frac{1}{2}A^{2}_{c}+\frac{1}{2}%
k^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}=\dfrac{\overline{m^{2}(t)}}{1/k^{2}_{a}+\overline{m^{2}(t)}}\quad
=\frac{\overline{m^{2}(t)}}{A^{2}+\overline{m^{2}(t)}}=\fbox{$\frac{\mu^{2}}{2+\mu^{2}}$}$
\end{mybox}
\end{minipage}
\end{multicols*}
\end{document}
答案2
使用\tiny
,会影响整个盒子的其余部分,是导致问题的主要原因。我认为甚至没有必要使用\tiny
。
既然您无论如何都要加载geometry
包,我会设置一个选项,而margin=3mm
不是使用五个\advance
语句来修改一些低级文本块参数。
而且,既然您正在加载mathtools
包,请考虑使用aligned
环境来排版两行公式。通过使用环境aligned
,您还可以更好、更直接地控制公式中的换行符出现的位置。特别是,换行符将不再受所选环境宽度的支配minipage
。
以下屏幕截图显示了原始代码和一些实现上述建议的代码的输出。顺便说一句,我不得不注释掉加载文本字体的命令,因为这些字体似乎没有安装在我的系统上。
\documentclass{article}
\usepackage[landscape,margin=3mm]{geometry}
%\advance\topmargin-1in
%\advance\textheight3in
%\advance\textwidth3in
%\advance\oddsidemargin-1.5in
%\advance\evensidemargin-1.5in
\usepackage[table]{xcolor}
\usepackage{mathtools}
\usepackage{multicol,lipsum}
\usepackage{amssymb,amsthm}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\newtcolorbox{mybox}[2][]{%
text width=0.97\textwidth,
fontupper=\scriptsize,
fonttitle=\bfseries\sffamily\scriptsize,
colbacktitle=black,enhanced,
attach boxed title to top left={yshift=-2mm,xshift=3mm},
boxed title style={sharp corners},
top=3pt,bottom=2pt,
title=#2,colback=white}
\makeatletter
\newcommand*\bigcdot{\mathpalette\bigcdot@{.5}}
\newcommand*\bigcdot@[2]{%
\mathbin{\vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}}}
\makeatother
\DeclareMathOperator{\di}{d\!}
\newcommand*\Eval[3]{\left.#1\right\rvert_{#2}^{#3}}
%============================================================
% FONTS
%============================================================
\usepackage{unicode-math} % loads 'fontspec' automatically
%%% I've commented out the following lines since the
%%% the text fonts aren't installed on my system.
%\setmainfont{Fira Sans Light}[
% Numbers = OldStyle,
% BoldFont = Fira Sans Medium,
% ItalicFont = Fira Sans Light Italic,
% BoldItalicFont= Fira Sans Medium Italic]
%\setsansfont{Fira Sans Light}[
% Numbers = OldStyle,
% BoldFont = Fira Sans Medium,
% ItalicFont = Fira Sans Light Italic,
% BoldItalicFont= Fira Sans Medium Italic]
%% For source code
%\setmonofont{Source Code Pro Light}[
% BoldFont=Source Code Pro]
%% Math font
\setmathfont{Asana Math} % or some other suitable font
\setlength{\parindent}{0pt}
\setlength{\parskip}{2pt}
\newcommand{\hr}{\centerline{\rule{3.5in}{1pt}}}
\begin{document}
\begin{multicols*}{3}
%% ------ AM: Double Sideband Large Carrier ------
%\hspace*{0.07cm}
\begin{minipage}{0.3\textwidth}
\begin{mybox}{AM: Double Sideband Large Carrier [DSB-LC\text{]}}
\hspace*{-0.5cm}
\tiny{Pwr Eff:} $\eta=\frac{\text{Pwr in DSB-SC Side Bands}}{\text{Total Pwr in AM Signal}}=\dfrac{\frac{1}{2}K^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}{\frac{1}{2}A^{2}_{c}+\frac{1}{2}%
k^{2}_{a}A^{2}_{c}\overline{m^{2}(t)}}=\dfrac{\overline{m^{2}(t)}}{1/k^{2}_{a}+\overline{m^{2}(t)}}\quad
=\frac{\overline{m^{2}(t)}}{A^{2}+\overline{m^{2}(t)}}=\fbox{$\frac{\mu^{2}}{2+\mu^{2}}$}$
\end{mybox}
\end{minipage}
\bigskip
\begin{minipage}{0.9\columnwidth}
\begin{mybox}{AM: Double Sideband Large Carrier [DSB-LC{]}}
%\hspace*{-0.5cm}
Pwr Eff:\quad
$\begin{aligned}[t]
\eta
&= \frac{\text{Pwr in DSB-SC Sidebands}}{%
\text{Total Pwr in AM Signal}}
= \frac{\frac{1}{2}K^2_aA^2_c\,\overline{m^2(t)}}{%
\frac{1}{2}A^2_c +\frac{1}{2}k^2_a A^2_c\,\overline{m^2(t)}}\\
&= \frac{\overline{m^2(t)}}{1/k^2_a +\overline{m^2(t)}}
= \frac{\overline{m^2(t)}}{A^2 +\overline{m^2(t)}}
= \fbox{$\dfrac{\mu^2}{2+\mu^2}$}
\end{aligned}$
\end{mybox}
\end{minipage}
\end{multicols*}
\end{document}