# Problems using import package with included files that load packages

I have the following structure (the MWE files here aren't worth it, but they represent something significantly larger I'm working on):

test
├── config
│   └── tikz.tex    <-- This file groups related TikZ commands
├── img
│   └── image.tex   <-- Image generated with TikZ for testing purposes
├── mwe.tex         <-- Main .tex file
└── preamble.tex    <-- Common preamble file (for the standalone package)


The MWE files are:

mwe.tex

\documentclass[12pt,letterpaper]{article}
\usepackage{standalone}
\input{preamble}
\begin{document}
Hi there!
\begin{figure}[H]
\centering
\includestandalone{img/image}
\end{figure}
\end{document}


preamble.tex

\usepackage{float}
\input{config/tikz}


config/tikz.tex

\usepackage{tikz}
\tikzset{%
pics/circleHi/.style args = {msg #1}{%
code = {\draw (0,0) circle (2) node at (0,0) {#1};}
}%
}


img/image.tex (Note I'm using the import package)

\documentclass{standalone}
\usepackage{import}
\subimport*{../}{preamble}
\begin{document}
\begin{tikzpicture}
\draw pic at (-3,0) {circleHi={msg Hi}};
\draw pic at (0,0) {circleHi={msg there}};
\draw pic at (3,0) {circleHi={msg friends!}};
\end{tikzpicture}
\end{document}


When I compile the file mwe.tex with

latexmk -xelatex mwe.tex


Everything is fine, and I get the PDF with the following result:

However, when I try to compile only the image located in img/image.tex I get the following error, despite the fact I'm using \subimport*{../}{preamble}.

! LaTeX Error: File float.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:


Am I misunderstanding the purpose of the import package? Did I miss something? Is there any other possibility to allow relative paths, in case import is not suitable for this scenario?

It's important for me to compile the standalone TikZ graphics, to use them directly in the document and reduce compilation time, without using the standalone class as I want the image files in the same folder as the LaTeX sources (for this MWE that doesn't matter, but it does on larger projects).

Thanks in advance! :)

• Does using \subimport{../}{preamble} work? I think that what is happening is that latex can't find float.sty because the * option of \subimport disables TEXINPUTS. Removing the * should fix your problem. I haven't tested this because I am too lazy to set up all of your files (sorry!). – Andrew Sep 5 '16 at 6:24
• @Andrew I removed it, and it works! :) So it seems that's the problem. Please answer and I'll finish this! – user101590 Sep 5 '16 at 11:52
• Great. Glad it worked. Have added this as an answer. – Andrew Sep 5 '16 at 21:05

What is happening is that latex can't find float.sty because the * option of \subimport disables TEXINPUTS. Removing the *` should fix your problem.