Changes

Jump to navigation Jump to search
3,737 bytes added ,  10:47, 25 May 2023
m
Change link to mag-1101.pdf to https
< [[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.
 :<i><b>Note</b>: the project structure explained on this page is not the only way to handle complex documents. If you are working on a project with a single output file, it may be simpler to use {{cmd|startdocument}} (perhaps in combination with {{cmd|usemodule}} or {{cmd|environment}} and {{cmd|startcomponent}} as explained below) and ignore the elaborate project and product setups.</i>  If you use the same layout for several related products, it may make sense to use the project support in ConTeXt. You then save your layout settings as an '''environment''' file, and you can reuse various document parts in multiple products. How to split up a large project, say a bookcollection of books, in several handy parts? – Use ConTeXt's project management facilities.
* a '''project''' links one or more '''products''' to their environment
* project: magazine
* product: one volume of the magazine
* component: an a single article
Example 2: Book
* component: part or chapter
[[Image:projectProject-structure.png]]
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}} (e.g. table of content, sectioning commands, text, {{cmd|component}} etc.). So all the things on project level have to be put inside a {{cmd|product}}, otherwise they will show up in the individual components (or products), too. That also makes it problematic to use {{cmd|component}} directly inside a project file, i.e. you '''have''' to use {{cmd|product}}, 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://codeberg.org/fiee/context-tools/ Codeberg 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
 
\completetableofcontents
\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 Perl script <tt>makeprojectstructured example where we keep all parts of one product together:  env_mymag.tex project_mymag.tex 2011-01/prd_issue2011-01.tex 2011-02/prd_issue2011-02.pl<tex 2011-03/tt> at Hraban's site [http:prd_issue2011-03.tex ... 2011-03/c_editorial.tex 2011-03/wwwc_article1.tex ..ramm.ch 2011-03/fieeimg/texniqueauthor1.jpg ... general_img/?menu=0logo.pdf ... With directories, the 'c_' prefix becomes obsolete.  '''Environment'''<texcode>\startenvironment env_mymag\project project_mymag ... % where \product and \component look for TeX input files\usepath[{2011-01,2011-102,2011-3&lang03}] % where to look for images\doifmodeelse{*product} {\setupexternalfigures[directory={../general_img}]} {\setupexternalfigures[directory=en {../general_img, img}]} ...\stopenvironment</texcode> ''fiëé teXnique'Product'] to help creating the ''<texcode>\startproduct prd_issue2011-01\project project_mymag\environment env_mymag \component c_editorial\component c_article1... \stopproduct</texcode> ConTeXt automatically looks into parent directories. =Command behaviour= Within a <code>\start...\stop...</code> environment, project, product, and environment definition files are loaded only once, while component files (are loaded at every mention.ini files can be used In addition, certain loading commands are ignored inside certain environments -- for initial contentexample, it makes no sense to load a <code>\component</code> inside a <code>\startenvironment</code> block. The table below gives an overview. {|| || {{cmd|project}} || {{cmd|environment}} || {{cmd|product}} || {{cmd|component}} |-| {{cmd|starttext}} || &mdash; || once || &mdash; || at every mention |-| {{cmd|startproject}} || &mdash; || once || once || &mdash; |-| {{cmd|startenvironment}} || &mdash; || once || &mdash; || &mdash; |-| {{cmd|startproduct}} || once || once || &mdash; || at every mention |-| {{cmd|startcomponent}} || once || once || &mdash; || at every mention |} =See also= Hans Hagen (2011)[https://pragma-ade.nl/general/magazines/mag-1101. This functionality would be nice to be integrated in any editor supporting pdf Project Structure], ConTeXtmagazine #1101...  [[Category:Basics]][[Category:Tools]]
1

edit

Navigation menu