Questions tagged [literate-programming]

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.

1
vote
3answers
50 views

modular macro list structure to iterate it

Based on the Wipet's answer, and with the same learning spirit, about the iterate loop "for", it's interesting to find out how the proposed "for loop" could be more modular. I want to pass, as an ...
0
votes
1answer
44 views

How do I change the font of code generated by lhs2TeX?

This Guide to lhs2TeX shows an example of customization of the poly style in 4.2 which is pretty much exactly what I want, but it does not actually show the way to achieve this. I am quite new LaTeX ...
1
vote
0answers
49 views

How to get noweb and listings to cooperate?

The introduction of the Linux subsystem for Windows has made it possible again to use noweb under Windows. I'd like to pretty-print the resulting code, for which arguably the listings package is the ...
1
vote
1answer
40 views

How to generate a Makefile from dtx // keeping the tab width

For a complete documentation I would like to maintain and explain the Makefile within my dtx-file. Two problems occur: docstrip always adds an extension to the generated file (\file{Makefile}{\from{\...
2
votes
1answer
45 views

Paragraph does not pagebreak after a code chunk when using noweb

I am using literate programming (more specifically noweb) for writing a tech report. But something seems to prevent paragraphs from breaking at the end of a page directly after code segments, which ...
1
vote
1answer
155 views

how to draw arrows in a literary text.

I would like to insert in a literary text some text like in the picture. To be honest, I have no any idea. Could you please me?
2
votes
0answers
480 views

Modern Literate Programming Tool? [closed]

Author's Note: I'd have posted this to the 'Software Recommendations' Stack Exchange if I'd seen any questions posted about literate-programming software when I did a cursory search there, but I didn'...
5
votes
0answers
433 views

Which language would Knuth use to (re-)write TeX today? [closed]

[ yes, this is "primarily opinion based;" VTC if you must ] In Literate Programming Knuth wrote: ... I chose PASCAL as the programming language ... ; it is not my favorite language for system ...
0
votes
2answers
81 views

Iterating over single string of elements

I currently want to implement a LaTeX program, which iterates over the output of a (in my case) perltex command. The output is a single string with iterables separated by commas. A full working ...
1
vote
1answer
101 views

Where can I find the plain TeX source file on my PC?

I've been looking around on my PC for the source file of plain TeX but without result. It's better to start with plain TeX and change its definitions, little by little, when you want to design your ...
0
votes
1answer
102 views

typesetting source code (Funnelweb)

Am using the Funnelweb literate programming tool, producing Tex output. In some code I have, I need to insert ASCII code 25 in the C source code. This works fine as far as producing the C code, but ...
8
votes
2answers
207 views

Typesetting literate programs: how to enable page breaking mid-paragraph, but not mid-code?

I'm writing a book that is a literate program. A literate program is divided into "chunks" or "sections," each of which has a documentation part and a code part. (It is also permissible, and in my ...
29
votes
4answers
2k views

Literate R Programming

I'd like to embed some R into a LaTeX document. After a bit of googling I found that Sweave and knitr allow you to do this. I compiled a simple example with Sweave and it works. I'd be much obliged ...
4
votes
1answer
272 views

Is there a way to have xesearch search and replace a term and have the replacement compiled as LaTeX command?

I have used the package xesearch https://www.ctan.org/pkg/xesearch?lang=en xesearch in my header to automatically replace shorthand notations: \usepackage{xesearch} \SearchList{list1}{Very Long ...
2
votes
1answer
65 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 example,...
8
votes
1answer
7k 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 ...
5
votes
1answer
978 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 (for ...
2
votes
2answers
250 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
319 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: \documentclass[...
3
votes
1answer
429 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(): """...
11
votes
1answer
1k 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 ...
15
votes
1answer
475 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 ...
9
votes
2answers
207 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 ...
3
votes
1answer
836 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 \...
13
votes
3answers
827 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 ...
11
votes
3answers
386 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 ...
6
votes
0answers
145 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". ...
3
votes
4answers
387 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 it ...
1
vote
2answers
468 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} \begin{...
36
votes
3answers
4k 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 ...
20
votes
5answers
2k 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 ...
10
votes
1answer
1k 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, ...
12
votes
1answer
403 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 ...
6
votes
0answers
800 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 ...
10
votes
1answer
671 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, ...
7
votes
2answers
3k 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 ...
12
votes
3answers
6k 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 ...
3
votes
1answer
2k 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' ...