我想在标题中添加一个 Font Awesome 图标,tcolorbox
但我的 MWE 看起来更像是临时工作,而不是专业的解决方案。
我遇到的问题是标题没有水平和垂直居中。
\documentclass[12pt]{article}
\usepackage{tcolorbox}
\usepackage{fontawesome5}
\begin{document}
\begin{tcolorbox}[
title = {\Large\faPython} \hfill Code Python \hfill\null,
coltitle = black,
colbacktitle = black!10!white,
colback = white,
center title
]
Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla,
\end{tcolorbox}
\begin{tcolorbox}[
title = Code Python,
coltitle = black,
colbacktitle = black!10!white,
colback = white,
center title
]
Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla,
\end{tcolorbox}
\end{document}
答案1
您可以使用覆盖。
\documentclass[12pt]{article}
\usepackage[skins]{tcolorbox}
\usepackage{fontawesome5}
\begin{document}
\begin{tcolorbox}[enhanced,
title = Code Python,
coltitle = black,
colbacktitle = black!10!white,
colback = white,
center title,
overlay={%
\begin{tcbclipframe}
\node[anchor=north west,inner ysep=1.5pt] at (frame.north west){\Large\faPython};
\end{tcbclipframe}
}
]
Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla,
\end{tcolorbox}
\end{document}