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

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

4
  • 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 4 '19 at 15:45
  • 1
    @latexforti I am not familiar with texmarker, but you can find the style file at ctan.org/pkg/stackengine and place it in your working directory. Apr 4 '19 at 16:12
  • i embeded your code in my file. But warning icon imgur.com/xIGODZA : ! outside of the box. Can you center "!" symbol? Thanks
    – latexforti
    Apr 5 '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). Apr 5 '19 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.