1

I have a standalone setup with the following file structure

A
├── A.tex
└── sections
    ├── B
    │   ├── Bimages
    │   │   └── cat.png
    │   └── B.tex
    └── C
        ├── Cimages
        └── C.tex

I have a main tex file called A and two subfiles B and C, such that the content of A is a title page then B and C concatenated. B has its own images directory, which is referenced in B.tex using \graphicspath{ {./Bimages/} } and C similarly has ./Cimages/. B and C compile separately perfectly well, however, when I compile A, I get LaTeX Warning: File Bimages/cat.png not found on input line 89.

Is this expected behaviour with standalone? Will it not account for relative file paths in subdirectories? If so, is there a way to work around this such that I can organise my images into separate folders(preferably without having to do \graphicspath{ {./sections/B/Bimages} {./sections/C/Cimages} } in A.tex, as I may have many more similar directories in the future.

0

2 Answers 2

1

Because your problem is interesting and somebody may have a similar problem when using OpTeX, I give OpTeX solution here. Note, that OpTeX isn't LaTeX and if you are using LaTeX then my answer isn't for you.

OpTeX declares for including graphics the token register \picdir and, of course, there is an equivalent control sequence \_picdir which is the same token register. Suppose, that you have \picdir{Bimages/} in the B.tex file and \picdir{Cimages/} in the C.tex file. Then you can run OpTeX on B.tex or C.tex standalone.

In the main file A.tex, you can deactivate the \picdir and use only \_picdir. A part of A.tex can look like this:

\let\picdir=\ignoreit
\_picdir{B/Bimages/}
\input B/B.tex
\_picdir{C/Cimages/}
\input C/C.tex
\bye
0

you might want to change the way you import your subfiles

\input just copies the text content of B.tex into A.tex before compiling.
That makes A look for the graphicspath in it's home directory (which is /A/)

\include (I think) creates aux files for every sub-file and therefore might be able to find the correct subpath (for example /A/B/Bimages/)

I DID NOT TEST THIS!

see this for reference


If that does not do the trick, then you could maybe switch to using global paths for your images
(like "~/foo/bar/A/B/Bimages/" instead of "./B/Bimages/").

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .