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
19 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 ...
user avatar
1 vote
1 answer
76 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{...
user avatar
6 votes
2 answers
670 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 ...
user avatar
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 ...
user avatar
  • 11.4k
0 votes
1 answer
201 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 ...
user avatar
  • 440
3 votes
0 answers
101 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 ...
user avatar
  • 950
7 votes
2 answers
156 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, ...
user avatar
  • 701
4 votes
0 answers
139 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 ...
user avatar
1 vote
3 answers
68 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 ...
user avatar
0 votes
1 answer
189 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 ...
user avatar
  • 155
1 vote
0 answers
205 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 ...
user avatar
2 votes
1 answer
111 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{\...
user avatar
2 votes
1 answer
66 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 ...
user avatar
  • 211
1 vote
1 answer
649 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?
user avatar
  • 431
2 votes
0 answers
738 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'...
user avatar
6 votes
0 answers
565 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 ...
user avatar
  • 275
0 votes
2 answers
180 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 ...
user avatar
  • 21
1 vote
1 answer
185 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 ...
user avatar
  • 651
0 votes
1 answer
164 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 ...
user avatar
  • 163
8 votes
2 answers
256 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 ...
user avatar
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
541 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 ...
user avatar
  • 3,930
2 votes
1 answer
79 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,...
user avatar
11 votes
1 answer
18k 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 ...
user avatar
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 ...
user avatar
2 votes
2 answers
306 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 ...
user avatar
3 votes
2 answers
471 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[...
user avatar
  • 559
3 votes
1 answer
663 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(): """...
user avatar
  • 26.7k
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 ...
user avatar
  • 2,481
15 votes
1 answer
568 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 ...
user avatar
9 votes
2 answers
290 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 ...
user avatar
  • 7,242
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 \...
user avatar
  • 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 ...
user avatar
  • 5,876
12 votes
3 answers
530 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 ...
user avatar
  • 5,876
6 votes
0 answers
153 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". ...
user avatar
  • 2,352
3 votes
4 answers
453 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 ...
user avatar
  • 3,569
1 vote
2 answers
526 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{...
user avatar
  • 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 ...
user avatar
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 ...
user avatar
  • 34.4k
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, ...
user avatar
13 votes
1 answer
496 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 ...
user avatar
7 votes
0 answers
884 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 ...
user avatar
10 votes
1 answer
697 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, ...
user avatar
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 ...
user avatar
14 votes
3 answers
8k 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 ...
user avatar
  • 11.5k
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' ...
user avatar