The introduction of the Linux subsystem for Windows has made it possible again to use noweb (https://www.cs.tufts.edu/~nr/noweb/) under Windows. I'd like to pretty-print the resulting code, for which arguably the listings package is the method of choice.

% -*- TeX:UK -*-
\usepackage[utf8]{inputenc}%suitable for most modern operating systems
\usepackage{babel,%foreign language support
            xcolor,%handle colours
            css-colors,%defines named web-safe colors
            listings,%typeset computer code
            noweb}%support for literate programming
        numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,
\author{Engelbert Buxbaum }
\abstract{Noweb is a simple to use system for literate programming. It 
is suitable for all programming languages, but has no
pretty-printing capabilities. Listings can pretty-print, but has no 
literate programming ability. A combination of both would be ideal. }
The example code is:
program HelloWorld;
  write('Hello, World');
Unfortunately, the output is not what was intended.

noweave -delay test.nw > test.tex produces the following LaTeX-code (critical piece only):

program HelloWorld;
  write('Hello, World');

iow, some code for noweb.sty ends up in the listings environment and is printed verbatim rather than executed. Putting the \begin{lstlisting} and \end{lstlisting} between the <<*>> and @ is of course no solution.

How can I do this? Thanks in advance.


  • Do you have any news for us? Is your issue solved? How?
    – Mensch
    Jun 23, 2019 at 19:27
  • No, unfortunately not. Currently, I maintain the docs and the source code separately, which of course is contrary to literate programming doctrine. Jun 25, 2019 at 14:47
  • Well, then you should perhaps explain what "noweb" is, never heared of it. Just explain your issue better ...
    – Mensch
    Jun 29, 2019 at 0:46
  • As I mentioned, noweb (cs.tufts.edu/~nr/noweb) is a tool for literate programming. Unlike Knuth's original web (and its successor cweb) it is language-independent as it has no pretty-printing ability. Literate programming means that the source code of a program and its docu are maintained in a single file, from which (no)weave extracts the docu and (no)tangle the source code. The idea behind that is that because code and docu are maintained in a single file, they are always updated together, and the docu always reflects the current state of the code. Jun 30, 2019 at 9:52


Your Answer

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

Browse other questions tagged or ask your own question.