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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

How can I syntax-highlight non-inlined code?

One of the delights of using org-mode to edit LaTeX documents is the ability to see figures inline, as I am editing the buffer. By runnning (org-toggle-inline-images) , bound by default to C-cC-xC-v, ...
  • 385
2 votes
1 answer
38 views

noweave not respecting indentation

In the past, I have often used noweb for Python projects, but this time I get strange behavior: indentation is not respected in the weaved file. Here is a minimal example, using noweb 2 (version ...
  • 1,900
0 votes
1 answer
47 views

How to "\DoNotIndex" an environment?

I'm writing a dtx file for a class I created. I'm using \EnableCrossrefs, but I have the minted environment indexed. \DoNotIndex{minted} does not work. How do I tell makeindex to not index a specific ...
  • 3
1 vote
1 answer
178 views

Draw points in tikz with foreach

I have the following code: \documentclass{standalone} \usepackage[portuguese, shorthands=off]{babel} \usepackage[utf8]{inputenc} \usepackage{tikz} \usepackage{xfp} \usepackage{pgfplots} \usepackage{...
6 votes
2 answers
732 views

Equational Reasoning for Functional Programming

How can I create equational reasoning proof like the ones in CS literatures: A + (B + C) = { Associativity } (A + B) + C = { Commutativity } (B + A) + C I can't seem to find the right ...
0 votes
0 answers
31 views

Iterate over comma separated values and optional argument [duplicate]

I would like to adapt this answer of another post for one optional argument but my MWE is just a M(not)WE. \documentclass{article} \usepackage{xparse} \newcommand\test[2]{#1+#2\par} \ExplSyntaxOn ...
  • 12.7k
0 votes
1 answer
267 views

Using */ and /** as code block fences with the markdown package

I have written a program in a style close to literate programming. The program source code contains large chunks of Markdown blocks in block comments like this. /** ## Entities, state variables, and ...
  • 440
3 votes
0 answers
108 views

Is the DOC version of PTEX available anywhere?

At the beginning of TeX: The Program we find that Preliminary plans to convert the SAIL code into a form somewhat like the present "web" were developed by Luis Trabb-Pardo and the author at the ...
  • 950
7 votes
2 answers
198 views

Is there a `for each` loop in primitive (La)TeX? [duplicate]

I am trying to iterate over the list of all basic colours: \def\thecolors{black, blue, brown, cyan, darkgray, gray, green, lightgray, lime, magenta, olive, orange, pink, purple, red, teal, violet, ...
  • 711
4 votes
0 answers
149 views

Is there a specialized literate programming web-file editor that supports navigating in a Knuth's web file e.g. "tex.web"?

What do I mean by that? displaying starred and unstarred sections of cursor position displaying title of starred section displaying See also sections if exists displaying This code is used in ...
1 vote
3 answers
87 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
1 answer
230 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 ...
  • 177
2 votes
1 answer
277 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 (https://www.cs.tufts.edu/~nr/noweb/) under Windows. I'd like to pretty-print the resulting code, for which ...
2 votes
1 answer
127 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
1 answer
74 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 ...
  • 221
1 vote
1 answer
735 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?
  • 451
2 votes
0 answers
780 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'...
6 votes
0 answers
652 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 ...
  • 275
0 votes
2 answers
257 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 ...
  • 21
1 vote
1 answer
209 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 ...
  • 711
0 votes
1 answer
172 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 ...
  • 187
8 votes
2 answers
267 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 ...
30 votes
4 answers
3k 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 ...
user avatar
4 votes
1 answer
602 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 ...
  • 3,960
2 votes
1 answer
90 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,...
11 votes
1 answer
20k 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
1 answer
1k 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
2 answers
325 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
2 answers
496 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[...
  • 579
3 votes
1 answer
712 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(): """...
  • 27.1k
11 votes
1 answer
2k 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 ...
  • 2,511
15 votes
1 answer
579 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
2 answers
313 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 ...
  • 7,312
4 votes
1 answer
1k 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 \...
  • 43
13 votes
3 answers
1k 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 ...
  • 6,016
12 votes
3 answers
565 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,016
6 votes
0 answers
154 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". ...
  • 2,432
3 votes
4 answers
475 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 ...
  • 3,659
1 vote
2 answers
542 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{...
  • 11
39 votes
3 answers
6k 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 ...
23 votes
5 answers
3k 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 ...
  • 35.3k
10 votes
1 answer
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, ...
13 votes
1 answer
508 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 ...
7 votes
0 answers
921 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
1 answer
703 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
2 answers
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 ...
15 votes
5 answers
9k 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 ...
  • 11.9k
3 votes
1 answer
3k 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' ...