Annotation of loncom/html/adm/help/tex/Authoring_Output_Tags.tex, revision 1.27
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.27 ! raeburn 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.
1.23 damieng 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 :
1.3 albertel 17: \begin{verbatim}
1.10 raeburn 18: <chem>O2 + 2H2 -> 2H2O</chem>
1.3 albertel 19: \end{verbatim}
1.23 damieng 20: will be rendered:
1.26 damieng 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}
1.23 damieng 44:
1.17 lira 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.
1.3 albertel 46: \begin{verbatim}
1.17 lira 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
1.3 albertel 55: \end{verbatim}
56: \item \textbf{parse}\index{parse}: to display the parsed view of a variable's
57: contents
58: \begin{verbatim}
1.8 felicia 59: <script type="loncapa/perl">
1.13 bisitz 60: $table='<table>';
1.3 albertel 61: for ($i=1;$i<=10;$i++) {
1.13 bisitz 62: $table.='<tr><td>'.$i.'</td><td>'.&random(1,10,1).'</td></tr>';
1.3 albertel 63: }
1.13 bisitz 64: $table.='</table>';
1.3 albertel 65: </script>
1.8 felicia 66: <parse>$table</parse>
1.3 albertel 67: \end{verbatim}
68:
1.8 felicia 69: \item \textbf{standalone}\index{standalone}: Everything in between the
1.2 vandui11 70: start and end tag is shown only on the web and only if the resource
1.1 bowersj2 71: is not part of a course.
72: \item \textbf{displayduedate}\index{displayduedate}: This will insert the
1.2 vandui11 73: current due date if one is set in the document. It is generated to
1.6 foxr 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}
1.1 bowersj2 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}
1.7 albertel 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}
1.8 felicia 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
1.16 www 148: \item \textbf{printtext} the text that should appear instead of a footnote when printed
1.7 albertel 149: \end{itemize}
150:
1.14 www 151: When printing, the included text will get turned into a real footnote.
152:
1.15 www 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:
1.14 www 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
1.21 raeburn 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'
1.14 www 169: \end{itemize}
170:
171: When printing, the included text will be rendered in a visible box.
1.7 albertel 172:
1.4 albertel 173:
1.25 damieng 174: \item \textbf{m}\index{m}\index{equations}: The inside text is \LaTeX{}, and is converted
1.8 felicia 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
1.4 albertel 177: overriden by setting the attribute \textbf{display} to one of
1.23 damieng 178: ``\textbf{tth}'', ``\textbf{mimetex}'' or ``\textbf{mathjax}'' which
1.27 ! raeburn 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}
1.23 damieng 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.
1.4 albertel 188:
1.8 felicia 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
1.27 ! raeburn 191: example, \texttt{<m eval=''on''>\$ \$eqn \$</m>},
1.23 damieng 192: will evaluate the variable \$eqn first and then use the
193: display mechanism. Anytime you use a variable inside of the m tag,
1.8 felicia 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:
1.27 ! raeburn 204: \texttt{<m eval=''on''>\$ \$eqn \$</m>}
1.8 felicia 205:
206: You will get the equation rendered with no +-, no matter what value
207: \$b may take on.
208:
209:
1.25 damieng 210: \item \textbf{lm}\index{lm}\index{equations}: This is another way to input math, which does not require
1.24 damieng 211: knowing \LaTeX{}.
212: 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.
213: Eventually, this syntax will also be used to evaluate \texttt{<formularesponse>} (it is already used for the real-time preview).
214:
215: \begin{description}
216: \item[Spaces]~\\
217: Spaces are always ignored.
218:
219: \item[Decimal separators and function parameter separators]~\\
220: 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.
221:
222: \item[Variables and constants]~\\
223: Variable names and constant names are used directly, without any special character before. They are displayed in italics.
224:
225: \item[Units]~\\
226: 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.
227:
228: \item[Parenthesis]~\\
229: Parenthesis can be used to specify evaluation order. They are only displayed when necessary.
230:
231: \item[Operators]~\\
232: arithmetic: \texttt{+ - * / \^{}}\\
233: factorial: \texttt{!}\\
234: relational: \texttt{= \# < <= >= >}\\
235: units: \texttt{`}\\
236: Example: \texttt{2`m + 3`m = 5`m}\\
237: scalar product for vectors, multiplication for matrices: \texttt{.}\\
238:
239: \item[Implicit operators]~\\
240: \texttt{*} and \texttt{`} are implicit.
241:
242: The parser will try to guess which operator is missing whenever possible. The choice between * and ` depends on the mode for interpreting equations.
243:
244: 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).
245:
246: \item[Functions]~\\
247: Functions use the syntax \texttt{f(a,b)}.
248:
249: basic:
250:
251: \quad \texttt{sqrt(x)}, \texttt{abs(x)}, \texttt{exp(x)=e\^{}x}, \texttt{factorial(x)=x!}
252:
253: binomial (displayed like a vector):
254:
255: \quad \texttt{binomial(n,p)=n!/(p!*(n-p)!)}
256:
257: sum and product (requiring symbolic mode):
258:
259: \quad \texttt{sum(f(x),x,x1,x2)}, \texttt{product(f(x),x,x1,x2)}
260:
261: differential, integral, limit:
262:
263: \quad \texttt{diff(expr,x,n)}, \texttt{integrate(expr,x,a,b)}, \texttt{limit(expr,x,val,dir)}
264:
265: \item[Vectors and matrices]~\\
266: Vectors and matrices are defined with square brackets. A matrix is made of a list of row vectors.
267:
268: vectors: \texttt{[1,2,3]}\\
269: matrices: \texttt{[[1,2],[3,4]]}
270:
271: \item[Sets]~\\
272: Sets are defined with curly brackets: \texttt{\{1,2,3\}}
273:
274: union: \texttt{union(\{1,2\},\{1,3\}) = \{1,2,3\}}\\
275: intersection: \texttt{intersection(\{1,2\},\{1,3\}) = \{1\}}
276:
277: \end{description}
278:
279:
1.2 vandui11 280: \item \textbf{randomlabel}\index{randomlabel}: This shows a specified image
1.1 bowersj2 281: with images or text labels randomly assigned to a set of specific
282: locations. Those locations may also have values assigned to them.
1.2 vandui11 283: A hash is generated that contains the mapping of labels to locations,
1.1 bowersj2 284: labels to values, and locations to values. Example: \begin{verbatim}
285:
286: <randomlabel bgimg="URL" width="12" height="45" texwidth="50">
287: <labelgroup name="GroupOne" type="image">
288: <location x="123" y="456" value="10" />
289: <location x="321" y="654" value="20" />
290: <location x="213" y="546" value="13" />
291: <label description="TEXT-1">IMG-URL</label>
292: <label description="TEXT-2">IMG-URL</label>
293: <label description="TEXT-3">IMG-URL</label>
294: </labelgroup>
295: <labelgroup name="GroupTwo" type="text">
296: <location x="12" y="45" />
297: <location x="32" y="65" />
298: <location x="21" y="54" />
299: <label>TEXT-1</label>
300: <label>TEXT-2</label>
301: <label>TEXT-3</label>
302: </labelgroup>
303: </randomlabel>
304:
1.5 albertel 305: \end{verbatim}
306:
307: Possible attributes are:
1.1 bowersj2 308:
309: \begin{itemize}
310: \item \textbf{bgimg}\index{bgimg}: Either a fully qualified URL for an
1.2 vandui11 311: external image or a LON-CAPA resource. It supports relative references
1.1 bowersj2 312: (../images/apicture.gif). The image must either be a GIF or JPEG.
313: \item \textbf{width}\index{width}: The width of the image in pixels.
314: \item \textbf{height}\index{height}: The height of the image in pixels.
1.2 vandui11 315: \item \textbf{texwidth}\index{texwidth}: The width of the image in millimeters.
1.1 bowersj2 316: \end{itemize}
1.11 felicia 317:
318: \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}
319: <problemtype mode="show" for="exam,survey">
1.25 damieng 320: <startouttext />
321: The formula for the circumference of a circle is 2*pi*r
322: <endouttext />
1.11 felicia 323: </problemtype>
324: \end{verbatim}
325: 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.
326:
1.1 bowersj2 327: \end{itemize}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>