0

I have an image that is inserted into the text using tikzpicture environment. I want to add some text and shapes to the left of the picture that is out of the picture's scope. This action moves the picture to the right and the picture is not centered anymore. How can I force the picture to be always horizontally aligned in tikzpicture environment? I use these codes:

\begin{figure}[htbp]
    \centering
\begin{tikzpicture}[show grid]      \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.7\textwidth]{figures/airfoil.pdf}};
        \node (1)  at (-1,5) {SOME TEXT}; %by adding this, the picture is not aligned anymore
    \end{tikzpicture}
\end{figure}
1
  • You could place the node containing the text inside of a pgfinterruptedboundingbox environment to hide it from the bounding box calculation, as for example shown here: tex.stackexchange.com/a/565838/134144 Please be aware that this might lead to the text protruding into the left margin. – leandriis Jan 17 at 14:28
1

Option overlay can be used (e.g. for \node or with the scope environment) to add stuff that is not used for the bounding box calculation:

\documentclass{article}
\usepackage{graphicx}
\usepackage{ribbonproofs}
\usepackage{tikz}
\begin{document}
\begin{figure}
  \centering
  \begin{tikzpicture}[show grid]
    \node[anchor=south west,inner sep=0] (image) at (0,0)
      {\includegraphics[width=0.7\textwidth]{example-image}};
    \begin{scope}[overlay]
      \node (1)  at (-1,5) {SOME TEXT};
    \end{scope}
  \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

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.