# Display Macros

From WeBWorK

(Difference between revisions)

(→Display Macros: fixed typos: $LTE and $LTS mixed up) |
(The example for how to use latex using the latex construction in notes wasn't wrapped in <code> and so it was interpreted) |
||

Line 27: | Line 27: | ||

'''Notes''' | '''Notes''' | ||

− | <blockquote> 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.<br /><br /> * The codes for displaying mathematics (<code>$BM</code> begin math, <code>$EM</code> end math, <code>$BDM</code> begin display math and <code>$EDM</code> 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 <code>BEGIN_TEXT/END_TEXT</code> block, or which is processed by "EV3". <br /><br /> * 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 <code>$LE</code> or <code>$LGE</code>. Similarly for other mathematical symbols. <br /> If you reassign the value of <code>$PAR</code> or other variables in this section you will probably get the trouble you deserve, although unfortunately I can't guarantee it. Fortunately the macro <code>PAR() </code>is a bit harder to redefine.</blockquote> | + | <blockquote> 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.<br /><br /> * The codes for displaying mathematics (<code>$BM</code> begin math, <code>$EM</code> end math, <code>$BDM</code> begin display math and <code>$EDM</code> 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 <code>\( ...math mode here ...\)</code> or <code>\[ ... display math on separate line mode ...\]</code> for mathematics which is in a <code>BEGIN_TEXT/END_TEXT</code> block, or which is processed by "EV3". <br /><br /> * 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 <code>$LE</code> or <code>$LGE</code>. Similarly for other mathematical symbols. <br /> If you reassign the value of <code>$PAR</code> or other variables in this section you will probably get the trouble you deserve, although unfortunately I can't guarantee it. Fortunately the macro <code>PAR() </code>is a bit harder to redefine.</blockquote> |

[[Category:manpages]] | [[Category:manpages]] |

## Latest revision as of 16:00, 1 October 2019

### 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 modegreater than or equal

$GTS or GTS() --deprecated -- use > in math modestrictly greater than

$LB or LB ()left brace

$LBRACE or LBRACE()left brace

$LQ or LQ()left double quote

$LTE or LTE() -- deprecated-- use backslash le in math modeless than or equal

$LTS or LTS() -- deprecated-- use < in math modestrictly 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.