GNU TeXmacsUser manualReferenceAboutEnglish
Multi-file documents: projects, inclusions and document parts

1.Introduction

Long documents such as books are rarely kept in a single file. TeXmacs offers three mechanisms for working with documents which consist of several pieces, and they are often used together:

Inclusions

The include tag inserts the body of another file into a document. The master file of a book typically consists of a preamble and one include per chapter.

Projects

A chapter file can be attached to a master file. When the chapter is edited on its own, it then uses the references, auxiliary data, chapter and page numbers of the master, so that cross references between chapters work.

Document parts

A single document can be split into parts (usually at its principal sections) of which only some are shown, and a document with inclusions can be opened as a part view tmfs://part/… in which the included files are expanded and can be edited in place.

This chapter describes how these mechanisms are implemented. It assumes familiarity with the buffer data (new_data_rep) and the prj field of buffers, described in buffers, with the reference and auxiliary tables of links, loci and references, and with the generation of automatic content in structured editing, search and automatic content.

2.Overview

The three mechanisms live at different levels:

The following picture summarizes the data flow for a book book.tm with a chapter ch1.tm:

book.tm  (master, project-flag = true)
  <include|ch1.tm>
    part-info:  label part:ch1.tm, write parts (chapter-nr, …)
    include*:   load_inclusion (ch1.tm), typeset as part of book.tm

ch1.tm   (project = "book.tm")
  buffer->prj   = buffer of book.tm (loaded in the background)
  labels        = own table first, then the table of book.tm
  init_update   : chapter-nr, page-first, … from book.tm

tmfs://part/…/book.tm   (part view)
  includes expanded into <shared|uid|ch1.tm|body>
  edits of body forwarded to the buffer ch1.tm when it is open

3.Source files

Paths are relative to

src/src/

for C++ files and to

src/TeXmacs/

for the others.

Texmacs/Data/new_project.cpp

Attaching a project to the current buffer, implicit projects, project_get.

Texmacs/Data/new_buffer.cpp

Loading the project buffer in set_buffer_tree; the inclusion cache (load_inclusion, reset_inclusions, reset_inclusion).

Edit/Editor/edit_typeset.cpp

Binding of the reference and auxiliary tables of the master (edit_typeset_rep constructor), init_update, clear_local_info.

Typeset/Env/env_exec.cpp
,
Typeset/Bridge/bridge_rewrite.cpp

Evaluation and typesetting of include*.

Typeset/Concat/concat_macro.cpp

Typesetting of the include primitive (typeset_include).

Data/Convert/Texmacs/fromtm.cpp

extract_document, which turns an included file into a body.

Texmacs/Server/tm_server.cpp

inclusions_gc.

packages/standard/std-automatic.ts

The macros include, part-info and shared.

packages/standard/std-fold.ts

The macros show-part, hide-part, show-preamble and hide-preamble.

progs/generic/document-part.scm

Preamble mode, in-buffer document parts, the list of inclusions, expanding inclusions, the Document\(\rightarrow\)Part and project management menus.

progs/generic/document-menu.scm

The Document\(\rightarrow\)Project menu and the update commands.

progs/part/part-tmfs.scm

The part handlers of the TeXmacs file system.

progs/part/part-shared.scm

Synchronization of shared and mirror tags with each other and with whole buffers.

progs/part/part-menu.scm

The menus which open the included files as part views.

4.Contents of this chapter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".