2

I am trying to make over/underset play nicely with scripts. However, the alignment is wrong, and I am not sure how to fix it.

If I put the prescript in the overset and underset, i.e. \underset{\beta}{\overset{\alpha}{\prescript{1}{4+5}{\Pi}}}, I get this:

enter image description here

If I put the overset and underset inside the prescript, i.e. \prescript{1}{4+5}{\underset{\beta}{\overset{\alpha}{\Pi}}}, I get this:

enter image description here

However, this is what I want:

enter image description here

How is this achievable in LaTeX?

2
  • Welcome to TeX.SE. Do you want \Pi, or do you maybe want \prod? (\Pi is to \prod as \Sigma is to \sum.) Please advise.
    – Mico
    Commented Feb 28 at 22:33
  • 1
    I want \Pi, I picked it because I was trying to replicate Typst code in LaTeX for a project I was doing, and just copied from the Typst documentation.
    – ejx
    Commented Mar 2 at 1:02

3 Answers 3

2

Add the prescripts to a phantom.

\documentclass{article}
\usepackage{amsmath,mathtools}

\newcommand{\adornPi}[4]{%
  \prescript{#1}{#2}{\vphantom{\Pi}}%
  \overset{#3}{\underset{#4}{\Pi}}%
}

\begin{document}

\[
\adornPi{1}{4+5}{\alpha}{\beta}
\]

\end{document}

enter image description here

1
  • Accepted, this is exactly what I was looking for. Thanks!
    – ejx
    Commented Mar 2 at 1:02
3

One way is to use sideset from the amsmath package. It requires the use of a large operator, so \prod instead of \Pi. Left-side scripts are left-justified, so adding \mathllap (mathtools, which includes amsmath) will place the longer script where it belongs.

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\[
\sideset{^1_{\mathllap{4+}5}}{}\prod^{\alpha}_{\beta}
\]

\end{document}
1
  • What if there's something in front of the symbol?
    – egreg
    Commented Feb 28 at 21:23
1

The following answer combines some of the ideas in @SandyG's and @egreg's answers. I use \prod rather than \Pi, while I also use \prescript rather than \sideset. The user macro \adornprod can be used in both text-style and display-style math mode.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for \prescript macro
\newcommand\adornprod[4]{%
   \prescript{#1}{#2}{\vphantom{\prod}}\prod\limits^{#3}_{#4}}
\begin{document}
$-\Pi\prod{\displaystyle\prod}{-} % illustrate size differences
 \qquad 
 \adornprod{1}{4+5}{\alpha}{\beta} 
 \qquad 
 \displaystyle 
 \adornprod{1}{4+5}{\alpha}{\beta}$
\end{document}

You must log in to answer this question.

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