emarsden -> Lout FAQ/HOWTO |
"
) or backslashes (\
) in Lout?
Rodrigo Vanegas <rv@cs.brown.edu> (former maintainer of the Lout mailing list) writes:
Quotes are explained in the reference manual, section 2.1.
To get this You type this
" \"
\ \\
but these things only work inside "..."
. So the way
to print quoted strings in source code listings is like this (for
example) :
puts("hello\n"); puts("\"hello\\n\"");
In other words, you replace the opening "
by
"\"
, you replace the closing quote by
\""
, and any \
inside you replace by \\
.
The best way is to compile Lout in 8-bit mode and to use an editor which allows the insertion of accents. In Emacs, for example, you can use iso-accents-mode.
If this isn't possible you can use a simple script to transform
"prefixed-accents" to Lout @Char
form. For French
accents, for example :
#!/usr/local/bin/perl
while( <> )
{
s/'e/\@Char{eacute}/g;
s/`e/\@Char{egrave}/g;
s/`a/\@Char{agrave}/g;
s/`u/\@Char{ugrave}/g;
s/\^e/\@Char{ecircumflex}/g;
s/\^o/\@Char{ocircumflex}/g;
s/\^u/\@Char{ucircumflex}/g;
# etc
print;
}
A more complete set of conversions is provided by the txt2lout script by Mark Summerfield (see "Useful Tools" section).
This sort of task is best left to a Postscript postprocessor. Lout outputs Postscript which conforms closely to the Adobe Document Structuring Conventions (see the file notes.dsc included with the Lout distribution). This means, among other things, that it includes page numbering information in its output, which is why Postscript previewers permit you to skip to an arbitrary page in the document, and which makes it possible to select specific pages from Lout's output.
PS Utils http://www.dcs.ed.ac.uk/~ajcd/psutils/ by Angus Duggan <angus@harlequin.co.uk> is a great postprocessor for Postscript documents. Some of the programs in the suite are
alter document paper size
selects pages and page ranges
rearranges pages into signatures
put multiple pages per physical sheet of paper
performs general page rearrangement and selection
Uwe explains how to add a new font to Lout:
You will need two files for each font: an AFM and a PFA/PFB. The AFM (Abode Font Metrics) file describes the metrics of the font, providing incformation about glyph sizes, ligatures, kerning etc which is necessary to Lout. AFM is documented in Adobe's Tech Note #5004, Adobe Font Metrics File Format Specification. For Type1 fonts (widely used under Windows and MacOS) the metrics are usually in PFM (Printer Metrics Format, documented in the Windows 3.x DDK). Ghostscript 6 includes a program called pf2afm which creates an AFM file from a clean PGB/PFA file. When a PFM file is available it uses it to provide better kerning information (as well as extracting other information not available in PFB/PFA files).
Font vendors generally provide both AFM and PFM metrics, so this should not be a problem.
The second file required for printing is a PFA (Printer Format ASCII), which you need to embed in your documents or download to the printer. Most Type1 fonts are in PFB format (Printer Format Binary); you can used pfbtops from the groff distribution or t1ascii from t1utils to convert PFB to PFA.
Ghostscript can use either PFA or PFB (the latter takes less space), but since you will need the PFA anyway, it's simpler to use PFA everywhere.
$LOUTLIB/font
directory or specify
the directory with -F<dir> option. AFM is the only thing
Lout needs or cares about.
If you use a non standard encoding for the font, you will have to
write a LCM (Lout Character Mapping) file describing your
encoding. Generally one of the existing LCMs, such as LtLatin1.LCM
or LtLatin2.LCM will work (see $LOUTLIB/maps
for how Lout
looks for LCM files).
You will then need a fontdef statement to declare the font. You
can put fontdef anywhere you can put a definition, such as in
mydefs.lt
or before the @Include
of your
document setup. You could alternatively append to Lout's
include/fontdefs
file, or create a new file for site
fonts and include it in your setup file. Here is an example
fontdef for a hypothetical Fooney-Regular
font:
fontdef Fooney Base {
Fooney-Regular # font name, see FontName in the AFM
Fooney-Regular.AFM # AFM file
LtLatin1.LCM # LCM file
Recode # Recode (or NoRecode if you
# know what you're doing)
}
Here fontdef Fooney Base
declares Lout's Base face of
family Fooney
. The name Base
is a matter of
convention, standard setups use Base to denote the regular, or
roman or upright or whatever-the-base-face-is-called.
See $LOUTLIB/include/fontdefs
for examples of how
complete families are defined. You just repeat the same steps
for all the fonts in the family, only using Slope
(i.e.
italic) Bold
and BoldSlope
instead of Base
.
Lout will put appropriate %%IncludeResource
DSC comments in its
PostScript output so that your spooler can process it.notes.dsc
in the Lout distribution).
For GhostScript you put the font somewhere where GS can find it
(GS_LIB_DEFAULT compilation parameter, $GS_LIB environment
variable and -I option), and add an entry or the font to the
Fontmap file.
Or you can configure your spooler to perform resource inclusion.
If you use `includeres' from PSUtils then make a symlink to the
font PFA file in the directory where `includeres' looks for
resources. The name of the link should be exactly the font name
without any suffixes.
I have seen a lot of TeX users who embed Postscript fonts
into their documents to make life easier for people who read their
document and don't have appropriate font. Of course such .ps files are
much bigger, but I am wondering if it is possible to do the same with
Lout.
With Ghostscript 6.0 and up, Postscript fonts are automatically embedded. Users of older version will need to use `includeres' from PSUtils (see the Resources section).
Uwe writes: One word of caution, though. Lout put
%%IncludeResource
comments into page setup section, only fonts of
the first page goes to the document setup section. So if you use some
font on every page except the first a copy of font will be inserted
into every page setup section which will really bloat the result. You
might want to move all the %%IncludeResource
comments (for
commonly used fonts) into document setup before running `includeres'.
Note that embedding is not necessary if you're only printing locally:
you can configure your printing software so that it knows the font.
This requires you to download the necessary fonts to the printer's
Postscript interpreter: see Adobe TechNote #5040, or for ghostscript
you simply need to put the PFA or PFB file in the fonts
directory
and add an entry to the Ghostscript Fontmap file. Embedding only
works for Postscript fonts; it is currently not implemented for PDF
documents.
Is it possible to split a two-column page (as in I guess, have a column
break)? The effect I am looking for is:
- some text flow into two columns in the top third/half of a page
- column break signified by a column-spanning ruled line
- more text (also flowing into two columns)
Jeff answers (executive summary: probably not in a way that would suit you or that could be made to happen quickly):
The standard Lout packages are not set up to do this. Someone who set out to write some definitions to do it would strike a problem:
A B
--------
C D
If text flows into A then on into B, the only reason why it would stop flowing into A is because space there runs out. But if space there runs out there would be no space for C either. Lout can't see that it would be a good thing to make columns A and B have equal height.
The only approximation would be to decide in advance how much height
to allow for A and B, and to use a @High
symbol to restrict them
to this height. Then when A fills up the text would flow on to B, but
this filling would occur when the height limit was reached, allowing C
(which is outside the @High
and not affected by it) to receive
other text later.
BibTeX is a widely used format for storing bibliographic references. A few tools to convert bibtex databases to the format required by Lout are available from http://turtle.gis.umn.edu/people/dajm/lout/ (written by David Middleton).
A person coming to Lout from LaTeX will notice several differences
between the systems. With its default settings, Lout takes into
account all inter-word white space (as does troff). You can ask
Lout to use the LaTeX conventions (multiple spaces are treated as
a single space) with the @InitialSpace
option (see the User's
Guide section 1.18).
LaTeX lets you signal non-breaking spaces (as in Dr. Watson, where
you don't want a line break between Dr. and Watson) with a ~
(tilde). The same effect can be obtained in Lout with the
following definition (predefined in recent versions of Lout) :
def "~" left x right y { @OneRow { x &1s y } }
LaTeX considers that an empty line signals the start of a new
paragraph, whereas Lout waits for an explicit @PP
(indented
paragraph) or @LP
(non-indented paragraph) symbol.
You can simulate TeX glue with the following definitions
def @VFill { @VExpand {} }
def @HFill { @HExpand {} }
Here is a list of packages which you may find useful in conjunction with Lout (please send me any additional suggestions):
The Linux Gazette, a free online monthly newsletter, has published two articles mentioning Lout:
Unlike TeX (which Don Knuth has frozen for eternity now that he considers that most bugs have been detected), Lout is evolving. For example, the treatment of whitespace was changed in 1995 (two options were added at users' request). If you have a suggestion for improvement, gripe loutly and Jeff will hear you (to quote Uwe :-).