Giter Site home page Giter Site logo

latexswiftui's People

Contributors

colinc86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

latexswiftui's Issues

Incorrect parsing of block math

Whenever a math block is delimited with $$ but there is a line break around it, the library doesn't parse this correctly, as in the example below.

See how the code below renders:

A function $f(z)$ is said to be holomorphic in an open region $\Omega$ if it is complex differentiable at every point $z$ in $\Omega$. In other words, the derivative $f'(z)$ exists in the given region.

On the other hand, a function $f(z)$ is said to be analytic if it can be locally represented by a convergent power series. Specifically, for any point $z_0$ in the function's domain, there is a power series which converges to $f(z)$ in a neighborhood of $z_0$. The power series can be expressed as:

$$
f(z) = \sum_{n=0}^{\infty} a_n (z - z_0)^n
$$

Where $a_n$ are coefficients, and the power series converges for all $z$ in a neighborhood of $z_0$.

example

This is correctly handled my mathjax in the browser. This issue is also significant because subsequent math blocks (inline or not) are not correctly detected when they would have been without this issue.

View doesn't change when using "LaTeX"

I'm not sure of the proper terminology (it's either the View or the State not updating, something like that), but here's a simple example of what doesn't appear to be working properly (this was also occurring for version 1.2.3).

The following correctly changes the View when the Button is pressed:

`struct ContentView: View {
@State var eqToggle: Bool = false

var body: some View {
    VStack {
        Button("Toggle", action: {
            eqToggle.toggle()
        })
        Text("")
        eqToggle ? Text("$ 2x + \\sqrt{x} = 3 $ is the primary equation") : Text("The primary equation, $ -x^{2} + y_{0} > 12 \\text{,} $ is unknown.")
    }
}

}
`

The following does not:

`
struct ContentView: View {
@State var eqToggle: Bool = false // 1st LaTeX call remains in place (true) or 2nd LaTeX call remains in place (false)

var body: some View {
    VStack {
        Button("Toggle", action: {
            eqToggle.toggle()
        })
        Text("")
        eqToggle ? LaTeX("$ 2x + \\sqrt{x} = 3 $ is the primary equation") : LaTeX("The primary equation, $ -x^{2} + y_{0} > 12 \\text{,} $ is unknown.")
    }
}

}
`

What's preventing the view from updating?

Arrays do not render vertical lines or horizontal lines correctly

When making an array, for example:

"\begin{array}{|c|c|c|} a & b & c \\ d & e & f \\ \end{array}"
only the outer two vertical lines will render
Further,
if a horizontal line is placed on top:

"\begin{array}{|c|c|c|} \hline a & b & c \\ d & e & f \\ \end{array}"
the top line renders fine.

when another is added anywhere else:
"\begin{array}{|c|c|c|} \hline a & b & c \\ d & e & f \\ \hline \end{array}"

the whole section becomes a black box.

Further, any lines placed between rows are not rendered.

fraction support

$$\cos x + \cos y = 2 \cos \frac{x + y}{2} \cos \frac{x - y}{2}$$

image

This doesn't work in Playgrounds for some reason

After adding the package to a Playgrounds App, the app no longer refreshes.

Also, none of the required packages (MathJaxSwift, etc.) are loaded. They can obviously be loaded individually by finding the addresses in the package manifest, but I'm not sure if that's a Playgrounds issue or an issue with this package.

Any chance you can add support for macOS 12?

Great package. Like the title, any chance you can add support for macOS 12?

Or can you give some pointers on which part of the codebase I should change to support macOS 12.

Thanks

LaTeX view not updating when string input updated

Title is self explanatory. Take this code for example:

import SwiftUI
import LaTeXSwiftUI

struct TestView: View {
    @State var varLatex = "$a$"
    
    var body: some View {
        VStack {
            Text(varLatex)
            LaTeX(varLatex)
            Button("Switch") {
                varLatex = "$b$"
            }
        }
    }
}

#Preview {
    TestView()
}

When the button is clicked, varLatex is updated and so is the Text view. But the LaTeX view is not updated... I have tried on multiple examples: whenever the input is updated, the view does not. And there is no workaround...

It feels like the LaTeX only works with constant strings, since iterating with ForEach over a constant list of strings works perfectly.

My knowledge in Swift is too little for me to open a PR... I hope this can be fixed soon!

Incorrect render \( and \)

  1. "Integral [\int_{a}^{b} x^2 ,dx] inside text" is rendered
  2. "[\int_{a}^{b} x^2 ,dx]" is rendered
  3. "Integral (\int_{a}^{b} x^2 ,dx) inside text" isn't rendered
  4. "(\int_{a}^{b} x^2 ,dx)" isn't rendered

How do I scale the rendered equation to match the surrounding text?

Changing the font size doesn't affect the rendered equation:

import SwiftUI
import LaTeXSwiftUI

@main
struct iOSApp: App {
    var body: some Scene {
        WindowGroup {
            LaTeX("Solve the following: $(9-2)^2\\cdot9^2$")
            LaTeX("Solve the following: $(9-2)^2\\cdot9^2$").font(.system(size: 8))
        }
    }
}

Simulator Screenshot - iPhone 14 Pro - 2023-08-29 at 20 50 10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.