Alt text on math symbols

Announcements, comments, ideas, feedback, and "How do I... ?" questions
Post Reply
ptarjan
Posts: 4
Joined: Sun Nov 30, 2008 10:12 am

Alt text on math symbols

Post by ptarjan »

I'm not sure how you generate your math symbols, but they are rendered as images what an alt text of "". That means if I copy and paste the problem into the top of my source code, I get blanks wherever the images are. If you can set the alt text to be a good representation of the symbol, that would make it much more accessible and easier to put as the header for my source code.

Example:

http://projecteuler.net/images/symbol_le.gif could have alt text "<="

Thanks. Its just kinda funny to see the top of my source code : For 1 k 55, sk = [100003 200003k + 300007k3]. Hard to figure out what I was doing.

Thanks for the great side. I'm really enjoying it.

Paul
User avatar
euler
Administrator
Posts: 5095
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: Alt text on math symbols

Post by euler »

I've learned something new today! I hadn't realised that when web content is copied and pasted into a text editor that the images are replaced with the "alt" text; thanks for that, ptarjan.

Anyway, you'll be pleased to see that the HTML entity name is now contained in the alt value. Just a shame about superscript and subscript text now.
Image
impudens simia et macrologus profundus fabulae
ptarjan
Posts: 4
Joined: Sun Nov 30, 2008 10:12 am

Re: Alt text on math symbols

Post by ptarjan »

Thanks for the fast reply, and the REALLY fast implementation, looks great :)

I was playing with a few ways to do the sup and sub, and I came up with:

c<img style='display:none' alt='**'/><sup>2</sup>

or you could use "^" instead of "**". Similarly, "_" could be for sub.

Or if you want to get fancy, you can put a "(" to the left and ")" img to the right. Up to you.

I don't know if it is worth it to you, but it does make copying and pasting nice :)

http://fileserver.paulisageek.com/test/sup.html

Thanks again.

Paul
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Re: Alt text on math symbols

Post by elendiastarman »

What would happen if you did "2^2^2^2"?
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
User avatar
euler
Administrator
Posts: 5095
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: Alt text on math symbols

Post by euler »

I got fancy. :wink:

Unfortunately, I've discovered that this is only works in Firefox. However, unlike the typical statistics found on the internet, it is interesting to note that around 60% of our members use Firefox. So those with good taste will reap the benefits.
(FYI, around 20% of our members use IE, and the rest use Safari, Opera, and others in that order.)
elendiastarman wrote:What would happen if you did "2^2^2^2"?
It would appear as 2^(2^(2^(2)))).
Image
impudens simia et macrologus profundus fabulae
ptarjan
Posts: 4
Joined: Sun Nov 30, 2008 10:12 am

Re: Alt text on math symbols

Post by ptarjan »

Looks great, thank you euler.

Also, I'm happy to see the browser statistics :) I'll check it in IE6-8 when I get home and see which copys the alt text. Some might use the title text. I'm not sure if there is a standard, or even if there is a de-facto standard.

Anyways, thanks a ton for being so responsive. I love this site!
sigh
Posts: 5
Joined: Wed Nov 19, 2008 11:46 pm

Re: Alt text on math symbols

Post by sigh »

Wow, that's pretty cool :). Thanks for all the work you do, euler.

Btw, now some of the problems look a bit funny now:
Problem 7 wrote: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13.

What is the 10001^(st) prime number?
It doesn't really bother me, but I thought I'd mention it in case you didn't intend for this. This issue arises in quite a few problems.
User avatar
hk
Administrator
Posts: 12831
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Alt text on math symbols

Post by hk »

I don't see anything weird when viewing the text of problem 7 in IE8, Firefox and Opera. All is as should be.
I presume that, as far as copying is concerned, the text between <sup> and </sup> is translated into ^(..).
I don't see any way of doing it otherwise and I think the guys that insist on copying should interpret it back that way.
Image
War ruins the life and health of untold numbers of innocent children.
sigh
Posts: 5
Joined: Wed Nov 19, 2008 11:46 pm

Re: Alt text on math symbols

Post by sigh »

I didn't mean to imply that it should be one way or another, or that it was behaving differently to how euler described.

I was just pointing out that rendering x^(2) correctly also has the side effect of rendering things like 1st as 1^(st) and 1/7 as ^(1)/_(7).

