Following the Project Structure Wiki and Subfiles Wiki, I've built the following project structure:
./mydocument.tex
./mystyle.sty
./tex/mysubfile.tex
./img/
mydocument.tex looks like:
\documentclass{report}
\usepackage{mystyle}
\begin{document}
\subfile{./tex/mysubfile.tex}
\end{document}
mystyle.sty looks like:
\ProvidesPackage{mystyle}
\usepackage{subfiles}
% other packages
% command declarations
mysubfile.tex looks like:
\documentclass[../mydocument.tex]{subfiles}
\begin{document}
% stuff goes here.
\end{document}
I'm using (1) the subfiles package because I'd like to compile mysubfile.tex by itself and (2) mystyle.sty because I'd like to modularize this project a bit and split package and command declarations into their own .sty file. The problem is that when I try and compile mysubfile.tex by itself it can't "see" mystyle.sty.
Q: Is there some way I can still satisfy (1), (2), and the project structure outlined above and get things working? Some sort of option or command in the subfiles package?
I've tried: (1) moving mystyle.sty to different directories, (2) moving the subfiles declaration \usepackage{subfiles} to different parts of the document, (3) checking the subfiles documentation. All no dice.
I suppose that the second best option would be to stick all project files in the same folder and get rid of my .\tex folder. At least then, I can get things to compile. But I'd rather not sacrifice the project structure.
subfilespackage does something very similar. One thing I like about thesubfilespackage is that it allows me to put sub-documents in folders different from the main document. I can just pass the location of the main document as an option tosubfilespackage declaration. – lowndrul Feb 28 '11 at 01:35.texfiles in sub-folders, but it is recommended in a number locations like, here, here, and here. Plus, I just like the structure. Ahh well, I guess something will have to give. – lowndrul Feb 28 '11 at 01:40subfilespackage is that you don't need to include extra package declarations in your sub-files. – lowndrul Feb 28 '11 at 01:47subfilesandstandaloneare doing something very similar just look at the preamble-sharing from two different sites. What I like onstandaloneis that you don't have to update your main preamble every time you include one of your subfiles! IMHO the subfiles are independent from the main file because they are used in many different main files (digest, paper, presentation of that paper, thesis). I can freely mix my subfiles (holding mostly diagrams) andstandalonemakes sure all required packages are loaded. – Martin Scharrer Feb 28 '11 at 09:11standaloneand I agree that different types of files might be placed in different directories. I normally put my figures intofigures/. What I don't get is why put other.texfiles in different directory by default as the main.texfile? I also put.texholding diagrams into a central directory and use theTEXINPUTSenvironment variable to a pointlatexthere. No package option required. Putting all of these files into atexmftree might be even better. – Martin Scharrer Feb 28 '11 at 09:18texdirectory. – Martin Scharrer Feb 28 '11 at 09:21.texfiles into separate directories only seems to increase the chance of bugs (which I've had). But, I will say that being able to split your.texsub-files into a/texsub-directory and keeping amain.texup in the main project directory is nice in that it discourages an unknowledgeable user from mucking around with the sub-files and to just compile from themain.tex. Minor point I suppose. – lowndrul Feb 28 '11 at 21:27