Math output

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2009
Posts: 123
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Math output

 
2
  #1
Sep 29th, 2009
Hi!!!!!!!
I have made a window application in which i am entering mathematical equations and side by side the corresponding math format is generated like we see in books.
In this, I am using LATEX/MimeTEX for generating math format and it uses special symbols for generating math format.
Like for square root ,we use "\sqrt" , for divide symbol we use "\div" , for fraction we use "\frac" and so on .The complete list of symbols can be seen on following link:
http://www.forkosh.com/mimetextutorial.html

Now, i want to make it more user friendly in such a way that when user clicks on divide button then a divide sign should appear like "÷" but in coding it should implement "\div" and generate the coresponding math format.Similarly for fraction ,in the textbox there should appear "()/()" and in background it should implement "\frac {}{}".Similarly for other functions also such text should appear in textbox which user can understand easily but in ocding it should implement the symbols which mimeTex can understand.

Can anyone give me the solution for this.............
If anyone finds solution for this,and if he\she wants then I will attach my application.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 378
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 68
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #2
Sep 29th, 2009
Hi, you have working code that takes the user input and displays it in Math format, is that correct?
If so, could you post that code here and we can show you how to rework it
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 123
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #3
Sep 29th, 2009
my application is attached here............
In this open "Eq2ImgWinForms" in visual studio
Kindly help me and reply soon..........
Attached Files
File Type: zip eq2img_all.zip (1.49 MB, 8 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 378
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 68
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #4
Sep 29th, 2009
personally, i would display the readable characters in the textbox, then parse the textbox.text trhough a function that swaps out the readable characters for math format using string.replace.

  1.  
  2. private string FormatText(string input)
  3. {
  4. input = input.Replace("÷", "//div");
  5. input = input.Replace("√", "sqrt");
  6. //and so on
  7. return input;
  8. }
  9.  
  10. //then call the function like this:
  11. WriteEquation(FormatText(textBoxEquation.Text));

it may be easier to use regular expressions, but i have very limited experience with them so someone more versed may be able to point you in the right direction.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,263
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 581
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Math output

 
0
  #5
Sep 29th, 2009
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 123
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #6
Sep 30th, 2009
Originally Posted by sknake View Post
Take a look at these articles:
http://www.c-sharpcorner.com/UploadF...alculator.aspx
http://www.bestcode.com/html/bcparser_net.html
Hi,I have already read these articles..........
These are for calculations.But I want to show math format not the calculations............
And the application which I have attached ,in that I have done almost everything.........I just want you to modify it in such a way that it becomes user friendly.For example, for fraction latex symbol used is "\frac {}{}",but for user I want that if he clicks on fraction button then in textbox there should appear "()/()" but in coding it should implement for MIMETex................
Kindly help me regarding this ,how in code I could replace the textbox text with Mimetex and correspondingly it generate math output......
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 378
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 68
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #7
Sep 30th, 2009
The way i see it there are two choices:

1) you can try the way i suggested, populate the textbox with the user friendly text then reformat it using string functions/regex.

2) build two strings, any time you add to the user friendly textbox, add the math format to a class level string variable as well. This way you'll have one string that the user can read and one that is formatted for the MIMETex. The problem you'll have here is keeping the two in sync...very tricky, since you'd have to capture the changes in the textbox : /

I think 1) is the way to go... just pass the string through a function that pulls out the user friendly text and rearranges it into MIMETex format.

Regular expressions would probably be helpful to you here. Check out:
http://msdn.microsoft.com/en-us/libr...66(VS.71).aspx
http://www.regular-expressions.info/
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 123
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #8
Sep 30th, 2009
Hi Ryshad,
I tried in the same way.
But ,for example, for fractions I used "()/()" in textbox and in FormatText() function I added a line "input = input.Replace("()/()","\\frac {}{}");".
But its not working......
Also ,I am not able to get how to reformat it using string function.
As I have already given you my code.Kindly modify that and help me out...
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 378
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 68
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Whiz

Re: Math output

 
0
  #9
Sep 30th, 2009
Hi,

The replace function will only replace exact string matches, so if the user has entered numebrs into the brackets then the string will no longer match : "(12)/(24)" != "()/()"

You will definitely need to use regular expressions here to find the sections you want to replace. Read through the links i sent you...its been a long time since i worked with Regex so i cant rewrite the code for you atm : /

Perhaps someone more familair with it can give you a sample
Last edited by Ryshad; Sep 30th, 2009 at 7:08 am.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 123
Reputation: vinnijain is an unknown quantity at this point 
Solved Threads: 10
vinnijain vinnijain is offline Offline
Junior Poster

Re: Math output

 
0
  #10
Sep 30th, 2009
hi Sknake,
The links which you have given me,I have already read those.I don't want calculation,but only want to generate math format for the equation entered in the textbox.
The work which I have done is attached in this thread...........
Kindly help me out.....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC