Re: [NTG-context] components and figure search paths

2006-05-10 Thread Hans Hagen
Sanjoy Mahajan wrote:
 Using components (e.g. book chapters), with each component in its own
 directory, say I have

 \startproduct onebook
 \project manybooks
 \component 1/chap
 \component 2/chap
 \stopproduct

 with this 1/chap.tex:

 \startcomponent 1/chap
 \product onebook
 \project manybooks
 \title{One}
 An essential chapter.
 \useexternalfigure[ff][abc.1]
 \placefigure[here][ff]{Some caption}{\externalfigure[ff]}
 \stopcomponent

 I'd like to keep the figures and source for a chapter together,
 e.g. abc.mp and abc.1 in 1/chap/ since each chapter has many figures,
 and I edit and test one chapter at a time.
   
untested extension: \currentcomponentpath

\def\currentcomponentpath{.}

\def\donextlevel#1#2#3#4#5#6#7\\%
  {\pushmacro\currentcomponent
   \pushmacro\currentcomponentpath
   \let\currentcomponent#1%
   \setsystemmode\currentcomponent
   \splitfilename{#1}%
   \ifx\splitoffpath\empty
 \def\currentcomponentpath{.}%
   \else
 \let\currentcomponentpath\splitoffpath
   \fi
   \beforesplitstring#7\at.\to#2\relax % can become path + base
   \ifcase\filelevel\relax
 \starttext
 \def\project ##1 {#3{##1}}%
 \def\environment ##1 {#4{##1}}%
 \def\product ##1 {#5{##1}}%
 \def\component   ##1 {#6{##1}}%
   \fi
   \increment\filelevel\relax
   \fullexpandoneargafter\addtocommalist{#1}\loadedfiles}

\def\doprevlevel
  {\popmacro\currentcomponentpath
   \popmacro\currentcomponent
   \setsystemmode\currentcomponent
   \ifnum\filelevel=\plusone
 \expandafter\stoptext
   \else
 \decrement\filelevel\relax
 \expandafter\endinput
   \fi}


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] components and figure search paths

2006-05-10 Thread Sanjoy Mahajan
  Is the idea to use \currentcomponentpath in the directory={...}?  I put

 indeed

I've just tried the version below, but abc-1.eps cannot be found (I
also tried \noexpand\currentcomponentpath):

% file: chap/1/c_ch1.tex
\startcomponent c_ch1
\product onebook
\project project_books
\setupexternalfigures[directory={\currentcomponentpath}]
% but, just as a sanity check, this way works:
%  \setupexternalfigures[directory={chap/1}]
\title{One}
Hi
\useexternalfigure[ff][abc-1.eps]
\placefigure[here][ff]{Some caption}{\externalfigure[ff]}
\stopcomponent
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] components and figure search paths

2006-05-10 Thread Hans Hagen
Sanjoy Mahajan wrote:
 Is the idea to use \currentcomponentpath in the directory={...}?  I put
   
   
 indeed
 

 I've just tried the version below, but abc-1.eps cannot be found (I
 also tried \noexpand\currentcomponentpath):

 % file: chap/1/c_ch1.tex
 \startcomponent c_ch1
 \product onebook
 \project project_books
 \setupexternalfigures[directory={\currentcomponentpath}]
 % but, just as a sanity check, this way works:
 %  \setupexternalfigures[directory={chap/1}]
 \title{One}
 Hi
 \useexternalfigure[ff][abc-1.eps]
 \placefigure[here][ff]{Some caption}{\externalfigure[ff]}
 \stopcomponent
   
so how is this component, when run on itself, supposed to locate itself, 

- how does the dir structure look
- where did you put the file
- where did you run it

(there is also the option to say: \usesubpath[1,2,3,4,5,6]) 

Hans 


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] components and figure search paths

2006-05-10 Thread Sanjoy Mahajan
 so how is this component, when run on itself, supposed to locate itself, 

Not sure I completely understand your question.  But if I run one
component, I change to its directory first:

  cd chap/1  texexec c_ch1.tex

Or is the canonical method:

  texexec chap/1/c_ch1.tex 

?

I've been in the habit of not doing it this way with tex tools, since
(la/pdf)tex put the generated files in the current directory instead
of in the directory of the source file.

 - how does the dir structure look

./chap/1/abc-1.eps
./chap/1/c_ch1.tex
./project_books.tex
./env_books.tex
./onebook.tex

 - where did you put the file

It's in chap/1/ (along with the eps figure)

 - where did you run it

