TransWikia.com

Scale own math symbol / image appropriately

TeX - LaTeX Asked by nopx on November 6, 2021

In this thread we learned how to create our own math symbol. Now the question is how we force it to scale appropriately when used in sub- or superscript:

See the following example:

documentclass[12pt]{article}%, border=2pt]{standalone}
usepackage{graphics}

DeclareRobustCommand{triangleLeft}{ensuremath{includegraphics{triangleLeft}}}

begin{document}
$triangleLeft_{x}$
$X_{triangleLeft_{x}}$

begin{figure}
caption{$triangleLeft_{x}$ test}
end{figure}

end{document}

As we see in the result. The image is equally big in the subscript but it should be scaled down a little bit.

Do you have any ideas how I can fix this?

Kind regards and Thanks,
Max

One Answer

The features of scalerel can accomplish this.

documentclass[12pt]{article}%, border=2pt]{standalone}
usepackage{MnSymbol}
usepackage{sansmath}
usepackage{stackengine, amsfonts,scalerel} %
newcommand{leftharpoontriangleX}{mathord{ensurestackMath{%
  stackinset{c}{0pt}{c}{-0.3ex}{scriptstyleleftharpoonup}%
  {largetriangleup}}}}
newcommand{rightharpoontriangleX}{mathord{ensurestackMath{%
  stackinset{c}{0pt}{c}{-0.3ex}{scriptstylerightharpoonup}%
  {largetriangleup}}}}
newcommand{leftharpoontriangle}{%
  scalerel*{leftharpoontriangleX}{largetriangleup}}
newcommand{rightharpoontriangle}%
  {scalerel*{rightharpoontriangleX}{largetriangleup}}
begin{document}

sansmath
 $ rightharpoontriangle_{!x}quadleftharpoontriangle_{!x}$

 $ x_{rightharpoontriangle}quad x_{leftharpoontriangle}$

 $ y_{ x_{rightharpoontriangle}quad x_{leftharpoontriangle}}$
end{document} 

enter image description here

Answered by Steven B. Segletes on November 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP