MdSymbol
是一个优秀的无数学(仅符号)字体宏包
我觉得\int
它的上标太紧了,如何设置\int
它的上标之间的间距?
这是一个例子,请使用它
\documentclass[10pt,utf8]{beamer}
\usepackage[T1]{fontenc}
\usepackage{sansmathfonts}
\usepackage{mdsymbol}
\newcommand*\uppi\pi
\begin{document}
\begin{frame}
\begin{align*}
\int_{-\frac{\uppi}2}^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\,\mathrm{d}x
&{} = 2\int_0^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\,\mathrm{d}x
= 2\int_0^{\frac{\uppi}2} \frac{\cos^2 x}{1+\cos^4 x}\,\mathrm{d}x\\
&{} = 2\int_0^{\frac{\uppi}2} \frac{\sec^2 x}{\sec^4 x + 1}\,\mathrm{d}x
= 2\int_0^{\frac{\uppi}2} \frac{\mathrm{d}(\tan x)}{(1+\tan^2 x)^2 + 1}\\
(\tan x \wedgeq u)\quad
&{} = 2\int_0^{+\infty} \frac{\mathrm{d}t}{(1+t^2)^2 + 1}
= \int_{-\infty}^{+\infty} \frac{\mathrm{d}t}{(1+t^2)^2 + 1}\\
\Bigl(t \wedgeq \frac1u\Bigr)\quad
&{} = \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{u^2 + \frac1{2u^2}+1}
= \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{\bigl(u-\frac1{u\sqrt{2}}\bigr)^2 + (\sqrt{2}+1)}\\
&{} = \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{u^2 + (\sqrt{2}+1)}
= \frac{\uppi}{2\sqrt{\sqrt{2}+1}} = \frac{\uppi}{2}\sqrt{\sqrt{2}-1}.
\end{align*}
It's using follow $\int^0 \dotsi \int^\infty \dotsi \int^d \dotsi \int^g$\quad%
$\displaystyle \int^0 \dotsi \int^\infty \dotsi \int^d \dotsi \int^g$
\[
\int_{-\infty}^{+\infty} f\Bigl(x-\frac{a}{x}\Bigr)\,\mathrm{d}x
= \int_{-\infty}^{+\infty} f(x)\,\mathrm{d}x, \quad
\int_{-\infty}^{+\infty} \frac{\mathrm{d}x}{x^2 + \alpha^2}
= \frac{\uppi}{\alpha}\quad (a>0,\alpha>0).
\]
\end{frame}
\end{document}
答案1
您可以使用e
参数说明符xparse
进行扫描,查看是否出现下标或上标。如果出现,则添加\,
到上标和\!
到下标。
这是通过\fixlimits
在 的工作末尾添加来实现的\int
。您可能希望对其他整数类型执行类似的操作,\xapptocmd
每个整数类型都有类似的行。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{sansmathfonts}
\usepackage{mdsymbol}
\usepackage{xparse,xpatch}
\newcommand{\uppi}{\pi}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\NewDocumentCommand{\fixlimits}{e{^_}}{%
\IfValueT{#1}{^{\,#1}}%
\IfValueT{#2}{_{\!#2}}%
}
\xapptocmd{\int}{\fixlimits}{}{}
\begin{document}
\begin{align*}
\int_{-\frac{\uppi}2}^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\diff x
&{} = 2\int_0^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\diff x
= 2\int_0^{\frac{\uppi}2} \frac{\cos^2 x}{1+\cos^4 x}\diff x\\
&{} = 2\int_0^{\frac{\uppi}2} \frac{\sec^2 x}{\sec^4 x + 1}\diff x
= 2\int_0^{\frac{\uppi}2} \frac{\diff (\tan x)}{(1+\tan^2 x)^2 + 1}\\
(\tan x \wedgeq u)\quad
&{} = 2\int_0^{+\infty} \frac{\diff t}{(1+t^2)^2 + 1}
= \int_{-\infty}^{+\infty} \frac{\diff t}{(1+t^2)^2 + 1}\\
\Bigl(t \wedgeq \frac1u\Bigr)\quad
&{} = \frac12\int_{-\infty}^{+\infty} \frac{\diff u}{u^2 + \frac1{2u^2}+1}
= \frac12\int_{-\infty}^{+\infty} \frac{\diff u}{\bigl(u-\frac1{u\sqrt{2}}\bigr)^2 + (\sqrt{2}+1)}\\
&{} = \frac12\int_{-\infty}^{+\infty} \frac{\diff u}{u^2 + (\sqrt{2}+1)}
= \frac{\uppi}{2\sqrt{\sqrt{2}+1}} = \frac{\uppi}{2}\sqrt{\sqrt{2}-1}.
\end{align*}
It's using follow $\int^0 \dotsi \int^\infty \dotsi \int^d \dotsi \int^g$\quad%
$\displaystyle \int^0 \dotsi \int^\infty \dotsi \int^d \dotsi \int^g$
\[
\int_{-\infty}^{+\infty} f\Bigl(x-\frac{a}{x}\Bigr)\diff x
= \int_{-\infty}^{+\infty} f(x)\diff x, \quad
\int_{-\infty}^{+\infty} \frac{\diff x}{x^2 + \alpha^2}
= \frac{\uppi}{\alpha}\quad (a>0,\alpha>0).
\]
\end{document}
与此同时,我改变了所有明确的内容,\mathrm{d}
所以当你最终回到数学家的世界时,你只需改变一行就可以让你的 d 变成斜体。;-)
答案2
假设您可以使用 LuaLaTeX,那么可以直接“动态”应用一些间距调整,前TeX 开始其常规处理。
以下基于 LuaLaTeX 的解决方案中的工作假设是积分的下限和上限要么由单个字母或数字组成,要么用花括号括起来。因此,\int_0^1
可以处理,而\int^\infty
不能。(您需要写\int^{\infty}
- 这可能是一种很好的做法。)还假设下限总是在上限之前输入。最后,只有上限的积分是可以的。
下面的代码将下限向左移动(移动2mu
),将上限向右移动(同样移动2mu
);您可以随意调整移动量。哦,3mu
相当于 1 个单位的细空间(= 1/6em
)。
运行 即可激活 Lua 函数\AdjustIntSpacingOn
。如果您需要停用它,只需运行 即可\AdjustIntSpacingOff
。
\documentclass[10pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{sansmathfonts,mdsymbol}
\let\uppi\pi
\usepackage{luacode}
\begin{luacode}
function int_spacing ( s )
s = s:gsub ( "\\int%s-_%s-(%b{})%s-^%s-(%b{})" , "\\int_{\\mkern-2mu%1}^{\\mkern2mu%2}" )
s = s:gsub ( "\\int%s-_%s-(%w)%s-^%s-(%b{})" , "\\int_{\\mkern-2mu%1}^{\\mkern2mu%2}" )
s = s:gsub ( "\\int%s-_%s-(%w)%s-^%s-(%w)" , "\\int_{\\mkern-2mu%1}^{\\mkern2mu%2}" )
s = s:gsub ( "\\int%s-^%s-(%b{})" , "\\int^{\\mkern2mu%1}" )
s = s:gsub ( "\\int%s-^%s-(%w)" , "\\int^{\\mkern2mu%1}" )
return s
end
\end{luacode}
\newcommand\AdjustIntSpacingOn{\directlua{luatexbase.add_to_callback(
"process_input_buffer", int_spacing, "int_spacing")}}
\newcommand\AdjustIntSpacingOff{\directlua{luatexbase.remove_from_callback(
"process_input_buffer", "int_spacing")}}
\AtBeginDocument{\AdjustIntSpacingOn}
\begin{document}
\begin{frame}
\begin{align*}
\int_{-\frac{\uppi}2}^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\,\mathrm{d}x
&= 2\int_0^{\frac{\uppi}2} \frac{\sin^2 x}{1+\sin^4 x}\,\mathrm{d}x
= 2\int_0^{\frac{\uppi}2} \frac{\cos^2 x}{1+\cos^4 x}\,\mathrm{d}x\\
&= 2\int_0^{\frac{\uppi}2} \frac{\sec^2 x}{\sec^4 x + 1}\,\mathrm{d}x
= 2\int_0^{\frac{\uppi}2} \frac{\mathrm{d}(\tan x)}{(1+\tan^2 x)^2 + 1}\\
(\tan x \wedgeq u)\quad
&= 2\int_0^{+\infty} \frac{\mathrm{d}t}{(1+t^2)^2 + 1}
= \int_{-\infty}^{+\infty} \frac{\mathrm{d}t}{(1+t^2)^2 + 1}\\
\Bigl(t \wedgeq \frac1u\Bigr)\quad
&= \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{u^2 + \frac1{2u^2}+1}
= \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{\bigl(u-\frac1{u\sqrt{2}}\bigr)^2 + (\sqrt{2}+1)}\\
&= \frac12\int_{-\infty}^{+\infty} \frac{\mathrm{d}u}{u^2 + (\sqrt{2}+1)}
= \frac{\uppi}{2\sqrt{\sqrt{2}+1}} = \frac{\uppi}{2}\sqrt{\sqrt{2}-1}\,.
\end{align*}
It's using
$\int_0^1 \dotsi \int{^\infty} \dotsi \int^d \dotsi \int^g$\quad
$\displaystyle
\int_0^1 \dotsi \int^{\infty} \dotsi \int^d \dotsi \int^g$
\[
\int_{-\infty}^{+\infty} f\Bigl(x-\frac{a}{x}\Bigr)\,\mathrm{d}x
= \int_{-\infty}^{+\infty} f(x)\,\mathrm{d}x, \quad
\int_{-\infty}^{+\infty} \frac{\mathrm{d}x}{x^2 + \alpha^2}
= \frac{\uppi}{\alpha}\quad (a>0,\alpha>0)\,.
\]
\end{frame}
\end{document}