1

In my main.tex I am requesting my preamble to be loaded through the command \usepackage{preamble}, which is in the same folder as my main.tex. My subfiles are located one folder below, e.g. MAIN/introduction/introduction.tex.

I would like to compile my subfiles as individual documents as well, but I get the error preamble.sty not found, which I presume is because I do not have a preamble.tex file located in my subfile folders, only in the main folder.

Is there a possible way around this? For example, would I be able to specify two paths for my preamble, e.g. \usepackage{preamble} when I am compiling my main document and \usepackage{../preamble} when I am compiling my subfile?

Thanks for the help.

EDIT:

My preamble is in .sty format, and I load it in my main.tex with \usepackage{preamble}. I am unable to write the same thing in my subfile document because AFAIK the layout of a subfile has to only have \documentclass[main.tex]{subfiles}. Otherwise, I would also write \usepackage{../preamble} in my subfile document.

My folder structure is as follows:

main_folder/
   preamble.sty
   main.tex
   introduction_folder/
       introduction.tex

When I compile main.tex with \usepackage{preamble}, it works just fine. When I compile introduction.tex, I get the error that preamble.sty not found, even if I add \usepackage{../preamble}. I am using the subfiles package to create my subfiles.

  • 1
    Welcome to TeX.SE. The command \usepackage{preable} tells LaTeX to install a package (typically with extension .sty) named preamble... and so far as I know there is no such package by that name. If you want to include preamble.tex, just use \input{preamble.tex} instead-- if it is in the main folder with your main.tex, I think it should connect properly. – Partha D. Feb 11 '19 at 04:39
  • To use the same preamble for the tex files in your subfolder, use \input{../preamble.tex} there. – Partha D. Feb 11 '19 at 04:48
  • @ParthaD. Yes I've done that. My preamble is a .sty format and I load it with \usepackage. I have tried writing \usepackage{../preamble} in my subfile document to tell it to locate the preamble one folder above, but I am thrown an error. I suspect it's because subfiles is strict on the subfiles' layout (i.e. only \documentclass[main.tex]{subfiles}) is permitted. – elihpoivulp Feb 11 '19 at 07:15
  • @RichardGao Can you provide your folder structure? – MadyYuvi Feb 11 '19 at 07:24
  • @MadyYuvi Absolutely. I've edited my original post, hopefully it's more clear. – elihpoivulp Feb 11 '19 at 16:39
  • the main reason for a texmf structure is to do similar to what you are aiming for thus it should be possible to place any.sty in texmf-local and expect it to be available from any other location thus you need to check which folder is currently set. it is possible to have diferent paths from editor and console so best to use a console to check what is set and any editor should respect that location. –  Feb 12 '19 at 04:22

0 Answers0