Hi Ikumi,

On Tue, Mar 24, 2026 at 01:22 (+0900), Ikumi Keita wrote:

>>>>>> Jim <[email protected]> writes:
>> So based on your comments, I discovered that having "../" is not needed,
>> either for compiling one file (with C-C C-b) or the entire document (with
>> C-c C-c).  It would appear that ConTeXt LMTX searches for the environment
>> file in ".." as well as ".".

>> Therefore if I remove the "../" from all the different chapters, it seems
>> my problem will nicely disappear.

> That's fine for both of us.

Yes, it provides a nice solution to my problem.

>> But I will add bit more information below, in case anyone reads this in the
>> future when trying to solve a similar problem.

> 😆

>> I can understand the logic for where _region_.tex is created (and compiled
>> from) in both cases:
> -> TeX-master = t                           _region_.tex in "."
> -> TeX-master = "../introCTX.tex"           _region_.tex in ".."
>> This is fine (I imagine) in most cases, but doesn't work so well for
>> documents that have chapters in a sub-directory with
>>         \environment ../file.tex

> Agreed. I don't think that is a fault of `TeX-master'. _region_.tex
> should be put there due to the nature of TeX itself.  The origin of the
> problem is localized to special behavior of \environment.

Or, maybe, how \environment was used in the document I am editing.

>> ConTeXt does have something analogous to a preamble, but it seems to be a
>> bit more complicated.  An ordinary one-file ConTeXt document looks like

>>         <preamble stuff>

>>         \starttext
>>         ... document body
>>         \stoptext

>> But it gets more complicated in multi-file documents, because the preamble
>> (which in this case is stored in the introCTX_env.tex file) can be "input"
>> in every separate file.  (I am guessing that is different than LaTeX.)

> I think so, too. I suppose that repeated appearance of the same preamble
> in one document would cause trouble in most cases for LaTeX document.

That is my assumption too.

>> Including the preamble from every file makes it convenient to compile each
>> chapter by itself, *without* needing an editor (or something else) to
>> extract the preamble from the master(?) file and put it at the beginning of
>> the _region_.tex file.

> Hmm, then ConTeXt is more flexible than LaTeX with respect to that
> aspect.  LaTeX needs "standalone" package to achieve similar behavior.

Another difference with ConTeXt is that you can include multiple
\environment commands.  So instead of having all of your customization in
one environment file, you could (for example) have environment files for
different things, like
-> a particular choice of typefaces
-> your own macro definitions
-> customizations for the way chapter and section heading are laid out
-> customizations for how the table of contents is done.

So at the beginning of a document you could pick and choose among your
various environment files to set up the look of a document the way you
want, without having to have one "preamble" for every possible combination.

So (as I understand it) this is a fair bit different than how LaTeX does
things.

>> Also, the chapters in the document I am editing start like this:
>>         \environment ../introCTX_env.tex

>>         \startcomponent b08_Lists.tex

>>         \startchapter
>>           [
>> reference=cap:toc,
>> title={Table of contents, indexes, lists},
>> bookmark={Table of contents, indexes, lists},
>>           ]
>> so "\startcomponent" can be used instead of "\starttext" to say "the
>> preamble is over, here comes the content".

>> And there is also \startTEXpage to start the document body.  And others.

> Maybe we should consider to add such delemiters to `TeX-header-end' in
> ConTeXt mode.

That is probably a good idea.  I took a very quick look at the code right
now, and while someone more familiar with the code base might see how to do
that immediately, for me it will be another research project. ;-)


                                Jim

Reply via email to