I ran 'texexec onebook' in the ./ directory.

Running the component works fine (if I cd to its directory first),
because abc-1.eps is easy to find.

-Sanjoy

`Never underestimate the evil of which men of power are capable.'
 --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] components and figure search paths

2006-05-10 Thread David Arnold
Hans and Sanjoy,

I am doing something similar, so I am following this discussion closely.

On my machine, the main directory is ~/Documents/IntAlgText/trunk.  
The main directory contains my environment files and book.tex (the  
project).

Then I have these directories.

~/Documents/IntAlgText/trunk/chapter0
~/Documents/IntAlgText/trunk/chapter1
...
~/Documents/IntAlgText/trunk/chapter8

Each of these directories contains a chapter and sections for that  
chapter. So, for example, I have:

~/Documents/IntAlgText/trunk/chapter0/chapter0.tex
~/Documents/IntAlgText/trunk/chapter0/section1.tex
~/Documents/IntAlgText/trunk/chapter0/section2.tex

Each of these directories contains a figure directory. So, I have:

~/Documents/IntAlgText/trunk/chapter0/figures
~/Documents/IntAlgText/trunk/chapter1/figures
...
~/Documents/IntAlgText/trunk/chapter8/figures

Each of these figure directories contain all of the figures for the  
chapter (the product). There are two files for each section of  
chapter that generate the figures.

~/Documents/IntAlgText/trunk/chapter0/figures/section1figs.tex
~/Documents/IntAlgText/trunk/chapter0/figures/figlibSection1.xml
~/Documents/IntAlgText/trunk/chapter0/figures/section2figs.tex
~/Documents/IntAlgText/trunk/chapter0/figures/figlibSection2.xml


My project (book.tex) looks like this:

\startproject book
%\environment bookenv
\doifnotmode{clean1-screen}{\environment bookenv-clean1-print}
\doifmode{clean1-screen}{\environment bookenv-clean1-screen}
\product chapter1/chapter0
\product chapter1/chapter1
\product chapter2/chapter2
\product chapter3/chapter3
\product chapter4/chapter4
\product chapter5/chapter5
\product chapter6/chapter6
\product chapter7/chapter7
\product chapter8/chapter8
\stopproject

chapter0.tex looks like this:

\startproduct chapter0
\project book
\startbodymatter
\setupheadnumber[chapter][-1]
\chapter[chap:0]{Preliminaries}
\component chapter0/section1  %Number Systems
\component chapter0/section2   %Logic
\stopbodymatter
\stopproduct

And the beginning lines in section1.tex look like this:

\startcomponent section1
\project book
\product chapter0/chapter0
\usemodule[newmat]
\usemodule[fig-base]
\usefigurebase[figures/figlibSection1]
\section[section:numbers]{Number systems}

The beginning lines in section2,tex look like this:

\startcomponent section1
\project book
\product chapter0/chapter0
\usemodule[newmat]
\usemodule[fig-base]
\usefigurebase[figures/figlibSection1]
\section[section:numbers]{Number systems}

The files section1figs.tex and section2figs.tex contain Metapost code in

\startMPpage
...
\stopMPpage

pairs. The figure libraries figlibSection1.xml and figlibSection2.xml  
look like this:

?xml version='1.0'?
?context-directive job module fig-make ?
?context-directive job mode letter ?
figurelibrary language=en

description
organizationCollege of the Redwoods Mathematics Department/ 
organization
projectIntermediate Algebra Text/project
productChapter 0/product
commentFigures for Section 1/comment
/description

figure
filesection1figs-mpgraph.1/file
labelsec1onea/label
copyrightCollege of the Redwoods Mathematics Department/copyright
comment/comment
/figure

/figurelibrary

This figure library also contains other graphics such as screen  
captures of my graphing calculator.

It all seems to work. I have compiled individual sections, like  
section1.tex and I've compiled chapters, like chapter0.tex. I haven't  
tried to compile book.tex (too big), so I don't know if that works.

Hope this helps.

On May 10, 2006, at 7:38 AM, Hans Hagen wrote:

 Sanjoy Mahajan wrote:
 Is the idea to use \currentcomponentpath in the directory= 
 {...}?  I put


 indeed


 I've just tried the version below, but abc-1.eps cannot be found (I
 also tried \noexpand\currentcomponentpath):

 % file: chap/1/c_ch1.tex
 \startcomponent c_ch1
 \product onebook
 \project project_books
 \setupexternalfigures[directory={\currentcomponentpath}]
 % but, just as a sanity check, this way works:
 %  \setupexternalfigures[directory={chap/1}]
 \title{One}
 Hi
 \useexternalfigure[ff][abc-1.eps]
 \placefigure[here][ff]{Some caption}{\externalfigure[ff]}
 \stopcomponent

 so how is this component, when run on itself, supposed to locate  
 itself,

 - how does the dir structure look
 - where did you put the file
 - where did you run it

 (there is also the option to say: \usesubpath[1,2,3,4,5,6])

 Hans


 -
   Hans Hagen | PRAGMA ADE
   Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
  | www.pragma-pod.nl
 -

 ___
 ntg-context mailing list
 ntg-context@ntg.nl
 http://www.ntg.nl/mailman/listinfo/ntg-context

___

Re: [NTG-context] components and figure search paths

2006-05-10 Thread Sanjoy Mahajan
 And the beginning lines in section1.tex look like this:

 \startcomponent section1
 \project book
 \product chapter0/chapter0

Does it matter what you put after the \startcomponent?  I'm always
trying to figure out whether to use the full relative path or just the
last piece of it.

Would 
  \product chapter0
also work?  I'm pretty sure it would: I think the \product line is
ignored and only the \project file is read.  When I compile a
component that begins with

  \startcomponent c_ch1
  \product onebook
  \project project_books

I get:

  systems : begin file c_ch1 at line 1
  systems : begin file project_books at line 3
  (../../project_books.tex
  systems : begin file env_books at line 3
  (../../env_books.tex)
  systems : end file env_books at line 3
  )
  systems : end file project_books at line 3

 \usefigurebase[figures/figlibSection1]

Ah, that must be the equivalent of
\setupexternalfigures{directory=figures/figlibSection1}

 I haven't tried to compile book.tex (too big), so I don't know if
 that works.

It might work, though I remember reading on the list sometime that one
isn't supposed to compile the project file -- only the components or
the products.  Which brings me back to what I don't understand about
the project structuring (the purpose of the \product command).

-Sanjoy

`Never underestimate the evil of which men of power are capable.'
 --Bertrand Russell, _War Crimes in Vietnam_, chapter 1.
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] components and figure search paths

