Difference between revisions of "Display Macros"

From WeBWorK_wiki
Jump to navigation Jump to search
m (DisplayMacros moved to Display Macros: consistent naming)
(The example for how to use latex using the latex construction in notes wasn't wrapped in <code> and so it was interpreted)
 
(One intermediate revision by one other user not shown)
Line 11: Line 11:
 
'''Params'''
 
'''Params'''
   
<blockquote> Style and Formatting Constants<blockquote> $BBOLD or BBOLD()<blockquote> begin bold typeface</blockquote><br /> $BCENTER or BCENTER()<blockquote> begin centered environment</blockquote><br /> $BDM or BDM() -- deprecated -- use \[<blockquote> begin display math</blockquote><br /> $BEGIN_ONE_COLUMN or BEGIN_ONE_COLUMN()<blockquote> begin one-column mode</blockquote><br /> $BITALIC or BITALIC()<blockquote> begin italic typeface</blockquote><br /> $BM or BM() -- deprecated -- use \(<blockquote> begin math</blockquote><br /> $BR or BR()<blockquote> line break character</blockquote><br /> $CARET or CARET()<blockquote> a caret sign</blockquote><br /> $E or E()<blockquote> the number e</blockquote><br /> $EBOLD or EBOLD()<blockquote> end bold typeface</blockquote><br /> $ECENTER or ECENTER()<blockquote> end centered environment </blockquote><br /> $END_ONE_COLUMN or END_ONE_COLUMN()<blockquote> end one-column mode</blockquote><br /> $EDM or EDM() -- deprecated -- use \]<blockquote> end display math</blockquote><br /> $HR or HR()<blockquote> horizontal rule</blockquote><br /> $EITALIC or EITALIC()<blockquote> end italic typeface</blockquote><br /> $EM or EM() -- deprecated -- use \)<blockquote> end math</blockquote><br /> $PAR or PAR() <blockquote> paragraph character (\par or &lt;p&gt;)</blockquote></blockquote><br /> Symbol and Math Typesetting Constants<blockquote> $DOLLAR or DOLLAR()<blockquote> a dollar sign</blockquote><br /> $GTE or GTE() --deprecated -- use backslash ge in math mode<blockquote> greater than or equal</blockquote><br /> $GTS or GTS() --deprecated -- use &gt; in math mode<blockquote> strictly greater than</blockquote><br /> $LB or LB ()<blockquote> left brace</blockquote><br /> $LBRACE or LBRACE()<blockquote> left brace</blockquote><br /> $LQ or LQ()<blockquote> left double quote</blockquote><br /> $LTE or LTE() -- deprecated-- use &lt; in math mode<blockquote> less than or equal</blockquote><br /> $LTS or LTS() -- deprecated-- use backslash le in math mode<blockquote> strictly less than</blockquote><br /> $PERCENT or PERCENT()<blockquote> a percent sign</blockquote><br /> $PI or PI() <blockquote> the number pi (use backslash pi in math mode for the symbol)</blockquote><br /> $RB or RB ()<blockquote> right brace</blockquote><br /> $RBRACE or RBRACE()<blockquote> right brace</blockquote><br /> $RQ or RQ() <blockquote> right double quote</blockquote><br /> $SPACE or SPACE()<blockquote> space character (tex and latex only)</blockquote><br /> $US or US()<blockquote> underscore character _</blockquote></blockquote><br /> Other constants<blockquote> $HINT or HINT_HEADING()<blockquote> hint headline</blockquote><br /> $SOL or SOLUTION_HEADING()<blockquote> A standardized way of entering the solution heading. See also "solution()"</blockquote><br /> $SOLUTION or SOLUTION_HEADING()<blockquote> solution headline</blockquote><br /> @ALPHABET or ALPHABET() <blockquote> an array of the capital letter alphabet -- ALPHABET[0] = 'A' <br />for use in labeling answers or questions.</blockquote></blockquote></blockquote>
+
<blockquote> Style and Formatting Constants<blockquote> $BBOLD or BBOLD()<blockquote> begin bold typeface</blockquote><br /> $BCENTER or BCENTER()<blockquote> begin centered environment</blockquote><br /> $BDM or BDM() -- deprecated -- use \[<blockquote> begin display math</blockquote><br /> $BEGIN_ONE_COLUMN or BEGIN_ONE_COLUMN()<blockquote> begin one-column mode</blockquote><br /> $BITALIC or BITALIC()<blockquote> begin italic typeface</blockquote><br /> $BM or BM() -- deprecated -- use \(<blockquote> begin math</blockquote><br /> $BR or BR()<blockquote> line break character</blockquote><br /> $CARET or CARET()<blockquote> a caret sign</blockquote><br /> $E or E()<blockquote> the number e</blockquote><br /> $EBOLD or EBOLD()<blockquote> end bold typeface</blockquote><br /> $ECENTER or ECENTER()<blockquote> end centered environment </blockquote><br /> $END_ONE_COLUMN or END_ONE_COLUMN()<blockquote> end one-column mode</blockquote><br /> $EDM or EDM() -- deprecated -- use \]<blockquote> end display math</blockquote><br /> $HR or HR()<blockquote> horizontal rule</blockquote><br /> $EITALIC or EITALIC()<blockquote> end italic typeface</blockquote><br /> $EM or EM() -- deprecated -- use \)<blockquote> end math</blockquote><br /> $PAR or PAR() <blockquote> paragraph character (\par or &lt;p&gt;)</blockquote></blockquote><br /> Symbol and Math Typesetting Constants<blockquote> $DOLLAR or DOLLAR()<blockquote> a dollar sign</blockquote><br /> $GTE or GTE() --deprecated -- use backslash ge in math mode<blockquote> greater than or equal</blockquote><br /> $GTS or GTS() --deprecated -- use &gt; in math mode<blockquote> strictly greater than</blockquote><br /> $LB or LB ()<blockquote> left brace</blockquote><br /> $LBRACE or LBRACE()<blockquote> left brace</blockquote><br /> $LQ or LQ()<blockquote> left double quote</blockquote><br /> $LTE or LTE() -- deprecated-- use backslash le in math mode<blockquote> less than or equal</blockquote><br /> $LTS or LTS() -- deprecated-- use &lt; in math mode<blockquote> strictly less than</blockquote><br /> $PERCENT or PERCENT()<blockquote> a percent sign</blockquote><br /> $PI or PI() <blockquote> the number pi (use backslash pi in math mode for the symbol)</blockquote><br /> $RB or RB ()<blockquote> right brace</blockquote><br /> $RBRACE or RBRACE()<blockquote> right brace</blockquote><br /> $RQ or RQ() <blockquote> right double quote</blockquote><br /> $SPACE or SPACE()<blockquote> space character (tex and latex only)</blockquote><br /> $US or US()<blockquote> underscore character _</blockquote></blockquote><br /> Other constants<blockquote> $HINT or HINT_HEADING()<blockquote> hint headline</blockquote><br /> $SOL or SOLUTION_HEADING()<blockquote> A standardized way of entering the solution heading. See also "solution()"</blockquote><br /> $SOLUTION or SOLUTION_HEADING()<blockquote> solution headline</blockquote><br /> @ALPHABET or ALPHABET() <blockquote> an array of the capital letter alphabet -- ALPHABET[0] = 'A' <br />for use in labeling answers or questions.</blockquote></blockquote></blockquote>
   
 
'''Returns'''
 
'''Returns'''
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 (&lt;), 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 (&lt;), 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 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 backslash le in math mode

less than or equal


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