Annotation of loncom/html/adm/help/tex/Authoring_Output_Tags.tex, revision 1.26

1.1       bowersj2    1: \label{Authoring_Output_Tags}
                      2: 
                      3: 
1.2       vandui11    4: This group of tags generates useful output. 
1.1       bowersj2    5: 
                      6: \begin{itemize}
1.17      lira        7: \item \textbf{algebra}\index{algebra}\index{format algebra}: Typesets algebraic expressions
1.3       albertel    8: \begin{verbatim}
1.8       felicia     9: <algebra>2x^y+sqrt(3/x^2)</algebra>
1.3       albertel   10: \end{verbatim}
1.23      damieng    11: Expressions are displayed using the math expression display mechanism defined in the user's preferences.  See the section below concerning the $<$m$>$ tag for more information on that as well as on the \textbf{display} attribute.
                     12: 
                     13: Recognized functions are all trigonometric functions, and the following:
                     14: exp, abs, logten, log, ln, sqrt, sgn, step, fact, int, lim, funX.
                     15: \item \textbf{chem}\index{chem}\index{format reaction}: Typesets chemical equation :
1.3       albertel   16: \begin{verbatim}
1.10      raeburn    17:   <chem>O2 + 2H2 -> 2H2O</chem>
1.3       albertel   18: \end{verbatim}
1.23      damieng    19: will be rendered:
1.26    ! damieng    20: $\mathrm{O_2} + 2\,\mathrm{H_2} \to 2\,\mathrm{H_2O}$
        !            21: 
        !            22: \textbf{Syntax Description}
        !            23: \begin{itemize}
        !            24: \item Reactants are separated from products by `\texttt{->}'.
        !            25: \item Individual reactants and products are separated by `\texttt{  +}' (leading space is obligatory).
        !            26: \item Numbers preceding the first symbol of a chemical specie are considered to be stoichiometric coefficients.
        !            27: \item Numbers appearing after the first symbol of a chemical specie are considered to be subscripts.
        !            28: \item Superscripts are initialized by `\texttt{\^{}}' and terminated by a space.
        !            29: \item Ionic charges are superscripts composed of a number followed by a sign (i.e. `\texttt{\^{}2+}').
        !            30: \end{itemize}
        !            31: 
        !            32: \textbf{More examples}
        !            33: \begin{itemize}
        !            34: \item $\mathrm{Ca}(\mathrm{NO}_3)_2$ is written as:\\
        !            35: \texttt{Ca(NO3)2}
        !            36: \item $\mathrm{OH}^- + \mathrm{H_3O}^+ \to 2\mathrm{H_2O}$ is written as:\\
        !            37: \texttt{OH\^{}- + H3O\^{}+ -> 2H2O}
        !            38: \item $[\mathrm{Co}(\mathrm{H_2O})_6]^{2+} + 4\mathrm{Cl}^- \to [\mathrm{CoCl_4}]^{2-} + 6\mathrm{H_2O}$ is written as:\\
        !            39: \texttt{[Co(H2O)6]\^{}2+ + 4Cl\^{}- -> [CoCl4]\^{}2- + 6H2O}
        !            40: \item $^3_1\mathrm{H} + ^2_1\mathrm{H} \to ^4_2\mathrm{He} + ^1_0\mathrm{n}$ is written as:\\
        !            41: \texttt{\^{}3 1H + \^{}2 1H -> \^{}4 2He + \^{}1 0n}
        !            42: \end{itemize}
1.23      damieng    43: 
1.17      lira       44: \item \textbf{num}\index{num}\index{format number}: Typesets a number formatted in scientific notation, fixed point, fixed point with commas, fixed point with commas and dollar sign, or in significant digits. 
1.3       albertel   45: \begin{verbatim}
1.17      lira       46:   <num format="2E">31454678</num> results in 3.15 x 10^7
                     47:   <num format="2f">31454678</num> results in 31454678.00
                     48:   <num format="4g">31454678</num> results in 3.145 x 10^7
                     49:   <num format="4g">314.54678</num> results in 314.5
                     50:   <num format=",2f">31454678</num> results in 31,454,678.00
                     51:   <num format="$2f">31454678</num> results in $31,454,678.00
                     52:   <num format="2s">31454678</num> results in 31000000
                     53:   <num format=",2s">31454678</num> results in 31,000,000