2006-05-10 Thread Aditya Mahajan
On Thu, 11 May 2006, Sanjoy Mahajan wrote:

 I haven't tried to compile book.tex (too big), so I don't know if
 that works.

 It might work, though I remember reading on the list sometime that one
 isn't supposed to compile the project file -- only the components or
 the products.

I had experienced that problem. If you compile a project, it compiles, 
but there are difference in page breaks for project and product. The 
product and component have the same page break. Hans had asked for an 
example to show the problem, and I could not get time to produce the 
problem in a small example. My example where the problem occurs was 
big. I will try again to come up with a minimal example.

 Which brings me back to what I don't understand about
 the project structuring (the purpose of the \product command).

Is there any functionality of \project that is not covered in 
\product?

Aditya

-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] components and figure search paths

2006-05-09 Thread Sanjoy Mahajan
Using components (e.g. book chapters), with each component in its own
directory, say I have

\startproduct onebook
\project manybooks
\component 1/chap
\component 2/chap
\stopproduct

with this 1/chap.tex:

\startcomponent 1/chap
\product onebook
\project manybooks
\title{One}
An essential chapter.
\useexternalfigure[ff][abc.1]
\placefigure[here][ff]{Some caption}{\externalfigure[ff]}
\stopcomponent

I'd like to keep the figures and source for a chapter together,
e.g. abc.mp and abc.1 in 1/chap/ since each chapter has many figures,
and I edit and test one chapter at a time.

That arrangement works fine if I build the component:
  cd 1  texexec chap.tex
but not if I build the product:
  texexec book.tex
(it doesn't find abc.1 since it's not in the same dir as book.tex)

The details.pdf manual says that figures are searched for in the local
path (current directory) and the global one, with the global one set by
the directory keyword:

\setupexternalfigures[directory={c:/fig/eps,c:/fig/pdf}]

Is there a way to specify current directory relative to this
component, or a way to add that setting to the default 'local' path
(even before '.')?

I could add it manually in the preamble of the 1/chap.tex but it would
mean hardwiring the pathname into it, which seems hacky. E.g. it fails
if I export the whole source tree to /tmp/tmp.2773ab/ to test rebuilding
all the pdf's from scratch.

-Sanjoy
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context