PDA

View Full Version : Maths Equation Formatting


Tomgupper
03-12-2008, 04:36 AM
I'm currently working on a series of maths quizzes. Users answer questions, and get a 'yay, you're smart' if they get it right, or a popup explaining how to get the correct answer if they're wrong.

For example, the popup for Area of a Triangle reads as follows :


The Correct answer for this question would have been :
Base = TheBaseValue
Height = TheHeightValue
Press Restart to attempt the exercise again. Good Luck!


You might be able to see my problem.
what would be the best way to format this text, so that the '=' signs are always aligned vertically down the page - *without* there being a massive gap between the '=' sign, and the text on either side.

Essentially I want the stuff on the left to be right justified, the stuff on the right to be left justified, and the equals signs to be aligned down the page.

I've gotta solve this now, because further down the road I'll be dealing with larger equations, and I'll need some form of formatting system in order to keep them organised.

I've tried using HTML formatting, but nothing seems to work correctly. Suggestions ?

lordofduct
03-12-2008, 05:08 AM
First use a constant width font. This is a font that all characters use the same amount of pixels wide (i.e. the font used by Notepad on windows).

Then just check the string length of each string before each = sign, and set all those strings to the same length (append spaces to the ends of the shorter ones).

Tomgupper
03-12-2008, 05:11 AM
First use a constant width font. This is a font that all characters use the same amount of pixels wide (i.e. the font used by Notepad on windows).

Then just check the string length of each string before each = sign, and set all those strings to the same length (append spaces to the ends of the shorter ones).

Yep, that makes sense.
Is there a solution without using a fixed width font ?