ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Search path for .tex files (mkiv)
@ 2012-10-30 14:31 John Devereux
  2012-10-30 14:59 ` Wolfgang Schuster
  2012-10-30 15:05 ` Marco Patzer
  0 siblings, 2 replies; 9+ messages in thread
From: John Devereux @ 2012-10-30 14:31 UTC (permalink / raw)
  To: ntg-context


Hi,

What is the correct way to set or modify the search path for tex files?

I want to make it mode-dependent. For example, for figures I have
something like

\doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
\doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}

[...]

\setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]


I want to be able to do for example

\input disclaimer

And have it use the correct version. (There are more complicated
scenarios too).

In case there is a better way to do it, what I want is to have language-
or mode- specific versions of some "boilerplate" texts. These would be
in individual files. Documents elsewhere in a directory tree could
reference these using a standard name and it would be picked according
to the set language/mode.

Thanks,

John

-- 

John Devereux
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 14:31 Search path for .tex files (mkiv) John Devereux
@ 2012-10-30 14:59 ` Wolfgang Schuster
  2012-10-30 16:12   ` John Devereux
  2012-10-30 15:05 ` Marco Patzer
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2012-10-30 14:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 30.10.2012 um 15:31 schrieb John Devereux <john@devereux.me.uk>:

> 
> Hi,
> 
> What is the correct way to set or modify the search path for tex files?
> 
> I want to make it mode-dependent. For example, for figures I have
> something like
> 
> \doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
> \doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}
> 
> [...]
> 
> \setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]


Figures:

\startmodeset
  [en]     {\setupexternalfigures[directory={fig,fig/lang_en}]}
  [de]     {\setupexternalfigures[directory={fig,fig/lang_de}]}
  [default]{\setupexternalfigures[directory={fig}]}
\stopmodeset


Language:

\startmodeset
  [en]{\mainlanguage[en]}
  [de]{\mainlanguage[de]}
\stopmodeset


Suffix:

\define\DocumentSuffix
  {\doifmodeelse{en}{EN}{\doifmode{de}{DE}}}

or

\startmodeset
  [en]     {\defineexpandable\DocumentSuffix{EN}}
  [de]     {\defineexpandable\DocumentSuffix{DE}}
  [default]{\defineexpandable\DocumentSuffix{EN}}
\stopmodeset

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 14:31 Search path for .tex files (mkiv) John Devereux
  2012-10-30 14:59 ` Wolfgang Schuster
@ 2012-10-30 15:05 ` Marco Patzer
  2012-10-30 16:24   ` John Devereux
  1 sibling, 1 reply; 9+ messages in thread
From: Marco Patzer @ 2012-10-30 15:05 UTC (permalink / raw)
  To: ntg-context

2012-10-30 John Devereux:

> What is the correct way to set or modify the search path for tex files?
> 
> I want to make it mode-dependent. For example, for figures I have
> something like
> 
> \doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
> \doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}
> 
> [...]
> 
> \setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]
> 
> 
> I want to be able to do for example
> 
> \input disclaimer

You can either trigger on the language or on the mode. The directory
structure looks like this

    text/en/alpha.tex
    text/en/beta.tex
    text/de/alpha.tex
    text/de/beta.tex
    images/en
    images/de

You can create the individual files as components and create a
product file:

    \startproduct *

      \mainlanguage [de]
      \project [project]

      \component [a]
      \component [b]

    \stopproduct

and a project file:

    \startproject *

      \startmode [*en]
      \usepath
        [text/en]
      \setupexternalfigures
        [directory={images/en}]
      \stopmode

      \startmode [*de]
      \usepath
        [text/de]
      \setupexternalfigures
        [directory={images/de}]
      \stopmode

    \stopproject

To trigger by language, you use *en, *de, etc. To trigger by mode,
you use the mode name, in that case you can move the \mainlanguage
call to the corresponding language setup.


Marco

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 14:59 ` Wolfgang Schuster
@ 2012-10-30 16:12   ` John Devereux
  2012-10-30 16:20     ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: John Devereux @ 2012-10-30 16:12 UTC (permalink / raw)
  To: ntg-context

Wolfgang Schuster <wolfgang.schuster@gmail.com> writes:

> Am 30.10.2012 um 15:31 schrieb John Devereux <john@devereux.me.uk>:
>
>> 
>> Hi,
>> 
>> What is the correct way to set or modify the search path for tex files?
>> 
>> I want to make it mode-dependent. For example, for figures I have
>> something like
>> 
>> \doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
>> \doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}
>> 
>> [...]
>> 
>> \setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]
>
>
> Figures:
>
> \startmodeset
>   [en]     {\setupexternalfigures[directory={fig,fig/lang_en}]}
>   [de]     {\setupexternalfigures[directory={fig,fig/lang_de}]}
>   [default]{\setupexternalfigures[directory={fig}]}
> \stopmodeset
>
>
> Language:
>
> \startmodeset
>   [en]{\mainlanguage[en]}
>   [de]{\mainlanguage[de]}
> \stopmodeset
>
>
> Suffix:
>
> \define\DocumentSuffix
>   {\doifmodeelse{en}{EN}{\doifmode{de}{DE}}}
>
> or
>
> \startmodeset
>   [en]     {\defineexpandable\DocumentSuffix{EN}}
>   [de]     {\defineexpandable\DocumentSuffix{DE}}
>   [default]{\defineexpandable\DocumentSuffix{EN}}
> \stopmodeset

