Forum archive 2000-2006

Zbigniew Fiedorowicz - predefined PG constants

Zbigniew Fiedorowicz - predefined PG constants

by Arnold Pizer -
Number of replies: 0
inactiveTopicpredefined PG constants topic started 2/19/2001; 11:32:00 AM
last post 2/20/2001; 11:00:43 AM
userZbigniew Fiedorowicz - predefined PG constants  blueArrow
2/19/2001; 11:32:00 AM (reads: 931, responses: 1)
There used to be some documentation on predefined PG constants for use in the problem text, stuff like $PAR, $BR, etc. I can't seem to find this documentation any more.

Specifically I was looking for how to write the dollar sign symbol $ in the problem text without getting it interpreted by either TeX or PERL.

After some experimentation I found that defining a PERL variable

$dollar = '~~$';

and using $dollar in the problem text would more or less work. There is a slight drawback: in formatted-text mode, the dollar sign is preceded by an unwanted backslash. Omitting the escapes ~~ in the definition of $dollar gets rid of the backslash in formatted-text mode, but then l2h mode doesn't work.

Is there a better solution?

Zig

<| Post or View Comments |>


userMichael Gage - Re: predefined PG constants  blueArrow
2/20/2001; 11:00:43 AM (reads: 1174, responses: 0)
Hi,

The list of defined constants is here:

http://webhost.math.rochester.edu/webworkdocs/docs/pglanguage/pod/PGbasicmacros#display%20constants

(I'll also try to make a more prominent link to this information, but I won't be able to do that right away.)

For a US dollar sign use

$DOLLAR

or

DOLLAR() a dollar sign

 

We use MODES() to define $DOLLAR appropriately for each displayMode. You can see how this works by looking inside PGbasicmacros.pl at the subroutine DOLLAR().

sub DOLLAR { MODES( TeX => '\$', Latex2HTML => '\$', HTML => '$' ); };

Note that in a macro.pl file (as opposed to a .pg file) the backslash is NOT protected. These are pure perl files with no preprocessing. This means that in a macro.pl file every TeX command has to begin with a double backslash, but also that one can use the backslash as in perl (~~ is not defined in pure perl).

(This is a minor headache if you first define a subroutine in a problem.pg file and then later transfer it to a macro.pl file. You will need to replace all backslashes with double backslashes and all occurences of ~~ with a single backslash. The reasoning behind this design is that while in a problem file you use TeX as much or more than perl, in a macro file you use perl more than TeX. Constantly having to use double backslashes in a problem file was a major source of frustration.)

-- Mike

<| Post or View Comments |>