This group of tags generates useful output.
- algebra: Typesets algebraic expressions
<algebra>2x^y+sqrt(3/x^2)</algebra>
Expressions are displayed using the math expression display mechanism for the current context. The default is to use
the display mechanism the user has selected in preferences. This can be overriden by setting the display attribute for the tag. See the section below concerning the < m > tag for more information on how the default is set and on the display attribute.
Recognized functions are all trigonometric functions, and the following:
exp, abs, logten, log, ln, sqrt, sgn, step, fact, int, lim, funX.
- chem: Typesets chemical equation :
<chem>O2 + 2H2 -> 2H2O</chem>
will be rendered:
O2 + 2 H2 ® 2 H2O
Syntax Description
- Reactants are separated from products by '->'.
- Individual reactants and products are separated by ' +' (leading space is obligatory).
- Numbers preceding the first symbol of a chemical specie are considered to be stoichiometric coefficients.
- Numbers appearing after the first symbol of a chemical specie are considered to be subscripts.
- Superscripts are initialized by '^' and terminated by a space.
- Ionic charges are superscripts composed of a number followed by a sign (i.e. '^2+').
More examples
- Ca(NO3)2 is written as:
Ca(NO3)2
- OH- + H3O+ ® 2H2O is written as:
OH^- + H3O^+ -> 2H2O
- [Co(H2O)6]2+ + 4Cl- ® [CoCl4]2- + 6H2O is written as:
[Co(H2O)6]^2+ + 4Cl^- -> [CoCl4]^2- + 6H2O
- 31H + 21H ® 42He + 10n is written as:
^3 1H + ^2 1H -> ^4 2He + ^1 0n
- num: Typesets a number formatted in scientific notation, fixed point, fixed point with commas, fixed point with commas and dollar sign, or in significant digits.
<num format="2E">31454678</num> results in 3.15 x 10^7
<num format="2f">31454678</num> results in 31454678.00
<num format="4g">31454678</num> results in 3.145 x 10^7
<num format="4g">314.54678</num> results in 314.5
<num format=",2f">31454678</num> results in 31,454,678.00
<num format="$2f">31454678</num> results in $31,454,678.00
<num format="2s">31454678</num> results in 31000000
<num format=",2s">31454678</num> results in 31,000,000
- parse: to display the parsed view of a variable's
contents
<script type="loncapa/perl">
$table='<table>';
for ($i=1;$i<=10;$i++) {
$table.='<tr><td>'.$i.'</td><td>'.&random(1,10,1).'</td></tr>';
}
$table.='</table>';
</script>
<parse>$table</parse>
- standalone: Everything in between the
start and end tag is shown only on the web and only if the resource
is not part of a course.
- displayduedate: This will insert the
current due date if one is set in the document. It is generated to
be inside a table of 1x1 elements. The displayduedate tag accepts
The following attributes:
- style="plain" Makes the due date appear without any boxing.
If the parameter value is other than "plain",
or if the style parameter is omitted, the
due date will be displayed within a box.
- format="fmt_string"
Allows you to control the format of the due date.
"fmt_string" is an arbitrary string that
can contain any of the following formatting items:
- %a Replaced by the abbreviated weekday
name according to the current locale.
- %A Replaced by the full weekday name
according to the current locale.
- %b The abbreviated month name according to the
current locale.
- %B The full month name according to the
current locale.
- %c The preferred date and time representation
for the current locale (the default format
string is just this).
- %C The century number as a two digit integer
- %d The day of the month as a decimal number.
Leading zeroes are shown for single digit day numbers.
- %D Equivalent to %m/%d/%y
- %e Like %d but a leadnig zero is replaced by a space.
- %F Equivalent to %Y-%m-%d
- %G The four digit year number.
- %g The two digit year numbger.
- %H The hour as a two digit number in the range 00 thorugh 23.
- %I The hour as a two digit number in the range 00 through 12.
- %j The day your the year in the range 001 through 366.
- %k The hour (24 hour clock), single digits are preceded by a blank.
- %l Like %k but using a 12 hour clock.
- %m The month as a two digit decimal number in the range 01 through 12.
- %M The minute as a two digit decimal number in the range 00 through 59.
- %n A newline character.
- %p AM or PM depending on the time value.
- %P am or pm.
- %r The time in am or pm notation.
- %R Time in 24 hour notatinon (%H:%M). See also %T below.
- %s Number of seconds since midnight of January 1, 1970.
- %S The second as a decimal number int the range 00 through 59.
- %t A horizontal tab character.
- %T The time in 24 hour notation (%H:%M:%S).
- %u Day of the week as a decimal number with Monday as 1.
- %U The week number of the current year in the range 00 through 53.
Week 1 is the week containing the first Sunday of the year.
- %V Same as %U but week 1 is the first week with at least 4 days,
with Monday being the first day of a week.
- %w Day of the week as a decimal integer in the range 0 through 7, Sunday is 0.
- %W Week number of the current year in the range 00 through 53, where
the first Monday of the year is the first day of week 01.
- %x The preferred date notation in the current locale without the time.
- %X The preferred time notation in the current locale without the date.
- %y The year as a decimal number without the century (range 00 through 99).
- %Y The year as a decimal number including the century.
- %% A % character.
- %+ Date and time in the form returned by the Unix date command.
- displaytitle: This will insert the title
of the problem from the metadata of the problem. Only the first displaytitle
in a problem will show the title; this allows clean usage of displaytitle
in LON-CAPA style files.
- window: This creates a link that when clicked shows the intervening information in a pop-up window. By default the window will be 500 pixels wide and 200 pixels tall, and the link text will be a superscript * (so as to look like a footnote). These can be changed using the attributes
- width controls the starting width of the popup window
- height controls the starting height of the popup window
- linktext the text that should appear as the link that causes the creation of the window
- printtext the text that should appear instead of a footnote when printed
When printing, the included text will get turned into a real footnote.
- windowlink: This creates a link to a resource that comes up in a pop-up window. The link will be the intervening information
between the start and the end tag. By default the window will be 500 pixels wide and 200 pixels tall.
- width controls the starting width of the popup window
- height controls the starting height of the popup window
- href the address
- togglebox: This creates a toggling box that can be clicked open and close.
- heading heading text of the box, by default no heading
- headerbg background color of the header, by default white
- showtext the text that appears to make the box visible, by default the translation of 'show'
- hidetext the text that appears to hide the box again, by default the translation of 'hide'
When printing, the included text will be rendered in a visible box.
- m: The inside text is LATEX, and is converted
to HTML (or MathML) on the fly. The default is to convert
to the display mechanism that the user has selected in preferences. This can be
overriden by setting the attribute display to one of
"tth", "mimetex" or "mathjax" which
will force a specific display mechanism. Note that the "jsmath" display is deprecated today, and MathJax is used instead when it is specified. If a display attribute is not included, the display mechanism is determined in the following order, with the first one set being the one in effect:
- In course context: Course-wide default set by Course Coordinator via Settings > Course Settings > Display of resources > Force use of a specific math rendering engine
- User's own personal preference set by the user hovering over the user's name at top left of a LON-CAPA page, and selecting Preferences > Math display settings
- Domain default set by a Domain Coordinator
- System default set for the LON-CAPA version installed on the server (tth in 2.11 and earlier, mathjax in 2.12).
The contents of <m> </m> are interpreted as LaTeX outside math environment, which is why using <m>$ $</m> is needed to switch to the LaTeX math environment. However, the "mathjax" display (which is used by default in recent versions of LON-CAPA) interprets all the contents of <m> </m> as math, and does not support non-math LaTeX. For content to work well with all the display mechanisms, it is therefore important to never use non-math LaTeX for web targets. Even purely for printing, it is better to avoid using non-math LaTeX, as the printing mechanism might use HTML instead of LaTeX in the future.
If you want variables inside of this tag to be evaluated before the
tex gets converted, then use eval="on" . For
example, <m eval="on">$ $eqn $</m>,
will evaluate the variable $eqn first and then use the
display mechanism. Anytime you use a variable inside of the m tag,
you will want to set eval to on.
For example, put the following in a script in the resource:
$eqn = "$a+$b";
$eqn = s/\+-/-/g;
and in a text area, you can type:
<m eval="on">$ $eqn $</m>
You will get the equation rendered with no +-, no matter what value
$b may take on.
- randomlabel: This shows a specified image
with images or text labels randomly assigned to a set of specific
locations. Those locations may also have values assigned to them.
A hash is generated that contains the mapping of labels to locations,
labels to values, and locations to values. Example:
<randomlabel bgimg="URL" width="12" height="45" texwidth="50">
<labelgroup name="GroupOne" type="image">
<location x="123" y="456" value="10" />
<location x="321" y="654" value="20" />
<location x="213" y="546" value="13" />
<label description="TEXT-1">IMG-URL</label>
<label description="TEXT-2">IMG-URL</label>
<label description="TEXT-3">IMG-URL</label>
</labelgroup>
<labelgroup name="GroupTwo" type="text">
<location x="12" y="45" />
<location x="32" y="65" />
<location x="21" y="54" />
<label>TEXT-1</label>
<label>TEXT-2</label>
<label>TEXT-3</label>
</labelgroup>
</randomlabel>
Possible attributes are:
- bgimg: Either a fully qualified URL for an
external image or a LON-CAPA resource. It supports relative references
(../images/apicture.gif). The image must either be a GIF or JPEG.
- width: The width of the image in pixels.
- height: The height of the image in pixels.
- texwidth: The width of the image in millimeters.
- problemtype: This tag allows you to show or hide output based on what the problem-type parameter is set to in the course. For example:
<problemtype mode="show" for="exam,survey">
<startouttext />
The formula for the circumference of a circle is 2*pi*r
<endouttext />
</problemtype>
Will only show the output text when the problem is set to the type of exam or survey in the course. The attribute for mode can be set to show or hide. The attribute for for can be problem, exam, survey, or practice.