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

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

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