答案1
以下是一些可供您开始使用的内容:
\documentclass{article}
\usepackage{fontawesome5}
\usepackage[many]{tcolorbox}
\NewDocumentCommand \GitHubBadge { m m m }
{
\tcbsidebyside
[
enhanced, sidebyside, sidebyside adapt=both,
bicolor, colback=black, colbacklower=green!70!black,
frame hidden,
left=2pt, right=2pt, top=0pt, bottom=0pt,
sidebyside gap=1em,
]
{\sffamily\textcolor{gray}{#1}~\textcolor{white}{#2}\hspace{-.5em}\phantom{q}}
{\sffamily\hspace{-1.5em}\phantom{#1}\textcolor{white}{#3}\hspace{-.5em}\phantom{q}}
}
\begin{document}
\GitHubBadge { \faIcon{github} } { Build } { passing }
\end{document}
s\phantom
表示两侧文本的垂直对齐。
以下是带有文本阴影的版本:
\documentclass{article}
\usepackage{fontawesome5}
\usepackage[many]{tcolorbox}
\usepackage{shadowtext}
\NewDocumentCommand \GitHubBadge { m m m }
{
\shadowoffsetx{0pt}
\shadowoffsety{0.6pt}
\tcbsidebyside
[
enhanced, sidebyside, sidebyside adapt=both,
bicolor, colback=black, colbacklower=green!70!black,
frame hidden,
left=2pt, right=2pt, top=0pt, bottom=0pt, boxsep=1.5pt,
sidebyside gap=0em,
]
{\shadowcolor{black!80}\sffamily\textcolor{gray}{#1}\!\textcolor{white}{\shadowtext{#2}}\hspace{-.5em}\phantom{q}}
{\shadowcolor{black!60}\sffamily\hspace{-1.5em}\phantom{#1}\textcolor{white}{\shadowtext{#3}}\hspace{-1em}\phantom{q}}
}
\begin{document}
\GitHubBadge { \faIcon{github} } { Build } { passing }
\end{document}