2

This warning icon in link: How to print a warning sign (triangle with exclamation point)?

i want to fill red colour in backgroud like attached image enter image description here

This minimal code:

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

! can black or white Please help. Thank in advance

latexforti
  • 2,091

1 Answers1

6
\documentclass{article}
\usepackage{stackengine}
\usepackage{scalerel}
\usepackage{xcolor,amssymb}
\newcommand\dangersignb[1][2ex]{%
  \scaleto{\stackengine{0.3pt}{\scalebox{1.1}[.9]{%
  \color{red}$\blacktriangle$}}{\tiny\bfseries !}{O}{c}{F}{F}{L}}{#1}%
}
\newcommand\dangersignw[1][2ex]{%
  \scaleto{\stackengine{0.3pt}{\scalebox{1.1}[.9]{%
  \color{red}$\blacktriangle$}}{\color{white}\tiny\bfseries !}{O}{c}{F}{F}{L}}{#1}%
}
\begin{document}
This is a (black) danger sign 5ex tall: \dangersignb[5ex]\par
Here is the default (2ex) size: \dangersignb

This is a (white) danger sign 5ex tall: \dangersignw[5ex]\par
Here is the default (2ex) size: \dangersignw
\end{document}

enter image description here

  • B.Segletes. Your above code work in overleaf. But I run in texmarker this come error: "package stackengine could not be installed". please help. thanks – latexforti Apr 04 '19 at 15:45
  • 1
    @latexforti I am not familiar with texmarker, but you can find the style file at https://www.ctan.org/pkg/stackengine and place it in your working directory. – Steven B. Segletes Apr 04 '19 at 16:12
  • i embeded your code in my file. But warning icon https://imgur.com/xIGODZA : ! outside of the box. Can you center "!" symbol? Thanks – latexforti Apr 05 '19 at 10:21
  • 1
    @latexforti I am not sure why the result is as you show. The vertical placement of the ! is controlled by the length 0.3pt shown in my macro (try increasing it). The stretched shape of the triangle is controlled by the scale number [.9] shown in my macro (try decreasing it). – Steven B. Segletes Apr 05 '19 at 11:34