# Setting superscript for custom symbol

How do I set a superscript for my custom symbol generated with \newcommand*\mysymbol{\includegraphics{mysymbol.eps}}? Default superscripts appear way too far right from the place they should be in. Any 'duct tape' solution would be fine.

• Welcome to TeX.SE! – Mensch Mar 16 '19 at 18:20
• A screenshot of your attempt together with a complete "Minimal Working Example" (MWE) (including \documentclass, \usepackage, \begin and \end{document}) would be very helpful here. Also please describe specifically how you would like your output to be changed. – Sandy G Mar 17 '19 at 14:19

This will make your symbol always as tall as the letter X in the current math style, though you can pick a different footprint if you wish.

If your spacing still seems off using your image, perhaps there is excess margin built into your image that needs to be clipped.

\documentclass{article}
\usepackage{graphicx,scalerel}
\newcommand\mysymbol{\scalerel*{\includegraphics{example-image}}{X}}
\begin{document}
$A\mysymbol^2 = e^{-2\mysymbol x}$
\end{document}


As I said, if you need clipping, it can be done at the source or it can be done inside LaTeX thus:

\documentclass{article}
\usepackage{graphicx,scalerel,trimclip}
\newcommand\mysymbol{%
\scalerel*{\clipbox{30pt 0pt 70pt 0pt}{\includegraphics{example-image}}}{X}}
\begin{document}
$A\mysymbol^2 = e^{-2\mysymbol x}$
\end{document}


I do not have access to your eps file so I needed to make a dummy for myself. Here is a dirty solutions:

\documentclass{scrartcl}
\usepackage{amsmath,graphicx}

\newcommand*\mysymbol{\includegraphics[height=1em]{mysymbol.png}}
\newcommand*\mysymbolss{\textsuperscript{\includegraphics[height=0.83333em]{mysymbol.png}}}
\newcommand*\mysymbolssb{\kern-0.2ex\lower0.25em \hbox{\includegraphics[height=0.83333em]{mysymbol.png}}}%manual solution

\begin{document}

A\mysymbol
A\mysymbolss
A\textsuperscript\mysymbol
A\mysymbolssb

$\mysymbol^{\hspace{-0.5ex}\mysymbolss}$

$\mysymbol^{\mysymbolssb}$

\end{document}


You will most likely have to change the length to make it fit for your needs. Observe the \kern and \lower commands to adjust the position of an element.

As an alternative: You should see whether your symbol is actually defined, compare How to look up a symbol or identify a math symbol or character?.

• Unfortunately, it seems, that I did not describe what I need clearly enough, or, perhaps, you misunderstood me. I need to make a superscript to my symbol appear to the left of the default setting, not to make my own symbol a superscript – alex.kalug Mar 17 '19 at 11:08
• @alex.kalug Thank you for your response. Please accept my apologies. Perhaps it would be easier to see an illustration of the problem. Is the manual shift of the elements in my answer not helpful? – CampanIgnis Mar 17 '19 at 13:42