![将文本放置在 textpos 中的图像上](https://linux22.com/image/479613/%E5%B0%86%E6%96%87%E6%9C%AC%E6%94%BE%E7%BD%AE%E5%9C%A8%20textpos%20%E4%B8%AD%E7%9A%84%E5%9B%BE%E5%83%8F%E4%B8%8A.png)
我想将文本放在文本块中的图像上。
我的最低限度的编码:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[poster]{tcolorbox}
\usepackage[absolute]{textpos}
\pagestyle{empty}
\begin{document}
\begin{textblock*}{10cm}(3.0cm,3.5cm)
\begin{center}
\small X \vspace*{0.5cm}
\Huge Y \vspace*{0.2cm}
\small Z
\includegraphics[width=8cm]{example-image-a}
\end{center}
\end{textblock*}
\end{document}
答案1
借助\tikz
:将图像括在节点中,然后相对于节点添加带有字母 X、Y、Z 或其他字母的节点。
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[poster]{tcolorbox}
\usepackage[absolute]{textpos}
\pagestyle{empty}
\usepackage{tikz} % new
\usetikzlibrary{positioning} % new
\begin{document}
\begin{textblock*}{10cm}(3.0cm,3.5cm)
\begin{center}
\tikz% image and letters are inserted in nodes
{
\node (image) [inner sep=0pt] {\includegraphics[width=8cm]{example-image-duck}};
\node[below=5mm of image.north, font=\small, text=red] {X};
\node[font=\huge, text=red] {Y};
\node[above=5mm of image.south, font=\small, text=red] {Z};
}
\end{center}
\end{textblock*}
\end{document}