TEXPRETTY 1 "21 May 2001" "Version 0.02"

Table of contents


NAME

texpretty - prettyprint TeX (and AmSLaTeX, AmSTeX, ETeX, LAmSTeX, LaTeX, LaTeXinfo, SliTeX, TeXinfo, ...) files

SYNOPSIS

texpretty [ -? ] [ -@ ] [ -a ] [ -c ] [ -d ] [ -e modename ] [ -f filename ] [ -h ] [ -i nnn ] [ -l filename ] [ -m nnn ] [ -n ] [ -o filename ] [ -q ] [ -s filename ] [ -t ] [ -v ] [ -w nnn ]


< infile > outfile


or


file(s) > outfile

texpretty [ --? ] [ --texinfo ] [ --author ] [ --copyright ] [ --displaymath-all ] [ --emacs-mode modename ] [ --filename filename ] [ --help ] [ --indent nnn ] [ --logfile filename ] [ --math-conversions nnn ] [ --no-comment-banner ] [ --outfile filename ] [ --quick ] [ --stylefile filename ] [ --tabular-as-verbatim ] [ --version ] [ --width nnn ]



< infile > outfile


or


file(s) > outfile

DESCRIPTION

texpretty filters its TeX input from stdin, or from one or more files named on the command line, and prettyprints it to stdout. Most formatting systems based on TeX, including AmSTeX, AmSLaTeX, ETeX (K. Berry's Extended plain TeX), LAmSTeX, LaTeX, and SliTeX, are handled reasonably well. texpretty also includes support for the Free Software Foundation's GNU Project TeXinfo, whose markup syntax resembles that of scribe(1) rather than that of TeX.

LaTeXinfo is similar enough to LaTeX that it can be handled by texpretty, provided a suitable supplementary style file is supplied; an example is given in the STYLE FILES section below.

Although prettyprinters of necessity impose a certain style that may not be universally agreed upon, they have nevertheless proven useful for many programming languages for heuristic syntax checking, and for generating a consistent appearance in files that may have been prepared by many authors (human, or computer programs), or even by a single author with lax file preparation discipline.

Because of their low-level markup, plain TeX and AmSTeX files offer fewer opportunities for useful prettyprinting than do LaTeX, LAmSTeX, and SliTeX. Nevertheless, the heuristic error checking provided by texpretty may still be useful for catching brace, dollar, and environment balance errors.

LaTeX users are advised to make regular use of lacheck(1), which warns about many other kinds of likely errors that LaTeX itself cannot detect. texpretty will automatically repair some of these types of errors.

texpretty may be less useful for files consisting only of macro definitions (e.g., plain.tex, or LaTeX style files), because

Because TeX commands can be arcane, and do unexpected things, users of texpretty are urged to check the output carefully, and not replace input files with prettyprinted output files until the latter have been typeset and verified.

texpretty does not examine included files that would be read by TeX during processing of commands like \bibliography, \include, \input, \listoffigures, \listoftables, \printindex, \tableofcontents, ... You must provide these files to texpretty explicitly if you want them to be prettyprinted.


OPTIONS

The following command-line options are supported, and they affect all remaining filenames on the command line. Option values are always provided as separate arguments following the option name.

Letter case in option names is not significant, although it may be in option values.

GNU- and POSIX-style long options of the form --name are also recognized: they begin with one or two option prefix characters. Long option names may be abbreviated to any unique leading prefix, unless a shorter prefix is documented.

Any argument that begins with a hyphen is expected to be an option, and will raise an error if it is not recognized. If a filename begins with a hyphen, you therefore need to disguise it by supplying a leading directory path. For example, ./-foo represents the file named -foo in the current directory in UNIX.

Unrecognized arguments, or arguments lacking an expected value string, result in an error message on stderr, and immediate termination with a failure status code.

-@
--texinfo
Set TeXinfo mode, so that at-sign is the escape character instead of backslash. Although backslash-prefixed control sequences continue to be recognized, dollar signs are ordinary characters, so special treatment of TeX mathematics mode is disabled. In addition, any settings from -d (display math formatting), -e (Emacs mode), -i (indentation), and -m (mathematics conversion) options are ignored, and the indentation level spacing is set to zero, because leading spaces can be significant in the info-mode text produced from TeXinfo files.

Because TeXinfo is a continually evolving language, all TeXinfo commands that do not require special handling are enumerated in texpretty; any others that it finds will raise a warning message. Such new commands can probably be handled without modifying texpretty; see the STYLE FILES section below.

-a
--author
Show author information on stderr, and terminate immediately with a success status code.
-c
--copyright
Show copyright information on stderr, and terminate immediately with a success status code.
-d
--displaymath-all
Use display-mathematics style formatting for inline mathematics. This helps to set off mathematics text, and makes it easier to inspect it for correctness, However, in documents that make heavy use of inline mathematics, it may detract from readability of the non-mathematics material.
-e modename
--emacs-mode modename
Supply an Emacs mode name for the leading comment banner (default: TeX).
-f filename
--filename filename
Supply an alternate input filename for use in the output comment banner. This overrides the actual filename(s), and provides a way to name the output, even when no named input file is available, because standard input is redirected, or comes from a pipe.
-h or -?
--help
Display brief usage information on stderr, and terminate immediately with a success status code.
-i nnn
--indent nnn
Set the number of spaces for each indentation level (default: 4). The value is forced into the nearest endpoint of the range 0 ... 16 if it is outside that interval. Although a zero value is accepted, it is not recommended, because suppressing indentation obscures the logical structure.
-l filename
--logfile filename
Redirect warning and error messages from stderr to the indicated filename. This option is provided for user convenience on operating systems (e.g., IBM PC DOS) that fail to provide for redirection of stderr to a specified file.

If the file cannot be opened for output, texpretty will terminate silently (because the internal attempted redirection required the closure of stderr) with a non-zero exit code.

-m nnn
--math-conversions nnn
Select the mathematics mode style conversion (default: 0 --- no conversion). The value nnn is the sum of the desired numbers from this list (for each of the two cases of inline and display mathematics, the largest number chosen is the one that is used):
1
Inline mathematics is coded as $ ... $.
2
Inline mathematics is coded as \( ... \) (LaTeX).
4
Inline mathematics is coded as \begin{math} ... \end{math} (LaTeX).
8
Display mathematics is coded as $$ ... $$.
16
Display mathematics is coded as \[ ... \] (LaTeX).
32
Display mathematics is coded as \begin{displaymath} ... \end{displaymath} (LaTeX).

texpretty recognizes all of these forms in the input stream.

This option may be helpful in assisting in the conversion between LaTeX and plain TeX markup, in standardizing the markup of mathematics in LaTeX, and in improving the possibilities for detection of begin-end imbalances (when the dollar forms are eliminated, and an editor or other software capable of delimiter balance checking is employed).

Although the double-dollar markup style for display mathematics is frequently found in LaTeX documents, strictly speaking, it should be replaced by either of the alternatives above.

-n
--no-comment-banner
Suppress generation of the default leading comment banner.
-o filename
--outfile filename
Redirect output from stdout to the indicated filename. This option is provided for user convenience on operating systems that fail to provide for convenient redirection of stdout to a specified file.

If the file cannot be opened for output, texpretty will terminate with an error message and a non-zero exit code.

-q
--quick
Suppress reading of the two default style files (see the STYLE FILES section below). Style files explicitly specified with the -s options will still be processed.
-s filename
--stylefile filename
Name a style file (see the STYLE FILES section below) to augment texpretty's built-in knowledge of standard environments and control sequences.
-t
--tabular-as-verbatim
Copy tabular environments verbatim. This is sometimes desirable if they have already been carefully formatted.

Otherwise, texpretty carries out its normal prettyprinting activities inside tabular environments, except that there, it lines up ampersand column separators on line positions that are multiples of 8, to improve vertical alignment for better readability. This is about the best it can do with only a single pass over the environment.

-v
--version
Show version information on stderr, and terminate immediately with a success status code.
-w nnn
--width nnn
Set the maximum output line width (default: 72). This limit may be exceeded if an excessively long string without embedded spaces is encountered, and it is ignored completely inside comments and verbatim text. The line width value is forced into the nearest endpoint of the range 16 ... 1024 if it is outside that interval.

FORMATTING ACTIONS

texpretty carries out these major formatting actions (except in verbatim environments, where all input text is preserved exactly):

AmSLaTeX and LaTeX files that adhere to the markup defined in the LaTeX User's Guide and Reference Manual by Leslie Lamport (Addison-Wesley, 1985 (ISBN 0-201-15790-X), 1994 (ISBN 0-201-52983-1)), and the LaTeX Companion by Michel Goossens, Frank Mittelbach, and Alexander Samarin (Addison-Wesley, 1994 (0-201-54199-8)), will benefit most from texpretty's processing.


STYLE FILES

In the current implementation of texpretty, all of the standard AmSTeX, AmSLaTeX, ETeX, LAmSTeX, LaTeX, and SliTeX control words, environments, and comment syntax that require special formatting are hard-coded into the program. However, users can define new control sequences and environments with TeX \def, \edef, \gdef, and \xdef commands, and with LaTeX \newcommand, \newenvironment, \newtheorem, ... commands.

In order to allow the user to control the formatting of these new features, texpretty supports a simple style file mechanism. At startup, it processes a style file in the user's home directory, and another in the current directory. Neither of these need exist. During command-line argument processing, additional style files can be provided with the -s option. These style files support user-specific, directory-specific, and file-specific prettyprinting control.

The default name of the first two style files is system dependent: .texprettyrc (UNIX), texpty.ini (IBM PC DOS), and texpretty.ini (DEC VMS and OpenVMS).

The line length limit in style files is system-dependent, but guaranteed to be at least 1024 characters.

texpretty's formatting actions group control sequences into the following style classes:

chapter
sectional division
LAmSTeX: \docstyle \subtopic \topic
LaTeX: \appendix \backmatter \chapter \documentclass \documentstyle \frontmatter \mainmatter \paragraph \part \section \subparagraph \subsection \subsubsection
plain TeX: \beginchapter \beginsection \endchapter
chapter-line
sectional division with argument all text to end of line
TeXinfo: @chapter @section @subsection @subsubsection @unnumbered @unnumberedsec @unnumberedsubsec @unnumberedsubsubsec
cite
literature citation
LAmSTeX and LaTeX: \cite
LaTeX: \nocite
TeXinfo: @cite
command-argument
control sequence with its braced argument on same line
TeXinfo: @code @emph @kbd @key @ref @samp @TeX @var @w @xref
command-line
control sequence with argument all text to end of line
TeXinfo: @auindex @cindex @defcodeindex @defindex @findex @kindex @pindex @printindex @shorttitlepage @tindex @vindex
comment
comment to end of line (any TeX)
all but TeXinfo: %
TeXinfo: @c @comment
default

all but TeXinfo: unrecognized backslash control sequences
TeXinfo: @ETC @b @bullet @copyright @dfn @dmn @dots @enddots @equiv @expansion @file @headword @i @math @minus @occur @par @point @print @pxref @r @refill @regularbooksize @result @sc @strong @t @thischapter @thischaptername @thisfile @thispage @thistitle @titlefont @today @value
displaymath
displayed mathematics
any TeX: $$
LaTeX: \begin{displaymath} \end{displaymath} \[ \]
environment
text group with specialized formatting
AmSTeX: \CD \endCD \Refs \endRefs \Sb \endSb \Sp \endSp \Vmatrix \endVmatrix \abstract \endabstract \affil \endaffil \align \endalign \alignat \endalignat \aligned \endaligned \alignedat \endalignedat \block \endblock \bmatrix \endbmatrix \cases \endcases \cfrac \endcfrac \comment \endcomment \curraddr \endcurraddr \dedicatory \enddedicatory \definition \enddefinition \demo \enddemo \document \enddocument \email \endemail \example \endexample \gather \endgather \gathered \endgathered \graf \endgraf \head \endhead \keywords \endkeywords \matrix \endmatrix \multline \endmultline \pmatrix \endpmatrix \proclaim \endproclaim \remark \endremark \smallmatrix \endsmallmatrix \specialhead \endspecialhead \split \endsplit \subhead \endsubhead \subjclass \endsubjclass \subsubhead \endsubsubhead \toc \endtoc \topmatter \endtopmatter \translator \endtranslator \vmatrix \endvmatrix \xalignat \endxalignat \xxalignat \endxxalignat
LAmSTeX: \Figure \endFigure \Figurepair \endFigurepair \Figuretriple \endFiguretriple \HL \endHL \Table \endTable \bdmatrix \endbdmatrix \claim \endclaim \heading \endheading \island \endisland \makebib \endmakebib \partition \endpartition
LaTeX (with exceptions given in other classes): \begin{envname} \end{envname}
plain TeX: \begingroup \endgroup \bgroup \egroup
TeXinfo: @cartouche @display @end @flushleft @flushright @format @group @ifinfo @iftex @quotation @smallexample @smalllisp @titlepage
footnote
comment and newline before
ETeX: \numberedfootnote
LAmSTeX: \plainfootnote \plainproclaim
LaTeX: \footnote \footnotetext \label \pageref \ref
plain TeX: \vfootnote
TeXinfo: @footnote
index
index and glossary
ETeX: \idx \idxmarked \idxname \idxsubmarked \sidx \sidxmarked \sidxname \sidxsubmarked
LaTeX: \glossary \index
list
list of items
AmSTeX: \roster \endroster
ETeX: \numberedlist \endnumberedlist \orderedlist \endorderedlist \unorderedlist \endunorderedlist
LAmSTeX: \bib \endbib \bullist \endbullist \describe \enddescribe \list \endlist \margins \endmargins
LaTeX: \begin{description} \end{description} \begin{enumerate} \end{enumerate} \begin{itemize} \end{itemize} \begin{list} \end{list} \begin{thebibliography} \end{thebibliography} \begin{trivlist} \end{trivlist}
TeXinfo: @enumerate @ftable @itemize @table @vtable
list-item
item in a list
AmSTeX: \runinitem
LaTeX: \bibitem \item
plain TeX: \itemitem
TeXinfo: @item @itemx
math
inline mathematics
any TeX: $
LaTeX: \begin{math} \end{math} \( \)
newline-after
newline after control sequence
LaTeX: \ \* \kill
plain TeX: \cr \crcr \endline
TeXinfo: @*
newline-before
newline before control sequence
AmSLaTeX: \DeclareMathOperator \DeclareMathSymbol \DeclareSymbolFont \numberwithin \swapnumbers \newtheoremstyle \theoremstyle
AmSTeX: \adjustfootnotemark \book \bookinfo \bookinquotes \botcaption \by \bysame \captionwidth \define \ed \eds \finalinfo \inbook \issue \jour \lang \moreref \newsymbol \no \noquotes \page \pages \paper \paperinfo \paperinquotes \parshape \preaffil \preauthor \predate \predefine \prepaper \pretitle \publ \publaddr \redefine \shoveleft \shoveright \toappear \topcaption \transl \undefine \vol \widestnumber \yr
ETeX: \defineindex \definecontentsfile \center \columnfill \doublecolumns \edefappend \flushleft \flushright \for \iffileexists \innerdef \innerinnerdef \innernewbox \innernewcount \innernewdimen \innernewfam \innernewhelp \innernewif \innernewinsert \innernewmuskip \innernewread \innernewskip \innernewtoks \innernewwrite \listing \makecolumns \quadcolumns \readindexfile \readtocfile \testfileexistence \tocchapterentry \tocsectionentry \triplecolumns \writenumberedtocentry \writetocentry
LAmSTeX: \Cgaps \Entry \Entryxref \LETTER \Morexref \Noexpand \Nonexpanding \Offset \Page \PageSpan \Pagespan \PostCDSpace \PreCDSpace \Reset \Rgaps \Topage \Xref \cgaps \cleartable \counter \everytable \ex \exs \flushpar \fnote \foottext \hL \hdashed \hl \hls \htablelines \iabbrev \idefine \litbackslash \litdelimiter \mainfile \makepiece \manyby \measuretable \modifyfootnote \nameHL \namehl \newHL \newclaim \newfontstyle \newhl \newisland \newnumstyle \newpost \newpre \newstyle \newword \note \pageorder \postCDspace \postdocstyle \preCDspace \predocstyle \pullin \pullinmore \purge \readaux \rgaps \runningchapter \runningsection \shortenclaim \showstored \sss \storetable \tablewidth \tbldocstyle \tdefine \toclevel \tredefine \tss \unpurge \usetable \vleft \vright \vs \vsolid \vtablelines
LAmSTeX and LaTeX: \author \date \thanks \title
LaTeX: \address \caption \closing \glossaryentry \include \includeonly \indexentry \makeglossary \makeindex \marginpar \markboth \markright \multiput \newblock \newboolean \newcommand \newcounter \newenvironment \newlength \newsavebox \newtheorem \opening \printindex \providecommand \put \renewcommand \renewenvironment \signature \typein \typeout \usepackage \vspace
plain TeX: \centerline \chardef \closein \closeout \countdef \def \dimendef \edef \else \endinput \eqalign \eqalignno \errmessage \fi \futurelet \futurenonspacelet \gdef \global \halign \hang \hoffset \hyphenation \ialign \if \ifcase \ifcat \ifdim \ifeof \iffalse \ifhbox \ifhmode \ifinner \ifmmode \ifnum \ifodd \iftrue \ifundefined \ifvbox \ifvmode \ifvoid \ifx \immediate \input \leftline \leqalignno \let \line \listing \loop \magnifiction \mark \mathchardef \message \narrower \newbox \newcount \newdimen \newfam \newhelp \newif \newinsert \newmuskip \newread \newskip \newtoks \newwrite \noalign \openin \openout \parindent \read \repeat \rightline \show \showbox \showboxbreadth \showdepth \showhyphens \showlists \showthe \skipdef \special \tabalign \textindent \toksdef \tracingall \tracingcommands \tracinglostchars \tracingmacros \tracingonline \tracingoutput \tracingpages \tracingparagraphs \tracingrestores \tracingstats \vadjust \valign \voffset \vskip \write \xdef
TeXinfo: @appendix @appendixsec @appendixsection @appendixsubsec @appendixsubsubsec @asis @inforef @setfilename @vskip
standalone
control sequence isolated on its own line
AmSLaTeX: \allowdisplaybreaks \displaybreak
AmSTeX: \BlackBoxes \CenteredTagsOnSplits \ChangeBuffer \LimitsOnInts \LimitsOnNames \LimitsOnSums \Monograph \MultLineGap \NoBlackBoxes \NoPageNumbers \NoRunningHeads \ResetBuffer \Runinitem \TagsAsMath \TagsAsText \TagsOnLeft \TagsOnRight \TopOrBottomTagsOnSplits \UseAMSsymbols \UseBibTeX \captionwidth \endinsert \foldedpar \galleys \hcorrection \ininbook \loadbold \loadeufb \loadeufm \loadeurb \loadeurm \loadeusb \loadeusm \loadmsam \loadmsbm \midinsert \multlinegap \operatorname \pageheight \pageinsert \pagewidth \printoptions \showallocations \spreadlines \spreadmatrixlines \syntax \topinsert \vcorrection
LAmSTeX: \Figureproofing \FlushedFigs \Initialize \NS \NoFlushedFigs \RefWarnings \alldq \boxedtables \columnbreak \continuelist \figureproofing \indexfile \indexproofing \inlevel \keepitem \makelistFigures \makelistTables \makelistfigures \makelisttables \maketoc \newcolumn \noFigureproofing \nocolumnbreak \nofigureproofing \noshowsecondpass \opentables \outlevel \shortlastcolumn \showcolwidths \showsecondpass \sides \ssizeCDlabels \tocfile \tsizeCDlabels
LAmSTeX and LaTeX: \bibliography \bibliographystyle
LaTeX: \bigpagebreak \cleardoublepage \clearpage \definecolor \enlargethispage \flushbottom \fussy \hline \indexspace \linebreak \listfiles \listoffigures \listoftables \maketitle \medpagebreak \newline \newpage \nofiles \nolinebreak \nopagebreak \nopagenumbers \normalbottom \normalmarginpar \onecolumn \onlynotes \onlyslides \pagebreak \pagecolor \pagenumbering \pagestyle \raggedleft \reversemarginpar \sloppy \smallpagebreak \suppressfloats \tableofcontents \thispagestyle \twocolumn
plain TeX: \allowbreak \annotations \batchmode \bigbreak \bigskip \body \break \bye \centering \dosupereject \eject \endletter \errorstopmode \filbreak \frenchspacing \goodbreak \indent \leavevmode \makelabel \medbreak \medskip \noindent \nonfrenchspacing \nonstopmode \par \raggedbottom \raggedcenter \raggedright \removelastskip \scrollmode \smallbreak \smallskip \ttraggedright \vfil \vfilneg \vfill
TeXinfo: @afourpaper @bye @contents @cropmarks @finalout @lowersections @noindent @page @raisesections @shortcontents @smallbook @summarycontents
tabular
tabular text
LaTeX: \begin{tabular} \end{tabular} \begin{tabular*} \end{tabular*}
verb
inline verbatim
ETeX: \verbatim (may contain line breaks, and doubled delimiters representing a single character)
LAmSTeX: \Lit \lit (\Lit can contain line breaks, but its syntax is that of \lit)
LaTeX: \verb \verb*
any TeX: \path
verbatim
multiline verbatim environment
LaTeX: \begin{verbatim} \end{verbatim} \begin{verbatim*} \end{verbatim*}
TeXinfo: @defcv @deffn @defivar @defmac @defmethod @defop @defopt @defspec @deftp @deftypefn @deftypefun @deftypefunx @deftypevar @deftypevr @defun @defunx @defvar @defvr @example @ignore @lisp @menu @tex

The style class default can be used to force a command or environment to revert to the default formatting rules: no special indentation for commands, and normal indentation for environments. You can use this to override earlier style file settings, and most of the built-in ones.

Style class names, like TeX control sequences and LaTeX environments, are case sensitive. All of the ones recognized by texpretty must be spelled with lowercase letters.

The style file is expected to contain lines of the form:

style-class : envname1 envname2 ... \command1 \command2 ...
Blank lines, leading and trailing whitespace, and text from the TeX comment character (%) to end of line, are ignored. Whitespace separates items, and can be omitted around the colon. There is no significance to the order of items on a line, or lines in the file, except that later settings can override earlier ones. The same style class name may occur on multiple lines.

For example, suppose you have defined new sectional division commands named \Kapitel and \Teil, a new tabular environment named \SuperTabular, and two new display math environments named EasyMath and HardMath. Your style file might then look something like this:

% additional texpretty style specifications
% [02-Jun-1995]
chapter :       \Kapitel \Teil
tabular :       SuperTabular
displaymath :   EasyMath HardMath

LaTeXinfo is, sadly, less widely used than TeXinfo; it supports most of the standard LaTeX commands, plus a few others: some additional sectioning and indexing commands, two comment-start macros (\c and \comment), a hypertext link macro (\node) and a menu environment in which line breaks are significant. Here is a suitable texpretty style file for LaTeXinfo files (there are additional LaTeXinfo control sequences not listed here, but they do not require any particular special formatting):

% LaTeXinfo style file for texpretty
% [08-Jun-1995]
chapter        : \unnumbered \unnumberedsec \unnumberedsubsec
chapter        : \unnumberedsubsubsec
comment        : \c \comment \node
index          : \cindex \cpindexbold \cpsubindex \findex
index          : \kindex \pindex \tindex \vindex
newline-after  : \* \br
newline-before : \copyright \newindex \setfilename \synindex
verbatim       : ifinfo ignore menu
The \node macro can be handled by the comment class because all of its arguments follow on the same line, up to the end of the line. Menu environments are usually laid out neatly, because their formatting is preserved exactly in the ASCII output used for online info documentation; prettyprinting them in verbatim mode ensures that the layout will be retained. The \* macro will actually not be recognized in the current version of texpretty, because macro names definable in style files may contain only letters after the leading backslash. In this case, no harm will arise, since the default formatting of control sequences containing special characters is adequate.

There is no built-in support in texpretty for LaTeXinfo, because it has not achieved widespread use; however, the style file above should be sufficient for texpretty to prettyprint LaTeXinfo files correctly.

The last style class attached to command or environment name is the one that is used, so specifications in a command-line style file can override those in the current directory style file, and those in turn override settings from the home directory style file.

The -d and -t command-line options affect the prettyprinting of all commands in the math and tabular classes.

Don't use the -m math mode translation option if you specify the math class in a style file; if you do, those commands and environments will be renamed. When math mode translation is selected, it may also be advisable to specify the -q option, and avoid -s options, to eliminate all style file input.

For the purposes of matching TeX control words, texpretty assumes that they begin with a backslash followed by one or more letters or at-sign; the latter is commonly used inside macro packages to create command names that are supposed to be hidden from the end user. There is no provision in style files for modifying this assumption.

Occasionally, it may be desirable to have a control sequence and its arguments handled together as an indivisible unit. To support this, control sequences in style files may be followed by zero or more of the following patterns, in whatever order is required:

*
Match an optional literal asterisk; LaTeX uses this for variant forms.
[]
Match an optional argument in balanced brackets (LaTeX).
""
Match an optional argument in quotes (AmSTeX and LAmSTeX).
()
Match a required argument in balanced parentheses (LaTeX).
{}
Match a required argument in balanced braces (any TeX).
\
Match an alphabetic control sequence (LAmSTeX).
These patterns are ignored for index, verb, and verbatim style classes, because they have their own specialized formatting requirements.

Here is a sample style file that illustrates the use of argument patterns:

default        : \makebox()[]{} % LaTeX
list-item      : \item""        % AmSTeX and LAmSTeX
standalone     : \Reset\        % LAmSTeX: e.g., \Reset \list
When argument patterns are processed, whitespace before and between arguments in the input stream is discarded as long as an argument match is found. Arguments themselves are copied verbatim, even if they include line breaks or comments. The only requirement is that braced, bracketed, or parenthesized arguments have balanced delimiters.

Control sequence name matching against style file specifications does not include any argument patterns, so if the same control sequence name is specified more than once in a style file, as in

list-item      : \myitem"" \myitem() \myitem[] \myitem{}
only the last one will be effective, in this case, a required braced argument. This should not normally be a serious limitation, because TeX control sequence definitions that include argument delimiter characters also have this behavior. However, it is possible with special programming to use one-character lookahead to distinguish between argument types, and LaTeX does this internally for optional bracketed arguments, and asterisked variants.

LIMITATIONS

A fundamental assumption of any prettyprinter is that whitespace (blank, horizontal tab, vertical tab, carriage return, formfeed, newline) is not significant. While this is generally the case, it is not so in those rare TeX files where whitespace is made active by \catcode modification. Avoid using texpretty on such files, or on files where the comment character is something other than the normal percent character. There is no problem with LaTeX verbatim macros and environments, because texpretty recognizes them and preserves their contents exactly.

User-defined control sequences for which whitespace is significant, or whose use is idiosyncratically formatted, will likely conflict with prettyprinting.

The plain TeX \obeylines and \obeyspaces commands, and the ETeX \obeywhitespace command, would be similarly mishandled, except that texpretty watches for them, and once they are seen, copies the remainder of the file in verbatim mode, effectively suppressing further prettyprinting. It has to do this, because it has no reliable way to detect the end of scope for these commands.

For a small number of control sequences, there are formatting conflicts between two or more macro packages. In such a case, preference is first given to LaTeX (and AmSLaTeX and SliTeX), then to AmSTeX, then to LAmSTeX, and finally to plain TeX and ETeX.

There are also cases in some of these macro packages where the same control sequence has environment-dependent meaning, so formatting irregularities may appear.


SEE ALSO

amstex(1), amslatex(1), chkdelim(1), etex(1) (or visit Emacs info node eplain), lacheck(1), lamstex(1), latex(1), latexinfo(1) (or visit Emacs info node latexinfo), scribe(1), tex(1), texinfo(1) (or visit Emacs info node texinfo).

AUTHOR

Nelson H. F. Beebe
Center for Scientific Computing
University of Utah
Department of Mathematics, 322 INSCC
155 S 1400 E RM 233
Salt Lake City, UT 84112-0090
USA
Email: beebe@math.utah.edu, beebe@acm.org,


beebe@computer.org, beebe@ieee.org (Internet)
WWW URL: http://www.math.utah.edu/~beebe
Telephone: +1 801 581 5254
FAX: +1 801 585 1640, +1 801 581 4148

AVAILABILITY

texpretty is freely available, and is licensed under the Free Software Foundation's GNU Public License (GPL), included in the file COPYING in the distribution.

texpretty's master distribution can be found at

ftp://ftp.math.utah.edu/pub/misc/
http://www.math.utah.edu/pub/misc/

in the file texpretty-x.yz.tar.gz where x.yz is the current version. Additional distribution formats are usually available at the same location.

That site is mirrored to several other Internet archives, so you may also be able to find it elsewhere on the Internet; try searching for the string texpretty at one or more of the popular Web search sites, such as

http://altavista.digital.com/
http://search.microsoft.com/us/default.asp
http://www.dejanews.com/
http://www.dogpile.com/index.html
http://www.euroseek.net/page?ifl=uk
http://www.excite.com/
http://www.go2net.com/search.html
http://www.google.com/
http://www.hotbot.com/
http://www.infoseek.com/
http://www.inktomi.com/
http://www.lycos.com/
http://www.northernlight.com/
http://www.snap.com/
http://www.stpt.com/
http://www.yahoo.com/