Re: real subscripts and superscripts?

2014-12-02 Thread Karl Berry
can't be that difficult to implement a suitable \superscript macro.

Indeed.

I committed the changes to texinfo.tex (and the documentation) so that
@sub/@sup stay in math mode inside @math, and do a textual
sub/superscript outside @math.

The remaining complication (unsolved) is if someone wants a word as a
sub/superscript inside @math, like my original example,
@math{x@sub{first}}

You suggested using @asis, but that doesn't make sense to me; @asis
should just mean, well, as-is.  @r works, more or less by accident, but
@i (what one would typically want) doesn't, for two reasons: 1) @math
switches to (99% of) @tex mode, where @i = plain \i = dotless i.  That
would be easy enough (though undesirable in principle, it seems to me)
to kludge around, but then there is (2) the TeX font families aren't all
set up since we haven't needed them before.

It all gets pretty painful, and it seems an unlikely usage, so I'm
hoping we can just leave it unsolved for now.

k




Re: real subscripts and superscripts?

2014-12-01 Thread Patrice Dumas
On Fri, Nov 28, 2014 at 07:01:09PM +, Karl Berry wrote:
 
 Is your proposal really just working around makeinfo not recognizing ^
 and _ in math in the first place?  It seems to me that might be
 implementable without too much trouble -- the parsing could maybe be
 treated like the accent commands, so that if the next thing is a
 non-lbrace single token, the braces aren't necessary.  Seems to me that
 could only help, in any case, if it's doable.  Patrice, wdyt?

I think that we should refrain from trying to convert the TeX in @math
in Texinfo.  If there is some TeX parser and converter we can embed it,
but I don't think it is worth doing it ourselves.  So, for HTML, tex4ht
can do the translation of math, and if something similar exists that
outputs simple text, fine, but otherwise, this seems to me to be a bad
idea for a Texinfo parser to parse TeX math too.

 If I may dare to generalize a tiny bit -- in principle, I'd rather that
 we recognize TeX math in the first place than invent new Texinfo
 commands to do the same thing.

I agree, but I add that I'd rather that we use specialized TeX renderers
rather than handle it ourselves.

-- 
Pat



Re: real subscripts and superscripts?

2014-12-01 Thread Per Bothner

On 12/01/2014 04:31 PM, Karl Berry wrote:

The remaining question would be about @sup/@sub outside
of math -- go into math by default, or stay in text?  I would be
inclined toward the latter (which is also what texi2any does now).


I think the latter makes most sense: it seems more useful and consistent.
It is maybe *slightly* easier to implement @sup{TEXT} as $^{TEXT}$
rather than \superscript{TEXT} or whatever, but it can't be that difficult
to implement a suitable \superscript macro.
--
--Per Bothner
p...@bothner.com   http://per.bothner.com/



Re: real subscripts and superscripts?

2014-11-28 Thread Gavin Smith
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=mathe =
 mcsup2/sup/span
 or similar - i.e. I want to use sup2/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.



Re: real subscripts and superscripts?

2014-11-28 Thread Per Bothner



On 11/28/2014 11:01 AM, Karl Berry wrote:

Sure, sub/superscripts are most commonly used in math.  Thus @math, as
in @math{e=mc^2}.  I never expected anything else to be used, certainly
not clunky macros.  This is why @math was created in the first place.

Is your proposal really just working around makeinfo not recognizing ^
and _ in math in the first place?


My use case is primarily *not* math - I mainly want subscripts and superscripts.
For example function prototypes:
  (list exp@sub{1} ... exp@sub{n})
Syntax descriptions:
  list = nil | (value@sup{+})
Language names:
  Schema as specified by R@sup{7}RS.

However, I do have some need for math:
  A quaternion is a number that can be expressed in the form ‘w+xi+yj+zk’,
  where w, x, y, and z are real, and i, j, and k are imaginary units satisfying
  @math{i^2 = j^2 = k^2 = ijk = -1}. The magnitude of a quaternion is defined 
to be its
  Euclidean norm when viewed as a point in @math{R^4}.

I want some sane way of writing i^2 and R^4 so I get tolerably-looking
expressions with superscripts in both TeX andDocBook/HTML.


Having been drafting the documentation, I can say that it feels quite
clean to say use @sub/@sup for text, @math{^_...} for math.  It's no
problem to implement @sub/@sup being like ^ and _ in math mode and doing
text in text mode, etc., but, I don't know, usage doesn't seem as clear.

If I may dare to generalize a tiny bit -- in principle, I'd rather that
we recognize TeX math in the first place than invent new Texinfo
commands to do the same thing.


In the above example I don't care if I have to write @math{R^4} or 
@math{R@sup{4}},
as long as I don't have to use conditionals, and I get a sup when
emitting HTML.

--
--Per Bothner
p...@bothner.com   http://per.bothner.com/



Re: real subscripts and superscripts?

2014-11-28 Thread Karl Berry
I want some sane way of writing i^2 and R^4 so I get tolerably-looking
expressions with superscripts in both TeX andDocBook/HTML.

Sure.

First, with non-letter superscripts (numbers, +, etc.), you're fine with
the present @sup inside math, regardless of whether @sub/@sup mean text
inside math for TeX, because numbers are typeset by TeX in roman, not
math italic, in any case.

makeinfo presently outputs @math as em.../em, which results in
italic sub/superscripts inside @math (as well as everything else),
regardless of their content.  That's inconsistent with TeX, but I think
it's expected and reasonable for HTML.

Implementing ^_ in makeinfo would allow for better matching of
input/output, i.e., allowing documents to use ^_ inside @math and get
the expected output.  I think that's desirable for its own sake,
separate from any question of @sub and @sup.

Anyway, it's alphabetic sub/superscripts where the question of whether
@sub/@sup means text inside math makes a difference to TeX (nothing
else).  I'll await Patrice's comments before finalizing the TeX versions
and documentation.  I don't feel that strongly about it.

karl



Re: real subscripts and superscripts?

2014-11-27 Thread Karl Berry
Per and all,

In TeX inside @math: ^{TEXT}
In TeX otherwise: use a macro ...

I'm thinking that TeX, either inside or outside @math, should treat TEXT
as text, not math.  That is, if you simply want to produce the math
expression a-to-the-power-of-b, you'd write @math{a^b}, rather than
@math{a@sup{b}}.  The difference is whether b is typeset in math italic
or roman.  After all, sometimes people want to typeset a word in math,
as in @math{a@sup{first}}.

This seems more consistent with the treatment in the other output
formats.  Also, since there's already a way to get math
super/subscripts, but no way to get text super/subscripts, we might as
well provide something new.

Unless there's an argument otherwise?

(FYI, Patrice has already implemented @sub and @sup per your suggestion
+ discussion in texi2any.)

Thanks,
Karl



Re: real subscripts and superscripts?

2014-11-27 Thread Per Bothner



On 11/27/2014 04:13 PM, Karl Berry wrote:

Per and all,

 In TeX inside @math: ^{TEXT}
 In TeX otherwise: use a macro ...

I'm thinking that TeX, either inside or outside @math, should treat TEXT
as text, not math.  That is, if you simply want to produce the math
expression a-to-the-power-of-b, you'd write @math{a^b}, rather than
@math{a@sup{b}}.  The difference is whether b is typeset in math italic
or roman.  After all, sometimes people want to typeset a word in math,
as in @math{a@sup{first}}.

This seems more consistent with the treatment in the other output
formats.  Also, since there's already a way to get math
super/subscripts, but no way to get text super/subscripts, we might as
well provide something new.


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=mathe = mcsup2/sup/span
or similar - i.e. I want to use sup2/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

This is painful, though I guess you could write a macro:

