2

How can I left-align text in substack from amsmath? If it isn't built for this, is there a command which is?

This answer suggests that a tabular might work, but I don't know enough about fonts to do it myself: https://tex.stackexchange.com/a/728947/319072

I will study it in the mean time.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \xrightarrow
    [
        \substack
        {
            \text{This is some text.}\\ 
            \text{This is some more text.}
        }
    ]
    {}
\]
\end{document}

output

To elaborate on my above comment:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \xrightarrow
    [
        \begin{tabular}{@{}l@{}}
            \text{This text is not as small as substack text.}\\ 
            \text{Neither is this text.}
        \end{tabular}
    ]
    {
        \text{This is the size of substack text.}
    }
\]
\end{document}

output2

2
  • 1
    Isn't \substack{...} just \begin{subarray}{c}... \end{subarray} making the answer self evident.
    – daleif
    Commented Dec 2 at 7:25
  • @daleif ahh, change the column type to l. Thank you
    – Jasper
    Commented Dec 2 at 7:26

3 Answers 3

7

In amsmath the macro \substack{...} is defined as \begin{subarray}{c}...\end{subarray}.

Thus manually using \begin{subarray}{l}...\end{subarray} would make the same font size, but left aligned.

5

I guess from the question that your substacks should contain text only. Adapting code I wrote for another question of yours:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\NewDocumentCommand{\textsubstack}{O{c}m}{%
  \mbox{%
    \linespread{1}% just in case
    \fontsize{\sf@size}{\fpeval{1.1*\sf@size}}\selectfont
    \begin{tabular}{@{}#1@{}}#2\end{tabular}%
  }%
}
\NewCommandCopy{\amsmathxrightarrow}{\xrightarrow}
\RenewDocumentCommand{\xrightarrow}{om}{%
  \IfNoValueTF{#1}{%
    \amsmathxrightarrow{#2}%
  }{%
    \amsmathxrightarrow[{#1}]{#2}%
  }%
}
\makeatother

\begin{document}

\begin{gather*}
\xrightarrow[\textsubstack[l]{This is some text \\ This is some more text}]{f}
\\
\xrightarrow[\textsubstack{This is some text \\ This is some more text}]{f}
\\
\xrightarrow[\textsubstack[r]{This is some text \\ This is some more text}]{f}
\end{gather*}

\end{document}

output

The redefinition of \xrightarrow allows to nest optional arguments; do similarly for \xleftarrow if you also need it.

3

This is not the proper method, but it works:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \xrightarrow
    [
        \substack
        {\parbox{8pc}{
            \text{This is some text.}\\ 
            \text{This is some more text.}
        }}
    ]
    {}
\]
\end{document}

enter image description here

3
  • Is there a way to make the text the same size as substack text?
    – Jasper
    Commented Dec 2 at 7:23
  • Thank you for your answer, and sorry for accepting it prematurely. The subarray answer preserves the text size.
    – Jasper
    Commented Dec 2 at 7:47
  • 1
    @Jasper No issues, In my post itself, I've mentioned that its not the proper method, daleif is one of a great
    – MadyYuvi
    Commented Dec 2 at 9:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .