[NTG-context] documents inside documents

Aditya Mahajan adityam at umich.edu
Wed Jun 26 19:56:04 CEST 2013


On Tue, 25 Jun 2013, Pablo Rodríguez wrote:

> Dear list,
>
> I need for a document explaining some ConTeXt features, to be able to
> include a document inside (a page that includes the feature).
>
> I know I can create another document and then insert the pages, but it
> would be much easier for me to be able to have the code inside the main
> the document.
>
> Is there a standard way to do it with ConTeXt?

Another option is to use the filter module (it takes care of caching and 
naming of temporary files, and you can specify an output directory for 
all auxillary files)

https://github.com/adityam/filter

\usemodule[filter]

\traceexternalfilters

\defineexternalfilter
   [CONTEXT]
   [
     output=\externalfilterbasefile.pdf,
     filter={context --batch --result=\externalfilteroutputfile \space},
     readcommand=\ShowPDF,
     cache=yes,
     bufferbefore={context:before},
     bufferafter={context:after},
   ]

\define[1]\ShowPDF
     {\midaligned{\externalfigure[#1][frame=on]}}

\startbuffer[context:before]
   \mainlanguage[en]
   \setuplanguage[en][patterns={en,agr}]
   \definepapersize[mine][width=6in,height=2in]
   \setuppapersize[mine]
   \usemodule[simplefonts]
   \setmainfont[Dejavu]
   \definelinenote[contxt]
   \setupnote[contxt][paragraph=yes, inbetween=\hskip1.5em]
   \setupnotation[contxt][numbercommand=,alternative=serried,distance=1em,compress=yes,compressseparator=]

   \starttext
\stopbuffer

\startbuffer[context:after]
   \stoptext
\stopbuffer

\starttext

\startCONTEXT
\startlinenumbering
οὐκ οἶσθ᾽\contxt{οἶσθ᾽: οἶσθα, 2nd sg.,
οἶσδα} ὅτι πολλῶν ἐτῶν\contxt{πολλῶν
ἐτῶν: for…; gen. time within} Ἀγάθων ἐνθάδε
οὐκ ἐπιδεδήμηκεν\contxt{ἐπιδεδήμηκεν: pf.
ἐπιδήμέω}, ἀφ᾽ οὗ\contxt{ἀφ᾽ οὗ: since;
“from which (time)”} δ᾽ ἐγὼ Σωκράτει
συνδιατρίβω\contxt{συνδιατρίβω: I have been
spending; pres. but pf. progressive in translation} καὶ
ἐπιμελὲς πεποίημαι\contxt{ἐπιμελὲς
πεποίημαι: I have made it my business; “have made it my
care,” pf.}
\stoplinenumbering
\stopCONTEXT

\stoptext


More information about the ntg-context mailing list