kostub / iosMath

Beautiful math equation rendering on iOS and MacOS
MIT License
1.36k stars 234 forks source link

Negative sign doesn't render #161

Closed maxgiraldo closed 2 years ago

maxgiraldo commented 3 years ago

If I use the following LaTeX:

3z+20 > −3z+1

Then it renders as:

Screen Shot 2021-05-04 at 4 06 38 PM

Notice that the -3z renders as 3z

Does anyone know why that is? If I delete the negative sign and then re-add it, then sometimes it will render.

maxgiraldo commented 3 years ago

Here is an example SwiftUI view to reproduce the bug:

import SwiftUI
import iosMath

struct MathText: UIViewRepresentable {
    let latex: String

    func makeUIView(context: UIViewRepresentableContext<MathText>) -> MTMathUILabel {
        let label = MTMathUILabel()
        label.textAlignment = .center
        return label
    }

    func updateUIView(_ uiView: MTMathUILabel, context: UIViewRepresentableContext<MathText>) {
        uiView.latex = latex
    }
}

#if DEBUG
struct MathText_Previews: PreviewProvider {
    static let sample = "3z+20 > −99z+3"

    static var previews: some View {
        return (
            VStack {
                MathText(latex: sample)
                    .fixedSize()
            }
        )
    }
}
#endif

Here is what the preview looks like:

Screen Shot 2021-05-08 at 2 28 07 PM
akardas16 commented 3 years ago

If I use the following LaTeX:

3z+20 > −3z+1

Then it renders as:

Screen Shot 2021-05-04 at 4 06 38 PM

Notice that the -3z renders as 3z

Does anyone know why that is? If I delete the negative sign and then re-add it, then sometimes it will render.

Hi, please remove − sign which is in front of 3z and replace with your minus sign in keyboard Note: (-) and (−) signs seem different. The first sign works.

maxgiraldo commented 2 years ago

Thanks @akardas16. Resolved by using UTF-8 hyphen-minus (U+002D) and not minus (U+2212)