我遇到了一个自己无法解决的问题:我正在尝试制作一个包含图像和文本的 tcolorbox。我想更改文本对齐方式以使其居中
額定:
\documentclass{article}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage[skins,theorems]{tcolorbox}
\usepackage{mwe}
\newtcbox{\important}{enhanced,on line,
colframe=red,colback=red!5!white, box align=center,
boxrule=0.5pt,arc=4pt,boxsep=0pt,left=6pt,right=6pt,top=6pt,bottom=6pt}
\newcommand{\appel}{\begin{center} \important{\includegraphics[scale=0.07]{image} Here you write the text }\end{center}}
\begin{document}
\appel
\end{document}
这可能很容易,但我不知道如何改变它-_-我可能在我的/newtcbox中尝试了一些愚蠢的事情,哈哈
答案1
感谢@GonzaloMedina
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}
\usetikzlibrary{calc}
\newtcolorbox{mybox}{ enhanced,
left=0pt,
right=0pt,
top=8pt,
bottom=8pt,
colback=red!5,
colframe=red,
width=\textwidth,
enlarge left by=0mm,
boxsep=5pt,
fontupper=\itshape\small,
arc=4pt,
outer arc=4pt,
leftupper=1.5cm,
overlay={
\node[anchor=west]
at ([xshift=10pt] $ (frame.north west)!0.5!(frame.south west) $ )
{\includegraphics[width=1cm,height=1cm]{example-image-a}};}
}
\begin{document}
\begin{mybox}
Add some text here in the center
\end{mybox}
\end{document}