我正在尝试将一些文字放在投影仪中的图形上方,例如
\begin{tikzpicture}
\node[anchor=top ,inner sep=0] (image) at (0,0) {\includegraphics[width=60mm,height=110pt]{./chapter6/figures_susy/RankingMET08.eps}};
\node[align=top west,black] at (image.center) {TEXT HERE};
\end{tikzpicture}
但文本出现在图表的中间 - 我怎样才能使文本与图形的顶部对齐?
答案1
你犯了一些错误。anchor=top
应该是anchor=north
。top
不存在。同样align=top west
应该是align=left
。
代码:
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=north,inner sep=0] (image) at (0,0) {\includegraphics[width=60mm,height=110pt]{example-image}};
\node[align=left,black,anchor=south] at (image.north) {TEXT HERE};
\end{tikzpicture}
\end{frame}
\end{document}
现在我们将两个图形放在同一行。我已将图形宽度改为 3 厘米,使它们变小,并增加了keepaspectratio
防止它们扭曲的尺寸。调整图形宽度和4cm
宽度right=4cm of image1
以满足您的需求。
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=north,inner sep=0] (image1) at (0,0) {\includegraphics[width=30mm,height=110pt,keepaspectratio]{example-image}};
\node[align=left,black,anchor=south] at (image1.north) {TEXT HERE};
%% second figure Change 4cm appropriately.
\node[anchor=north,inner sep=0,right=4cm of image1] (image2) {\includegraphics[width=30mm,height=110pt,keepaspectratio]{example-image-a}};
\node[align=left,black,anchor=south] at (image2.north) {TEXT HERE};
\end{tikzpicture}
\end{frame}
\end{document}
您还可以tikzpicture
并排使用 2。
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=north,inner sep=0] (image1) at (0,0) {\includegraphics[width=30mm,height=110pt,keepaspectratio]{example-image}};
\node[align=left,black,anchor=south] at (image1.north) {TEXT HERE};
\end{tikzpicture}%
%\hfill
\begin{tikzpicture}
\node[anchor=north,inner sep=0] (image2) at (0,0) {\includegraphics[width=40mm,height=110pt,keepaspectratio]{example-image-a}};
\node[align=left,black,anchor=south] at (image2.north) {TEXT HERE};
\end{tikzpicture}
\end{frame}
\end{document}