3

I want to start using context to write my thesis but I can't even get a simple project layout to work:

product.tex

\environment env
\startproduct product

\component test

\stopproduct

env.tex

\startenvironment env
\usepath[{components}]
\setuphead[color=red]
\stopenvironment

components/test.tex

\product product

\startcomponent test
\section{Hello}
this is just a test.
\stopcomponent

When I compile product.tex it says

open source     > 3 > 5 > components/test.tex
open source     > 4 > 6 > product.tex
open source     > 5 > 7 > components/test.tex
open source     > 6 > 8 > product.tex
open source     > 7 > 9 > components/test.tex
open source     > 8 > 10 > product.tex
open source     > 9 > 11 > components/test.tex
open source     > 10 > 12 > product.tex
open source     > 11 > 13 > components/test.tex
open source     > 12 > 14 > product.tex
open source     > 13 > 15 > components/test.tex
open source     > 14 > 16 > product.tex
open source     > 15 > 17 > components/test.tex
open source     > 16 > 18 > product.tex
open source     > 17 > 19 > components/test.tex
open source     > 18 > 20 > product.tex
open source     > 19 > 21 > components/test.tex
open source     > 20 > 22 > product.tex
open source     > 21 > 23 > components/test.tex
open source     > 22 > 24 > product.tex
open source     > 23 > 25 > components/test.tex
open source     > 24 > 26 > product.tex
open source     > 25 > 27 > components/test.tex
open source     > 26 > 28 > product.tex
open source     > 27 > 29 > components/test.tex
open source     > 28 > 30 > product.tex
open source     > 29 > 31 > components/test.tex
open source     > 30 > 32 > product.tex
open source     > 31 > 33 > components/test.tex
open source     > 32 > 34 > product.tex
open source     > 33 > 35 > components/test.tex
open source     > 34 > 36 > product.tex
open source     > 35 > 37 > components/test.tex
open source     > 36 > 38 > product.tex
open source     > 37 > 39 > components/test.tex
open source     > 38 > 40 > product.tex
open source     > 39 > 41 > components/test.tex
open source     > 40 > 42 > product.tex
open source     > 41 > 43 > components/test.tex
open source     > 42 > 44 > product.tex
open source     > 43 > 45 > components/test.tex

tex error       > error on line 5 in file components/test.tex: ! TeX capacity exceeded, sorry [text input levels=127]


\processfilemany #1->\clf_processfilemany {#1}

l.5 }

\m_syst_action_nop #1 ->\clf_useproduct {#1}

l.1 \product product


1     \product product
2     
3     \startcomponent test
4     \section{Hello}
5 >>  this is just a test.
6     \stopcomponent
7 

Obviously it gets cought in an infite loop of the component and the product including each other. If I take out the first line (\product product) from the component it compiles fine but then it doesn't load the environment.

What am I doing wrong?

1 Answer 1

2

I do not use the project-product-component structure, so I am not 100% sure what is the right solution. But you have two possibilities:

  1. Change the structure as follows:

    Product.tex:

    \startproduct *
    \environment env
    
    \component test
    \stopproduct
    

    components/test.tex:

    \startcomponent *
    \environment env
    
    This is a test
    \stopcomponent
    
  2. Add a project file:

    project.tex

    \startproject project
    \environment env
    \product product
    \stopproject
    

    product.tex:

    \startproduct product
    \project project
    \component components/test
    \stopproduct
    

    components/test.tex:

    \startcomponent test
    \project project
    
    \section{Hello}
    this is just a test.
    \stopcomponent
    

In both cases, you compile only the product file or the component file. You never compile the project file.

The first alternative is somewhat simpler; the second is slightly more elaborate.

OT: Note that it is possible to use \startcomponent * etc. so that you do not have to type the full name of the component.

4
  • Hi Aditya, thanks for your answer! Both of your solutions work but I have a few questions: 1) The wiki article about Project structure always defines \environment, \project and \product outside of start~...stop~ and it is the same in the ThisWay referenced at the end of the article. Is this simply outdated or how come you put it inside the start~...stop~? 2) Isn't the whole point of product/component that I don't have to specify the envs in every single component? 3) If the compiler can derive the component/product name from the filename and there is always only one component per file,...
    – DP.
    Jun 28, 2016 at 21:47
  • why does \startcomponent even require a name or asterisk? 4) In your last example you didn't map the component to a specific product but just to the project itself. I think this does make sense as you might want to reuse components but still it seems odd – maybe the hierarchical project/product/component strucuture doesn't make sense after all? And finally: If you don't use this structure, how do you organize larger projects?
    – DP.
    Jun 28, 2016 at 21:50
  • @DP: 1) Both styles are okay. The advantage of using \environment .. after \startproduct or \startcomponent is that the *product or *component mode is enabled. So, you can do different styles depending on whether a product or a component is being compiled. 2) Yes and you can do so with both methods. With the first method, you create an environment file that calls other environments; with the second method, simply list all your environments in the project file. ....
    – Aditya
    Jun 29, 2016 at 4:10
  • ... 3) For backward compatibility. At some stage the name of the component/product, etc. was used to make sure that the same file is not processed more than once; now just the filename is used for that purpose. 4) There is no need to refer to the product in a component; just the project. 5) Method 1 (just don't call the main file a product). I have never really felt the need for project/product/component structure.
    – Aditya
    Jun 29, 2016 at 4:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .