# [NTG-context] using environments with project structure (in MkIV)

Sanjoy Mahajan sanjoy at MIT.EDU
Fri Feb 28 16:03:15 CET 2014

MkIV.  Here's how the problem arises.

As Aditya and Wolfgang have pointed out, the recommended way to set up
fonts in MkIV is before \starttext or \startcomponent.  For a component,
the setups usually go in an environment file that is referenced by the
project file, and the project file is mentioned with a \project, e.g.

\startcomponent test
\project testproject
\input knuth
\stopcomponent

However, the \project line has to come *after* \startcomponent.  If it
comes before \startcomponent, then context doesn't process the component
file at all, and no PDF file is generated.  An example:

\project testproject
\startcomponent test
\input knuth
\stopcomponent

(with testproject.tex containing \startproject blah \stopproject)

A workaround is to replace the \project line with \environment env where
env is what testproject would have included anyway.  e.g.

\environment env
\startcomponent test
\input knuth
\stopcomponent

Here, env.tex has all the setups including the font setups (and one
would do the same in the product file, i.e. in the file that includes
the components, by putting "\environment env" before the \startproduct).

The first problem is that it seems some of the functionality of
products, projects, and components is lost.  But maybe that's a matter
of taste.

Another problem is that env.tex doesn't know that one is compiling a
product or component---thus, the system modes *product and *component
are not defined while reading env.tex.

Is there another way of doing project structure that I am missing?

My update to the wiki page on project structure (on putting \project
before \startcomponent) seems to be wrong, and I'll fix it once I
understand what to do!

-Sanjoy