Display Macros

From WeBWorK_wiki
Revision as of 20:18, 18 November 2009 by Aubreyja (talk | contribs) (DisplayMacros moved to Display Macros: consistent naming)
Jump to navigation Jump to search

Display Macros

Description

These variables and their corresponding macros are initialized to produce the correct markup symbols (either TeX or HTML) depending on the context in which the problem is rendered. For example $PAR will either become <p> for HTML output, or \par for TeX output. Always use these variables instead of entering HTML markup directly so that the problems will be correctly rendered on both webpages (which uses HTML) and for PDF or hardcopy (which uses TeX).

Syntax

Within a BEGIN_TEXT/END_TEXT paragraph you can use the variable $PAR or execute the macro: \{PAR()\}.
Outside the BEGIN_TEXT/END_TEXT context either the variable $PAR or the macro form PAR() can be used directly in perl code. In general $PAR is easier to use for most purposes, but the macro version PAR() can also be useful when constructing other macros.

Params

Style and Formatting Constants

$BBOLD or BBOLD()

begin bold typeface


$BCENTER or BCENTER()

begin centered environment


$BDM or BDM() -- deprecated -- use \[

begin display math


$BEGIN_ONE_COLUMN or BEGIN_ONE_COLUMN()

begin one-column mode


$BITALIC or BITALIC()

begin italic typeface


$BM or BM() -- deprecated -- use \(

begin math


$BR or BR()

line break character


$CARET or CARET()

a caret sign


$E or E()

the number e


$EBOLD or EBOLD()

end bold typeface


$ECENTER or ECENTER()

end centered environment


$END_ONE_COLUMN or END_ONE_COLUMN()

end one-column mode


$EDM or EDM() -- deprecated -- use \]

end display math


$HR or HR()

horizontal rule


$EITALIC or EITALIC()

end italic typeface


$EM or EM() -- deprecated -- use \)

end math


$PAR or PAR()

paragraph character (\par or <p>)


Symbol and Math Typesetting Constants

$DOLLAR or DOLLAR()

a dollar sign


$GTE or GTE() --deprecated -- use backslash ge in math mode

greater than or equal


$GTS or GTS() --deprecated -- use > in math mode

strictly greater than


$LB or LB ()

left brace


$LBRACE or LBRACE()

left brace


$LQ or LQ()

left double quote


$LTE or LTE() -- deprecated-- use < in math mode

less than or equal


$LTS or LTS() -- deprecated-- use backslash le in math mode

strictly less than


$PERCENT or PERCENT()

a percent sign


$PI or PI()

the number pi (use backslash pi in math mode for the symbol)


$RB or RB ()

right brace


$RBRACE or RBRACE()

right brace


$RQ or RQ()

right double quote


$SPACE or SPACE()

space character (tex and latex only)


$US or US()

underscore character _


Other constants

$HINT or HINT_HEADING()

hint headline


$SOL or SOLUTION_HEADING()

A standardized way of entering the solution heading. See also "solution()"


$SOLUTION or SOLUTION_HEADING()

solution headline


@ALPHABET or ALPHABET()

an array of the capital letter alphabet -- ALPHABET[0] = 'A'
for use in labeling answers or questions.

Returns

A string containing the appropriate HTML or TeX markup.

Examples

* To force a line break at the end of this sentence use $BR
(stands for break)

* To force a new paragraph (usually indicated by either indentation or a skipped line or both) use: $PAR

(stands for paragraph).

* To make the entire problem occupy a double column space across the page the code looks something like:
DOCUMENT();
loadMacros(.....);
TEXT($BEGIN_ONE_COLUMN);
TEXT(beginproblem());
.... bulk of problem here......
TEXT($END_ONE_COLUMN);
ENDDOCUMENT();

Notes

Many markup symbols come in pairs, e.g. $BBOLD and $EBOLD ('begin bold' and 'end bold') is used to bracket a section of text which is to be rendered in boldface type.

* The codes for displaying mathematics ($BM begin math, $EM end math, $BDM begin display math and $EDM end display math) are used in the macros "EV2" and "EV3" and some old demonstration problems, however it is better to use the constructions borrowed from LaTeX \( ...math mode here ...\) or \[ ... display math on separate line mode ...\] for mathematics which is in a BEGIN_TEXT/END_TEXT block, or which is processed by "EV3".

* Within the math modes, the latex codes for less than (<), or less than or equal (backslash le) can be used instead of the more cumbersome $LE or $LGE. Similarly for other mathematical symbols.
If you reassign the value of $PAR or other variables in this section you will probably get the trouble you deserve, although unfortunately I can't guarantee it. Fortunately the macro PAR() is a bit harder to redefine.