2

I am trying to place some text around an image like this: enter image description here

And this is done using tikzpicture.

However, as soon as I change (x,y) in

        \node[align=center] at (x,y) {left};

Both the box and the text move at the same time!

I know this probably has something to do with the "align=center" option, but I am not sure how to change it so they are not moving at the same time.

Can someone please help!

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
     \begin{tikzpicture}
            \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[scale=0.5]{box}};
            \node[align=center] at (-2,5) {up};
            \node[align=center] at (-2,1) {down};
            \node[align=center] at (1,-1) {left};
            \node[align=center] at (3,-1) {right};
        \end{tikzpicture}
\end{frame}


\end{document}
4

You could position the elements relative to the page:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
     \begin{tikzpicture}[remember picture, overlay]
            \node (image) at (current page.center) {\includegraphics[scale=0.5]{example-image}};
            \node[align=center,yshift=3cm] at (current page.center) {up};
            \node[align=center,yshift=-3cm] at (current page.center) {down};        
            \node[align=center,xshift=-4cm] at (current page.center) {right};   
            \node[align=center,xshift=4cm] at (current page.center) {left};                               
        \end{tikzpicture}
\end{frame}


\end{document}

Or you could place an invisible square which is large enough to encompass all elements of your image:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
     \begin{tikzpicture}
        \path (-4,-3.5) rectangle (4,3.5);
            \node (image) at (0,0) {\includegraphics[scale=0.5]{example-image}};
            \node[align=center] at (0,3) {up};
            \node[align=center] at (0,-3) {down};
            \node[align=center] at (-3.5,0) {left};
            \node[align=center] at (3.5,0) {right};
        \end{tikzpicture}
\end{frame}


\end{document} 

If you don't mind that your labels will stick out into the margin, you could also exclude them from the bounding box of your image:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
     \begin{tikzpicture}
            \node (image) at (0,0) {\includegraphics[scale=0.5]{example-image}};
            \begin{pgfinterruptboundingbox}
            \node[align=center] at (0,3) {up};
            \node[align=center] at (0,-3) {down};
            \node[align=center] at (-3.5,0) {left};
            \node[align=center] at (3.5,0) {right};
            \end{pgfinterruptboundingbox}
        \end{tikzpicture}
\end{frame}


\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.