1.3       albertel   54: \end{verbatim}
                     55: \item \textbf{parse}\index{parse}: to display the parsed view of a variable's
                     56: contents
                     57: \begin{verbatim}
1.8       felicia    58:   <script type="loncapa/perl">
1.13      bisitz     59:    $table='<table>';
1.3       albertel   60:    for ($i=1;$i<=10;$i++) {
1.13      bisitz     61:       $table.='<tr><td>'.$i.'</td><td>'.&random(1,10,1).'</td></tr>';
1.3       albertel   62:    }
1.13      bisitz     63:    $table.='</table>';
1.3       albertel   64:   </script>
1.8       felicia    65:   <parse>$table</parse>
1.3       albertel   66: \end{verbatim}
                     67: 
1.8       felicia    68: \item \textbf{standalone}\index{standalone}: Everything in between the
1.2       vandui11   69: start and end tag is shown only on the web and only if the resource
1.1       bowersj2   70: is not part of a course. 
                     71: \item \textbf{displayduedate}\index{displayduedate}: This will insert the
1.2       vandui11   72: current due date if one is set in the document. It is generated to
1.6       foxr       73: be inside a table of 1x1 elements.  The displayduedate tag accepts
                     74: The following attributes:
                     75:    \begin{description}
                     76:       \item{style=``plain'' }  Makes the due date appear without any boxing.
                     77:                                If the parameter value is other than  ``\emph{plain}'',
                     78: 			       or if the \textbf{style} parameter is omitted, the
                     79: 			       due date will be displayed within a box.
                     80:       \item{format=``fmt\_string''} 
                     81:                               Allows you to control the format of the due date.
                     82: 			      ``\emph{fmt\_string}'' is an arbitrary string that
                     83: 			      can contain any of the following formatting items:
                     84: 			      \begin{description}
                     85: 			         \item{\%a} Replaced by the abbreviated weekday
                     86: 				            name according to the current locale.
                     87: 			         \item{\%A} Replaced by the full weekday name 
                     88: 				           according to the current locale.
                     89: 		                 \item{\%b} The abbreviated month name according to the
                     90: 				            current locale.
                     91: 			         \item{\%B} The full month name according to the
                     92:                                             current locale.
                     93: 			         \item{\%c} The preferred date and time representation
                     94: 				            for the current locale (the default format
                     95: 					    string is just this).
                     96: 			         \item{\%C} The century number as a two digit integer
                     97: 				 \item{\%d} The day of the month as a decimal number.
                     98: 				            Leading zeroes are shown for single digit day numbers.
                     99: 				 \item{\%D} Equivalent to \%m/\%d/\%y  
                    100: 				 \item{\%e} Like \%d but a leadnig zero is replaced by a space.
                    101: 				 \item{\%F} Equivalent to \%Y-\%m-\%d
                    102: 				 \item{\%G} The four digit year number.
                    103: 				 \item{\%g} The two digit year numbger.
                    104: 				 \item{\%H} The hour as a two digit number in the range 00 thorugh 23.
                    105: 				 \item{\%I} The hour as a two digit number in the range 00 through 12.
                    106: 				 \item{\%j} The day your the year in the range 001 through 366.
                    107: 				 \item{\%k} The hour (24 hour clock), single digits are preceded by a blank.
                    108: 				 \item{\%l} Like \%k but using a 12 hour clock.
                    109: 				 \item{\%m} The month as a two digit decimal number in the range 01 through 12.
                    110: 				 \item{\%M} The minute as a two digit decimal number in the range 00 through 59.
                    111: 				 \item{\%n} A newline character.
                    112: 				 \item{\%p} AM or PM depending on the time value.
                    113: 				 \item{\%P} am or pm.
                    114: 				 \item{\%r} The time in am or pm notation.
                    115: 				 \item{\%R} Time in 24 hour notatinon (\%H:\%M).  See also \%T below.
                    116: 				 \item{\%s} Number of seconds since midnight of January 1, 1970.
                    117: 				 \item{\%S} The second as a decimal number int the range 00 through 59.
                    118: 				 \item{\%t} A horizontal tab character.
                    119: 				 \item{\%T} The time in 24 hour notation (\%H:\%M:\%S).
                    120: 				 \item{\%u} Day of the week as a decimal number with Monday as 1.
                    121: 				 \item{\%U} The week number of the current year in the range 00 through 53.
                    122: 				            Week 1 is the week containing the first Sunday of the year.
                    123: 				 \item{\%V} Same as \%U but week 1 is the first week with at least 4 days,
                    124: 				            with Monday being the first day of a week.
                    125: 			         \item{\%w} Day of the week as a decimal integer in the range 0 through 7, Sunday is 0.
                    126: 				 \item{\%W} Week number of the current year in the range 00 through 53, where
                    127: 				            the first Monday of the year is the first day of week 01.
                    128: 			         \item{\%x} The preferred date notation in the current locale without the time.
                    129: 				 \item{\%X} The preferred time notation in the current locale without the date.
                    130: 				 \item{\%y} The year as a decimal number without the century (range 00 through 99).
                    131: 				 \item{\%Y} The year as a decimal number including the century.
                    132: 				 \item{\%\%} A \% character.
                    133: 				 \item{\%+} Date and time in the form returned by the Unix date command.
                    134: 			      \end{description}
                    135:    \end{description}
