Changes

Jump to navigation Jump to search
1,605 bytes added ,  19:10, 4 October 2018
move \product and \project below \start...
< [[The ConTeXt Way]] | [[Structurals]] >
 
==Introduction==
ConTeXt knows no document classes (as LaTeX does). You can define your [[Layout|layout]] yourself. If you use the same layout for several products, save it as an '''environment''' file.
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.
In addition, you have to keep in mind that when compiling a product or component file, ConTeXt goes "up" to the project file and compiles everything it finds in there that is not a <{{cmd>|product</cmd> }} (e.g. table of content, sectioning commands, text, <{{cmd>|component</cmd> }} etc.). So all the things on project level have to be put inside a <{{cmd>|product</cmd>}}, otherwise they will show up in the individual components (or products), too. That also makes it problematic to use <{{cmd>|component</cmd> }} directly inside a project file, i.e. you '''have ''' to use <{{cmd>|product</cmd>}}, you can't skip it. While you can compile ("tex") products and single components, the project is not intended for compiling; trying might lead to infinite inclusion loops and the error message "TeX capacity exceeded". ==File and directory setup== ===Naming conventions===
[[User:Hraban|Hraban]] uses and suggests the following naming conventions
* c_foo
* env_foo
 
There's a Python script <tt>contextproject.py</tt> at Hraban's [http://github.com/fiee/tools/blob/master/contextproject.py github repository] to help creating the files (.ini files can be used for initial content). This functionality would be nice to be integrated in any editor supporting ConTeXt...
 
===Example files===
'''Project'''
\product prd_year2004-03
\product prd_year2004-04
 
\product tableofcontent
\stopproject
\startcomponent c_editorial
\product prd_year2004-01 % but you can use it in other products anyway
\project project_mymag
\title{Editorial}
</texcode>
There's ===Subdirectories=== If you keep all files in one directory, it tends to get confusing. Here’s a Python script <tt>contextprojectstructured example where we keep all parts of one product together:  env_mymag.tex project_mymag.py<tex 2011-01/tt> at Hraban's [http:prd_issue2011-01.tex 2011-02/prd_issue2011-02.tex 2011-03/githubprd_issue2011-03.comtex ... 2011-03/fieec_editorial.tex 2011-03/toolsc_article1.tex ... 2011-03/blobimg/masterauthor1.jpg ... general_img/contextprojectlogo.pdf ... '''Environment'''<texcode>\startenvironment env_mymag\project project_mymag .py github repository.. % where \product and \component look for TeX input files\usepath[{2011-01,2011-02,2011-03}]  % where to help creating the files (look for images\doifmodeelse{*product} {\setupexternalfigures[directory={../general_img}]} {\setupexternalfigures[directory={../general_img, img}]} ...ini files can be used for initial content)\stopenvironment</texcode> '''Product'''<texcode>\startproduct prd_issue2011-01\project project_mymag\environment env_mymag \component c_editorial\component c_article1. This functionality would be nice to be integrated in any editor supporting ConTeXt.. \stopproduct</texcode> ConTeXt automatically looks into parent directories.
'''Summary (for MkIV)'''==Command behaviour==
Depending on the (Within a <code>\start-...\stop) ...</code> environment, project, product, and environment a command will either load a file definition files are loaded only once, or many times or not while component files are loaded at allevery mention. In addition, certain loading commands are ignored inside certain environments -- for example, it makes no sense to load a <code>\component</code> inside a <code>\startenvironment</code> block. The following table specifies what happens when: below gives an overview.
{|
| || <{{cmd>|project</cmd> }} || <{{cmd>|environment</cmd> }} || <{{cmd>|product</cmd> }} || <{{cmd>|component</cmd> }}
|-
| <{{cmd>|starttext</cmd> }} || once &mdash; || once || once &mdash; || many at every mention
|-
| <{{cmd>|startproject</cmd> }} || once &mdash; || none once || once || none &mdash;
|-
| <{{cmd>|startenvironment</cmd> }} || once &mdash; || none once || once &mdash; || none &mdash;
|-
| <{{cmd>|startproduct</cmd> }} || once || once || once &mdash; || none at every mention
|-
| <{{cmd>|startcomponent</cmd> }} || once || once || once &mdash; || none at every mention
|}
 
==See also==
 
Hans Hagen (2011) [http://pragma-ade.com/general/magazines/mag-1101.pdf Project Structure], ConTeXt magazine #1101.

Navigation menu