@iftex
@macro mathsup{THING}
^\THING\
@end macro
@end iftex
@ifnottec
@macro mathsup{THING}
@sup{\THING\|
@end macro
@end ifnottex

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.

For the rare cases where you *don't* want math italic, an idea is to use @asis.
I.e. @sup{@asis{TEXT}} means typeset TEXT raised and smaller but in a roman 
font.

OTOH for most people it won't really matter is TEXT is math italic or roman.
What they want is to be able to write @sup{TEXT} and have it come out
as a superscript and not looking to weird.

It just seems to be that @sup{TEXT} inside @math using math italic is more
likely to be what you want - most of the time.  It seems a more robust default.
People who don't want math italic formatting would probably not use @math.
Or use @asis to override mathe styling.
--
--Per Bothner
p...@bothner.com   http://per.bothner.com/



Re: real subscripts and superscripts?

2014-11-23 Thread Karl Berry
 I can add these to texinfo.tex and texinfo.texi, etc., easily enough.
 Do you have time to add it to makeinfo?

Yes.  

Great.  I will work on it next week.

For HTML cross manual I propose doing the same as for style
commands and key and kbd, that is replace by the content.

Agreed.

Also in raw text, I propose using content as is without any formatting
(used for instance for file names, for index sorting).

Fine.

Thanks,
K



Re: real subscripts and superscripts?

2014-11-22 Thread Dumas Patrice
On Sat, Nov 22, 2014 at 07:08:48PM +0100, Dumas Patrice wrote:
 On Wed, Nov 19, 2014 at 11:07:04PM +, Karl Berry wrote:
  Maybe I would favor using x^{2}y in textual context too, since there is
  no good solution, and it is simpler to implement and explain ...
  
  Ok by me.  Doing the simple way (always add braces) first seems
  reasonable; if it turns out that the feature gets used enough and people
  really don't like it, the output can always be tweaked later.
  
  I can add these to texinfo.tex and texinfo.texi, etc., easily enough.
  Do you have time to add it to makeinfo?
 
 Yes.  For HTML cross manual I propose doing the same as for style
 commands and key and kbd, that is replace by the content.

Also in raw text, I propose using content as is without any formatting
(used for instance for file names, for index sorting).

-- 
Pat



Re: real subscripts and superscripts?

2014-11-19 Thread Karl Berry
Maybe I would favor using x^{2}y in textual context too, since there is
no good solution, and it is simpler to implement and explain ...

Ok by me.  Doing the simple way (always add braces) first seems
reasonable; if it turns out that the feature gets used enough and people
really don't like it, the output can always be tweaked later.

I can add these to texinfo.tex and texinfo.texi, etc., easily enough.
Do you have time to add it to makeinfo?

Thanks,
Karl







Re: real subscripts and superscripts?

2014-11-18 Thread Karl Berry
Hi Per,

Are real subcripts/superscripts planned?

There has been no specific plan to date, for this or any of the many
other things lacking in Texinfo.  Your message is very helpful in that
regard.

(2) Introduce new @sub and @sup commands (or @subscript/@superscript

@sub and @sup sound good to me.  The only complication I can think of is
that \sup already exists in TeX (typesets the mathematical operator
sup, three roman letters).  It would not be feasible to distinguish
@sup from \sup, although of course it would be trivial to create \supop
or some such to still be able to access it.  I rather suspect that the
number of existing Texinfo documents that use TeX's \sup is zero.

In info or plaintext: ^TEXT
In HTML: supTEXT/sup
In DocBook: superscriptTEXT/superscript
In XML: I suggest supTEXT/sup
In TeX inside @math: ^{TEXT}
In TeX otherwise: use a macro ...

That all sounds fine to me.  I only wonder about Info/plaintext needing
some kind of delimiter in the case where TEXT is multiple characters.
As in x@sup{2y} is different from x@sup{2}y, but both would be
represented by x^2y given the above.  Maybe x@sup{2y} should go to
x^(2y) in Info.

That's a math example so I suppose people should use @math, although you
can be sure that once the feature exists, it will get (ab)used for
everything possible.  I'm not sure if there are examples of textual
super/subscripts where parens or something would be desirable.  I can't
think of any; something like 1@sup{st} is readable enough as 1^st (ugly
enough, too).

Patrice, Gavin, wdyt?

Thanks,
Karl



real subscripts and superscripts?

2014-11-17 Thread Per Bothner

Currently texinfo only supports subscripts and superscripts in @math,
which are only effective in tex mode.  This is unfortunate since both
HTML and DocBook support them.  Are real subcripts/superscripts planned?

I can see two ways to do it:

(1) Parse @math to extract the ^ and _ characters and turn them into the
correct HTML/DocBook elements. This requiring parsing tex math, which is 
non-trivial.
Also, the result is probably wrong if the raised/lowered text contains actual
text (as supposed to numbers or math symbols).

(2) Introduce new @sub and @sup commands (or @subscript/@superscript if you want
to be more verbose - and follow DocBook).  The effect of (say) @sup{TEXT} would 
be:

In info or plaintext: ^TEXT
In HTML: supTEXT/sup
In DocBook: superscriptTEXT/superscript
In XML: I suggest supTEXT/sup
In TeX inside @math: ^{TEXT}
In TeX otherwise: use a macro that raises the text and reduces the font-size
--
--Per Bothner
p...@bothner.com   http://per.bothner.com/