| | |
Math output
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 123
Reputation:
Solved Threads: 10
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.
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.
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.
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.
C# Syntax (Toggle Plain Text)
private string FormatText(string input) { input = input.Replace("÷", "//div"); input = input.Replace("√", "sqrt"); //and so on return input; } //then call the function like this: 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.
Take a look at these articles:
http://www.c-sharpcorner.com/UploadF...alculator.aspx
http://www.bestcode.com/html/bcparser_net.html
http://www.c-sharpcorner.com/UploadF...alculator.aspx
http://www.bestcode.com/html/bcparser_net.html
•
•
Join Date: Jul 2009
Posts: 123
Reputation:
Solved Threads: 10
•
•
•
•
Take a look at these articles:
http://www.c-sharpcorner.com/UploadF...alculator.aspx
http://www.bestcode.com/html/bcparser_net.html
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......
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/
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
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
•
•
Join Date: Jul 2009
Posts: 123
Reputation:
Solved Threads: 10
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...
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...
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
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
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
![]() |
Similar Threads
- how to use regex or an array to display some output from an arithmetic input? (VB.NET)
- Trouble with area (Java)
- math help (PHP)
- math program (C)
- Math.max prob???...XD (Java)
- So Stuck (C++)
- Assigning Array Values En Masse (Java)
- Output in Text file-How to apply fprintf()? (C)
- Output in the text file (C)
- missing function header (C++)
Other Threads in the C# Forum
- Previous Thread: How to generate button at runtime and its text from database for windows application
- Next Thread: password setting in a software
| Thread Tools | Search this Thread |
.net access ado.net algorithm api array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ grantorrevokepermissionthroughc#.net gtk hospitalmanagementinformationsystem httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick mysql operator oracle path photoshop picturebox pixelinversion platform post programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wordautomation wpf xml






