2

I would like to center a picture and draw an arrow to the part of the picture to have a text box with description. I have come up with an idea which is to put text box and picture under the same 'tikzpicture' but my picture doesn't go center that I want.

What I did is:

\begin{figure}[H]
    \centering
    \begin{tikzpicture}% based on https://tex.stackexchange.com/a/9561/ (Caramdir's fantastic answer to another question)
    \node (map) [anchor=south west, inner sep=0pt] at (1.35,0.0) 
    {\fbox{\includegraphics[scale=.5]{photo/map.png}}};
    \node (box) [draw, rectangle] at (0.0,1.0) {Location};
    \begin{scope}[x={(map.south east)},y={(map.north west)}]
        \draw [->](box)--(.35,.4);
    \end{scope}
    \end{tikzpicture}
    \caption{Map}
    \label{fig:map}
\end{figure}

Any help is appreciated!

Bernard
  • 271,350

1 Answers1

1

Using @leandriis idea from his comment and some my small changes of your code, where consider also Caramdir's answer:

\documentclass{article}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\usepackage{tikz} \usetikzlibrary{arrows.meta, positioning} \usepackage{graphicx} \usepackage[skip=0.33\baselineskip]{caption}

\begin{document} \begin{figure}[ht] \centering \begin{tikzpicture}[node distance = 2mm] \node (map) [draw, anchor=south west] % <--- https://tex.stackexchange.com/questions/9559/ % drawing-on-an-image-with-tikz)/9561#9561 (Caramdir) {\includegraphics[scale=.8]{example-image-duck}}; \begin{pgfinterruptboundingbox}% <--- proposed by @leandriis \node (box) [draw, left=of map] {Location}; \begin{scope}[x={(map.south east)},y={(map.north west)}] \draw[-Straight Barb, semithick] (box) -- (0.5,0.35); \end{scope} \end{pgfinterruptboundingbox} \end{tikzpicture} \caption{Map} \label{fig:map} \end{figure} \end{document}

enter image description here

Zarko
  • 296,517