2

I would like to be able produce a source code listing within a box and line numbers applied - using ConTeXt.

The snippets below work - however the box does not break across pages and instead just runs over the bottom of the first page.

Is anyone able to please suggest some command to allow page breaks to occur or perhaps an alternative approach within ConTeXt?

http://wiki.contextgarden.net/Verbatim_text#Line_numbering

\defineframedtext
  [framedcode]
  [strut=yes,
   offset=2mm,
   width=7cm,
   align=right]

\definetyping[code][numbering=line,
                    bodyfont=small,
                    before={\startframedcode},
                    after={\stopframedcode}]

http://wiki.contextgarden.net/Command/typefile

%print the config file verbatim
\typefile[code]{source_code_file_over_many_pages.rb}

An example of the boxed text with line numbers shown below - which is the look I want - I just need it to break across pages in a nice way.

enter image description here

4

Use textbackground instead of framedtext. See Frame whole sections in ConTeXt for configuration details.

\definetextbackground
  [framedcode]
  [framecolor=black,
   background=,
   corner=round,
   location=paragraph]

\definetyping[code][numbering=line,
                    bodyfont=small,
                    before={\startframedcode},
                    after={\stopframedcode}]

\starttext

\typefile[code]{/usr/include/stdio.h}

\stoptext

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.