It's possible that these cases were overlooked when deciding what to implement, so I pointed it out on the chance that you hadn't considered it and didn't think it desirable.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Alt text on math symbols

Post by stijn263 »

elendiastarman wrote:What would happen if you did "2^2^2^2"?
I was wondering, what is the value of 3^3^3 ? Is it 3^27 or 27^3? Maple returns:
Error, ambiguous use of `^`, please use parentheses
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Re: Alt text on math symbols

Post by elendiastarman »

I always go with latest-first.
So, in my opinion, 3^3^3 = 3^27.
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Alt text on math symbols

Post by rayfil »

What would happen if you did "2^2^2^2"?
This one would be irrelevant. Being ambiguous, such a statement would NEVER be used in the definition of a PE problem. :?
When you assume something, you risk being wrong half the time.
User avatar
uws8505
Posts: 58
Joined: Tue Sep 30, 2008 3:13 pm
Location: South Korea

Re: Alt text on math symbols

Post by uws8505 »

stijn263 wrote:I was wondering, what is the value of 3^3^3 ? Is it 3^27 or 27^3? Maple returns:
Error, ambiguous use of `^`, please use parentheses
Mathematica gives 3^3^3 = 3^27 = 7625597484987, not 27^3 = 19683. Maybe the order of ^ operation is right-to-left.
Math and Programming are complements
User avatar
xan
Posts: 621
Joined: Sat Jul 28, 2007 12:43 am
Location: North Carolina, USA
Contact:

Re: Alt text on math symbols

Post by xan »

rayfil wrote:Being ambiguous, such a statement would NEVER be used in the definition of a PE problem.
When typeset, I think the font sizing clarifies things. If each 2 is smaller than the previous, then it's right-to-left. Closest I can find in PE is Problem 197 (View Problem). There's a quadratic binomial in the exponent, but I can't repeat the formula here since the forum software doesn't seem to support nested tags.
User avatar
euler
Administrator
Posts: 5095
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: Alt text on math symbols

Post by euler »

But copying and pasting it using Firefox gives the expected (flat) equivalent: f(x) = ⌊2^(30.403243784-x^(2))⌋ × 10^(-9)
Image
impudens simia et macrologus profundus fabulae
User avatar
Georg
Posts: 157
Joined: Mon Jan 21, 2008 7:00 am
Location: Mannheim, Germany
Contact:

Re: Alt text on math symbols

Post by Georg »

stijn263 wrote:I was wondering, what is the value of 3^3^3 ? Is it 3^27 or 27^3? [...]
elendiastarman wrote:[...] So, in my opinion, 3^3^3 = 3^27.
rayfil wrote:[...] Being ambiguous, [...]
uws8505 wrote:[...] Maybe the order of ^ operation is right-to-left.
xan wrote:[...] If [...] then it's right-to-left.
In mathematics, exponentiation of real numbers is a right-associative operation.

In programming languages, the associativity of an operator depends on the programming language in question.
Last edited by Georg on Tue Dec 09, 2008 3:26 pm, edited 2 times in total.
User avatar
xan
Posts: 621
Joined: Sat Jul 28, 2007 12:43 am
Location: North Carolina, USA
Contact:

Re: Alt text on math symbols

Post by xan »

I did a survey of programming languages a while back when I was writing an interpreter for a scripting language and found there was no universal agreement among them about left or right associativity for the exponentiation operator. VisualBasic, I think, is one where it's left-associative.
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Re: Alt text on math symbols

Post by elendiastarman »

What are the advantages of left- over right- associativity?
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
User avatar
DNS
Posts: 30
Joined: Thu Oct 16, 2008 9:32 am
Location: Ukraine, Nikolaev

Re: Alt text on math symbols

Post by DNS »

hk wrote:I don't see anything weird when viewing the text of problem 7 in IE8, Firefox and Opera. All is as should be.
I presume that, as far as copying is concerned, the text between <sup> and </sup> is translated into ^(..).
I don't see any way of doing it otherwise and I think the guys that insist on copying should interpret it back that way.
I haven't seen it too, but in time when LAN Internet had problems, I use my smartphone (with "small-opera"). There I see problems.
2 x 2 = 4 = true
Post Reply