Special Characters and Commands in PG

  1. Escape characters: Both TeX and Perl have backslash their escape character (think of all the commands that start with backslash like \newline in LaTeX and \n in Perl). Since PG is built on both TeX and Perl, this creates a conflict --- in PG, which language (TeX or Perl) should get to use backslash as its escape character? To resolve this conflict, PG reserves backslash as the escape character for all TeX commands. To get the Perl escape code to work in PG, use two tildes ~~ instead of backslash. When the PG file is executed, the two tildes (in PG mode) will automatically be remapped to backslash (in Perl mode). So, if you have a reference to an array in PG, you should use ~~@array instead of \@array.

  2. A text block in a PG file is enclosed by BEGIN_TEXT and END_TEXT, BEGIN_HINT END_HINT, or BEGIN_SOLUTION END_SOLUTION. Everything in a text block is in a new mode determined by PG, and it is possible to temporarily switch to TeX inline mode using \( \), TeX display mode using \[ \], or Perl mode using \{ \}. Inside a text block, you will not be able to access some special characters like $, %, ^, _ simply by typing them, so PG has special commands for them.
    $DOLLAR  produces $
    $PERCENT produces %
    $CARET   produces ^
    $US      produces _
    
    In a text block, you may want to break a line, create a new paragraph, center text, or make text bold, italic, underlined, or quoted. The commands for these things are different in HTML and TeX, so PG provides you with commands that work properly in both HTML and TeX. Notice that, for example, we have written ${BBOLD}Text made bold${EBOLD} with extra curly braces around ${BBOLD} and ${EBOLD} to keep them from running together with the text they enclose. However, since the centered text is on a separate line from $BCENTER and $ECENTER, there is no chance of things running together and we omit the extra curly braces.
    $BR  produces a line break
    $PAR produces a paragraph break
    
    $BCENTER
    Text made centered
    $ECENTER
    
    ${BBOLD}Text made bold${EBOLD}
    ${BITALIC}Text made italic${EITALIC}
    ${BUL}Text underlined${EUL}
    ${LQ}Quoted text with curly TeX quotes${RQ}
    
    If you want inequalities or curly braces, use TeX's math mode.
    \( < \)       less than
    \( > \)       greater than
    \( \leq \)    less than or equal
    \( \geq \)    greater than or equal
    \( \lbrace \) left curly brace
    \( \rbrace \) right curly brace
    
    The commands just discussed are defined in PGbasicmacros.pl.

Online References