[Tex/LaTex] Justification inside Substack

horizontal alignmentsubscripts

How can I left-justify inside substack?

\documentclass{standalone}
\usepackage{amsmath}

\begin{document}

$L_{\textrm{disk}} = L_{ \substack{\textrm{disk} \\ \textrm{orbital} } } + L_{ \substack{\textrm{disk} \\ \textrm{spin} } }#$

\end{document}

yields

enter image description here

I tried using \raggedright inside the \substack, but this failed.

Best Answer

You can use \begin{subarray}{l}, but perhaps it's better to define a new command based on subarray (just like \substack is based on subarray).

\documentclass[border=2bp]{standalone}
\usepackage{amsmath}

\makeatletter
\newenvironment{tsubarray}[1]{%
  \vcenter\bgroup
  \Let@ \restore@math@cr \default@tag
  \baselineskip\fontdimen10 \scriptfont\tw@
  \advance\baselineskip\fontdimen12 \scriptfont\tw@
  \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
  \lineskiplimit\lineskip
  \check@mathfonts
  \ialign\bgroup\ifx c#1\hfil\fi
    \normalfont\fontsize\sf@size\z@\selectfont\ignorespaces##\unskip\hfil\crcr
}{%
  \crcr\egroup\egroup
}
\makeatother
\newcommand{\tsub}[1]{\begin{tsubarray}{l}#1\end{tsubarray}}

\begin{document}

$L_{\tsub{disk}} = L_{\tsub{disk \\ orbital}} + L_{\tsub{disk \\ spin}}$

\end{document}

You have the advantage of not needing \textrm and also this avoids the subscripts being typeset in italic if the formula appears in an italic context like a theorem statement, because \normalfont takes care of selecting the default upshape font.

The argument to tsubarray can be c or l.

enter image description here