I know that it's possible to place an image within a node at precise coordinates, and to scale the image:
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
\node at (1,1) {
\includegraphics[scale=0.3]{"image"}
};
\end{tikzpicture}
\end{document}
However, what I want to do is to choose a rectangle with coordinates and place an image to fit inside:
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
\node at (1,1) rectangle (4,4) {
\includegraphics{"image"}
};
\end{tikzpicture}
\end{document}
Thus, it can precisely be positioned relatively to other elements like lines.
Is it possible to do that?
\textwidth
(which isn't what I want because I am looking for coordinates) and a draw command with apath
style, but the image doesn't fit inside (unless it is example-image). – Codoscope Feb 4 '18 at 19:35\textwidth
, obviously. You can specify the coordinate however you like. E.g.\path[fill overzoom image=example-image-a] (0,0) rectangle (6,4);
substituting6,4
for\textwidth,4cm
. It fits inside for me. Also works with the standardtiger
image. If you don't want it cropped in the other direction use e.g.\path[fill stretch image=tiger] (0,0) rectangle (6,4);
but, obviously, the image will be distorted in that case. – cfr Feb 4 '18 at 20:07\usepackage[skins]{tcolorbox}
in the header and then write\path[fill stretch image=my_image] (1,1) rectangle (4,4);
inside atikzpicture
block. – Codoscope Feb 10 '18 at 16:59