Hi Ikumi,

Thanks for replying.  Please see below.

On Sun, Mar 22, 2026 at 01:10 (+0900), Ikumi Keita wrote:

> Hi Jim,

>>>>>> Jim <[email protected]> writes:
>> Maybe someone can help me out, either by sharing some wisdom or pointing me
>> to the specific doc that explains this...

>> I am working on a ConTeXt project which has the following directory/file
>> structure:

>> ├── 00_FrontMatter
>> │   ├── a01_TitlePage.tex
>> │   └── a02_Preface.tex
>> ├── 01_BodyMatter
>> │   ├── b01_Introduction.tex
>> │   ├── ...
>> │   ├── b13_Floats.tex
>> ├── 02_Appendices
>> │   ├── Installation.tex
>> │   ├── Macros.tex
>> │   └── Symbols.tex
>> ├── introCTX.tex
>> └── introCTX_env.tex

>> To compile the whole thing, I would use
>>         context introCTX.tex
>> in the top-level directory.

>> The introCTX_env.tex file contains what ConTeXt calls the "environment"
>> (which might be what LaTeX people would call the "preamble", but I'm not
>> sure about that).

>> All of the chapter files \input the introCTX_env.tex file (in ConTeXt
>> second and subsequent inclusions of environment files have no effect).

>> The .tex files in the sub-directories all have

>> %%% Local Variables:
>> %%% mode: ConTeXt
>> %%% TeX-master: "../introCTX.tex"
>> %%% coding: utf-8-unix
>> %%% End:

>> With this setup, while editing (e.g.,) b13_Floats.tex, if I C-c C-c, it
>> runs context on introCTX.tex, compiling the whole book.  This takes a bit
>> longer than I would like.  So I would like to compile either a region or
>> the single chapter I am working on at the time.

>> If I try to compile a region, it creates the _region_.tex file in the
>> top-level directory, at which point "../introCTX.tex" is wrong because it
>> runs context while cd'ed to the top-level directory and doesn't find that
>> file in the dir above the top-level directory.

> I'm not sure whether I understand what trouble you are having.

Sorry, please allow me to better explain.

When I am editing (e.g., .../b01_Introduction.tex) and run (for example)
        C-c C-b
the compile fails, because the chapter I am editing tells ConTeXt to process
        ../introCTX_env.tex
but since the _region_.tex file is in the top directory (and apparently
that is the working directory for the context process), ".." refers to the
directory above the top directory, which does not have a file
"introCTX_env.tex".

I am sorry I did not make that clear enough in my original message, when I
said
>>         All of the chapter files \input the introCTX_env.tex file
I should have made it clearer that they use "../introCTX_env.tex" to find
the environment file.

If I do remove the "../" from
        \environment ../introCTX_env.tex
then C-c C-b does work, because now _region_.tex will refer to a file in
the same directory, which is where introCTX_env.tex is found.

Removing the "../" has two issues (in my opinion):
(1) it is a work-around for AUCTeX and doesn't represent the actual
    file-system relationship of those files, and
(2) if I compile the entire document from the top level (via the command
    line), then the \environment commands are now not going to find the
    environment file.

> While it is true that _region_.tex is created in the top directory, the
> TeX-master specification "../introCTX.tex" in it is harmless because
> "context" command invoked by C-c C-r ignores the commented line.

It isn't harmless (in this case) because with TeX-master set to a file in
the parent directory, AUCTeX makes the compile happen in the wrong
(top-level) directory, from where "../introCTX_env.tex" doesn't exist.

If I set TeX-master to t, then the compile happens in the same directory
where the chapter is found, and in that case ../ is the correct relative
path to find introCTX_env.tex.

But if I don't set TeX-master as in the %%% line, then I can't compile the
whole document from the buffer where I am editing a chapter.  I assume (am
I correct?) the whole point of TeX-master is to allow me to compile the
whole document while editing one part of it.

>> Finally my question: aside from changing TeX-master, is there A Right
>> Way to do this?

> I expect that C-c C-r (or C-c C-b, C-c C-s etc.) works out of the box
> even in the buffer of the file in the sub directories.

Unfortunately, they don't work, because the compile is done in a directory
where ".." takes us to the wrong place when looking for the
introCTX_env.tex file.

> What am I missing?

Perhaps it is because I didn't emphasize sufficiently the specifics of the
\environment command.

Now that I have (hopefully!) made that clearer, do you see the issue?

And, if so, do you know how I should approach this?  In other words, what
is The Right Thing to do in cases like this.

Thanks very much.
                                Jim

Reply via email to