File:  [LON-CAPA] / loncom / html / adm / help / tex / Authoring_Output_Tags.tex
Revision 1.27.2.1: download - view: text, annotated - select for diffs
Fri Jan 22 17:24:44 2021 UTC (3 years, 6 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_5_msu, version_2_11_5, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3
Diff to branchpoint 1.27: preferred, unified
- For 2.11
- Remove doc for <lm> (2.12 feature).

    1: \label{Authoring_Output_Tags}
    2: 
    3: 
    4: This group of tags generates useful output. 
    5: 
    6: \begin{itemize}
    7: \item \textbf{algebra}\index{algebra}\index{format algebra}: Typesets algebraic expressions
    8: \begin{verbatim}
    9: <algebra>2x^y+sqrt(3/x^2)</algebra>
   10: \end{verbatim}
   11: Expressions are displayed using the math expression display mechanism for the current context.  The default is to use
   12: the display mechanism the user has selected in preferences. This can be overriden by setting the \textbf{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.
   13: 
   14: Recognized functions are all trigonometric functions, and the following:
   15: exp, abs, logten, log, ln, sqrt, sgn, step, fact, int, lim, funX.
   16: \item \textbf{chem}\index{chem}\index{format reaction}: Typesets chemical equation :
   17: \begin{verbatim}
   18:   <chem>O2 + 2H2 -> 2H2O</chem>
   19: \end{verbatim}
   20: will be rendered:
   21: $\mathrm{O_2} + 2\,\mathrm{H_2} \to 2\,\mathrm{H_2O}$
   22: 
   23: \textbf{Syntax Description}
   24: \begin{itemize}
   25: \item Reactants are separated from products by `\texttt{->}'.
   26: \item Individual reactants and products are separated by `\texttt{  +}' (leading space is obligatory).
   27: \item Numbers preceding the first symbol of a chemical specie are considered to be stoichiometric coefficients.
   28: \item Numbers appearing after the first symbol of a chemical specie are considered to be subscripts.
   29: \item Superscripts are initialized by `\texttt{\^{}}' and terminated by a space.
   30: \item Ionic charges are superscripts composed of a number followed by a sign (i.e. `\texttt{\^{}2+}').
   31: \end{itemize}
   32: 
   33: \textbf{More examples}
   34: \begin{itemize}
   35: \item $\mathrm{Ca}(\mathrm{NO}_3)_2$ is written as:\\
   36: \texttt{Ca(NO3)2}
   37: \item $\mathrm{OH}^- + \mathrm{H_3O}^+ \to 2\mathrm{H_2O}$ is written as:\\
   38: \texttt{OH\^{}- + H3O\^{}+ -> 2H2O}
   39: \item $[\mathrm{Co}(\mathrm{H_2O})_6]^{2+} + 4\mathrm{Cl}^- \to [\mathrm{CoCl_4}]^{2-} + 6\mathrm{H_2O}$ is written as:\\
   40: \texttt{[Co(H2O)6]\^{}2+ + 4Cl\^{}- -> [CoCl4]\^{}2- + 6H2O}
   41: \item $^3_1\mathrm{H} + ^2_1\mathrm{H} \to ^4_2\mathrm{He} + ^1_0\mathrm{n}$ is written as:\\
   42: \texttt{\^{}3 1H + \^{}2 1H -> \^{}4 2He + \^{}1 0n}
   43: \end{itemize}
   44: 
   45: \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. 
   46: \begin{verbatim}
   47:   <num format="2E">31454678</num> results in 3.15 x 10^7
   48:   <num format="2f">31454678</num> results in 31454678.00
   49:   <num format="4g">31454678</num> results in 3.145 x 10^7
   50:   <num format="4g">314.54678</num> results in 314.5
   51:   <num format=",2f">31454678</num> results in 31,454,678.00
   52:   <num format="$2f">31454678</num> results in $31,454,678.00
   53:   <num format="2s">31454678</num> results in 31000000
   54:   <num format=",2s">31454678</num> results in 31,000,000
   55: \end{verbatim}
   56: \item \textbf{parse}\index{parse}: to display the parsed view of a variable's
   57: contents
   58: \begin{verbatim}
   59:   <script type="loncapa/perl">
   60:    $table='<table>';
   61:    for ($i=1;$i<=10;$i++) {
   62:       $table.='<tr><td>'.$i.'</td><td>'.&random(1,10,1).'</td></tr>';
   63:    }
   64:    $table.='</table>';
   65:   </script>
   66:   <parse>$table</parse>
   67: \end{verbatim}
   68: 
   69: \item \textbf{standalone}\index{standalone}: Everything in between the
   70: start and end tag is shown only on the web and only if the resource
   71: is not part of a course. 
   72: \item \textbf{displayduedate}\index{displayduedate}: This will insert the
   73: current due date if one is set in the document. It is generated to
   74: be inside a table of 1x1 elements.  The displayduedate tag accepts
   75: The following attributes:
   76:    \begin{description}
   77:       \item{style=``plain'' }  Makes the due date appear without any boxing.
   78:                                If the parameter value is other than  ``\emph{plain}'',
   79: 			       or if the \textbf{style} parameter is omitted, the
   80: 			       due date will be displayed within a box.
   81:       \item{format=``fmt\_string''} 
   82:                               Allows you to control the format of the due date.
   83: 			      ``\emph{fmt\_string}'' is an arbitrary string that
   84: 			      can contain any of the following formatting items:
   85: 			      \begin{description}
   86: 			         \item{\%a} Replaced by the abbreviated weekday
   87: 				            name according to the current locale.
   88: 			         \item{\%A} Replaced by the full weekday name 
   89: 				           according to the current locale.
   90: 		                 \item{\%b} The abbreviated month name according to the
   91: 				            current locale.
   92: 			         \item{\%B} The full month name according to the
   93:                                             current locale.
   94: 			         \item{\%c} The preferred date and time representation
   95: 				            for the current locale (the default format
   96: 					    string is just this).
   97: 			         \item{\%C} The century number as a two digit integer
   98: 				 \item{\%d} The day of the month as a decimal number.
   99: 				            Leading zeroes are shown for single digit day numbers.
  100: 				 \item{\%D} Equivalent to \%m/\%d/\%y  
  101: 				 \item{\%e} Like \%d but a leadnig zero is replaced by a space.
  102: 				 \item{\%F} Equivalent to \%Y-\%m-\%d
  103: 				 \item{\%G} The four digit year number.
  104: 				 \item{\%g} The two digit year numbger.
  105: 				 \item{\%H} The hour as a two digit number in the range 00 thorugh 23.
  106: 				 \item{\%I} The hour as a two digit number in the range 00 through 12.
  107: 				 \item{\%j} The day your the year in the range 001 through 366.
  108: 				 \item{\%k} The hour (24 hour clock), single digits are preceded by a blank.
  109: 				 \item{\%l} Like \%k but using a 12 hour clock.
  110: 				 \item{\%m} The month as a two digit decimal number in the range 01 through 12.
  111: 				 \item{\%M} The minute as a two digit decimal number in the range 00 through 59.
  112: 				 \item{\%n} A newline character.
  113: 				 \item{\%p} AM or PM depending on the time value.
  114: 				 \item{\%P} am or pm.
  115: 				 \item{\%r} The time in am or pm notation.
  116: 				 \item{\%R} Time in 24 hour notatinon (\%H:\%M).  See also \%T below.
  117: 				 \item{\%s} Number of seconds since midnight of January 1, 1970.
  118: 				 \item{\%S} The second as a decimal number int the range 00 through 59.
  119: 				 \item{\%t} A horizontal tab character.
  120: 				 \item{\%T} The time in 24 hour notation (\%H:\%M:\%S).
  121: 				 \item{\%u} Day of the week as a decimal number with Monday as 1.
  122: 				 \item{\%U} The week number of the current year in the range 00 through 53.
  123: 				            Week 1 is the week containing the first Sunday of the year.
  124: 				 \item{\%V} Same as \%U but week 1 is the first week with at least 4 days,
  125: 				            with Monday being the first day of a week.
  126: 			         \item{\%w} Day of the week as a decimal integer in the range 0 through 7, Sunday is 0.
  127: 				 \item{\%W} Week number of the current year in the range 00 through 53, where
  128: 				            the first Monday of the year is the first day of week 01.
  129: 			         \item{\%x} The preferred date notation in the current locale without the time.
  130: 				 \item{\%X} The preferred time notation in the current locale without the date.
  131: 				 \item{\%y} The year as a decimal number without the century (range 00 through 99).
  132: 				 \item{\%Y} The year as a decimal number including the century.
  133: 				 \item{\%\%} A \% character.
  134: 				 \item{\%+} Date and time in the form returned by the Unix date command.
  135: 			      \end{description}
  136:    \end{description}
  137: \item \textbf{displaytitle}\index{displaytitle}: This will insert the title
  138: of the problem from the metadata of the problem. Only the first \textbf{displaytitle}
  139: in a problem will show the title; this allows clean usage of \textbf{displaytitle}
  140: in LON-CAPA style files.
  141: 
  142: \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
  143: 
  144: \begin{itemize}
  145: \item \textbf{width} controls the starting width of the popup window
  146: \item \textbf{height} controls the starting height of the popup window
  147: \item \textbf{linktext} the text that should appear as the link that causes the creation of the window
  148: \item \textbf{printtext} the text that should appear instead of a footnote when printed
  149: \end{itemize}
  150: 
  151: When printing, the included text will get turned into a real footnote.
  152: 
  153: \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
  154: between the start and the end tag. By default the window will be 500 pixels wide and 200 pixels tall.
  155: 
  156: \begin{itemize}
  157: \item \textbf{width} controls the starting width of the popup window
  158: \item \textbf{height} controls the starting height of the popup window
  159: \item \textbf{href} the address
  160: \end{itemize}
  161: 
  162: \item \textbf{togglebox}\index{togglebox}: This creates a toggling box that can be clicked open and close.
  163: 
  164: \begin{itemize}
  165: \item \textbf{heading} heading text of the box, by default no heading
  166: \item \textbf{headerbg} background color of the header, by default white
  167: \item \textbf{showtext} the text that appears to make the box visible, by default the translation of `show'
  168: \item \textbf{hidetext} the text that appears to hide the box again, by default the translation of `hide'
  169: \end{itemize}
  170: 
  171: When printing, the included text will be rendered in a visible box.
  172: 
  173: 
  174: \item \textbf{m}\index{m}\index{equations}: The inside text is \LaTeX{}, and is converted
  175: to HTML (or MathML) on the fly. The default is to convert
  176: to the display mechanism that the user has selected in preferences. This can be
  177: overriden by setting the attribute \textbf{display} to one of
  178: ``\textbf{tth}'', ``\textbf{mimetex}'' or ``\textbf{mathjax}'' which
  179: will force a specific display mechanism. Note that the ``\textbf{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:
  180: \begin{enumerate}
  181: \item 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
  182: \item 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
  183: \item Domain default set by a Domain Coordinator 
  184: \item System default set for the LON-CAPA version installed on the server (tth in 2.11 and earlier, mathjax in 2.12).
  185: \end{enumerate}
  186: 
  187: 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.
  188: 
  189: If you want variables inside of this tag to be evaluated before the
  190: tex gets converted, then use eval=``on'' \index{eval=on}. For
  191: example,  \texttt{<m eval=''on''>\$ \$eqn \$</m>},
  192: will evaluate the variable \$eqn first and then use the
  193: display mechanism.  Anytime you use a variable inside of the m tag,
  194: you will want to set eval to on.
  195: 
  196: For example, put the following in a script in the resource:
  197: 
  198: \texttt{\$eqn = "\$a+\$b";}
  199: 
  200: \texttt{\$eqn =~ s/\textbackslash{}+-/-/g;}
  201: 
  202: and in a text area, you can type:
  203: 
  204: \texttt{<m eval=''on''>\$ \$eqn \$</m>}
  205: 
  206: You will get the equation rendered with no +-, no matter what value
  207: \$b may take on.
  208: 
  209: \item \textbf{randomlabel}\index{randomlabel}: This shows a specified image
  210: with images or text labels randomly assigned to a set of specific
  211: locations. Those locations may also have values assigned to them.
  212: A hash is generated that contains the mapping of labels to locations,
  213: labels to values, and locations to values. Example: \begin{verbatim}
  214: 
  215:  <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
  216:     <labelgroup name="GroupOne" type="image">
  217:       <location x="123" y="456" value="10" />
  218:       <location x="321" y="654" value="20" />
  219:       <location x="213" y="546" value="13" />
  220:       <label description="TEXT-1">IMG-URL</label>
  221:       <label description="TEXT-2">IMG-URL</label>
  222:       <label description="TEXT-3">IMG-URL</label>
  223:     </labelgroup>
  224:     <labelgroup name="GroupTwo" type="text">
  225:       <location x="12" y="45" />
  226:       <location x="32" y="65" />
  227:       <location x="21" y="54" />
  228:       <label>TEXT-1</label>
  229:       <label>TEXT-2</label>
  230:       <label>TEXT-3</label>
  231:     </labelgroup>
  232:    </randomlabel>
  233:     
  234: \end{verbatim}
  235: 
  236:  Possible attributes are:
  237: 
  238: \begin{itemize}
  239: \item \textbf{bgimg}\index{bgimg}: Either a fully qualified URL for an
  240: external image or a LON-CAPA resource. It supports relative references
  241: (../images/apicture.gif). The image must either be a GIF or JPEG.
  242: \item \textbf{width}\index{width}: The width of the image in pixels.
  243: \item \textbf{height}\index{height}: The height of the image in pixels.
  244: \item \textbf{texwidth}\index{texwidth}: The width of the image in millimeters.
  245: \end{itemize}
  246: 
  247: \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}
  248: <problemtype mode="show" for="exam,survey">
  249:   <startouttext />
  250:   The formula for the circumference of a circle is 2*pi*r
  251:   <endouttext />
  252: </problemtype>
  253: \end{verbatim}
  254: 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.
  255: 
  256: \end{itemize}

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