7

I'm defining a new function using triangle and its corners as inputs, it works for normal linear equations, but when it becomes supersript or subscript, the parameters become misaligned. Any suggestions on how to fix this? Output Code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\newcommand{\ca}[1]{\operatornamewithlimits{\mathpalette\cb{#1}}}
\newcommand{\cb}[2]{{%
  \vphantom{\triangle}%
  \ooalign{%
    $#1\triangle$\cr\hidewidth\cc{$#1#2$}\hidewidth\cr
  }%
}}
\newcommand{\cc}[1]{%
  \raisebox{.2\height}{\scalebox{0.5}{#1}}%
}
\newcommand{\hypop}[4]{{\ _{#2}\ca{#4}^#1} _#3}
\begin{document}
\[Intended~output~above~and~below~the~sum:\hypop{a}{b}{c}{n}\]
\[Actual~output:\sum^{\hypop{a}{b}{c}{n}}_{\hypop{a}{b}{c}{n}}\]
\end{document}
Andrew Swann
  • 95,762
Ariana
  • 185
  • 1
    The "limits" of operators are not placed above or below in exponents. In the definition of \hypop you need to put explicitly \ca{#4}\limits^#1. And another couple of spacing issues may be improved too :-) – campa May 20 '16 at 13:53
  • See also http://tex.stackexchange.com/q/11542/15925 – Andrew Swann May 20 '16 at 14:01
  • The letters "b" and "c" to the lower-left and lower-right of the triangle should be placed on the same baseline, right? – Mico May 20 '16 at 15:00

2 Answers2

5

A stackengine approach, with scalerel for handling the change in math style size.

REVISED ANSWER

This can present nicely in all math styles and corrects the issue with my alternate solutions that the drop of a subscript is not uniform but depends on the letter height. For this application, that is not a helpful feature.

\documentclass{article}
\usepackage{stackengine,scalerel}
\stackMath
\newcommand\hypop[4]{%
  \ThisStyle{\litlet{#2}\stackengine{.2\LMex}{%
   \stackengine{.2\LMex}{\SavedStyle\triangle}{\scalebox{.5}{$\SavedStyle#4$}}{O}{c}{F}{F}{L}%
  }{\SavedStyle\litlet{#1}}{O}{c}{F}{F}{S}\litlet{#3}}%
}
\newcommand\litlet[1]{\raisebox{-.4\LMex}{\scalebox{.7}{$\SavedStyle#1$}}}
\begin{document}
\[
\hypop{a}{b}{c}{n} ~
\scriptstyle\hypop{a}{b}{c}{n}~
\scriptscriptstyle\hypop{a}{b}{c}{n}
\]
\[\sum^{\hypop{a}{b}{c}{n}}_{\hypop{a}{b}{c}{n}} \]
\end{document}

enter image description here

ORIGINAL ANSWER

The triangle is always presented in \displaystyle and argument #4 is always presented in \scriptscriptstyle. However, the point letters of the triangle (arguments #1-#3) get smaller when \hypop is used as a subscript.

\documentclass{article}
\usepackage{stackengine,scalerel}
\stackMath
\newcommand\hypop[4]{%
  \ThisStyle{{}_{#2} \stackengine{1pt}{%
   \stackengine{\dimexpr.72ex+.10\LMex}{\triangle}{_{_{\mkern2mu#4}}}{O}{c}{F}{F}{L}%
  }{\SavedStyle_{#1}}{O}{c}{F}{F}{S} {}_{#3}}%
}
\begin{document}
\[Intended~output~above~and~below~the~sum:\hypop{a}{b}{c}{n}\]
\[Actual~output:\sum^{\hypop{a}{b}{c}{n}}_{\hypop{a}{b}{c}{n}} \]
\end{document}

enter image description here

One can keep the triangle size fixed, but if a smaller size is preferred, a \scalebox would work, here scaled by 80% with respect to the original presentation above:

\documentclass{article}
\usepackage{stackengine,scalerel}
\stackMath
\newcommand\hypop[4]{%
  \ThisStyle{%
  {}_{#2} \stackengine{1pt}{\scalebox{.8}{%
   $\stackengine{\the\dimexpr.72ex+.10\LMex}{\triangle}{_{_{\mkern2mu#4}}}{O}{c}{F}{F}{L}$}%
  }{\SavedStyle_{#1}}{O}{c}{F}{F}{S} {}_{#3}}%
}
\begin{document}
\[Intended~output~above~and~below~the~sum:\hypop{a}{b}{c}{n}\]
\[Actual~output:\sum^{\hypop{a}{b}{c}{n}}_{\hypop{a}{b}{c}{n}} \]
\end{document}

enter image description here

4

Here's a version that uses a few additional \raisebox and \scalebox instructions to place the letters "b" and "c".

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\newcommand{\ca}[1]{\operatornamewithlimits{\mathpalette\cb{#1}}}
\newcommand{\cb}[2]{{%
  \vphantom{\triangle}%
  \ooalign{$#1\triangle$\cr\hidewidth\cc{$#1#2$}\hidewidth\cr
  }%
}}
\newcommand{\cc}[1]{%
  \raisebox{.35\height}{\scalebox{0.45}{#1}}%
}
\newcommand{\hypop}[4]{%
    \raisebox{-0.25ex}{\scalebox{0.5}{$#2$}}
    \mkern-2.5mu
    \ca{#4}\limits^{\mkern-0.5mu\scalebox{0.5}{$#1$}}
    \mkern-2.8mu
    \raisebox{-0.25ex}{\scalebox{0.5}{$#3$}}}
\begin{document}
Various math styles:
$ \hypop{a}{b}{c}{n} \quad
  \scriptstyle  \hypop{a}{b}{c}{n} \quad 
  \scriptscriptstyle \hypop{a}{b}{c}{n}$

With summation symbol: 
$\displaystyle \sum^{\hypop{a}{b}{c}{n}}_{\hypop{a}{b}{c}{n}}$
\end{document}
Mico
  • 506,678