Thank you Wolfgang, these "modesets" are neat. But it was primarily the
.tex file search path I was interested in, I have figures working
already, although your way is nicer.

Is there something like \setuptexfilesdirectory?

-- 

John Devereux
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 16:12   ` John Devereux
@ 2012-10-30 16:20     ` Wolfgang Schuster
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2012-10-30 16:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 30.10.2012 um 17:12 schrieb John Devereux <john@devereux.me.uk>:

> Thank you Wolfgang, these "modesets" are neat. But it was primarily the
> .tex file search path I was interested in, I have figures working
> already, although your way is nicer.
> 
> Is there something like \setuptexfilesdirectory?

You can set search directories with the \usepath ind \usesubpath commands, e.g.

\usepath[de] searches components in the “de” directory

\usesubpath[one,two,three] search components in the “one”, “two” and “three” subdirectories of the “de” etc. directories

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 15:05 ` Marco Patzer
@ 2012-10-30 16:24   ` John Devereux
  2012-10-30 16:35     ` Wolfgang Schuster
  2012-10-30 16:38     ` Marco Patzer
  0 siblings, 2 replies; 9+ messages in thread
From: John Devereux @ 2012-10-30 16:24 UTC (permalink / raw)
  To: ntg-context

Marco Patzer <homerow@lavabit.com> writes:

> 2012-10-30 John Devereux:
>
>> What is the correct way to set or modify the search path for tex files?
>> 
>> I want to make it mode-dependent. For example, for figures I have
>> something like
>> 
>> \doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
>> \doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}
>> 
>> [...]
>> 
>> \setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]
>> 
>> 
>> I want to be able to do for example
>> 
>> \input disclaimer
>
> You can either trigger on the language or on the mode. The directory
> structure looks like this
>
>     text/en/alpha.tex
>     text/en/beta.tex
>     text/de/alpha.tex
>     text/de/beta.tex
>     images/en
>     images/de
>
> You can create the individual files as components and create a
> product file:
>
>     \startproduct *
>
>       \mainlanguage [de]
>       \project [project]
>
>       \component [a]
>       \component [b]
>
>     \stopproduct
>
> and a project file:
>
>     \startproject *
>
>       \startmode [*en]
>       \usepath
>         [text/en]
>       \setupexternalfigures
>         [directory={images/en}]
>       \stopmode
>
>       \startmode [*de]
>       \usepath
>         [text/de]
>       \setupexternalfigures
>         [directory={images/de}]
>       \stopmode
>
>     \stopproject
>
> To trigger by language, you use *en, *de, etc. To trigger by mode,
> you use the mode name, in that case you can move the \mainlanguage
> call to the corresponding language setup.
>
>
> Marco

Hello Marco,

It looks like \usepath is the key to what I want, thank you. I don't
quite understand your overall structure. Is the "*" a literal "*" with
some special meaning, or are you using it as a placeholder for
something? Sorry if I am being dense.

I am not using the project/product/component system, perhaps I should
look into it again.

Hmmm, alpha.tex defines component "a", beta.tex defines "b", is that
right?


-- 

John Devereux
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 16:24   ` John Devereux
@ 2012-10-30 16:35     ` Wolfgang Schuster
  2012-10-30 16:38     ` Marco Patzer
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2012-10-30 16:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 30.10.2012 um 17:24 schrieb John Devereux <john@devereux.me.uk>:

> Marco Patzer <homerow@lavabit.com> writes:
> 
>> 2012-10-30 John Devereux:
>> 
>>> What is the correct way to set or modify the search path for tex files?
>>> 
>>> I want to make it mode-dependent. For example, for figures I have
>>> something like
>>> 
>>> \doifmode{en} {\def\FigDirLanguage{fig/lang_en}\def\DocumentSuffix{EN}\mainlanguage[en]}
>>> \doifmode{de} {\def\FigDirLanguage{fig/lang_de}\def\DocumentSuffix{DE}\mainlanguage[de]}
>>> 
>>> [...]
>>> 
>>> \setupexternalfigures[directory={fig,{\FigDirLanguage},{../fig},{../\FigDirLanguage}}]
>>> 
>>> 
>>> I want to be able to do for example
>>> 
>>> \input disclaimer
>> 
>> You can either trigger on the language or on the mode. The directory
>> structure looks like this
>> 
>>    text/en/alpha.tex
>>    text/en/beta.tex
>>    text/de/alpha.tex
>>    text/de/beta.tex
>>    images/en
>>    images/de
>> 
>> You can create the individual files as components and create a
>> product file:
>> 
>>    \startproduct *
>> 
>>      \mainlanguage [de]
>>      \project [project]
>> 
>>      \component [a]
>>      \component [b]
>> 
>>    \stopproduct
>> 
>> and a project file:
>> 
>>    \startproject *
>> 
>>      \startmode [*en]
>>      \usepath
>>        [text/en]
>>      \setupexternalfigures
>>        [directory={images/en}]
>>      \stopmode
>> 
>>      \startmode [*de]
>>      \usepath
>>        [text/de]
>>      \setupexternalfigures
>>        [directory={images/de}]
>>      \stopmode
>> 
>>    \stopproject
>> 
>> To trigger by language, you use *en, *de, etc. To trigger by mode,
>> you use the mode name, in that case you can move the \mainlanguage
>> call to the corresponding language setup.
>> 
>> 
>> Marco
> 
> Hello Marco,
> 
> It looks like \usepath is the key to what I want, thank you. I don't
> quite understand your overall structure. Is the "*" a literal "*" with
> some special meaning, or are you using it as a placeholder for
> something? Sorry if I am being dense.
> 
> I am not using the project/product/component system, perhaps I should
> look into it again.

When you write a component file (assume it name is alpha.tex) you would begin the file with

  \startcomponent alpha

where \startcomponent takes the name of the current file as argument, the name of
the file is tired in the command \currentcomponent. In MkIV you can replace the name
with “*” and context would still print the correct name with \currentcomponent.


The asterisk in modes indicates that you use a system mode which created by system,
i.e. when you put \mainlanguage[en] in your document context enables the mode “*en”.

The opposite of this are user modes which are enable by the user itself with \enablemode[…].

> Hmmm, alpha.tex defines component "a", beta.tex defines "b", is that right?

No, that should be a typo because the command takes the name of the file as argument like \input but it doesn’t stop the processing when the file isn’t available.

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 16:24   ` John Devereux
  2012-10-30 16:35     ` Wolfgang Schuster
@ 2012-10-30 16:38     ` Marco Patzer
  2012-10-30 17:53       ` John Devereux
  1 sibling, 1 reply; 9+ messages in thread
From: Marco Patzer @ 2012-10-30 16:38 UTC (permalink / raw)
  To: ntg-context

2012-10-30 John Devereux:

> It looks like \usepath is the key to what I want, thank you.

Yes, combine \usepath with the \startmodeset syntax that Wolfgang
suggested and you should have a clean solution.

> I don't quite understand your overall structure.

You're right. Without file names it's hard to follow, especially
with the mistake I made.

> Is the "*" a literal "*" with some special meaning, or are you
> using it as a placeholder for something?

It is a literal `*`. That means that the file name will be used as a
component (or product) name.

> I am not using the project/product/component system, perhaps I should
> look into it again.
> 
> Hmmm, alpha.tex defines component "a", beta.tex defines "b", is that
> right?

No, that's my fault. Of course they have to match.


Marco

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Search path for .tex files (mkiv)
  2012-10-30 16:38     ` Marco Patzer
@ 2012-10-30 17:53       ` John Devereux
  0 siblings, 0 replies; 9+ messages in thread
From: John Devereux @ 2012-10-30 17:53 UTC (permalink / raw)
  To: ntg-context

Marco Patzer <homerow@lavabit.com> writes:

> 2012-10-30 John Devereux:
>
>> It looks like \usepath is the key to what I want, thank you.
>
> Yes, combine \usepath with the \startmodeset syntax that Wolfgang
> suggested and you should have a clean solution.
>
>> I don't quite understand your overall structure.
>
> You're right. Without file names it's hard to follow, especially
> with the mistake I made.
>
>> Is the "*" a literal "*" with some special meaning, or are you
>> using it as a placeholder for something?
>
> It is a literal `*`. That means that the file name will be used as a
> component (or product) name.
>
>> I am not using the project/product/component system, perhaps I should
>> look into it again.
>> 
>> Hmmm, alpha.tex defines component "a", beta.tex defines "b", is that
>> right?
>
> No, that's my fault. Of course they have to match.

Excellent, thanks to you and Wolfgang.


-- 

John Devereux
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2012-10-30 17:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-30 14:31 Search path for .tex files (mkiv) John Devereux
2012-10-30 14:59 ` Wolfgang Schuster
2012-10-30 16:12   ` John Devereux
2012-10-30 16:20     ` Wolfgang Schuster
2012-10-30 15:05 ` Marco Patzer
2012-10-30 16:24   ` John Devereux
2012-10-30 16:35     ` Wolfgang Schuster
2012-10-30 16:38     ` Marco Patzer
2012-10-30 17:53       ` John Devereux

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