Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I stumbled upon the following question:

In the preamble of my main tex file for my thesis, I've included several other files with definitions for abbreviations which are in the same path as main.tex, so I've only used the filename with the relative path to include them:

\include{abbrevations.tex}

For using some of my definitions also in other TeX-Documents (e. g. graphics created with IPE) I've created a file called IPE-Preamble.tex, which contains selected parts of my preamble, so also the lines \include{abbrevations.tex}.

Both mentioned files are located in the same path THESIS/

I've included the file IPE-Preamble.tex in many other files which are located in the path THESIS/graphics successfully, it works:

\input{/drive/path/path2/THESIS/IPE-Preamble.tex}

Now I wanted to use this file also in .tex files which are located elsewhere on the same computer (let's say path /drive/path3/path4/main2.tex). I used the same input command with the full path for IPE-Preamble as stated above, but I get an error message, that commands (which are defined in abbreviations.tex are "not defined", so it seems that the include command does not work in this case.

Does TeX search for the file /drive/path3/path4/abbreviations.tex because of the relative path of the include command in IPE-Preamble.tex?

share|improve this question
3  
Don't use \include for code snippets. \include is only useful for document parts like a complete chapter. In all other cases use \input. Regarding the relative pathes see the FAQ: tex.ac.uk/cgi-bin/texfaq2html?label=docotherdir –  Ulrike Fischer Jul 1 '11 at 15:00
1  
\include{abbrevations.tex} is wrong it should be called without any extension: \include{abbrevations}. While \input can be used with and without (defaults to .tex) extension to load any kind of text file (e.g. \lstinputlisting is using it internally), \include is explicitly for .tex files only. If you use the extension a file abbrevations.tex.aux is created not abbrevations.aux. I'm not sure if and what issues that may cause. –  Martin Scharrer Jul 1 '11 at 15:11
1  
You can also set the environment variable TEXINPUT=".:/drive/path/path2/THESIS:", to make LaTeX look for files also there. I do this a lot for my thesis. –  Martin Scharrer Jul 1 '11 at 15:14
    
@Ulrike: :-) I actually have an \include{abbrevations} in my Ph.D. thesis, so I can just use \includeonly if I need to give that list to my supervisor as PDF. Same for the ToC etc. They all belong on pages of their own anyway. But you are of course right, that \include shouldn't be used for code snippets and only if you have a reason to use it. –  Martin Scharrer Jul 1 '11 at 15:53

1 Answer 1

up vote 5 down vote accepted

The \include causes an .aux file to be written in the same directory of the included file; the most recent TeX distributions disallow writing in directories called with an explicit path or above the directory where the main file resides.

Use \input that doesn't suffer from these limitations, provided you have read access to the directories.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
http://tex.stackexchange.com/questions/22058/what-happens-to-a-relative-path-in-a-file-added-with-input
tex.stackexchange.com
crawl=CC-MAIN-2015-06
72647
application/http; msgtype=response
sha1:MVCPYDOCKVALTP7JSOA4U6ZGGW56HKA6
<urn:uuid:330defd7-0461-4399-88d2-b71a3b1ed4fb>
2015-01-27T19:26:29Z
198.252.206.140
sha1:SEX47ZLWG72SEUWW3FZTDXXTMO5G4SML
<urn:uuid:228bc6e5-d6c9-4a7f-9575-73b34e2283d3>
http://tex.stackexchange.com/questions/22058/what-happens-to-a-relative-path-in-a-file-added-with-input
response
<urn:uuid:0dc401f5-2183-4347-93b0-ab9d8c9ca14c>
robots: classic
hostname: ip-10-180-212-252.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-06
operator: CommonCrawl Admin
description: Wide crawl of the web with URLs provided by Blekko for January 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf