LaTeX Tips And Traps
Contents
LaTeX Tips and Traps
Problem authors can type virtually any LaTeX construct in a WeBWorK (PG) problem. There's a few caveats, though.
Remember that the source code of the problem is first interpreted by Perl. The preprocessed, embedded LaTeX code is then passed along to LaTeX for rendering. This means that your code can vary the input that is presented to LaTeX.
Dollar Sign
This procedure requires that the input code be valid Perl code. Since Perl uses the dollar sign '$
' to indicate a (scalar) variable name, we cannot use the '$
' sign in our LaTeX. Instead, use \(
and \)
to begin and end inline LaTeX math mode, and \[
and \]
to begin and end LaTeX display mode.
Percent Sign
LaTeX interprets a percent sign (%
) as starting a comment, which extends to the end of the line. To avoid confusion, wherever you need to have a percent sign appear in a problem, use the $PERCENT
display macro.
Right and Left Braces
LaTeX uses \{
to indicate a left brace, and \}
to indicate a right brace. The problem authoring language PG, however, uses this construction to indicated that text enclosed by \{ \}
is to be interpreted by Perl, and the result substituted. Thus: when typing a brace in LaTex, use \lbrace or \rbrace.
Backslashes
Since backslashes have meaning in both Perl and LaTeX, a literal backslash should be typed as ~~
(a double tilde).