Literate programming keeps code and its (extensive) documentation in a single source file. The documentation is typically typeset with TeX or LaTeX. Tools are used to extract the code (for compilations) and the documentation (for processing with (La)TeX) from the source file.

learn more… | top users | synonyms

35
votes
3answers
2k views

Different approach to literate programming for LaTeX

I have spent a couple of hours rethinking the literate style tools we have for LaTeX, which are essentially doc, docstrip and ltxdoc. Although the traditional workflow with a good editor can be less ...
17
votes
5answers
872 views

How to do literate programming in TeX?

How can I do literate programming in TeX where TeX, or some variant, is both the used programming language and what is used for typesetting the document? Is there more than one way to do it or ...
14
votes
1answer
389 views

Can I cross-reference computer code with LaTeX documentation?

I am updating documentation for a simulation model. Each parameter and equation is represented in different ways when found in the source code, primary references, and existing documentation. (these ...
11
votes
3answers
3k views

How to typeset Haskell ++ operator and friends?

Usually, the list concatenation operator in Haskell is printed as overlapping double plus signs in books. (In ASCII it is just ++) How can I typeset this sign in Haskell (in and perhaps outside of ...
10
votes
3answers
213 views

What does the “driver” section do in a .dtx file?

I've read the docstrip documentation, but have yet to form an intuition about how package documentation is extracted when I simply run pdflatex package.dtx. Let's say I'm using the simple dtxtut ...
10
votes
3answers
355 views

(How) Can I write a .dtx file without having to comment out *everything*?

I have a reasonable understanding now of how .dtx files work. But it's a great pain having to put a % character before every line of documentation. Also, depending on which editor you're using, it ...
10
votes
1answer
606 views

Polyglossia doesn't work with the ltxdoc document class

I have a package that uses the ltxdoc document class and the docstrip program for code and documentation generation. The package deals with some multilingual stuff and needs XeTeX (to be precise, ...
9
votes
1answer
300 views

Using doc/docstrip with other computer languages

The docstrip package mentions that it can be used to strip files of computer languages other than (La)TeX. I am looking to find a way to document other languages, for example JavaScript in a literate ...
8
votes
2answers
121 views

How to “\DoNotIndex \,” in a dtx file?

I'm using \EnableCrossrefs in a dtx file. In the index I now have \, indexed. I tried \DoNotIndex{{\,}} and \DoNotIndex{\thinspace} without success. Is there a way to prevent the inclusion of \, in ...
8
votes
1answer
724 views

How to create step by step annotated programming tutorial in LaTeX?

(question inspired by How to create a crossword puzzle in LaTeX? and provided solutions) How to make in most comfortable way in LaTeX (I use pdfLaTeX, but I am open for LuaTeX solutions) annotated, ...
8
votes
1answer
362 views

Different colors for default and language-specific listings

I'm generating pdf documents using knitr and pandoc. The conversion is mostly automated from R markdown -> markdown -> latex -> pdf. However, my documents combine R source code and its output, and I ...
6
votes
2answers
2k views

How to display filenames with underscores.

The following latex code uses fancyvrb VerbatimOut and VerbatimInput environment to write out and display code. The idea is to maintain only a latex file which contains code and documentation and ...
5
votes
1answer
119 views

Not colored digits after characters in lstlisting code

I am writing a LaTeX document with Verilog code and I would like to have colored digits in these occasions: simple digits (for example # 30) bus (for example [3:0]) binary or hex representation ...
5
votes
0answers
103 views

Capacity of ctangle exceeded [closed]

I'm interested in looking at (and maybe modifying) the code in MetaFont/MetaPost. To generate their C code, I applied ctangle to mp.w, and got an error message saying "token capacity exceeded". ...
4
votes
4answers
310 views

Iterate through list to generate references

I would like to create a new command, in which I pass a comma-separated list, which then will be iterated to create refs. Example: \iteratecommand{ref1, ref2, ref3} And within the iteratecommand ...
4
votes
0answers
530 views

Syntax highlighting blocks of code with LaTeX and literate programming tools [closed]

Using packages like minted (thanks to Pygments), LaTeX can generate beautifully highlighted/colored source code. Literate programming tools such as noweb and cweb can generate beautifully typeset and ...
3
votes
2answers
186 views

How can I loop thru a list of inputs that come after \maketitle, yet use that list as part of the \maketitle command?

Multilingual Document Question I would like to follow the principle of "don't repeat yourself" and create a single list of inputs, which are actually various versions of the same document in ...
3
votes
2answers
103 views

Indentation with lhs2TeX

I'm writing a literate Haskell paper, and I'm using lhs2TeX to help make it look pretty. However, lhs2TeX seems to mess up my indentation. I have some source that looks like this: ...
3
votes
1answer
77 views

Listings: syntax for literate

In the documentation for the listings package it says: literate = [*]<replacement item>. . .<replacement item> First note that there are no commas between the items. Each item ...
3
votes
1answer
368 views

Is there a PythonTex equivalent to \Sexpr{} in R?

I started to use the excellent PythonTex package to write reproducible reports but can't seem to get it to evaluate Python code inside a LaTeX command. R has Sweave & knitr which provide the ...
3
votes
1answer
1k views

Using Sweave, how can I reliably get .PNG figures instead of .EPS or .PDF figures?

I have tried to set the options in the preamble: \SweaveOpts{keep.source=TRUE, eps=FALSE, pdf=FALSE, png=TRUE} but this does not reliably produce only .png (or indeed any!) figures. I say 'reliably' ...
3
votes
1answer
148 views

Escape comment syntax in strings with listings

Consider the following: \documentclass{standalone} \usepackage{listings} \lstset{ language=Python, morecomment=[s]{<<}{>>}, } \begin{document} \begin{lstlisting} def expand(): ...
2
votes
1answer
25 views

How to make a document compile into two different orders of its parts?

I want to set up a diary that compiles in two different orders: One is work by day, the other is work by project according to tags I give to the particular chunks of work I did each day. For ...
1
vote
2answers
279 views

Changing font size of code in lhs2tex

I am a LaTeX / Haskell newbie and this question involves lhs2tex. Please let me know if I am posting on the wrong forum. I am writing a report in which I have fragments like: \begin{figure} ...
1
vote
0answers
111 views

writing comment in c++ with latex [closed]

I write my comments in c++ with latex, but i don't want the delimiter be appeared when converting to pdf. here is one of them: /*{\ {\color{blue}\subsection{Class Link} \verb|Link| is a \verb|Link| ...