1

There are ways to set global style. But how about add user define code?

If the use of the following summation notation is expected to appear for countless times:

\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty}

Is there any way to user-define this string into a certain code at the very beginning of the document such as "SUM" and later on when I type something like:

$SUM$

I can get the result analogous to

$\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty}$

And when I type:

$\displaystyle SUM a_i(x_ty_t)+SUM b_i(y_t)^2$

I will have:

$\displaystyle \sum_{i=1}^n \lim\limits_{t\rightarrow -\infty} a_i(x_ty_t)+\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty} b_i(y_t)^2$
Howard
  • 377
  • 2
  • 10
  • Well, not SUM but \newcommand{\MYSUM}{\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty} will do with \MYSUM. That's the purpose of macro definitions ;-) ... \to is perhaps better than \rightarrow –  Feb 05 '16 at 01:12
  • 2
    why using \displaystyle in inline math?` – David Carlisle Feb 05 '16 at 01:15
  • to make the "limits" position at the top and bottom of the summation – Howard Feb 05 '16 at 01:18
  • @Howard, this would increase the height of your text line –  Feb 05 '16 at 01:18
  • @ChristianHupfer Is there any package required for "\newcommand{\MYSUM}{\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty}"? I get an error " File ended while scanning use of @argdef." when adding it before \begin{document}. – Howard Feb 05 '16 at 01:22
  • @Howard: Sorry, I forgot a } in my comment above. See my answer –  Feb 05 '16 at 01:24
  • 2
    if you want limits on the sum you should use \sum\limits (as you have for \int), \displaystyle changes the whole formula but the whole point of inline math is to use a compressed style that fits in the line spacing of a paragraph and that defeats it, better to use a display \[\sum....\] in that case. – David Carlisle Feb 05 '16 at 01:24

1 Answers1

2

Perhaps this is meant. More features require a command with arguments etc.

The \displaystyle isn't recommended for inline math, since it increases the text height of the line, see the Inline: text.

\documentclass{article}


\newcommand{\MYSUM}{\sum_{i=1}^n \lim\limits_{t\rightarrow -\infty}}

\begin{document}
$\MYSUM$

Inline: $\displaystyle \MYSUM a_i(x_ty_t)+\MYSUM b_i(y_t)^2$

Inline: $\MYSUM a_i(x_ty_t)+\MYSUM b_i(y_t)^2$
\end{document}

enter image description here