[OS X TeX] include cannot be nested?
Alain Schremmer
Schremmer.Alain at gmail.com
Sat Nov 4 22:43:06 EST 2006
Ross Moore wrote:
> What you want is to *use* these commands within a particular context,
> along with doing other things. Thus you want to *define* a new command
> and then *use this* within your document source.
>
> e.g. something like this:
>
> \newcommand{\exinput}[3][]{% includes an exercise
> % #1 = optional indicator for hard exercises
> % #2 = title
> % #3 = file name where the exercise is stored
> \begin{exercise}[#1]{#2}%
> \input{#3}%
> \end{exercise}%
> }
>
> where the {exercise} environment is something that has been
> setup elsewhere for this document.
>
>
> Then the document source should contain instances, such as:
>
> \exinput{easy one}{exercises/ex1_1}
> \exinput{another easy one}{exercises/ex1_2}
> \exinput[*]{now a hard one}{exercises/ex1_3}
> \exinput[!]{now a really hard one}{exercises/ex1_4}
I did get it to work for my own (different) purpose—which was by no
means to be taken for granted—but, beyond the unimportant fact that I
don't understand the syntax of exinput so that I have not even tried to
get rid of the empty parentheses, I still need help. :-[
Here is what I did:
The preamble sets up the {exercise} environment and the definition of
\exinput.
I am using three folders side by side:
The folder PRINTchapter contains the file PrintChapter1 with
preamble and, in the document, \include{../EDITchap/1}
The folder EDITchapter contains the file EditChapter1 without
preamble and with the text of the chapter and the command
\exinput{}{../Exercises/1}
The folder Exercises which contains the file 1 which has two exercises
1) Things work well. (The only glitch is that in the output there are
three exercises with Exercise 1 empty and Exercises 2 and 3 being the
two exercises in the file Exercises/1. It must have to do with the
counters and I should be able to fix this.)
2) Here, though, is where I need help as I have not been able to get
something like
\newboolean{VersionWithExercises}
\ifthenelse{\boolean{VersionWithExercises}}{\exinput{#1}}{\url{#1}}
in the preamble so as to be able to switch from the VersionWithExercise
to the VersionWithURL by commenting
\setboolean{VersionWithExercises}{true}
in and out of PrintChapter1.
Very grateful (and hopeful) regards
--schremmer
P.S. Back on 4/24/06 7:44 PM, you wrote
LaTeX's \include is *not* the way to do this.
Instead I'd recommend the {comment} package,
where you can define your own named environments and specify
programatically whether they should be included or excluded.
but I was not able to find it.
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
More information about the MacOSX-TeX
mailing list