How to print a warning sign (triangle with exclamation point)?

I am interested in including a triangle with an exclamation point (unicode #9888: ⚠) in a tex document. I've looked in the usual places (detexify, etc.) and not found this symbol. The document should be compilable with pdflatex and the source should have ASCII encoding. I already have a tikz version that I like reasonably well, given by

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\newcommand{\warningsign}{\tikz[baseline=-.75ex] \node[shape=regular polygon, regular polygon sides=3, inner sep=0pt, draw, thick] {\textbf{!}};}
\begin{document}
\warningsign Warning
\end{document}


so I am also requiring that the answer be an actual character, or at least not done using graphics.

• I usually use {\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax} for that symbol. Feb 10, 2014 at 17:38
• @Nicola Talbot: Works like a charm! Please add that as an answer so that I can upvote it (and accept it unless someone comes along with a deeper explanation). Feb 10, 2014 at 17:53
• You also have \usepackage{bclogo} and \bcattention. Feb 11, 2014 at 1:51
• this command is incompatible with \usepackage[french]{babel} Sep 7, 2015 at 13:28

The fourier package provides \danger:

\documentclass{article}

\usepackage{fourier}

\begin{document}

\danger

\end{document}


I sometimes find that some of the fourier commands conflict with other packages I use, so if I only want this symbol I do:

\documentclass{article}

\begin{document}

{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax}

\end{document}


which is essentially what \danger does. This requires the futs font family which is provided with the fourier package, so the package must still be installed even though it's not actually being loaded.

If the futs font isn't available, the transcript will show the message:

LaTeX Font Warning: Font shape U/futs/m/n' undefined
(Font)              using U/cmr/m/n' instead on input line 5.


This means that the cmr font is being used instead, which has the letter B in the \char 66 slot.

• In the second example, note that you need to have the fourier package installed in your TeX Live distribution even though it is not explicitly loaded. Otherwise, you will just get a "B" instead of a warning triangle. May 10, 2017 at 3:08
• Thanks, @RadonRosborough. I was initially getting a "B". [at]NicolaTalbot could you add that to the answer as well? Jun 8, 2017 at 10:13
• I get this error in a Beamer document on Arch Linux: "mktexpk: don't know how to create bitmap font for futr8r. mktexpk: perhaps futr8r is missing from the map file." Is there another package I have to install? Sep 25, 2019 at 8:49
• Be aware that the command is now called \warning. Also, character number has changed to 49. So for option two use {\fontencoding{U}\fontfamily{futs}\selectfont\char 49\relax}. Mar 25 at 15:58

A \warning symbol (previously \danger) is provided by the fourier package (see The Comprehensive LATEX Symbol List, table 475, page 177).

If you don't have the need for the complete fourier package, but you want to use that symbol, you can extract it and use in your document:

\newcommand*{\TakeFourierOrnament}[1]{{%
\fontencoding{U}\fontfamily{futs}\selectfont\char#1}}
\newcommand*{\danger}{\TakeFourierOrnament{66}}


MWE

\documentclass{article}

\newcommand*{\TakeFourierOrnament}[1]{{%
\fontencoding{U}\fontfamily{futs}\selectfont\char#1}}
\newcommand*{\danger}{\TakeFourierOrnament{66}}

\begin{document}

\danger

\end{document}


Output

A simple build assigned to the unicode symbol, so you can use ⚠ or \Warning:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{newunicodechar}

\newcommand\Warning{%
\makebox[1.4em][c]{%
\makebox[0pt][c]{\raisebox{.1em}{\small!}}%
\makebox[0pt][c]{\color{red}\Large$\bigtriangleup$}}}%

\newunicodechar{⚠}{\Warning}

\begin{document}

on the power plug.

\end{document}


Here, I choose to build my own by overlaying a black, tiny ! atop a red $\triangle$, and then scaling the result to a desired [optional] size

\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{xcolor}
\newcommand\dangersign[1][2ex]{%
\renewcommand\stacktype{L}%
\scaleto{\stackon[1.3pt]{\color{red}$\triangle$}{\tiny !}}{#1}%
}
\begin{document}
This is a danger sign 5ex tall: \dangersign[5ex]\par
Here is the default (2ex) size: \dangersign
\end{document}


Zoom of result, to clarify my response to Charles' comment.

If one prefers a bolder !, just make it \bfseries:

\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{xcolor}
\newcommand\dangersign[1][2ex]{%
\renewcommand\stacktype{L}%
\scaleto{\stackon[1.3pt]{\color{red}$\triangle$}{\tiny\bfseries !}}{#1}%
}
\begin{document}
This is a danger sign 5ex tall: \dangersign[5ex]\par
Here is the default (2ex) size: \dangersign
\end{document}


• Perhaps it's my imagination, but the exclamation point in the small version looks slightly off-center. Feb 10, 2014 at 20:03
• @CharlesStaats Sometimes, when glyphs are overlaid, inexact rendering will make them appear off center. Zooming in reveals a better approximation, and the printed result is accurate. Zooming the small symbol to 6400% reveals aligned glyphs. Feb 10, 2014 at 20:05
• A question about the stackrel package: why does it render the \danger symbol from the fourier package as a letter B? Feb 11, 2014 at 2:26
• @CharlesStaats Do you mean scalerel package? I would note that scalerel macros process their argument in math mode, by default, and one must actually delimit them with $...$ to process in text mode. So my guess is that the symbol is being processed in the wrong mode. Feb 11, 2014 at 2:33
• Your guess seems to have been entirely correct. Thanks! Feb 11, 2014 at 4:29

When you use XeLaTeX or LuaLaTeX you can simply use the character as is:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{STIXGeneral}
\newcommand\warningsign{⚠}
\begin{document}
\warningsign Warning
\end{document}


Of course the font must contain it. (STIX does.)

It looks like this:

Notice that it is more common to give unicode code points in hexadecimal, here U+26A0.

If you don’t want to have unusual characters in your source code, you can specify the warning sign by its code point:

\newcommand\warningsign{\symbol{"26A0}}

• With the most recent version of the STIX fonts, the call should be \setmainfont[Ligatures=TeX]{STIX} Feb 10, 2014 at 18:36
• I appreciate the information, but prefer that my source code contain no characters that do not show up on my (American) keyboard. Feb 10, 2014 at 18:48
• @CharlesStaats: You can use ASCII characters: ^^^^26a0, see The ^^ notation in various engines Feb 10, 2014 at 18:54

The package fontawesome provides the commands \faWarning (equiv., \faExclamationTriangle for the warning icon, which looks like this:

A minimal example would be:

\documentclass{article}
\usepackage{fontawesome}

\begin{document}

\faWarning\, Warning: This product contains peanuts, %
which might not be very suitable for certain individuals.

\end{document}


The fontawesome package might be new, but it provides a wide range of high-quality web icons, and that makes it pretty relevant tool in terms of modern typesetting and design.