Qs: Quickscript

Quickscript layout marks described by category

Text Style

%FN,name% Change font family. The font name is given by a three or four letter code. Unrecognized codes will be ignored.
Tim (Times) Hel (Helvetica)
Cou (Courier) Sym (Symbol)
Pal (Palatino) NewC (New Century Schoolbook)
Book (Bookman) Ava (Avant Garde)
Cha (Zapf Chancery) HelN (Helvetica Narrow)
Din (Zapf Dingbats) Uft User­defined
U2 User­defined U3 User­defined
%FN,Tim% (Times­Roman) is the default. Only the first four families are guaranteed to be present in a PostScript machine.
%FN% If no name is given, the font in use before the last change will be used. A history of eight fonts is maintained, allowing progressive undo of font changes to a limited extent.
%SZ,number% Set the font height in printer's points. A printer's point is 1/72 of an inch. Inter­line spacing is 1.17 times the chosen height. Default size is 12 on 14.
%SZ% If no number is given, the size in use before the last change will be used. A history of the most recent eight sizes is maintained, allowing progressive undo of size changes to a limited extent.
%SN,number% Set the font height in printer's points, but do not alter the inter­line spacing.
%SN% If no number is given, the size in use before the last change will be used. A history of the most recent eight sizes is maintained, allowing progressive undo of size changes to a limited extent.
%BD% Bold typeface. To undo this command, use %LT%.
%LT% Light typeface, the opposite of bold.
%IT% "Italic", or slanted font style. To undo this command, use %RO%.
%RO% "Roman", or normal vertical font style, the opposite of Italic.
%NF% No fill; lines input will not be reformated to fill the lines output. Each line of input will become a separate line in output. Words are still checked to ensure that they will fit in the output line, and a new line will be forced if words do not fit. This is used frequently for setting poetry, songs, program listings, addresses, and simple tables. See also %FI% and %\%.
%NF,number% No fill; if input lines will not fit in the space provided, the line will be split at a word boundary, and the line continuation will be indented by number millimeters. Remembered positions can be specified with the "?" notation; see %W below.
%\% Ignore any following text on the line. This enables comments to be included in a document. If "no fill" (%NF) applies, treat the following line as a continuation of the current one.
%FI% Resume the default behaviour of output line filling (after a %NF directive). The lines of input are split into words, and output so as to fill the lines within the set margins.
%^% Make the following text a superscript. It is not possible for superscripts themselves to have subscripts or superscripts. The end of the superscript is indicated by %=%.
%V% Make the following text a subscript. It is not possible for subscripts themselves to have subscripts or superscripts. The end of the subscript is indicated by %=%.
%=% Return to normal size and position after super­ or subscript.
%TC,r,g,b% Set the colour for following text. r,g,b must be in the range from zero to one.
%TC% Restore the text colour to black.

Special Characters

%C,number%
%C,glyphname%
Special characters can be output by specifying the decimal value of the character in the PostScript extended ASCII table, or the internal name of the character in the font. Several numbers or names can be specified, separated by commas.

Eg.
Name PostScript
code
European
code
Name PostScript
code
European
code
Dash %C,208% %C,132% Bullet %C,183% %C,128%
Minus %C,177% %C,138% Degrees %C,202% %C,30%
Minutes %C,194% %C,180% Seconds %C,205% %C,28%
Pounds %C,163% %C,163% Cents %C,162% %C,162%
Decimal point %C,180% %C,183%

The numbers used will change if ISO Latin­1 encoding (European Characters) is used. A full set of character code numbers and names is available.

If you prefer to use octal numeric code as given in the PostScript reference manual and elsewhere, this is possible with %C,8#number%.

%_% Output a blank character, and do not allow the space to be the place where a line break occurs. Sometimes, spaces are wanted within a word, eg. a telephone number 268 8111. To ensure that no line break occurs at the gap, it is represented by 268%_%8111.
%% Output a % symbol. Whatever character is used to mark Quickscript layout instructions (% by default), then repeating the character enables it to be output in ordinary text.

In many situations, a single % can be typed and it will be treated as a single character to be output. However, Quickscript will look at the next character to see if it can be interpreted as a layout command, and if so, all following characters up to the next % will be taken to be part of that command.

%DF,n,ch% Dot fill using n is an optional position on the page, and ch is an optional fill­character. It has a similar effect to %TR, but in moving rightwards to the given position, dots are placed regularly along the current line. If the number is not given, dots fill out to the right margin. If a character or numeric code is given after the number, this character is used instead of a dot.

Vertical placement

%NP% Start a new page. If no output has been placed on the current page, no action will result.
%L% Go to the start of a new line. The horizontal position is based on the left margin set by the most recent %TB instruction, plus the paragraph body alignment. If no output has been placed on a page, %L% will not move down the page.
%L,n% Go to a new line, leaving an extra 'n' blank lines. %L,0% is equivalent to %L%. %L,-1% will go to the start of the current line. Fractional line spacings are allowed.
%LP% Move to start of the previous line. In general, this could be achieved with %L,-2%. However, if the current position is at the top of the page, this will have undesirable consequences which %LP% avoids.
%P% Start a new paragraph. The parameters of the paragraph will be the same as the previous paragraph.

By default, paragraphs have the body aligned with the left margin; there is no first line indentation; a blank line is left between paragraphs; and a new paragraph will not start within two lines of the bottom of the page, but instead be placed at the top of the next page.

%P,n1,n2,n3,n4% Start a new paragraph. Set the body alignment n1 MM to the right of the current tab margin. Indent the first line relative to the body by n2 MM. Set the inter­paragraph gap to one plus n3 blank lines; setting n3 to 0 will leave a single blank line between paragraphs, and setting n3 to -1 will cause new paragraphs to commence on a new line with no intervening blank line. Set the minimum acceptable distance from the bottom of the page for the start of a new paragraph to n4 MM; the default n4 is 30 MM. If the distance n4 is more easily measured as a number of inter­line gaps, this can be done by preceding the number with the character "L".

Any of the numeric fields can be altered without affecting the others, by simply not providing numbers for the unchanging field. Eg. %P,,,-1% will go to a new paragraph, leave unchanged the body alignment and first line indentation, and set the inter­paragraph gap to zero (1 - 1) lines.

Typical uses of these controls are:
%P,,10% will cause paragraphs to have their first lines indented by 10 MM, but normal body alignment.
%P,20,0% would be used for including a quotation in a body of text. The whole quotation would be indented relative to the main text.
%P,0,0,0% would restore paragraph layout to the default.
%P,15,-15% would have a hanging first line. The body is indented 15 MM, but the first line is aligned with the normal margin. This is useful for references, or for drawing attention to the first word of a paragraph.

If no output has been placed on a page, a new paragraph request will not move the current point down the page.

See also %PF to set paragraph style without commencing a new paragraph.

%PF,n1,n2,n3,n4% Modify the attributes of this and following paragraphs, but do not force a new paragraph immediately. The numbers are the same as for the %P% command. It is used mostly to modify the next inter­paragraph gap or the body alignment of the remainder of this paragraph, and is particularly useful in tables where the text in each cell is to commence at the top of its area, but the cells are to have different first line indentation or body alignment.
%PH,n1,n2,n3,n4% This is the same as the %P% command, except that the minimum distance from the bottom of the page is increased to 2.5 times the normal distance. This makes it suitable before a paragraph heading, where space for the heading and some of the following paragraph must be guaranteed.
%VM,n% Vertical move from the present position, to the start of the line the requested number of millimeters below. If the new position is below the bottom margin, go to a new page and move down the requested distance. It guarantees that an unbroken space of the requested size is left. If the current position is not at the start of a line, it will be moved to the start of the next line before moving down the requested distance.

If you know how many lines rather than millimeters are to be left empty, this can specified with an "L" before the number (%VM,L-2% will move up by 2 lines).

%VM can be used to prevent widow lines at the start of a section or paragraph that might fall at the end of a page. Eg. %VM,20%%VM,-20% will go to the start of a line with at least 20 MM clear space below it. If there is not 20 MM at the foot of a page, it will go to the top of the next page.

%VT,n% Vertical tab: Go to the start of a new line at the given position from the top of the page, measured in millimeters.

%VT,0% moves to the start position on the page. This will vary in response to current font size, to prevent large text from going beyond the strict page limits.

It is also possible to move to a line number remembered from a %W command using the "?" notation.

%W% Record the X,Y coordinates of the current position for later use. The position is referred to with the character '?' in VT, T, TB, TR, DF, RL, P, PH, ST, CL or NF instructions. Eg. %W% at a point in a document will record the position so that %VT,?% will move to the same vertical position. In use with %P, only the body alignment can be set this way.
%W,number% Record the X,Y coordinates of the current position, to be identified with the given number. It may be referred to in VT, T, TB, TR, DF, RL, P, PH, ST, CL or NF instructions with '?number'.

Horizontal placement

%CT% Centre the following text between the current left and right column margins. Text will still be measured to see how many words will fit on each line, and lines will be broken accordingly unless deliberately broken by some other formating instruction. Alternatives to this are FJ, LJ, or RJ. See also CL and RL.
%FJ% Set full­justification (left and right) for output of following text. Alternatives to this are LJ, RJ, or CT. See also CL and RL.
%LJ% Left justify the following output text. This is the default behaviour, which is sometimes called "ragged right". Alternatives to this are FJ, RJ, or CT. See also CL and RL.
%RJ% Right justify the following output text. Alternatives to this are FJ, LJ, or CT. See also CL and RL.
%CL% Centre the single line of text that follows between the current left margin and the current column right margin. No new­line is automatically generated (Beware!).

It is also possible to request that the line be centred about a certain position, with %CL,pos%, the position given as MM from the left margin.

%RL% The remainder of the line, or all characters up to the next positioning Quickscript command on the current input line, are to be right­justified on the output line.

If the text is to be right­justified to a certain position, this can be done with %RL,pos%, the position in MM.

%T,n% Move horizontally to the position, measured in millimetres, relative to the default left margin, on the current line only. It provides a local "go to".

For details of %T,?%, see %W% below.

%T% If no number is given, go to the current left margin, as set in the most recent %TB plus the current paragraph body alignment.
%T,+n% Move horizontally to the position, measured in millimeters, relative to the current left margin, on the current line only.
%TB,number% Move to a new left­hand tab margin, measured in millimetres, relative to the default left margin. All following text will be set to this margin.

Paragraph alignment will be relative to this position, so %TB,10%%P,5% will have the paragraph aligned to 15 MM from the normal left margin. %P,5%%TB,10% will have the same effect, except that the first line of this paragraph will commence 10 MM from the normal left margin, because the %TB sets the new margin as well as an immediate repositioning.

For details of %TB,?%, see %W% below.

%TB% Revert to the previous left margin, saving the current margin in case a %TB% is again encountered.
%TB,+n% Move to and set a new left­hand tab margin, measured in millimeters, relative to the current left margin, remembering the old one.
%TR,n% Move horizontally rightwards to the position, measured in millimeters, relative to the default left margin, on the current line only. If the current position is already to the right of this position, do not move left; current position will be unchanged. Remembered positions can be specified with the "?" notation; see %W below.
%TR,+n% Move horizontally rightwards to the position, measured in millimeters, relative to the current left margin, on the current line only.
%W% Record the X,Y coordinates of the current position for later use. The position is referred to with the character '?' in VT, T, TB, TR, DF, RL, P, PH, ST, CL or NF instructions. Eg. %W% at a point in a document will record the position so that %T,?% subsequently will tab across to the same horizontal position, and %VT,?% will move to the same vertical position. In use with %P, only the body alignment can be set this way.
%W,number% Record the X,Y coordinates of the current position, to be identified with the given number. It may be referred to in VT, T, TB, TR, DF, RL, P, PH, ST, CL or NF instructions with '?number'.

Eg. Very simple tables can be set up by defining tab positions, say at 10 MM, 50 MM, and 100 MM. These positions are recorded with
%T,10%%W,1% %T,50%%W,2% %T,100%%W,3%
The data in the table is then set by referring in turn to the positions as
%T,?1% %T,?2% %T,?3%
If a column is subsequently found to be too narrow, it can be widened by changing the numbers in the one line where the settings are recorded.

Up to fifty positions can be remembered in this way. In general, the %ST method of creating a table is greatly superior to simple use of remembered positions.

%P...% See the paragraph commands under "Vertical Placement" above.

Tables

%ST,pos,pos,pos...% Start a table based on the given positions that define the margins of each column. The position is measured in MM from the normal left margin, or can be remembered positions (see %W% below). Text following this will be placed in the first column. A trailing comma signifies the right margin of the page. See %CO% to change column, %VL% to draw vertical lines separating selected columns, %HL% to draw horizontal lines below a row, %TJ% to set the justification rule for the columns, %NR% to commence a new row, and %ET% to end a table.
%ET% End the table, restoring column margins and justification rule to the state prior to the table. Leave the current point at the lower right corner.
%NR% Start a new row of the current table, moving to the first column for following text.
%NR,number% Start a new row of the current table, moving to the column indicated by the number for following text.
%CO% Commence a cell in a new column of the table in the current row.
%CO,n% Commence a cell in column "n" of the table in the current row, where "n" is a number such as 2, 3, etc.
%CO,n1,n2% Commence a cell in column "n1" that will span the columns from "n1" to "n2" of the table in the current row, where "n1" and "n2" are numbers such as 2, 3, etc.
%TJ,chars% Set the justification rule to apply to each column of the current table. The rule is specified as a lower­case character: 'l' for left justified (the default), 'c' for centred, 'r' for right­justified, and 'f' for fully justified (ie both left and right). The characters are not separated by commas. %TJ,ccr% would mean that the first and second columns were to be centred, and the third right­justified.
%HL% Draw a horizontal line across the full width of the table below the current row, or at the top if nothing has yet been placed in the table.
%HL,n% Draw a horizontal line below cell "n" of the current row, or above if the table is still empty.
%HL,n1,n2% Draw a horizontal line spanning the cells "n1" to "n2" below the current row, or at the top if nothing has yet been placed in the table.
%HLn,...% Each of the above forms of line instruction can include a line width "n" before the comma. %HL2% will give a double­width line; %HL3,2% will draw a triple­width line below column two.
%VL,n1,n2,...% Record the table boundary positions where vertical lines are to be drawn, eg %VL,1,2,5% will draw vertical lines at the first, second and fifth table margins defined in the most recent %ST instruction. Numbers can be repeated, indicating that those lines are to have double thickness: %VL,1,1,1,5,5,5% will place thick boundaries at the first and fifth margins, but not at intervening positions. Vertical line information is cleared by a %ST instruction, so %VL must be placed after the start of the table. Vertical line placement can be modified within a table.
%VL% Do not draw vertical lines in the table.
%BC,col1,col2,r,g,b% Set the background colour in a table for the range of columns from col1 to col2. The first column is column 1. r,g,b must be in the range from zero to one in value.
%BC,col1,col2% Turn off the background colour in the table for the range of columns from col1 to col2.
%BC% Turn off the background colour in the table.

Page Organization

%PM,l,r,t,b% Set the page margins, the distance from the page edges to the text margins. By default, these are 25, 19, 25, 19 MM for left, right, top and bottom. Numbers omitted are left unchanged. Current point is not altered (so a %VT may be needed following this at the start of a document).
%PN% Number the pages, starting at page two on the following page.
%PN,number% Number the pages, starting with the given number on the current page. If the number is zero, page numbering will be disabled.
%CW,n% Column width, or more correctly, position of the right­hand column margin relative to the current left column margin, measured in millimetres. For single­column output this is no different from the page width. For single­ or multi­column output, this enables local control of the right margin in the same way that %TB controls the local left margin.

Its effect can be undone with %CW%, which reverts to the previous column width. The column width can be increased or decreased by having a "+" or "-" before the number. %CW is useful for building tables.

This is unrelated to the "column" of a table which is specified through the %ST and %CO instructions. It refers to the right margin of text within an ordinary document whether the pages are multi­columnar or a single column.

%NC,number% Change the following page layout to multi­columns. number is the number of columns. If this command is issued part way down a page, the multi­columnar layout commences from that position, so that text above is not overwritten.
%NC% Go to the top of the next column. In single column layout, this will cause a new page.

Document Organization

%SH% Start recording text for the page header, to appear beside the page number. See %EH.
%EH% Stop recording text for the page header that will appear beside the page number. See %SH.
%SC% Start recording text to make an item in the table of contents. See %EC, %OC, %PC, %CA.
%EC% Stop recording text for an entry in table of contents. Add the page number. See %SC, %PC, %OC, %CA.
%OC% Output the text for the table of contents to the screen or standard output. See also %PC.
%PC% Print the table of contents in the document at this point. Each line of the contents will contain the markers %DF,?%%RL% before the page number. This will give a dotted line from the text to a horizontal position that must already have been set up with a %W%. The page number will be right­justified within the column. It may be necessary to use a narrower column (see %CW) to improve appearance. It will also be necessary to change the current page number (%PN) if this page is to be inserted early in the document.
%SI% Start recording text to make an item in the index. See %EI, %OI, %PI, %CA.
%EI% Stop recording text for an entry in the index. Add the page number. See %SI, %PI, %OI, %CA.
%OI% Output the text for the index to the screen or standard output. See also %PI.
%PI% Print the index at this point in the document. Each item will be on a new line. Multi­column (%NC) format should be set first to improve layout.
%CA,text% Contents abbreviation. This defines the text which will appear left-abutted to the page number in a table of contents or index. It can be used to specify a short name or number for a chapter. Eg. %CA,Ch.1-%
%\% Ignore any following text on the line. This enables comments to be included in a document. If "no fill" (%NF) applies, treat the following line as a continuation of the current one.

Embedded PostScript

%PS commands% Execute the PostScript commands that follow %PS (beware strings).
Eg. %PS /IlGap 1.8 def%%SZ,12%
will cause text to be output double spaced. This means of embedding raw PostScript instructions within a document is suitable if the instructions can be fitted into a single input line. It allows access to the Quickscript procedures and variables. It is unsuitable for changing the content of text strings. (The %SZ command is required in the above example because the line spacing is calculated from the inter­line gap and the text size, and just altering the inter­line gap factor will not directly alter line spacing.)
%PS% The following input text will be interpreted as embedded PostScript by the PostScript interpreter. Anything following on the current input line is ignored. To revert to normal text processing by Quickscript, use the PE PostScript command. The Quickscript environment is no longer current, so accidental redefinition of names of Quickscript procedures or variables is prevented. If you need access to them, the Quickscript dictionary must be used, either with
    QSdict begin...end
or
    QSdict /name value put
PE Flag the end of embedded PostScript; the following text will be processed normally by Quickscript. Note the absence of % delimiting characters. This is actually a PostScript procedure within Quickscript.

Colour

%TC,r,g,b% Set the colour for following text. r,g,b must be in the range from zero to one.
%TC% Restore the text colour to black.
%BG,r,g,b,left,right%
%BG,r,g,b%
Set the background colour for a block of text. r,g,b must be in the range from zero to one in value. The background will be set from the normal left margin minus left to the normal right margin plus right. These two distances are interpreted as millimeters; if they are omitted, 14 pp and zero respectively will be used.
%BG% Turn off the background colour.
%BC,col1,col2,r,g,b% Set the background colour in a table for the range of columns from col1 to col2. The first column is column 1. r,g,b must be in the range from zero to one in value.
%BC,col1,col2% Turn off the background colour in the table for the range of columns from col1 to col2.
%BC% Turn off the background colour in the table.