Summary:
How do I get includegraphics
to be relative to the current file, when using tikzscale?
Details
Similar to pmav I like to have a .tikz
file which contains only the tikzpicture
environment. (Main reason beeing, that I am to lazy to wrap all my figures in a full preamble like the standalone
class would mandate, and that this is what tikzscale
needs as input).
Since I like to use my pictures in different documents my latex folder looks something like this:
pictures
-TEST.tex %contains documentclass and loads tikzpreamble,
% modified by hand to input the tikz file currently under development
-tikzpreamble.tex
-picture1.tikz
-picture2.tikz
documentA
-documentA.tex
-...
documentB
...
While this flow works without fault for pure tikzpictures, I lately had a tikzpicture using \includegraphics
. While it was no problem when I worked from inside the pictures folder (TEST.tex), I soon hit the issue that the input path is relative to the main tex file, rather than the current file.
A quick google search led me to the import
package with subimport
. While this allows me to load the tikzpicture in a way that the includegraphics
inside the tikzpicture
works, it does not support tikzscale
.
I thought I got lucky when I read the following in the tikzscale documentation, in regard to the problem:
If both tikzscale and currfile are loaded, the limitation is fixed, so that both [includegraphics relative to main file AND relative to current file] \includegraphics commands succeed.
However, for me it does not work. I.e. the following results in the png not beeing found:
Filetree:
pictures/tikzpicture.tikz
pictures/OtherSources/png.png
document1/doc1.tex
doc1.tex:
\documentclass{report}
\usepackage{tikz}
\usepackage{currfile}
\usepackage{tikzscale}
\begin{document}
\input{../pictures/tikzpicture.tikz}
\end{document}
tikzpicture.tikz
\begin{tikzpicture}
\includegraphics{OtherSources/png.png}
\end{tikzpicture}
=> Error message:
Package pdftex.def Error: File `OtherSources/png.png' not found. ...ng.png}
Related: Outsourcing TikZ code
\graphicspath{}
? That might work. If it were me, I'd probably just use sym links.graphicspath
I did not even know that it exists, so I will try that, however I would love the native feel of just amking allinput
and co commands relative to the current file.