ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* components and figure search paths
@ 2006-05-10  2:46 Sanjoy Mahajan
  2006-05-10 11:25 ` Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: Sanjoy Mahajan @ 2006-05-10  2:46 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10  2:46 components and figure search paths Sanjoy Mahajan
@ 2006-05-10 11:25 ` Hans Hagen
  2006-05-10 12:56   ` Sanjoy Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2006-05-10 11:25 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 11:25 ` Hans Hagen
@ 2006-05-10 12:56   ` Sanjoy Mahajan
  2006-05-10 13:31     ` Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: Sanjoy Mahajan @ 2006-05-10 12:56 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1829 bytes --]

>From Hans:
> untested extension: \currentcomponentpath

Thanks!

Is the idea to use \currentcomponentpath in the directory={...}?  I put
those three \defs into core-job.tex and remade the formats (cont-en:
ver: 2006.04.17 23:14 fmt: 2006.5.10).  But I couldn't figure out quite
how to use it.  The abc-1.eps figure, referred to in the component and
living in its directory, isn't found automatically though maybe I need
to use \currentcomponentpath explicitly?

[Meanwhile I'm using a workaround that Mojca suggested offlist: by hand
put the relative component path in the directory={...}, which is mostly
fine as I don't change the relative directory structure as much as I
change the root.]

But back to \currentcomponentpath.  I put \show\currentcomponentpath in
the component chap/1/c_ch1.tex to see what was going on.  If I
understand right, your intention is that \currentcomponentpath would be
chap/1 inside chap/1/c_ch1.tex.  But it ends up as "..".  Here are the
relevant lines from the texexec log:

$ texexec onebook
systems         : begin file onebook at line 1
systems         : begin file project_books at line 2
(./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 2
systems         : begin file chap/1/c_ch1 at line 3
(./chap/1/c_ch1.tex
> \currentcomponentpath=macro:
->..
l.3 \show\currentcomponentpath
                              
? 
figures         : figure abc-1 can not be found
floatblocks     : 1 placed
)
systems         : end file chap/1/c_ch1 at line 3
[1.1]
systems         : end file onebook at line 4
 )

And here is a .tgz file with all of these files in this structure:

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


[-- Attachment #2: component example --]
[-- Type: application/x-gtar, Size: 728 bytes --]

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 12:56   ` Sanjoy Mahajan
@ 2006-05-10 13:31     ` Hans Hagen
  2006-05-10 14:17       ` Sanjoy Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2006-05-10 13:31 UTC (permalink / raw)


Sanjoy Mahajan wrote:
> >From Hans:
>   
>> untested extension: \currentcomponentpath
>>     
>
> Thanks!
>
> Is the idea to use \currentcomponentpath in the directory={...}?  I put
>   
indeed

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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 13:31     ` Hans Hagen
@ 2006-05-10 14:17       ` Sanjoy Mahajan
  2006-05-10 14:38         ` Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: Sanjoy Mahajan @ 2006-05-10 14:17 UTC (permalink / raw)


> > 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 14:17       ` Sanjoy Mahajan
@ 2006-05-10 14:38         ` Hans Hagen
  2006-05-10 15:09           ` Sanjoy Mahajan
  2006-05-10 15:13           ` David Arnold
  0 siblings, 2 replies; 10+ messages in thread
From: Hans Hagen @ 2006-05-10 14:38 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 14:38         ` Hans Hagen
@ 2006-05-10 15:09           ` Sanjoy Mahajan
  2006-05-10 15:13           ` David Arnold
  1 sibling, 0 replies; 10+ messages in thread
From: Sanjoy Mahajan @ 2006-05-10 15:09 UTC (permalink / raw)


> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 14:38         ` Hans Hagen
  2006-05-10 15:09           ` Sanjoy Mahajan
@ 2006-05-10 15:13           ` David Arnold
  2006-05-11  4:29             ` Sanjoy Mahajan
  1 sibling, 1 reply; 10+ messages in thread
From: David Arnold @ 2006-05-10 15:13 UTC (permalink / raw)


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>
<organization>College of the Redwoods Mathematics Department</ 
organization>
<project>Intermediate Algebra Text</project>
<product>Chapter 0</product>
<comment>Figures for Section 1</comment>
</description>

<figure>
<file>section1figs-mpgraph.1</file>
<label>sec1onea</label>
<copyright>College 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-10 15:13           ` David Arnold
@ 2006-05-11  4:29             ` Sanjoy Mahajan
  2006-05-11  5:21               ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Sanjoy Mahajan @ 2006-05-11  4:29 UTC (permalink / raw)


> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: components and figure search paths
  2006-05-11  4:29             ` Sanjoy Mahajan
@ 2006-05-11  5:21               ` Aditya Mahajan
  0 siblings, 0 replies; 10+ messages in thread
From: Aditya Mahajan @ 2006-05-11  5:21 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-05-11  5:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10  2:46 components and figure search paths Sanjoy Mahajan
2006-05-10 11:25 ` Hans Hagen
2006-05-10 12:56   ` Sanjoy Mahajan
2006-05-10 13:31     ` Hans Hagen
2006-05-10 14:17       ` Sanjoy Mahajan
2006-05-10 14:38         ` Hans Hagen
2006-05-10 15:09           ` Sanjoy Mahajan
2006-05-10 15:13           ` David Arnold
2006-05-11  4:29             ` Sanjoy Mahajan
2006-05-11  5:21               ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).