CTWILL(1)
CTWILL(1) π
okay bestie, we're in the General Commands Manual section of the manual, and today's main character is ctwill β plus its little crew: ctwill-proofsort, ctwill-refsort, and ctwill-twinx. Together they translate CWEB to TeX with mini-indexes. slay. β¨
β¨ NAME β¨
ctwill, ctwill-proofsort, ctwill-refsort, ctwill-twinx β translate CWEB to TeX with mini-indexes π¦
πΈ SYNOPSIS πΈ
ctwill [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]
( ctwill-proofsort < texfile.tex ) 1<> texfile.tex
ctwill-refsort < indexfile.ref > indexfile.sref
ctwill-twinx outfile.tex [outfile.tex ...] > index.tex
π DESCRIPTION π
So ctwill takes a CWEB source document and converts it into a TeX file that you can format and print the normal way. It handles all the typographic details for you β page layout, indentation, italics, boldface, all of it β and it also hands you extensive cross-index information that it gathers up all by itself. no cap. π₯
CWEB lets you prep one single document that contains everything you need both to produce a compilable C/C++ program and to produce a well-formatted document describing that program in as much detail as you want. But heads up: if you're gonna use CWEB, you ought to be familiar with TeX as well as C/C++. that's the vibe check. π
π USAGE π
The command line should have one, two, or three names on it.
- The first is taken as the CWEB input file (and
.wis added if there's no extension). - If there's a second name, it's a change file (and
.chis added if there's no extension). The change file overrides parts of the CWEB file, as described in the documentation. - If there's a third name, it overrides the default name of the output file, which is ordinarily the same as the name of the input file (but on the current directory) with the extension
.tex.
If you just want to change the output file name but don't have a change file to apply, you can use - as the second argument. cute little hack, love that for us. π
ctwill is exactly like cweave except that it produces much better documentation, for which you must work much harder. π You should run ctwill twice β once to prime the pump and once to get decent answers. And on top of that, you must run the output twice through TeX. yes, that's four runs total. we don't make the rules. β¨
After tex foo you'll have output that looks like final pages except that the entries of mini-indexes won't be alphabetized. The first run produces a weird file called foo.ref. Say
ctwill-refsort < foo.ref > foo.sref
and then another tex foo will produce alphabetized output. π¦
The ctwill-twinx program compiles a master index for a set of related programs that have been processed by ctwill (not by cweave, mind you! π). The individual programs should define their names with a line of the form \def\title{NAME}. For your convenience, ctwill-twinx grabs the first "word" in \title and turns it into uppercase form. You should adapt file twinx-startup.tex for the first page of the master index.
The mini-indexes list identifiers that are used but not defined on each two-page spread. At the end of each section, ctwill gives TeX a list of identifiers used in that section and information about where they are defined.
The current meaning of every identifier is initially \uninitialized. Then ctwill reads the .aux file for your job, if any.
Before reading the .aux file, ctwill actually looks for a file called system.bux, which will be read if present. And after foo.aux, a third possibility is foo.bux. The general convention is to put definitions of system procedures such as printf into system.bux, and to put definitions found in specifically foo-ish header files into foo.bux. Like the .aux files, .bux files should contain only @$ specifications.
The meaning specified by @$...@> generally has four components:
- an identifier (followed by space)
- a program name (enclosed in braces)
- a section number (followed by space)
- a TeX part
A special proofmode is provided so that you can check ctwill's conclusions about cross-references. Run ctwill with the flag +P, and TeX will produce a specially formatted document with mini-indexes for each section, so that you can check that your specifications are correct. π
This proofmode format is used in conjunction with pdfctproofmac.tex that creates active hyperlinks in PDF and HINT output. You can use ctwill-proofsort to get the index entries in alphabetical order; just invoke
( ctwill-proofsort < texfile.tex ) 1<> texfile.tex
after invoking ctwill (twice), but before invoking TeX (once). yes bestie, order matters. π«Ά
More details how to use ctwill can be found in the first sections of its source code, respectively the change file cweav-twill.ch applicable to the cweave.w source. A complete example with all bells and whistles is described in Mini-Indexes for Literate Programs, pages 225β245 of Knuth's Digital Typography (CSLI, 1999). π
π DIFFERENCES TO ORIGINAL CTWILL π
The present incarnation of ctwill and its utilities tries hard to be a drop-in replacement for the original package. There are, however, a few differences worth noting:
- This version is based on the most recent version of CWEB (
4.12.1). - In TeX Live the utility programs are prefixed with
ctwill-and the macro files withctfor technical reasons. - Options
--help,--quiet,--verbose,--version, and flags+c,-i,-o, and+lXare new in CWEBbin and TeX Live. - Option
+lXis accompanied by example wrapper files forctwimac.texandctproofmac.texwith translated captions for German (+ld). - Option
+lXis also accompanied by an extendedpdfctwimac.texfor production of PDF and HINT output with active hyperlinks (+lpdf). ctwillin TeX Live operates silently by default; use the--verboseoption to get the original behavior.- File lookup with the environment variable
CWEBINPUTSis extended to permit several, colon-separated, paths; see ENVIRONMENT below. - If properly configured, the main program
ctwillis localized with the "GNU gettext utilities".
β¨ OPTIONS β¨
okay so the rules of the game: options on the command line may be either turned off with - (if they're on by default) or turned on with + (if they're off by default).
And here's the part that gets people: the options are processed from left to right, so a sequence like --verbose -h will only show the banner line (+b) and the progress report (+p), but leave out the happy message (-h). order is destiny bestie. π
+bβ print banner line on terminal+hβ print success message on completion+pβ print progress report messages+q/-qβ shortcut for-bhp; also--quiet(default)+v/-vβ shortcut for+bhp; also--verbose+cβ check temporary output for changes-eβ do not enclose C/C++ material in\PB{...}-fβ do not force a newline after every C/C++ statement in output-Fβ do not force a compound statement to start on a new line-iβ suppress indentation of parameter declarations-oβ suppress separation of declarations and statements-xβ omit indices, section names, table of contents+Pβ\input ctproofmac.texinstead ofctwimac.tex+lX/-lXβ use macros for language X as ofX{ctwimac|ctproofmac}.tex+sβ print usage statistics+tβ treattypenamein a template liketypedef--helpβ display help message and exit--versionβ output version information and exit
π¦ ENVIRONMENT π¦
The environment variable CWEBINPUTS is used to search for the input files, or the system default if CWEBINPUTS is not set. See tex(1) for the details of the searching. To avoid conflicts with other programs that also use the CWEBINPUTS environment, you can be more specific and use CWEBINPUTS_cweb for special requirements in CWEB.
If prepared for NLS support, ctwill like ctangle and cweave uses the environment variable TEXMFLOCALEDIR to configure the parent directory where the "GNU gettext utilities" search for translation catalogs.
These variables are preconfigured in TeX Live's texmf.cnf. πΈ
π FILES π
The location of the files mentioned below varies from system to system. Use the kpsewhich utility to find their locations. π
ctwimac.texβ The default TeX macros\inputin the first line of the output file.ctproofmac.texβ Ifctwillis invoked with the+Poption, it will change the first line of the output file to\input ctproofmac.tex.
In both cases you can request some prefix X with the +lX option, e.g., +ld will \input dctwimac.tex and +Pld will \input dctproofmac.tex. A special application is the use of option +lpdf that will \input pdfctwimac.tex or \input pdfctproofmac.tex for production of PDF and HINT output with active hyperlinks. β¨
webfile.buxβ Reference definitions to resolve from other modules.system.buxβ Reference definitions to resolve from C/C++ standard library header files like<stdio.h>.
Other auxiliary files with references are created automatically by ctwill and the actual index files are created by TeX.
cwebman.texβ The CWEB user manual, available in PDF from CTAN.
π SEE ALSO π
- The CWEB System of Structured Documentation: by Donald E. Knuth and Silvio Levy (hardcopy version of
cwebman.texand the source code listings ofcommon.w,ctangle.w, andcweave.w). - Digital Typography: by D. E. Knuth (CSLI, 1999).
- Literate Programming: by D. E. Knuth (CSLI, 1992).
- Weaving a Program: by Wayne Sewell.
π AUTHORS π
Don Knuth wrote ctwill based on cweave by Silvio Levy and Knuth. Contemporary development on https://github.com/ascherer/cwebbin. π«Ά
and that's the whole page bestie!! this one came from Web2c 2025 and it's dated January 1, 2025. go forth and weave, you absolute icon πβ¨ππ¦
π¦ where this page comes from
- alpine 3.24: texlive-doc 2026.0-r0 Β· GPL-2.0-or-later AND GPL-3.0-or-later
- fedora 44: texlive-cweb 12:svn77830-105.fc44 Β· Knuth-CTAN
- fedora 44: texlive-cweb 12:svn77830-111.fc44 Β· Knuth-CTAN
- opensuse-leap 16.0: texlive-cweb-doc 2025.221.svn73848-160000.3.1 Β· SUSE-TeX
- ubuntu resolute: texlive-binaries 2025.20250727.75242+ds-5build1 Β· TeX-Live
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms