{
    "mode": "man",
    "parameter": "ctwill-refsort",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/ctwill-refsort/1/json",
    "generated": "2026-08-07T11:36:55Z",
    "synopsis": "ctwill [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]\nctwill-refsort < indexfile.ref > indexfile.sref\nctwill-twinx outfile.tex [outfile.tex ...]  > index.tex",
    "sections": {
        "NAME": {
            "content": "ctwill, ctwill-refsort, ctwill-twinx - translate CWEB to TeX with mini-indexes\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ctwill [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]\nctwill-refsort < indexfile.ref > indexfile.sref\nctwill-twinx outfile.tex [outfile.tex ...]  > index.tex\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  ctwill program converts a CWEB source document into a TeX file that may be formatted and\nprinted in the usual way.  It takes appropriate care of typographic details like page  layout\nand  the  use  of indentation, italics, boldface, etc., and it supplies extensive cross-index\ninformation that it gathers automatically.\n\nCWEB allows you to prepare a single document containing all the information  that  is  needed\nboth  to produce a compilable C/C++ program and to produce a well-formatted document describ‐\ning the program in as much detail as the writer may desire.  The user of CWEB ought to be fa‐\nmiliar with TeX as well as C/C++.\n",
            "subsections": []
        },
        "USAGE": {
            "content": "The command line should have one, two, or three names on it.  The first is taken as the  CWEB\ninput  file  (and  .w is added if there is no extension).  If there is a second name, it is a\nchange file (and .ch is added if there is no extension).  The change file overrides parts  of\nthe CWEB file, as described in the documentation.  If there is a third name, it overrides the\ndefault  name  of the output file, which is ordinarily the same as the name of the input file\n(but on the current directory) with the extension .tex.  If you just want to change the  out‐\nput file name, but don’t have a change file to apply, you can use `-' as the second argument.\n\nctwill  is  exactly  like cweave except that it produces much better documentation, for which\nyou must work much harder.  You should run ctwill twice, once to prime the pump and  once  to\nget decent answers.  Moreover, you must run the output twice through TeX.\n\nAfter tex foo you will have output that looks like final pages except that the entries of mi‐\nni-indexes  won’t  be alphabetized.  The first run produces a weird file called foo.ref.  Say\nctwill-refsort < foo.ref > foo.sref and then another tex foo will produce  alphabetized  out‐\nput.\n\nThe ctwill-twinx program compiles a master index for a set of related programs that have been\nprocessed  by ctwill (not by cweave, mind you!).  The individual programs should define their\nnames with a line of the form \\def\\title{NAME}.  For your convenience, ctwill-twinx grabs the\nfirst “word” in \\title and turns it into uppercase form.  You should adapt file  twinx-start‐\nup.tex for the first page of the master index.\n\nThe  mini-indexes list identifiers that are used but not defined on each two-page spread.  At\nthe end of each section, ctwill gives TeX a list of identifiers used in that section and  in‐\nformation about where they are defined.\n\nThe  current  meaning of every identifier is initially \\uninitialized.  Then ctwill reads the\n.aux file for your job, if any.\n\nBefore reading the .aux file, ctwill actually looks for a file called system.bux, which  will\nbe  read if present.  And after foo.aux, a third possibility is foo.bux.  The general conven‐\ntion is to put definitions of system procedures such as printf into system.bux,  and  to  put\ndefinitions  found  in  specifically foo-ish header files into foo.bux.  Like the .aux files,\n.bux files should contain only @$ specifications.\n\nThe meaning specified by @$...@> generally has four components: an  identifier  (followed  by\nspace),  a  program  name  (enclosed  in braces), a section number (followed by space), and a\nTeX part.\n\nA special proofmode is provided so that you can check ctwill’s conclusions about cross-refer‐\nences.  Run ctwill with the flag +P, and TeX will  produce  a  specially  formatted  document\n(without mini-indexes) in which you can check that your specifications are correct.\n\nMore details how to use ctwill can be found in the first sections of its source code, respec‐\ntively  the change file cweav-twill.ch applicable to the cweave.w source.  A complete example\nwith all bells and whistles is described in Mini-Indexes for Literate Programs, pages 225–245\nof Knuth’s Digital Typography.\n",
            "subsections": []
        },
        "DIFFERENCES TO ORIGINAL CTWILL": {
            "content": "The present incarnation of ctwill and its utilities tries hard to be  a  drop-in  replacement\nfor the original package.  There are, however, a few differences worth noting:\n\n• This version is based on the most recent version of CWEB (4.8).\n\n• In  TeX Live the utility programs are prefixed with ctwill- and the macro files with ct for\ntechnical reasons.\n\n• Options --help, --quiet, --verbose, --version, and flags +c, -i, -o, and  +lX  are  new  in\nCWEBbin and TeX Live.\n\n• Option  +lX is accompanied by example wrapper files for ctwimac.tex and ctproofmac.tex with\ntranslated captions for German (+ld).\n\n• Option +lX is also accompanied by an extended pdfctwimac.tex for production of  PDF  output\nwith active hyperlinks (+lpdf).\n\n• ctwill in TeX Live operates silently by default; use the --verbose option to get the origi‐\nnal behavior.\n\n• File  lookup with the environment variable CWEBINPUTS is extended to permit several, colon-\nseparated, paths; see ENVIRONMENT below.\n\n• If properly configured, the main program ctwill is localized with the “GNU  gettext  utili‐\nties”.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Options  on the command line may be either turned off with `-' (if they are on by default) or\nturned on with `+' (if they are off by default).  In fact, the  options  are  processed  from\nleft  to  right,  so a sequence like --verbose -h will only show the banner line (+b) and the\nprogress report (+p), but leave out the happy message (-h).\n\n• +b: print banner line on terminal\n\n• +h: print success message on completion\n\n• +p: print progress report messages\n\n• +q/-q: shortcut for -bhp; also --quiet (default)\n\n• +v/-v: shortcut for +bhp; also --verbose\n\n• +c: check temporary output for changes\n\n• -e: do not enclose C/C++ material in \\PB{...}\n\n• -f: do not force a newline after every C/C++ statement in output\n\n• -i: suppress indentation of parameter declarations\n\n• -o: suppress separation of declarations and statements\n\n• -x: omit indices, section names, table of contents\n\n• +P: \\input ctproofmac.tex instead of ctwimac.tex\n\n• +lX/-lX: use macros for language X as of X{ctwimac|ctproofmac}.tex\n\n• +s: print usage statistics\n\n• +t: treat typename in a template like typedef\n\n• --help: display help message and exit\n\n• --version: output version information and exit\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "The environment variable CWEBINPUTS is used to search for the input files, or the system  de‐\nfault  if CWEBINPUTS is not set.  See tex(1) for the details of the searching.  To avoid con‐\nflicts with other programs that also use the CWEBINPUTS environment, you can be more specific\nand use CWEBINPUTScweb for special requirements in CWEB.\n\nIf prepared for NLS support, ctwill like ctangle and cweave  uses  the  environment  variable\nTEXMFLOCALEDIR to configure the parent directory where the “GNU gettext utilities” search for\ntranslation catalogs.\n\nThese variables are preconfigured in TeX Live’s texmf.cnf.\n",
            "subsections": []
        },
        "FILES": {
            "content": "The  location  of  the files mentioned below varies from system to system.  Use the kpsewhich\nutility to find their locations.\n\n• ctwimac.tex: The default TeX macros \\input in the first line of the output file.\n\n• ctproofmac.tex: If ctwill is invoked with the +P option, it will change the first  line  of\nthe output file to \\input ctproofmac.tex.\n\nIn  both  cases  you  can  request  some  prefix X with the +lX option, e.g., +ld will \\input\ndctwimac.tex and +Pld will \\input dctproofmac.tex.  A special application is the use  of  op‐\ntion  +lpdf  that  will \\input pdfctwimac.tex for production of PDF output with active hyper‐\nlinks.\n\n• webfile.bux: Reference definitions to resolve from other modules.\n\n• system.bux: Reference definitions to resolve from C/C++ standard library header files  like\n<stdio.h>.\n\nOther  auxiliary files with references are created automatically by ctwill and the actual in‐\ndex files are created by TeX.\n\n• cwebman.tex: The CWEB user manual, available in PDF from CTAN (https://ctan.org/pkg/cweb).\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "• The CWEB System of Structured Documentation: by Donald E. Knuth and Silvio  Levy  (hardcopy\nversion of cwebman.tex and the source code listings of common.w, ctangle.w, and cweave.w).\n\n• Digital Typography: by D. E. Knuth.\n\n• Literate Programming: by D. E. Knuth.\n\n• Weaving a Program: by Wayne Sewell.\n\ncweb(1), tex(1), cc(1)\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Don Knuth wrote ctwill based on cweave by Silvio Levy and Knuth.\nContemporary development on https://github.com/ascherer/cwebbin.\n\nWeb2c 2023                                  June 5, 2022                                   CTWILL(1)",
            "subsections": []
        }
    },
    "summary": "ctwill, ctwill-refsort, ctwill-twinx - translate CWEB to TeX with mini-indexes",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "cweb",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/cweb/1/json"
        },
        {
            "name": "tex",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/tex/1/json"
        },
        {
            "name": "cc",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/cc/1/json"
        }
    ]
}