In order to keep doc dir clean, I keep a master file in the top level of the doc, and other files in folders:
.
├── bib
│ └── refs.bib
├── img
│ ├── img1.png
│ └── img2.png
├── tex
│ ├── part1.tex
│ ├── part2.tex
│ └── part3.tex
├── tmp
└── master.tex
I import tex files from tex with:
% include from tex/
\usepackage{import}
\def\includeFromTex#1 {\subimport{tex/}{#1.tex}\include{#1}}
Example usage:
\begingroup\let\clearpage\relax % tweak that stops include from starting with newpage
\includeFromTex{10_-_calc}
\includeFromTex{20_-_disc}
\includeFromTex{30_-_app}
\endgroup
And every file under tex/
starts with:
% -*- TeX-master: "../master.tex" -*-
This works fine with tex, but breaks reftex ability to build toc, and reference things. Is it possible to notify reftex that I keep tex files under tex/
?
Edit:
Since I can't tweak reftex to do that, I moved texs to the doc dir:
.
├── bib
│ └── refs.bib
├── img
│ ├── img1.png
│ └── img2.png
├── tmp
├── 10_-_part1.tex
├── 20_-_part2.tex
├── 30_-_part3.tex
└── master.tex
Now I'm using plain \input{}
for files and everything works (latex and reftex).
(BTW if one numbers the parts, the the master file will always be the last one. In this case it is possible to make it TeX-master
automatically:
% -*- eval: (setq TeX-master (car (last (directory-files default-directory nil ".*\\.tex$")))) -*-
one should put this line at the top of child tex files)
\include{tex/part1}
?import
instead ofinclude
.reftex
parser only looks at\include
and\input
, so it might simply be easier to store the normal value of\include
in a macro via\let\oldinclude\include
, and then redefine\include
. I've used that trick before to get around exactly this issue where I wanted a specialized input command, but also wantedreftex
andauctex
to be able to find and parse stuff.\def
if you must but\def\foo#1 {....}
defines the argument of\foo
not to be the next{}
group but to be everything up to the next space.\def\foo#1{....}
would be the thing to use to define a command as\newcommand
would define it with an argument delimited by{}