2

I would like to make the following summation sign as wide as the subscript (but not taller) in the display mode:

\[ \sum_{i_1, i_2,\cdots,i_m=1}^n\]
  • 1
    Please clarify whether you use display or inline math, best by providing a MWE. – TeXnician Apr 23 '17 at 9:06
  • By "wide enough", do you mean "as wide as the subscript"? – Torbjørn T. Apr 23 '17 at 9:08
  • yes. As wide as the subscript and if not possible as wide as possible. – David R Apr 23 '17 at 9:09
  • In display math. I edited the question. – David R Apr 23 '17 at 9:10
  • 2
    BTW, the ellipsis should be on the base line: \dots instead of \cdots. – Heiko Oberdiek Apr 23 '17 at 9:42
14

I don't think you want something like this

oh, that's awful!

or

enter image description here

Code for the first image

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\newcommand{\widesum}[2]{%
  \mathop{\vcenter{\hbox{\dowidesum{#1}{#2}}}}_{#1}^{#2}
}
\newcommand{\dowidesum}[2]{%
  \sbox0{$\scriptstyle#1$}%
  \dimen0=\wd0
  \sbox0{$\scriptstyle#2$}%
  \ifdim\wd0>\dimen0 \dimen0=\wd0\fi
  \resizebox{\dimen0}{\height}{$\displaystyle\sum$}%
}

\begin{document}

\[
\widesum{i_1, i_2,\cdots,i_m=1}{n}
\]

\end{document}

Code for the second image

Just change \height into !

Better?

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}

\[
\sum_{\substack{1\le i_k\le n\\1\le k\le m}}
\]

\end{document}

enter image description here

2

You can use xparse embellishments for this.

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn

\box_new:N \l_tmpc_box
\cs_new:Nn \dim_max:nnn
{
  \dim_max:nn { \dim_max:nn { #1 } { #2 } } { #3 }
}

\NewDocumentCommand \dowidesum { m m }
{
  \hbox_set:Nn \l_tmpa_box { $\mathsurround=0pt\scriptstyle#1$ }
  \hbox_set:Nn \l_tmpb_box { $\mathsurround=0pt\scriptstyle#2$ }
  \hbox_set:Nn \l_tmpc_box { $\mathsurround=0pt\displaystyle\sum$ }
  \dim_set:Nn \l_tmpa_dim
  {
    \dim_max:nnn
    { \box_wd:N \l_tmpa_box }
    { \box_wd:N \l_tmpb_box }
    { \box_wd:N \l_tmpc_box }
  }
  \box_resize_to_wd_and_ht:Nnn \l_tmpc_box { \l_tmpa_dim } { \box_ht:N \l_tmpc_box }
  \mathop{\box_use:N \l_tmpc_box}\limits\sp{#1}\sb{#2}
}

\ExplSyntaxOff

\NewDocumentCommand \widesum {e{^_}}
{
  \dowidesum{#1}{#2}
}

\begin{document}

\[ \widesum_{i_1, i_2,\cdots,i_m=1}^n \]

\end{document}

enter image description here

  • The syntax for the e specifier will soon be changing, stay tuned. – egreg Apr 23 '17 at 9:43
  • Embellishment??? – Bernard Apr 23 '17 at 10:00
  • @Bernard That's what the L3 team calls these e-type arguments. – Henri Menke Apr 23 '17 at 10:08
  • @HenriMenke The change to e arguments have been deployed; you should directly define \widesum with argument list e{^_} (and the same replacement text as \dowidesum). – egreg Jun 12 '17 at 21:45
  • @egreg This doesn't quite work because _ has catcode 12 inside \ExplSyntaxOn...Off. But I adapted the rest of the syntax. – Henri Menke Jun 12 '17 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.