emarsden ->  Lout FAQ/HOWTO

Navigate: Next Previous Contents

5. How do I ... ?

5.1 How do I get quotes (") 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 \\.

5.2 How do I use accented characters in Lout?

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).

5.3 How do I print only a selection of pages of a Lout document?

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

psresize

alter document paper size

psselect

selects pages and page ranges

psbook

rearranges pages into signatures

psnup

put multiple pages per physical sheet of paper

pstops

performs general page rearrangement and selection

5.4 Adding new fonts

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.

5.5 Embedding Postscript fonts in a document

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.

5.6 Flowing text across columns

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.

5.7 Using BibTeX databases

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).

5.8 LaTeXisms

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 {} }
   

5.9 Related resources

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:

5.10 Whah! I want Lout to do this! Lout shouldn't work this way!

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 :-).


Next Previous Contents