我目前正在输入一份包含许多sum
符号的数学文档。我经常使用该align
环境来渲染方程式,尽管该环境的默认行为是渲染方程式displaystyle
\textstyle
,但我认为这会浪费垂直空间。因此,我在此环境中的每一行数学开头都添加了,但我正在寻找更方便的解决方案。
那么是否存在类似的环境align
除了默认显示textstyle
数学之外?谢谢。
答案1
不确定这个用途是什么,但这是一种可行的方法;它基于在每个单元格中发布声明的事实;当然,这有严重的局限性,因为align
例如将不起作用。\displaystyle
\dfrac
\documentclass{article}
\usepackage{amsmath}
\newenvironment{talign}
{\let\displaystyle\textstyle\align}
{\endalign}
\newenvironment{talign*}
{\let\displaystyle\textstyle\csname align*\endcsname}
{\endalign}
\begin{document}
This is a normal \texttt{align} environment
\begin{align}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{align}
and this is a \texttt{talign} environment
\begin{talign}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{talign}
followed by an unnumbered one
\begin{talign*}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{talign*}
\end{document}
如果希望能够在子公式中使用,则需要采用更复杂的方法:本地定义\displaystyle
命令以发出并将其自身重新定义为原始的。\displaystyle
\textstyle
\displaystyle
\documentclass{article}
\usepackage{amsmath}
\let\texdisplaystyle\displaystyle
\def\displaytotextstyle{\textstyle\let\displaystyle\texdisplaystyle}
\newenvironment{talign}
{\let\displaystyle\displaytotextstyle\align}
{\endalign}
\newenvironment{talign*}
{\let\displaystyle\displaytotextstyle\csname align*\endcsname}
{\endalign}
\begin{document}
This is a normal \texttt{align} environment
\begin{align}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{align}
and this is a \texttt{talign} environment
\begin{talign}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\dfrac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\dfrac{x^{2n+1}}{2n+1}
\end{talign}
followed by an unnumbered one
\begin{talign*}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{talign*}
\end{document}
答案2
我将其替换\displaystyle
为\textstyle
。同样,\dfrac
它将按预期工作。
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\renewcommand{\align@preamble}{%
&\hfil%
\strut@%
\setboxz@h{\@lign$\m@th\textstyle{##}$}%
\ifmeasuring@\savefieldlength@\fi%
\set@field%
\tabskip\z@skip%
&\setboxz@h{\@lign$\m@th\textstyle{{}##}$}%
\ifmeasuring@\savefieldlength@\fi%
\set@field%
\hfil%
\tabskip\alignsep@%
}
\makeatother
\begin{document}
\begin{align}
\log(1+x) &= \sum_{n\ge 1}(-1)^{n+1}\frac{x^n}{n} \\
\arctan x &= \sum_{n\ge 0}(-1)^{n}\frac{x^{2n+1}}{2n+1}
\end{align}
\end{document}
答案3
\begin{align}
& \text{not displayed (inline) math inside align environment:} \cr
& \begin{array}{l}
\int_{-1}^1 x dx = \int_1^{-1} x dx
\end{array} \cr
& \begin{array}{l}
\sup_{0<x<1} x^2 = 1
\end{array} \cr
& \text{usual displayed math inside align environment:} \cr
& \int_{-1}^1 x dx = \int_1^{-1} x dx \cr
& \sup_{0<x<1} x^2 = 1
\end{align}