kostub / matheditor Goto Github PK
View Code? Open in Web Editor NEWAn editor for math equations for iOS
License: MIT License
An editor for math equations for iOS
License: MIT License
怎么设置可以换行
For display formulas can use "MTEditableMathLabel" but how can I get it's result ?
for example if I enter label.mathList.stringValue 5^{2}, how can I get it's output.. Please help me out with suitable sample if possible.
@kostub
So there are two things that I want to achieve with the MTEditableMathLabel.
Change the Textalignment to left
Make the Label expand / shrink with the latex inside. I have this code from the example and converted it to Swift 3
`func textModified(_ label: MTEditableMathLabel!) {
let minHeight: CGFloat = 64
// Increase the height of the label as the height increases.
let mathSize: CGSize = label.mathDisplaySize()
if (mathSize.height > self.editLabel.frame.height - 10) {
label.layoutIfNeeded()
// animate
self.editLabel.frame = CGRect(x: self.editLabel.frame.origin.x, y: self.editLabel.frame.origin.y, width: self.editLabel.frame.width, height: mathSize.height + 10)
label.layoutIfNeeded()
}
else if (mathSize.height < self.editLabel.frame.height - 20) {
let newHeight: CGFloat = max(mathSize.height + 10, minHeight);
if (newHeight < self.editLabel.frame.height) {
label.layoutIfNeeded()
self.editLabel.frame = CGRect(x: self.editLabel.frame.origin.x, y: self.editLabel.frame.origin.y, width: self.editLabel.frame.width, height: newHeight)
label.layoutIfNeeded()
}
}
// Shrink the font as the label gets longer.
if (mathSize.width > label.frame.size.width - 10) {
label.fontSize = label.fontSize * 0.9;
} else if (mathSize.width < label.frame.size.width - 40) {
let fontSize: CGFloat = min(label.fontSize * 1.1, 30);
if (fontSize > label.fontSize) {
label.fontSize = fontSize;
}
}
}`
Do you have code do what this code is doing with the height with the width ?
So I was working on making it possible, so that you could insert an editable Matrix in your editable math label. What I did was inserting this code into MTEditableMathLabel:
`- (void) insertMatrix: (int)rows :(int)columns :(NSString )type
{
MTMathAtom atom = [MTMathAtomFactory placeholderMatrix:columns :rows :type];
if (_insertionIndex.subIndexType == kMTSubIndexTypeDenominator) {
if (atom.type == kMTMathAtomRelation) {
// pull the insertion index out
_insertionIndex = [[_insertionIndex levelDown] next];
}
}
if (atom) {
if (![self updatePlaceholderIfPresent:atom]) {
// If a placeholder wasn't updated then insert the new element.
[self.mathList insertAtom:atom atListIndex:_insertionIndex];
}
if (atom.type == kMTMathAtomFraction) {
// go to the numerator
_insertionIndex = [_insertionIndex levelUpWithSubIndex:[MTMathListIndex level0Index:0] type:kMTSubIndexTypeNumerator];
} else {
_insertionIndex = _insertionIndex.next;
}
}
self.label.mathList = self.mathList;
[self insertionPointChanged];
if ([self.delegate respondsToSelector:@selector(textModified:)]) {
[self.delegate textModified:self];
}
}`
and this code into MTMathAtomFactory
`+ (MTMathAtom *)placeholderMatrix: (int)width :(int)height :(NSString )envname
{
NSError error;
NSMutableArray<NSMutableArray<MTMathList*>*>* rows = [[NSMutableArray alloc] initWithCapacity:(NSInteger)height];
for (int y = 0; y < height; y++)
{
NSMutableArray<MTMathList*>* row = [[NSMutableArray alloc] initWithCapacity:(NSInteger)width];
for (int x = 0; x < width; x++)
{
MTMathList* list = [MTMathList new];
[list addAtom:[self placeholder]];
row[x] = list;
}
rows[y] = row;
}
MTMathAtom* table = [MTMathAtomFactory tableWithEnvironment:envname rows:rows error:&error];
return table;
}`
This displays the matrix fine, but when I try to select one of the Values in the matrix I get this error, which I have no idea where it is coming from.
'MTLine type regular inside an MTLine - shouldn't happen'
But the display is exactly the way I want it to be. What is wrong here ? I really need help on this please. Thanks a lot for any help in advance.
MathEditor keyboard is showing since apple removed UIRemoteKeyWindow..Any suggesstion on this pls
There is a significant delay between a user initiating the edit on the label and the math keyboard appearing, resulting in a poor user experience.
I am wondering if you have any plans to address this. If not, any pointers for how it could be fixed would be appreciated.
Is there a way in the iosMath Library to transform the Latex into unicode form or do I have to write a parser for this?
I used the [MTMathListBuilder mathListToString:[_mathLabel mathList]];
to get the Latex from the EditableLabel, now I want to parse the Latex into the unicode form, for example
\frac{5x^{2}}{2}+(58+95x)\div \cos (x^{2})
(5x^2)/(2) + (58+95x) / cos (x^2)
Hi,
first of all thanks for your amazing work, I hope you still follow this project. How can I pre-fill the label starting from a LaTeX string?
Thanks
How do you get the raw Latex from the MTEditableMathLabel if it is possible. I didnt find any label.text member
Hello,
I created two buttons which allow to navigate Left and navigate Right one position. I thought by just calling previous and next on the _mathIndex it would go over the whole equation. However, if there are fractions or square roots, or an any atom of any other type it skips over them and does not enter them.
I thought maybe I should level up or level down depending if the next _mathIndex is of type fraction or root or whatever, but I had no luck. It just keeps skipping over them.
I'm guessing I have the logic of the class understood wrong. How am I supposed to be able to traverse 1 position at a time throughout the equation?
The ideal interface looks like:
@interface MTMathUILabel : UIView
<...>
@property (nonatomic) BOOL adjustsFontSizeToFit;
<...>
@end
Do you have any ideas about the clear way to implement it?
Currently I see the following solutions:
The Degree in the radical has a major bug which crashes on [self insertionPointChanged]
when there are more than one digit in the degree.
Hi,
If you look at the screenshot below, when typing fraction while inside the root, you cannot continue writing anything under that root, it continues to write formula outside of the root.
The problem is, I assume, that you cannot somehow select that fraction as you can other elements so it doesn't really know where to continue. Because of this you also cannot delete just the fraction but it deletes the whole root.
Is this a bug or I am missing something?
Hello,
I created a new keyboard the same way you have made the keyboard. However, the keyboard I created has integrals, ointegrals, summations, limits, and many other special characters which are included in Latex. However, the MTEditableMathLabel is not drawing these special characters. I noticed since you have technically mapped in the code how each fractions, superscripts, subscripts it will draw them correctly accordingly given the cases, doing it this way will not be maintainable in the long run. Is there a way we can pass any latex and have it drawn and made editable correctly without having to go through the hassle of writing code for each new button or functionality added? I am trying to achieve a keyboard similar to PhotoMath with more functionalities and keys.
(Also I admit I might be wrong in the way I have analyzed your code, maybe I did something wrong)
So first of, thank you so much for developing such an awesome Pod. It really solved a lot of my problems but I have a few things to still take care of and this seemed like the right place to ask.
Is it possible, and if yes how, to enter and edit matrices ?
How do I implement a custom keyboard in Swift ? I am writing my App in swift and I would like to make a custom keyboard. So I implemented the MTMathKeybard protocol but I can’t get info about what methods to implement.
When the Input gets wider then the width of the label theres currently (to my knowledge) to way to get back and forth. How would you go about this ?
I also have a little Question about your uneditable label but it is in the Issues threat of the Repository. But again, thank you so much for sharing this awesome work. I really am amazed by your work.
All my best,
Jony
Currently the text font is reduced when we type beyond view bounds. We want to allow typing in next line when frame exceeds the bounding rect. Can we use CTFrame instead of CTLine to make it multiline?
Hi,
I don't see why when you press square root symbol it would have to move to the outside of the current square root.
How to fix this?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.