On Fri, Nov 28, 2014 at 6:54 AM, Per Bothner <p...@bothner.com> wrote: > Supposed I want to write a formula like e=mc^2 in TexInfo. > In TeX I'd like it to be typeset $e = mc^2$. > In HTML I'd like it to be typeset <span class="math">e = > mc<sup>2</sup></span> > or similar - i.e. I want to use <sup>2</sup>. Likewise for DocBook and XML. > > How would you express this in texinfo? > > With your proposal I'd have to write something like: > @iftex > @math{e=mc^2} > @end iftex > @ifnottex > @math{e=mc@sup{2}} > @end ifnottex >
There are many types of mathematical notation that may not be as easy to express in HTML. Rather than implement this and require document writers to write "c@sup{2}" instead of "c^2" if they want it to come out right in HTML, and then adding more commands later for other mathematical notation (e.g. fractions, integrals, summation symbols, square roots), maybe it would be better to look for ways to create an image file containing the typeset notation and include it in the HTML document. This would seem better to me than creating a lot of new Texinfo commands to replicate the functionality of the notation that already exists in TeX. The other argument would be that this use case (displaying mathematical expressions containing superscripts) is so common that it is worth adding as a special case, even if the general case is not implemented. However, I think it's likely that any document containing mathematical superscripts would like to avail itself of other mathematical notation too. (Taking the $e = mc^2$ example, we might want to give the expression for the energy of a moving object, $e = \sqrt{ (m_0 c^2)^2 + (pc)^2 }$.) > > It seems kind of klunky. I suspect most of the time if you have @sup{TEXT} > TEXT is a single number, symbol, or lesser, so you'd probably want it to > be in math italic. > I don't think numbers should be in italic in superscript. makeinfo would have to check whether it is a letter or number to decide whether to put in italics in the HTML output. If it is a more complicated expression like "n + 1", it would be stuck. Therefore it would be better for the author to explicitly encode when they want italics in the superscript: e.g., "@i{x}@sup{@i{n} + 1}". Another idea is to have a command explicitly intended for mathematical superscripts (e.g. @power instead of @sub), and not any general typographical use (whatever that might be). However, I can't see that this would achieve much.