0

I'm having troubles with the tikzscale package. I'm trying to insert arrows above a picture.

And, when I do so, I have the following error : "! Package tikzscale Error: Requested to scale unscalable graphic."

When I have exactly the same tikzpicture without the image. I have no problem.

My code is something like this :

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{etex}

\usepackage{tikz}
\usepackage{circuitikz}
\usepackage{pstricks}
\usepackage{chemfig}
\usepackage{epstopdf}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{capt-of}
\usepackage{tikzscale}

\begin{document}
\includegraphics[width=0.1\linewidth]{fig.tikz}
\end{document}

And my fig.tikz file is :

\begin{tikzpicture}
\node (label) at (0,0)[]{
        \includegraphics[width=\textwidth]{images/test.png}
      };
\put(0,0){\color{red} $\epsilon_1, \rho_1$}
\put(10,10){\color{red}$\epsilon_2, \rho_2$}
\draw[red, ->] (0,2) -- (0,0);
\put(93,50){\color{red}$g$}
\put(47,16){
\draw[red, |<->|] (0,0) -- (0,3);
}
\put(20,25){\color{red} $h$}
\draw[red, |<->|] (0,0) -- (2,0);
\put(47,51){\color{red}$d$}
\draw[color=red] (1,1.8) -- (1.8,1.8) -- (1.8,0) node[ground]{}; 
\put(68,30){\color{red}$U (tension)$}
\end{tikzpicture}

I noted that, when I use really higher values for the size of lines, I have no error returned but the aspect of the picture is not what I'm looking for.

For example, with this code no errors are returned:

\begin{tikzpicture}
\node (label) at (0,0)[]{
        \includegraphics[width=\textwidth]{images/test.png}
      };
\put(0,0){\color{red} $\epsilon_1, \rho_1$}
\put(10,10){\color{red}$\epsilon_2, \rho_2$}
\draw[red, ->] (0,2) -- (0,0);
\put(93,50){\color{red}$g$}
\put(47,16){
\draw[red, |<->|] (0,0) -- (0,30);
}
\put(20,25){\color{red} $h$}
\draw[red, |<->|] (0,0) -- (20,0);
\put(47,51){\color{red}$d$}
\draw[color=red] (1,1.8) -- (1.8,1.8) -- (1.8,0) node[ground]{}; 
\put(68,30){\color{red}$U (tension)$}
\end{tikzpicture}
zeslayer
  • 353
  • Welcome to TeX.SE! Please include your preamble. You defined node[ground]{} but what is the tikzset for ground? I'm asking because it might be important to your case in some way. – Alenanno May 19 '15 at 15:38
  • I understand that you want to do something like drawing-on-an-image-with-tikz – Ignasi May 20 '15 at 07:36
  • @Alenanno : I edited it with the preambule. I have the same problem without the 'node[ground]'. And ground is from circuitikz. – zeslayer May 20 '15 at 14:33
  • I think my explanation is cleared in my post now. Cause I have 2 files.

    Normally I can use a modification of width on my .tikz file because I'm using the tikzscale package but I do have an error when I try to compile it.

    – zeslayer May 20 '15 at 14:41
  • @Ignasi : It's not answering exactly the question because the problem is to rescale a Tikzpicture including an image but I could use your solution as another way to do the thing I wanted to do. So thanks you. – zeslayer May 20 '15 at 14:43

0 Answers0