Is it possible to use the align environment without the display math? For example, I would like \sum to look as if it were inline. The solution given here does not work, insofar as the summation symbols are still written in the big, display style. The alignat environment also produces this behaviour.
- 1,262
-
possible duplicate of Aligning in text (non-math) – Martin Van der Linden Apr 23 '15 at 19:36
3 Answers
You can use the fact that amsmath defines big operators in a uniform way; for instance \sum is redefined to use \sum@ surrounded by suitable macros.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\makesmaller}{m}
{
\goblin_makesmaller:n { #1 }
}
\cs_new_protected:Npn \goblin_makesmaller:n #1
{
\clist_map_inline:nn { #1 } { \goblin_makesmaller_sym:n { ##1 } }
}
\cs_new_protected:Npn \goblin_makesmaller_sym:n #1
{
\cs_gset_eq:cc { #1@saved@ } { #1@ }
\cs_set_protected:cpn { #1@ }
{
\mathop
{
\mathchoice { \textstyle \use:c { #1@saved@ } }
{ \use:c { #1@saved@ } }
{ \use:c { #1@saved@ } }
{ \use:c { #1@saved@ } }
}
}
}
\ExplSyntaxOff
\makesmaller{sum,bigoplus,bigcup}
\begin{document}
Here's an inline formula $\sum_{k=1}^n k^2=\frac{1}{6}n(n+1)(2n+1)$
and the same displayed, with some nonsense
\[
\bigoplus_{i\in I}\bigcup_{j=0}^{\infty}\sum_{k=1}^n k^2=\frac{1}{6}n(n+1)(2n+1)
\]
\end{document}
The argument to \makesmaller is the list of operators you want to be treated as \sum.
When you'll change your mind, hopefully soon ;-), just remove the call to \makesmaller.

- 1,121,712
As a workaround you can use \textstyle inside the aligned environment:
\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
text
$\begin{aligned}\textstyle
\sum_{i=1}^\infty&=1\\ \textstyle
\sum_{i=1}^\infty&=1
\end{aligned}$
more text
\end{document}
But it would be better to find better solution. It's more like a hack.

- 9,664
-
This seems to break the moment
\left(is used. e.g. \begin{aligned}\textstyle \left(\sum_{i=1}^\infty&=\right) \ \textstyle \sum_{i=1}^\infty&=1 \end{aligned} – goblin GONE Aug 07 '14 at 10:01 -
-
-
Thanks, but I'm still getting odd behaviours. Why doesn't the following code work, for example? \begin{aligned}\textstyle 2 &= \sum_{i \in k} i + \sum_{i \in k}i \ \textstyle 2 &= \sum_{i \in k} i + \sum_{i \in k}i \end{aligned} – goblin GONE Aug 07 '14 at 10:08
-
@goblin You need to put
\textstyleright before the\sumsymbols. Actually, @Bernard solution are much better with a custom\sumsymbol. – m0nhawk Aug 07 '14 at 10:10
You can define a \tsum command, just like there exists a \frac command. And also an \msum command (medium-sized sum), based on the nccmath package.
Another solution would be to use the tabstackengine package and its \alignCenterstack command. Here is a demonstration of all theses possibilities, with different vertical alignments:
\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}
\newcommand\tsum{\textstyle\sum\nolimits}
\newcommand\msum{\medop\sum}
\usepackage{tabstackengine}
\begin{document}
\noindent Text
$\begin{aligned}[t]
\tsum_{i = 1}^{n}x_{i}&=z\\
u+v&=w
\end{aligned}$
\enspace more text \enspace $ \sum_{i = 1}^{n}x_{i} $
\enspace more text\enspace
$\begin{aligned}[b]
\msum_{i = 1}^{n}x_{i}&=z\\
u+v&=w
\end{aligned}$
\enspace more text\enspace
$\begin{aligned}
\sum_{i = 1}^{n}x_{i}&=z\\
u+v&=w
\end{aligned}$
\enspace more text.
Some other text\enspace\stackMath\setstackgap{L}{3.5ex}$ \left[\alignCenterstack{
\sum_{i = 1}^{n}x_{i}&=z\\
\sum_{i = 1}^{n}u_{i} &=w }\right. $
\enspace more text.
\end{document}
