*Task*
How to use pretty-printed documents in LaTeX.
*Description*
The back-end [[AboxToLaTex][abox2latex]] produces LaTeX code according to the formatting defined in a [[BoxLanguage][Box]] term. In order to process this LaTeX code by latex, the `boxenv' style file is required.
The location of this style file depends on your GPP installation but [[AboxToLaTex][abox2latex]] includes a comment section in the generated LaTeX code that tells you where to find the style file.
A generated LaTeX file can be incorporated in a larger LaTeX document as follows:
1. Determine the location of the boxenv style file by inspecting the comments at the beginning of example.tex.
2. Add this location to your TEXINPUTS environment variable.
3. Add `\usepackage{boxenv}' to the preamble of main.tex.
4. Import the generated LaTeX file using `\input'.
5. Process the file by latex.
The paper [[http://www.cs.uu.nl/groups/ST/twiki/bin/view/Merijn/PaperALaTeXStyleFileForFormattingBOXExpressions][A LaTeX Style File For Formatting BOX Expressions]]
contains detailed information about the boxenv style file and its use.
*Changing Fonts*
You can change how text is displayed by LaTeX by redefining macros in a configuration file 'box-fonts.def'. The following macros can be defined:
KWf:: Defines how keywords are formatted (default '\textbf{...}')
VARf:: Defines how variables are formatted (default '\textit{...}')
NUMf:: Defines how numbers are formatted (default '\textrm{...}')
MATHf:: Defines how mathematical symbols are formatted (default '\ensuremath{...}')
COMMF:: Defines how to comments are formatted (default '\textrm{...}')
*Changing Symbols*
You can instruct [[AboxToLaTex][abox2latex]] to map symbols in an abox term to special LaTeX symbols. To that end, you create an abbreviations table containing mappings from [[BoxLanguage][Box]] symbols to LaTeX symbols, and pass that table to [[AboxToLaTex][abox2latex]] with the '-t' switch. For example, [[AboxToLaTex][abox2latex]] uses the following default abbreviations table:
[
["->" , "\\ensuremath{\\rightarrow}"],
[ "\\/" , "\\ensuremath{\\vee}"],
[ "/\\" , "\\ensuremath{\\wedge}"],
[ "==" , "\\ensuremath{\\equiv}"],
[ "++" , "\\ensuremath{+\\kern-.4em+}"]
]
*Examples*
The location of boxenv.sty can be appended to your TEXINPUTS environment variable as follows:
For Bourne shells
# TEXINPUTS=:${TEXINPUTS}; export TEXINPUTS
For C shells
# set TEXINPUTS=:${TEXINPUTS}; setenv TEXINPUTS
Assuming that the generated LaTeX code is stored in the file example.tex, then a typical LaTeX document that includes the file example.tex looks like:
\documentstyle{article}
\usepackage{boxenv}
\begin{document}
\input{example.tex}
\enddocument}
*Layout Preserving Pretty-Printing with GPP*
[[AboxToLaTex][Abox2latex]] can be used for layout preserving pretty-printing. To that end, you have to produce an abox term with [[AsFix2Abox][asfix2abox]] and pass it the '-c' switch to preserve layout in the [[BoxLanguage][Box]] expression. Then you use [[AboxToLaTex][abox2latex]] with the '--alltt' switch to produce a LaTeX alltt environment:
asfix2abox -c -i .asfix \
abox2latex --alltt -o .tex
Then you include the 'alltt' and 'boxenv' style files in your document, and input '<your_file>.tex:
\documentclass{article}
\usepackage{alltt}
\usepackage{boxenv}
\begin{document}
\input{.tex}
\end{document}
*See Also*
GenericPrettyPrinter, HowToPrettyPrintAGrammar, AboxToLaTex