# Symbol not in line with text

I'm using this solution of this question for printing a warning sign. But the text and the Symbol are vertically not correct algigned aligned in my special case.

I want to have the same lower baseline for the symbol as for letters like (a, b, c) and not (q, p, g, y). The upper baseline is okay for me.

• There is useful advice here: Raise/lower a single character of a font (hyphen) tex.stackexchange.com/q/154613/89098
– Ross
Jul 4, 2016 at 12:44
• Try with this solution but instead of \small and \Large, use \tiny and \normalsize, respectively.
– Fran
Jul 4, 2016 at 18:16

See edited answer at the end, with a cleaner and adaptative solution

Quick, dirty, and very explicit, but it works :

\documentclass{article}
\usepackage{fourier}
\usepackage{graphicx}

\begin{document}
\raisebox{0.325ex}{\resizebox{!}{1.2ex}{\danger}} dasdfcsdasda
\end{document}


of course, it need to be adapted according to the font you use...

# Explanations:

1. Initial state: \danger dasdfcsdasda

2. First, we need to reduce the size of the warning sign.

It is achieved through the macro \resizebox{width}{height}{what is to be resized} (of the graphicx package) where the argument ! is used to keep proportions the same. As first approximation, we took:

\resizebox{!}{1ex}{\danger} dasdfcsdasda


3. However, we observe that the resizebox keep the resized symbol bottom-aligned with the original one.

We thus need to "raise" is, using \raisebox{length}{content to be raised}. As first approximation, we used:

\raisebox{0.3ex}{\resizebox{!}{1ex}{\danger}} dasdfcsdasda


4. Finally, we fiddled the length in order to get something more correct

# Edit

Here is an adaptative solution that assess the lengths according to current context (font family, and size).

\documentclass{article}

\usepackage{graphicx}%                                          to access \settoheight and \settodepth macros

\usepackage{fourier}%                                           to access \danger icon
\usepackage{libertine}%                                         set serif font
\usepackage{roboto}%                                            set sans-serif font (different height)

\newlength{\myheight}
\newlength{\mydepth}

\newcommand{\myDanger}{%
\settoheight{\myheight}{l}%                                 in order to get the maximal height of letters in the font used
\settodepth{\mydepth}{\danger}%                             in order to retrieve the actual baseline
\resizebox{!}{\myheight}{\raisebox{\mydepth}{\danger}}%     seems counterintuitive to me (I'd have resized, then raised... but well, it works, so... !)
}

\begin{document}
\myDanger dasdfcsdasda

{\sffamily \myDanger dasdfcsdasda}

{\Huge \sffamily \myDanger dasdfcsdasda}

{\Huge \myDanger  dasdfcsdasda}

{\Huge\myDanger{\sffamily\myDanger}}
\end{document}


• I've briefly tried to make things cleaner assessing character height and depth using this answer and explanations found on this question (e.g. with \newlength{\myheight} \newlength{\myraise} \settoheight{\myheight}{d} \settodepth{\myraise}{p} \raisebox{\myraise}{\resizebox{!}{\myheight}{\danger}} dasdfcsdasda) but without real success Jul 4, 2016 at 13:04