[NTG-context] Project Structure - inheritance rules for environments

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Mon Mar 1 20:09:45 CET 2021

denis.maier at ub.unibe.ch schrieb am 28.02.2021 um 23:09:
> Hi,
> I’m just having a look a project structure again. I am using the example 
> given in the wiki: https://wiki.contextgarden.net/Project_structure, 
> i.e., in my component I’m linking to the product, but not to the 
> project. Now I was expecting that the component inherits the environment 
> set in the project via the product. The wiki currently explains: “If you 
> tex (compile) one single component (e.g. a chapter of a book) or product 
> (e.g. one volume of a magazine), the environment file of the project is 
> used.” That does not seem to be the case here. Can anyone confirm this? 
> Is this a bug or does the wiki needs to be revised?

The \product command doesn't load any files because it doesn't make
any sense. Let us take a look at the following example. When you process
only a single component and \product would load the parent file you're
running in a problem because the parent file is now loading the previous
component file etc.

This would end in a loop and to prevent this \product lines are ignored.
There are ways to avoid this by redefining \component etc. when
the parent file is loaded but it's a mess to take care about all
combinations in which files are loaded.

The best thing you can do here is to load the environment file
in each product and component because the file is only loaded once
on the first call. When you use multiple environment files you
can collect them in a project file and use \project to load only
one file but this is seldom needed.

%%%% begin product.tex
\startproduct *

\environment environment

\component component_1
\component component_2

%%%% end product.tex

%%%% begin component_1.tex
\startcomponent *

\environment environment


%%%% end component_1.tex


More information about the ntg-context mailing list