1.1       bowersj2  136: \item \textbf{displaytitle}\index{displaytitle}: This will insert the title
                    137: of the problem from the metadata of the problem. Only the first \textbf{displaytitle}
                    138: in a problem will show the title; this allows clean usage of \textbf{displaytitle}
1.7       albertel  139: in LON-CAPA style files.
                    140: 
                    141: \item \textbf{window}\index{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
                    142: 
                    143: \begin{itemize}
1.8       felicia   144: \item \textbf{width} controls the starting width of the popup window
                    145: \item \textbf{height} controls the starting height of the popup window
                    146: \item \textbf{linktext} the text that should appear as the link that causes the creation of the window
1.16      www       147: \item \textbf{printtext} the text that should appear instead of a footnote when printed
1.7       albertel  148: \end{itemize}
                    149: 
1.14      www       150: When printing, the included text will get turned into a real footnote.
                    151: 
1.15      www       152: \item \textbf{windowlink}\index{windowlink}: This creates a link to a resource that comes up in a pop-up window. The link will be the intervening information
                    153: between the start and the end tag. By default the window will be 500 pixels wide and 200 pixels tall.
                    154: 
                    155: \begin{itemize}
                    156: \item \textbf{width} controls the starting width of the popup window
                    157: \item \textbf{height} controls the starting height of the popup window
                    158: \item \textbf{href} the address
                    159: \end{itemize}
                    160: 
1.14      www       161: \item \textbf{togglebox}\index{togglebox}: This creates a toggling box that can be clicked open and close.
                    162: 
                    163: \begin{itemize}
                    164: \item \textbf{heading} heading text of the box, by default no heading
                    165: \item \textbf{headerbg} background color of the header, by default white
1.21      raeburn   166: \item \textbf{showtext} the text that appears to make the box visible, by default the translation of `show'
                    167: \item \textbf{hidetext} the text that appears to hide the box again, by default the translation of `hide'
1.14      www       168: \end{itemize}
                    169: 
                    170: When printing, the included text will be rendered in a visible box.
1.7       albertel  171: 
1.4       albertel  172: 
1.25      damieng   173: \item \textbf{m}\index{m}\index{equations}: The inside text is \LaTeX{}, and is converted
1.8       felicia   174: to HTML (or MathML) on the fly. The default is to convert
                    175: to the display mechanism that the user has selected in preferences. This can be
1.4       albertel  176: overriden by setting the attribute \textbf{display} to one of
1.23      damieng   177: ``\textbf{tth}'', ``\textbf{mimetex}'' or ``\textbf{mathjax}'' which
                    178: will force a specific display mechanism. Note that the ``\textbf{jsmath}'' display is deprecated today, and MathJax is used instead when it is specified.
                    179: 
                    180: The contents of \texttt{<m> </m>} are interpreted as LaTeX outside math environment, which is why using \texttt{<m>\$ \$</m>} is needed to switch to the LaTeX math environment. However, the ``\textbf{mathjax}'' display (which is used by default in recent versions of LON-CAPA) interprets all the contents of \texttt{<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.
1.4       albertel  181: 
1.8       felicia   182: If you want variables inside of this tag to be evaluated before the
                    183: tex gets converted, then use eval=``on'' \index{eval=on}. For
1.23      damieng   184: example,  \texttt{<m eval="on">\$ \$eqn \$</m>},
                    185: will evaluate the variable \$eqn first and then use the
                    186: display mechanism.  Anytime you use a variable inside of the m tag,
1.8       felicia   187: you will want to set eval to on.
                    188: 
                    189: For example, put the following in a script in the resource:
                    190: 
                    191: \texttt{\$eqn = "\$a+\$b";}
                    192: 
                    193: \texttt{\$eqn =~ s/\textbackslash{}+-/-/g;}
                    194: 
                    195: and in a text area, you can type:
                    196: 
1.23      damieng   197: \texttt{<m eval="on">\$ \$eqn \$</m>}
1.8       felicia   198: 
                    199: You will get the equation rendered with no +-, no matter what value
                    200: \$b may take on.
                    201: 
                    202: 
1.25      damieng   203: \item \textbf{lm}\index{lm}\index{equations}: This is another way to input math, which does not require
1.24      damieng   204: knowing \LaTeX{}.
                    205: The lm syntax describes mathematical operations rather than appearance (as opposed to LaTeX, which describes how the math should appear). Display is the same when the math operations are the same, for instance 2*(x) will be displayed just like 2x. One advantage to that system is that math will be displayed in a consistent way, even when written by several authors. The drawback is that display cannot be chosen precisely.
                    206: Eventually, this syntax will also be used to evaluate \texttt{<formularesponse>} (it is already used for the real-time preview).
                    207: 
                    208: \begin{description}
                    209: \item[Spaces]~\\
                    210:     Spaces are always ignored.
                    211: 
                    212: \item[Decimal separators and function parameter separators]~\\
                    213:     To keep compatible with previous \texttt{<formularesponse>} syntax, only ``.'' can be used as a decimal separator, and ``,'' is used to separate function and vector/matrix parameters.
                    214:     
                    215: \item[Variables and constants]~\\
                    216:     Variable names and constant names are used directly, without any special character before. They are displayed in italics.
                    217:     
                    218: \item[Units]~\\
                    219:     Unit names are used directly. They are displayed with a straight font. LON-CAPA has a list of known units and a list of known constants to differentiate them in units mode.
                    220:     
                    221: \item[Parenthesis]~\\
                    222:     Parenthesis can be used to specify evaluation order. They are only displayed when necessary.
                    223:     
                    224: \item[Operators]~\\
                    225:     arithmetic: \texttt{+ - * / \^{}}\\
                    226:     factorial: \texttt{!}\\
                    227:     relational: \texttt{= \# < <= >= >}\\
                    228:     units: \texttt{`}\\
                    229:     Example: \texttt{2`m + 3`m = 5`m}\\
                    230:     scalar product for vectors, multiplication for matrices: \texttt{.}\\
                    231: 
                    232: \item[Implicit operators]~\\
                    233:     \texttt{*} and \texttt{`} are implicit.
                    234: 
                    235:     The parser will try to guess which operator is missing whenever possible. The choice between * and ` depends on the mode for interpreting equations.
                    236: 
                    237:     Example: \texttt{2c+3m/s} is understood in unit mode to be \texttt{2*c + 3`(m/s)}. In symbolic mode, it would be interpreted \texttt{2*c + (3*m)/s} (m and s being variables).
                    238:     
                    239: \item[Functions]~\\
                    240:     Functions use the syntax \texttt{f(a,b)}.
                    241: 
                    242:         basic:
                    243: 
                    244:         \quad \texttt{sqrt(x)}, \texttt{abs(x)}, \texttt{exp(x)=e\^{}x}, \texttt{factorial(x)=x!}
                    245: 
                    246:         binomial (displayed like a vector):
                    247: 
                    248:         \quad \texttt{binomial(n,p)=n!/(p!*(n-p)!)}
                    249: 
                    250:         sum and product (requiring symbolic mode):
                    251: 
                    252:         \quad \texttt{sum(f(x),x,x1,x2)}, \texttt{product(f(x),x,x1,x2)}
                    253: 
                    254:         differential, integral, limit:
                    255: 
                    256:         \quad \texttt{diff(expr,x,n)}, \texttt{integrate(expr,x,a,b)}, \texttt{limit(expr,x,val,dir)}
                    257: 
                    258: \item[Vectors and matrices]~\\
                    259:     Vectors and matrices are defined with square brackets. A matrix is made of a list of row vectors.
                    260: 
                    261:         vectors: \texttt{[1,2,3]}\\
                    262:         matrices: \texttt{[[1,2],[3,4]]}
                    263: 
                    264: \item[Sets]~\\
                    265:     Sets are defined with curly brackets: \texttt{\{1,2,3\}}
                    266: 
                    267:         union: \texttt{union(\{1,2\},\{1,3\}) = \{1,2,3\}}\\
                    268:         intersection: \texttt{intersection(\{1,2\},\{1,3\}) = \{1\}}
                    269:     
                    270: \end{description}
                    271: 
                    272: 
1.2       vandui11  273: \item \textbf{randomlabel}\index{randomlabel}: This shows a specified image
1.1       bowersj2  274: with images or text labels randomly assigned to a set of specific
                    275: locations. Those locations may also have values assigned to them.
1.2       vandui11  276: A hash is generated that contains the mapping of labels to locations,
1.1       bowersj2  277: labels to values, and locations to values. Example: \begin{verbatim}
                    278: 
                    279:  <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
                    280:     <labelgroup name="GroupOne" type="image">
                    281:       <location x="123" y="456" value="10" />
                    282:       <location x="321" y="654" value="20" />
                    283:       <location x="213" y="546" value="13" />
                    284:       <label description="TEXT-1">IMG-URL</label>
                    285:       <label description="TEXT-2">IMG-URL</label>
                    286:       <label description="TEXT-3">IMG-URL</label>
                    287:     </labelgroup>
                    288:     <labelgroup name="GroupTwo" type="text">
                    289:       <location x="12" y="45" />
                    290:       <location x="32" y="65" />
                    291:       <location x="21" y="54" />
                    292:       <label>TEXT-1</label>
                    293:       <label>TEXT-2</label>
                    294:       <label>TEXT-3</label>
                    295:     </labelgroup>
                    296:    </randomlabel>
                    297:     
1.5       albertel  298: \end{verbatim}
                    299: 
                    300:  Possible attributes are:
1.1       bowersj2  301: 
                    302: \begin{itemize}
                    303: \item \textbf{bgimg}\index{bgimg}: Either a fully qualified URL for an
1.2       vandui11  304: external image or a LON-CAPA resource. It supports relative references
1.1       bowersj2  305: (../images/apicture.gif). The image must either be a GIF or JPEG.
                    306: \item \textbf{width}\index{width}: The width of the image in pixels.
                    307: \item \textbf{height}\index{height}: The height of the image in pixels.
1.2       vandui11  308: \item \textbf{texwidth}\index{texwidth}: The width of the image in millimeters.
1.1       bowersj2  309: \end{itemize}
1.11      felicia   310: 
                    311: \item \textbf{problemtype}\index{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: \begin{verbatim}
                    312: <problemtype mode="show" for="exam,survey">
1.25      damieng   313:   <startouttext />
                    314:   The formula for the circumference of a circle is 2*pi*r
                    315:   <endouttext />
1.11      felicia   316: </problemtype>
                    317: \end{verbatim}
                    318: 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.
                    319: 
1.1       bowersj2  320: \end{itemize}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>