Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:Exporting   [Contents][Index]


13.4 Include Files

During export, you can include the content of another file. Forexample, to include your ‘.emacs’ file, you could use:

#+INCLUDE: "~/.emacs" src emacs-lisp

There are three positional arguments after the include keyword, they are:

  1. The file name, this is the sole mandatory argument. Org neitherchecks for correctness or validates the content in any way.
  2. The block name to wrap the file content in. When this is‘example’, ‘export’, or ‘src’ the content is escaped byorg-escape-code-in-string. Arbitrary block names may be given,however block names starting with ‘:’ must be quoted, i.e. ‘":name"’.
  3. The source code language to use for formatting the contents. This is relevantto both ‘export’ and ‘src’ block types.

If an included file is not specified as having any markup language,Org assumes it be in Org format and proceeds as usual with a fewexceptions. Org makes the footnote labels (seeCreating Footnotes)in the included file local to that file. The contents of the includedfile belong to the same structure—headline, item—containing the‘INCLUDE’ keyword. In particular, headlines within the file becomechildren of the current section. That behavior can be changed byproviding an additional keyword parameter, ‘:minlevel’. It shifts theheadlines in the included file to become the lowest level. Forexample, this syntax makes the included file a sibling of the currenttop-level headline:

#+INCLUDE: "~/my-book/chapter2.org" :minlevel 1

Inclusion of only portions of files are specified using rangesparameter with ‘:lines’ keyword. The line at the upper end of therange will not be included. The start and/or the end of the range maybe omitted to use the obvious defaults.

#+INCLUDE: "~/.emacs" :lines "5-10"Include lines 5 to 10, 10 excluded
#+INCLUDE: "~/.emacs" :lines "-10"Include lines 1 to 10, 10 excluded
#+INCLUDE: "~/.emacs" :lines "10-"Include lines from 10 to EOF

Inclusions may specify a file-link to extract an object matched byorg-link-search130 (seeSearch Options in File Links). Theranges for ‘:lines’ keyword are relative to the requested element.Therefore,

#+INCLUDE: "./paper.org::*conclusion" :lines "1-20"

includes the first 20 lines of the headline named ‘conclusion’.

To extract only the contents of the matched object, set‘:only-contents’ property to non-nil. This omits any planning linesor property drawers. For example, to include the body of the headingwith the custom ID ‘theory’, you can use

#+INCLUDE: "./paper.org::#theory" :only-contents t

The following command allows navigating to the included document:

C-c ' (org-edit-special)

Visit the included file at point.


Footnotes

(130)

Note thatorg-link-search-must-match-exact-headline islocally bound to non-nil. Therefore,org-link-search only matchesheadlines and named elements.


Next:Macro Replacement, Previous:Table of Contents, Up:Exporting   [Contents][Index]


[8]ページ先頭

©2009-2025 Movatter.jp