Code: Select all
\include{../chapter1/chapter1}[\code]
Is what I am trying to do possible? I am sure it is but I don't know how to really program with latex. Any help would be much appreciated.
Thanks for your help
David Collins
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide : 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook : 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ : the first book about TikZ for perfect drawings in your LaTeX thesis
welcome to the board!Code: Select all
pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
[\CODE]
I moved all the chapter folders into the same folder as the root, it probably makes more sense that way anyway! This solves my initial problem of including tex files.
I have realised that if I try to include an image in a chapter tex file with the image location relative to that file it will compile if I test just the chapter from that folder, but, obviously, the root tex file will not be able to find it. Is there a way to tell the root tex file what directory I am using for a particular tex file?
I hope this makes sense, I am just trying to set everything up so that the on computer structure has a similar logical structure to the report, and all chapters are self contained and can be tested and complied independantly.
Thanks
David
Code: Select all
\input{..\subdir\file}
Code: Select all
%& --include-directory=dir1 --include-directory=dir2
% and the rest of your file goes below
That way you don't need any wrapper scripts.
I hope this helps a bit.
Cheers,
Tomek
Edit: fixed code
Hi Tomek,
that's a good explanation. Let me add something. First, you don't need to set TEXINPUTS on every compiler run. On a unix system I would put it into my ~/.profile file, like:
Code:
Select all
export TEXINPUTS=./images:$TEXINPUTS
On Windows it may be done in the control panel (system/ environment), on older systems, Windows 98 and below one could use
Code:
Select all
set TEXINPUTS=.\images;%TEXINPUTS%
inside autoexec.bat.
If that has been done, the TEXINPUTS will be correctly set for each section automatically.
Second, I would not use \input for the chapters. In general I'm using
\include
, this has the big advantage that I can compile just parts of the document like chapters individually by
\includeonly
. That way is explained by the document I linked above.
Best regards,
Stefan
Stefan_K wrote:
First, you don't need to set TEXINPUTS on every compiler run. On a unix system I would put it into my ~/.profile file, like:
Code:
Select all
export TEXINPUTS=./images:$TEXINPUTS
On Windows it may be done in the control panel (system/ environment), on older systems, Windows 98 and below one could use
Code:
Select all
set TEXINPUTS=.\images;%TEXINPUTS%
inside autoexec.bat.
If that has been done, the TEXINPUTS will be correctly set for each section automatically.
Yes, you could do that. The downside of autoexec.bat is that any change to TEXINPUTS will force you into system reboot. That's a major inconvenience for somebody like me, who doesn't like to turn off his PC. Editing the environment through the control panel (or directly through the registry) will require restarting of the affected application (you won't find many that will respond to system broadcast about the applied changes). Not as bad as reboot but still annoying. Plus, I don't like to rely on system-wide settings (environment) for job specific stuff. I think it's a bad practice. Anyway, I suppose everyone will have their own preferences in that respect. I like to keep everything as portable and self-contained as possible so it's easy to compile on other systems if the need arises (and it keeps my options open).
As for '\include vs. \input', I don't find '\include' + '\includeonly' all that helpful (again, a matter of personal preference). I do use it, though, since it's so easy to swap it for '\input' when I need it - '\let\include=\input' does the trick
.
Cheers,
Tomek
Hi Tomek!
T3. wrote:
The downside of autoexec.bat is that any change to TEXINPUTS will force you into system reboot.
That's not necessary. Just execute the
set
command on the command line. Editing autoexec.bat is only needed if you want to keep the setting for the next reboot in the future. Though perhaps nobody reading this will use autoexec.bat
the same argument is valid for newer systems too. Either I just type the
export
command in the shell of any unix system (or, if no bash is available, write set or setenv), or I edit my ~/.profile. That setting will be valid for the next login of my account, or after starting a shell or just executing .profile or as said typing it manually.
T3. wrote:
Editing the environment through the control panel (or directly through the registry) will require restarting of the affected application (you won't find many that will respond to system broadcast about the applied changes).
As far as TeX is concerned the compiler restarts for every run and will read the environment variables.
T3. wrote:
Plus, I don't like to rely on system-wide settings (environment) for job specific stuff. I think it's a bad practice. Anyway, I suppose everyone will have their own preferences in that respect.
Yes, there may be different requirements. I like the idea to configure file handling by separate settings like TEXINPUTS. If I take my tex files from my Unix OS to Windows, I probably don't need to change all my files as it might be necessary if I am using paths or sth. like \graphicspath inside. I just apply the setting one time to the other OS.
T3. wrote:
As for '\include vs. \input', I don't find '\include' + '\includeonly' all that helpful (again, a matter of personal preference). I do use it, though, since it's so easy to swap it for '\input' when I need it - '\let\include=\input' does the trick
.
I'm using both too. Often I just don't want the \clearpage implied by \include, then I will use \input. But again I like the idea to exclude some chapters of a very big document during development by \includeonly, because of the faster compile run, smaller output and quicker viewing. Especially now after the mainboard of my faster system is damaged and I'm using a slower one until the release of new processors in the third quarter of this year...
Stefan
Stefan,
Changes to the environment issued from a command interpreter on Windows will be local to that particular instance of command interpreter (although they will be inherited by programs launched from it after the changes occured). I'm sure that you are aware of this detail but some Windows users might not be. Most people launch latex compilation from their text editor and not directly from the command line. In that case this editor has to be started from the process making the changes to the environment or it won't see those changes.
To tell you the truth I don't like any of the solutions discussed in this thread. Having input-like command that would resolve paths relative to the file containing the command would be the best, IMO. But there's no such command and so the 1-level deep directory layout is the second best solution I've found so far. Since the directory layout described by OP is somewhat reminiscent of the one I use, I thought that my solution might suit him the best.
Of course using TEXINPUTS is just fine as well. As long as the user understands how process environments are hanled by the system there should be no problems there. One just has to keep in mind that such sources won't compile stright away on another system, so care must be taken when sending them to others.
Cheers,
Tomek
Hi Tomek,
I think it's useful to speak about those issues and what may be good practice. I'm interested in other users opinions too. I appreciate your posts.
T3. wrote:
Having input-like command that would resolve paths relative to the file containing the command would be the best, IMO.
\input and \include are able to resolve relative paths also to parent directories, it's just a security issue. On my unix system I just have to edit the file texmf.cnf to allow access to the parent directory:
Code:
Select all
% Allow TeX \openin, \openout, or \input on filenames starting with `.'
% (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)?
% a (any) : any file can be opened.
% r (restricted) : disallow opening "dotfiles".
% p (paranoid) : as 'r' and disallow going to parent directories, and
% restrict absolute paths to be under $TEXMFOUTPUT.
openout_any = a
openin_any = a
I don't have Windows to look for the configuration file, but I'm sure you could find it.
Stefan
LaTeX's Friends
↳ BibTeX, biblatex and biber
↳ MakeIndex, Nomenclature, Glossaries and Acronyms
↳ Conversion Tools
↳ Viewers for PDF, PS, and DVI
↳ XeTeX
↳ Others
LaTeX Distributions
↳ Decision Guidance
↳ MiKTeX and proTeXt
↳ TeX Live and MacTeX
↳ Others
LaTeX Editors
↳ Decision Guidance
↳ AUCTeX
↳ Kile
↳ LEd
↳ LyX
↳ Scientific Word/Workplace
↳ Texmaker and TeXstudio
↳ TeXnicCenter
↳ Announcements
↳ General
↳ Templates, Wizards & Tools
↳ Feature Suggestions
↳ Development
↳ TeXShop
↳ TeXworks
↳ WinEdt
↳ WinShell
↳ Others
LaTeX Templates
↳ Articles, Essays, and Journal Templates
↳ Theses, Books, Title pages
↳ Letters
↳ Presentations and Posters
↳ Curricula Vitae / Résumés
↳ Assignments, Laboratory books and reports
↳ Calendars and Miscellaneous
LaTeX Community
↳ Announcements
↳ Community talk
↳ Comments & Wishes
↳ New Members
LaTeX Books
↳ LaTeX Beginner's Guide
Learn LaTeX easily with newest books:
The
LaTeX Beginner's Guide
: 2nd edition and perfect for students writing a thesis
The
LaTeX Cookbook
: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ
: the first book about TikZ for perfect drawings in your LaTeX thesis
Advertisements by
Advertisement Management
Powered by
phpBB
® Forum Software © phpBB Limited
phpBB Two Factor Authentication ©
paul999
Privacy
Terms