--- loncom/html/adm/help/tex/Authoring_Output_Tags.tex 2017/01/19 21:12:45 1.23 +++ loncom/html/adm/help/tex/Authoring_Output_Tags.tex 2017/02/01 21:18:43 1.26 @@ -17,8 +17,30 @@ exp, abs, logten, log, ln, sqrt, sgn, st O2 + 2H2 -> 2H2O \end{verbatim} will be rendered: - $\mathrm{O_2} + 2\,\mathrm{H_2} \to 2\,\mathrm{H_2O}$ + +\textbf{Syntax Description} +\begin{itemize} +\item Reactants are separated from products by `\texttt{->}'. +\item Individual reactants and products are separated by `\texttt{ +}' (leading space is obligatory). +\item Numbers preceding the first symbol of a chemical specie are considered to be stoichiometric coefficients. +\item Numbers appearing after the first symbol of a chemical specie are considered to be subscripts. +\item Superscripts are initialized by `\texttt{\^{}}' and terminated by a space. +\item Ionic charges are superscripts composed of a number followed by a sign (i.e. `\texttt{\^{}2+}'). +\end{itemize} + +\textbf{More examples} +\begin{itemize} +\item $\mathrm{Ca}(\mathrm{NO}_3)_2$ is written as:\\ +\texttt{Ca(NO3)2} +\item $\mathrm{OH}^- + \mathrm{H_3O}^+ \to 2\mathrm{H_2O}$ is written as:\\ +\texttt{OH\^{}- + H3O\^{}+ -> 2H2O} +\item $[\mathrm{Co}(\mathrm{H_2O})_6]^{2+} + 4\mathrm{Cl}^- \to [\mathrm{CoCl_4}]^{2-} + 6\mathrm{H_2O}$ is written as:\\ +\texttt{[Co(H2O)6]\^{}2+ + 4Cl\^{}- -> [CoCl4]\^{}2- + 6H2O} +\item $^3_1\mathrm{H} + ^2_1\mathrm{H} \to ^4_2\mathrm{He} + ^1_0\mathrm{n}$ is written as:\\ +\texttt{\^{}3 1H + \^{}2 1H -> \^{}4 2He + \^{}1 0n} +\end{itemize} + \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. \begin{verbatim} 31454678 results in 3.15 x 10^7 @@ -148,7 +170,7 @@ between the start and the end tag. By de When printing, the included text will be rendered in a visible box. -\item \textbf{m}\index{m}: The inside text is \LaTeX{}, and is converted +\item \textbf{m}\index{m}\index{equations}: 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 \textbf{display} to one of @@ -178,6 +200,76 @@ You will get the equation rendered with \$b may take on. +\item \textbf{lm}\index{lm}\index{equations}: This is another way to input math, which does not require +knowing \LaTeX{}. +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. +Eventually, this syntax will also be used to evaluate \texttt{} (it is already used for the real-time preview). + +\begin{description} +\item[Spaces]~\\ + Spaces are always ignored. + +\item[Decimal separators and function parameter separators]~\\ + To keep compatible with previous \texttt{} syntax, only ``.'' can be used as a decimal separator, and ``,'' is used to separate function and vector/matrix parameters. + +\item[Variables and constants]~\\ + Variable names and constant names are used directly, without any special character before. They are displayed in italics. + +\item[Units]~\\ + 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. + +\item[Parenthesis]~\\ + Parenthesis can be used to specify evaluation order. They are only displayed when necessary. + +\item[Operators]~\\ + arithmetic: \texttt{+ - * / \^{}}\\ + factorial: \texttt{!}\\ + relational: \texttt{= \# < <= >= >}\\ + units: \texttt{`}\\ + Example: \texttt{2`m + 3`m = 5`m}\\ + scalar product for vectors, multiplication for matrices: \texttt{.}\\ + +\item[Implicit operators]~\\ + \texttt{*} and \texttt{`} are implicit. + + The parser will try to guess which operator is missing whenever possible. The choice between * and ` depends on the mode for interpreting equations. + + 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). + +\item[Functions]~\\ + Functions use the syntax \texttt{f(a,b)}. + + basic: + + \quad \texttt{sqrt(x)}, \texttt{abs(x)}, \texttt{exp(x)=e\^{}x}, \texttt{factorial(x)=x!} + + binomial (displayed like a vector): + + \quad \texttt{binomial(n,p)=n!/(p!*(n-p)!)} + + sum and product (requiring symbolic mode): + + \quad \texttt{sum(f(x),x,x1,x2)}, \texttt{product(f(x),x,x1,x2)} + + differential, integral, limit: + + \quad \texttt{diff(expr,x,n)}, \texttt{integrate(expr,x,a,b)}, \texttt{limit(expr,x,val,dir)} + +\item[Vectors and matrices]~\\ + Vectors and matrices are defined with square brackets. A matrix is made of a list of row vectors. + + vectors: \texttt{[1,2,3]}\\ + matrices: \texttt{[[1,2],[3,4]]} + +\item[Sets]~\\ + Sets are defined with curly brackets: \texttt{\{1,2,3\}} + + union: \texttt{union(\{1,2\},\{1,3\}) = \{1,2,3\}}\\ + intersection: \texttt{intersection(\{1,2\},\{1,3\}) = \{1\}} + +\end{description} + + \item \textbf{randomlabel}\index{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. @@ -218,9 +310,9 @@ external image or a LON-CAPA resource. I \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} - -The formula for the circumference of a circle is 2*pi*r - + + The formula for the circumference of a circle is 2*pi*r + \end{verbatim} 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.