答案1
有了tcolorbox
它就很容易了。此代码基于这个帖子。当然,你可以将它与其他tcolorbox
功能结合起来。这是一个基本的变体。
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc}
\definecolor{pride1}{RGB}{136,205,248}
\definecolor{pride2}{RGB}{226,168,182}
\tcbset{pride/.style={enhanced,hbox,colback=white,
underlay={\begin{tcbclipinterior}
\fill[pride1] let \p1=($(interior.north)-(interior.south)$) in
foreach \X in {1,5}
{([yshift={\X*\y1/5}]interior.south west) rectangle
([yshift={(\X-1)*\y1/5}]interior.south east)};
\fill[pride2] let \p1=($(interior.north)-(interior.south)$) in
foreach \X in {2,4}
{([yshift={\X*\y1/5}]interior.south west) rectangle
([yshift={(\X-1)*\y1/5}]interior.south east)};
\end{tcbclipinterior}}}}
\begin{document}
\begin{tcolorbox}[fontupper=\sffamily\bfseries,pride]
hello world
\end{tcolorbox}
\end{document}
这是一个使用附加选项的示例。
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usetikzlibrary{calc}
\definecolor{pride1}{RGB}{136,205,248}
\definecolor{pride2}{RGB}{226,168,182}
\tcbset{pride/.style={enhanced,hbox,colback=white,
underlay={\begin{tcbclipinterior}
\fill[pride1] let \p1=($(interior.north)-(interior.south)$) in
foreach \X in {1,5}
{([yshift={\X*\y1/5}]interior.south west) rectangle
([yshift={(\X-1)*\y1/5}]interior.south east)};
\fill[pride2] let \p1=($(interior.north)-(interior.south)$) in
foreach \X in {2,4}
{([yshift={\X*\y1/5}]interior.south west) rectangle
([yshift={(\X-1)*\y1/5}]interior.south east)};
\end{tcbclipinterior}}},
tight/.style={on
line,boxsep=0pt,left=#1,right=#1,top=#1,bottom=#1,arc=0pt,boxrule=0pt},
tight/.default=0pt}
\begin{document}
the heat
\begin{tcolorbox}[tight,pride]
trans
\end{tcolorbox}fer coefficient is yadda yadda yadda
\end{document}