# putting two indices and exponents side to side

I did not find the answer to my following question on the web. I apologize in advance if this question has already been answered somewhere. I would like to write a matrix with the two subscripts and exponents side by side, like in the following latex command.

${\left( T_{ij}\right)_{i=1}^n}_{j=1}^{p}$


However, in the command above, the indices and exponents are not at the same height. Does anyone know how to put them at the same height (while keeping them horizontally aligned)?

-
Try using \struts, as in $${\left(T_{ij}\right)_{i=1\strut}^{n\strut}}_{j=1\strut}^{p\strut}$$, to ensure that the boxes are all the same height. – ChrisS Apr 27 '14 at 11:24
What is \strut ? – Tarass Apr 27 '14 at 15:21

A workaround:

\documentclass{article}

\begin{document}
${ \left( T_{ij} \right) _{i=1} ^{n} } { \vphantom{ \left( T_{ij} \right) } } _{j=1} ^{p}$
\end{document}


Remark:

• A \vphantom makes an invisible box with width zero, but the height and depth of the formula.
-
Ok this works nicely for me. Many thanks! – user144871 Apr 27 '14 at 11:43

I would write it like a sum:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\mathop{(T_{ij})}\limits_{i=1,\, j=1}^{n,\, p}$

\end{document}


-

A different solution, using a variant of smallmatrix; it can be adjusted to cope with higher parentheses:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{lsmallmatrix}{\null\vcenter\bgroup
\Let@\restore@math@cr\default@tag
\baselineskip6\ex@ \lineskip1.5\ex@ \lineskiplimit\lineskip
\ialign\bgroup$\m@th\scriptstyle##$\hfil&&\thickspace
$\m@th\scriptstyle##$\hfil\crcr
}{%
\crcr\noalign{\vskip-.4ex}\egroup\egroup
}
\makeatother

\newcommand{\dbllimits}[3][.3ex]{%
\begin{lsmallmatrix}
#3\$#1] #2 \end{lsmallmatrix} } \begin{document} \[ (T_{ij})\dbllimits{i=1 & j=1}{n & p} \left(\frac{i}{j}\right)\!\!\dbllimits[3ex]{i=1 & j=1}{n & p}$

\end{document}


However, I'd write this in one of the following two ways:

$(T_{ij})_{\substack{1\le i\le n\\[2pt] 1\le j\le p}} \qquad (T_{ij})_{1\le i\le n,\,1\le j\le p}$


-

We can make a macro \dblbounds with a simple syntax using the stackengine and xstring packages. Using in addition xparse, we can define a macro \multibounds that accepts any number of bounds as a list, with an even simpler syntax: only one argument, the different "bounds" are written with the same syntax as above, and separated by a semicolon:

\documentclass[a4paper, 11pt]{book}

\usepackage{mathtools}
\usepackage{xstring, xparse}
\usepackage{stackengine}

\newcommand\dblbound[2]{\!\everymath{\scriptstyle}\setstackgap{L}{0.8\baselineskip}\Vectorstack[l]{\StrBehind{#1}{..} \StrBefore{#1}{..}}\:\Vectorstack[l]{\StrBehind{#2}{..} \StrBefore{#2}{..}}}

\newcommand\myVectorstack[1]{\def\stackalignment{l}\setstackEOL{..}\everymath{\scriptstyle}%
\raisebox{1pt}{\Vectorstack{\StrBehind{#1}{..}..\StrBefore{#1}{..}}}\:}
\DeclareDocumentCommand \multibounds
{ > { \SplitList { ; } } m}
{\!\ProcessList{#1}{\myVectorstack}}

\begin{document}

$% \left( T_{ij} \right)\dblbound{i = 1..n}{j = 1..p}% \qquad \begin{pmatrix}\displaystyle T_{i, j, k}\end{pmatrix}\multibounds{i = 1..n ; j = 1..p; k = 1.. q}{}$%

\end{document}


-