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.

Not so nice veritcally aligned sign

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

1 Answer 1


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

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


    \raisebox{0.325ex}{\resizebox{!}{1.2ex}{\danger}} dasdfcsdasda

enter image description here

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


1. Initial state: \danger dasdfcsdasda

enter image description here

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

enter image description here

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

enter image description here

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


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


    \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)


        \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... !)

    \myDanger dasdfcsdasda

    {\sffamily \myDanger dasdfcsdasda}

    {\Huge \sffamily \myDanger dasdfcsdasda}

    {\Huge \myDanger  dasdfcsdasda}


enter image description here

  • 2
    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
    – ebosi
    Commented Jul 4, 2016 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .