# Compilation with convert in subdirectory

Issue #27 open
Noctiflore created an issue

I need to compile a standalone (TikZ) file located in a subdirectory, like the example in this thread :

./mwe.tex
./sub/mwefig.tex

Using the given files, I can compile both mwe.tex and mwefig.tex from main directory with the following lines, respectively :

pdflatex -shell-escape mwe.tex                          % whole document
pdflatex -shell-escape -output-dir sub sub/mwefig.tex   % figure only

However, if I add convert to mwefig.tex : compiling the main document mwe.tex still compiles mwefig.tex and generate a PNG file, but compiling the figure only (with the same command) fails.

In fact, the failure comes from the internal compilation of mwefig.tex, that pdflatex searches in main directory (LaTeX Error: File `mwefig.tex' not found). If I manually type tex/mwefig.tex at the prompt, the mwefig.pdf and .png are generated in the main directory. As this internal compilation works whithout convert, I think this should work with convert.

Of course, if I compile from sub/, it works. However, my real use case implies the inclusion of files relative to main directory in sub/mwefig.tex.

1. repo owner

Hi, the problem here is that in the second case only the filename, not the whole path, is accessible with LaTeX. This makes it difficult to call LaTeX internally again with "sub/mwefig.tex" instead of "mwefig.tex". If you compile it from the main document using the standalone class the full path is already known.

The whole thing with subdirectories is quite tricky in general. I already implemented a way for this using my other package currfile and its abspath option. However, I forgot the document it in the manual. Try the following in mwefig.tex:

\documentclass[convert={png,realmainfile,latexoptions={ -shell-escape -output-dir=sub }}]{standalone}

and then run it like this:

pdflatex -recorder -shell-escape -output-dir sub sub/mwefig.tex

2. repo owner

I will try to extend the realmainfile option to set the output-dir setting automatically.

3. repo owner
• changed status to open