# Slightly Alter a symbol position

I am using a symbol and it looks too low vertically. I would like to slightly shift it up. Can I do this easily? I would like to do this "permanently" since it is probably more efficient than shifting it inline(I will be using the symbol a lot). I'd like to create a copy of the symbol so I do not modify the original.

I know how you guys love MWE's so here you go!! Hope it helps!!!

\documentclass{article}
\newcommand{\sym}{\diamondsuit}
\begin{document}
G$\sym$
\end{document}


Obviously I want \sym to be shifted up. In fact I would like it to be centered to the previous text which may different in the font than what the symbol uses. (On my screen the diamond sits slightly too low)

\documentclass{article}
\newcommand{\sym}{\diamondsuit}
\usepackage{fontspec}
\newfontfamily\fontt{cyklop}
\begin{document}
{\fontt G}$\sym$
\end{document}

-
Very related question: Shifting a symbol vertically in Math mode –  diabonas Apr 10 '12 at 12:54

That symbol is supposed to be centered with respect to the formula axis, the imaginary line where fraction lines are drawn.

If you really want to raise it so that the bottom vertex lies on the baseline it's very simple:

\newcommand{\sym}{\raisebox{\depth}{$\diamondsuit$}}


It's slightly more complicated if you want a symbol that changes size in subscripts or superscripts:

\newcommand{\sym}{\mathpalette\raisesym\relax}
\newcommand{\raisesym}[2]{\raisebox{\depth}{$#1\diamondsuit$}}


Here's an example with the second definition:

$A\sym_{A\sym_{A\sym}}B$


If you want to raise it less than the whole depth, use a fraction of \depth, for example

\newcommand{\raisesym}[2]{\raisebox{0.5\depth}{$#1\diamondsuit$}}


-
are these efficient? I have to use the sym a lot(10's of thousands of times) and if it has to recalculate everything it might get slow.Also, is there a way to center to the previous(or a specified) "font line" (middle of the previous font) –  Uiy Apr 10 '12 at 13:45
@Uiy One should know what's the meaning of "middle of a font": half the lowercase letter height or the uppercase letter height? –  egreg Apr 10 '12 at 13:54
The middle of maximum bounding box of the largest alphanumeric character(or even just the previous character group). When I try to display my symbols like "text." where '.' is some symbol. The '.' is to low and looks unnatural. I want to shift it up so that the '.' center of "mass" is horizontally the same as the center of mass of 'text'. Using bounding boxes to get the middle is fine since the symbols are relatively symmetric. For example, if text was all lower case it would shift the symbol of less than if it were all uppercase or even if just one character was uppercase. –  Uiy Apr 10 '12 at 14:01
@Uiy Not with standard TeX, which has no knowledge of "what was before"; with LuaTeX you can access the previous character node(s). –  egreg Apr 10 '12 at 14:06
In your example, the diamond is centered. But you hard coded it. I would like to automatically center it depending on the previous text. Suppose the base line is at 0pt. The previous bounding box of the text is 10pt then the "centerline" would be at 5pt. The symbol has a bounding box of 12pt then this means we would have to shift the baseline of the symbol by -1pt. This means the symbol will be from -1pt to 11pt while the previous text will be from 0pt to 10pt but both will have the same centers. –  Uiy Apr 10 '12 at 14:07