警告符号的背景颜色

警告符号的背景颜色

链接中的此警告图标:如何打印警告标志(带有感叹号的三角形)?

我想在背景中填充红色,如附图 在此处输入图片描述

这个最小代码:

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

!可以是黑色或白色请帮忙。提前谢谢

答案1

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

在此处输入图片描述

相关内容