如何在 macOS 中使用 iosMath 数学库?
How to use iosMath math library in macOS?
我感兴趣的是能够键入 LaTeX 以获得 格式化的数学输出 我的 macOS 项目。我曾尝试使用著名的 iosMath CocoaPod Library and also seen its working from their official examples Repository on GitHub. I am using Xcode 10, Swift 4.2 on macOS Mojave (10.14). Using the guidance given on the reply of this I was able to successfully incorporate the library and make it render Mathematical Text using latex in any iOS projects successfully. But it is giving great conflicts and problems in macOS. After Installing the CocoaPod in my own project successfully I tried to follow the paradigm given in their official macOS Example 进行多次试验和错误,但都以失败告终。
我正在描述我尝试过的任何内容:
- 正如我们所见,示例项目使用了 XIB 而不是 Storyboard,但是当在 Storyboard 中尝试 iOS 上的相同代码和机制时,它工作得很好.
- 根据他们的示例项目中的指导,我尝试在 iOS 和 macOS(即分别为 UIView 和 NSView)上使用自定义视图,并将该自定义视图附加到自定义 class MTMathUILabel 在 Identity Inspector 在 Storyboard 然后当然链接到 IBOutlet 在我的代码文件中的 MTMathUILabel 类型。它在 iOS 的情况下成功运行,但在 macOS 中失败,即使我在故事板的身份检查器中使用 MTMathUIView 自定义 Class。
- 根据他们的 macOS example File,我在 ViewController.Swift 中输入了 类似的代码 ,如下所示:
var mathViewCode: MTMathUILabel = MTMathUILabel()
@IBOutlet weak var mathViewIB: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
mathViewIB.latex = "\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k"
mathViewCode.latex = "\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}"
self.view.addSubview(mathViewCode)
}
- 当从 上面的代码 我只执行 编程 调用 MTMathUILabel 变量代码然后只是一个空白 window 打开没有其中的任何输出。但是当我尝试使用 IBOutlet 变量在 Custom NSView 中打印乳胶时(属性检查器中的 Custom Class 已设置到 MTMathUIView not MTMathUILabel 因为然后它崩溃了)应用程序再次打开 blank window 但这次有以下警告:
Failed to set (contentViewController) user defined inspected property
on (NSWindow): -[NSView setLatex:]: unrecognized selector sent to
instance 0x60000330d7c0
- 如果在 Storyboard 的自定义 NSView 身份检查器中,我将自定义 Class 设置为 MTMathUIView,则界面生成器 不会崩溃 但它也不起作用,如果我将它设置为 MTMathUILabel 那么 Interface Builder 崩溃 并出现以下错误:
IB Designables: Failed to render instance of MTMathUILabel: The agent
threw an exception.
- 然而,在上述场景中(Storyboard 的 Custom NSView's Custom Class in Attributes Inspector 已设置为 MTMathUILabel)应用程序编译成功但在崩溃后抛出以下 运行 时间错误:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
如您所见,我尝试遵循他们官方 macOS Sample Project 中给出的方法,但在我的情况下没有任何效果,即使他们的 示例项目成功编译并运行s好在我Xcode.
请帮我解决这个 iosMath 库 因为我真的很想用它 因为它的 Beautiful Output 和 强大的功能 或者请推荐一些其他的数学库来输入 LaTeX 在我的 Mac 应用程序中 在 macOS 上确实 运行s Swift。
非常感谢提前!!
我运行遇到了同样的问题。
我没有解决方案,但可以将 iosMath 与 MacOs 一起使用,并且
swift。
我创建了我的 Project LatexPic 并将其添加到原始 podfile。现在您可以在 macOS 应用程序中的视图控制器中使用它,例如:
let latexlabel = MTMathUILabel()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
self.view.addSubview(latexlabel)
latexlabel.backgroundColor = .white
latexlabel.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
latexlabel.latex = "\frac{2}{3}"
}
播客文件:
workspace 'iosMath.xcworkspace'
install! 'cocoapods', :deterministic_uuids => false
target 'iosMathExample' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'iosMathTests' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'MacOSMath' do
project 'MacOSMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'LatexPic' do
use_frameworks!
project 'LatexPic.xcodeproj'
pod 'iosMath', :path => './'
end
我感兴趣的是能够键入 LaTeX 以获得 格式化的数学输出 我的 macOS 项目。我曾尝试使用著名的 iosMath CocoaPod Library and also seen its working from their official examples Repository on GitHub. I am using Xcode 10, Swift 4.2 on macOS Mojave (10.14). Using the guidance given on the reply of this
- 正如我们所见,示例项目使用了 XIB 而不是 Storyboard,但是当在 Storyboard 中尝试 iOS 上的相同代码和机制时,它工作得很好.
- 根据他们的示例项目中的指导,我尝试在 iOS 和 macOS(即分别为 UIView 和 NSView)上使用自定义视图,并将该自定义视图附加到自定义 class MTMathUILabel 在 Identity Inspector 在 Storyboard 然后当然链接到 IBOutlet 在我的代码文件中的 MTMathUILabel 类型。它在 iOS 的情况下成功运行,但在 macOS 中失败,即使我在故事板的身份检查器中使用 MTMathUIView 自定义 Class。
- 根据他们的 macOS example File,我在 ViewController.Swift 中输入了 类似的代码 ,如下所示:
var mathViewCode: MTMathUILabel = MTMathUILabel()
@IBOutlet weak var mathViewIB: MTMathUILabel!
override func viewDidLoad() {
super.viewDidLoad()
mathViewIB.latex = "\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k"
mathViewCode.latex = "\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}"
self.view.addSubview(mathViewCode)
}
- 当从 上面的代码 我只执行 编程 调用 MTMathUILabel 变量代码然后只是一个空白 window 打开没有其中的任何输出。但是当我尝试使用 IBOutlet 变量在 Custom NSView 中打印乳胶时(属性检查器中的 Custom Class 已设置到 MTMathUIView not MTMathUILabel 因为然后它崩溃了)应用程序再次打开 blank window 但这次有以下警告:
Failed to set (contentViewController) user defined inspected property on (NSWindow): -[NSView setLatex:]: unrecognized selector sent to instance 0x60000330d7c0
- 如果在 Storyboard 的自定义 NSView 身份检查器中,我将自定义 Class 设置为 MTMathUIView,则界面生成器 不会崩溃 但它也不起作用,如果我将它设置为 MTMathUILabel 那么 Interface Builder 崩溃 并出现以下错误:
IB Designables: Failed to render instance of MTMathUILabel: The agent threw an exception.
- 然而,在上述场景中(Storyboard 的 Custom NSView's Custom Class in Attributes Inspector 已设置为 MTMathUILabel)应用程序编译成功但在崩溃后抛出以下 运行 时间错误:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
如您所见,我尝试遵循他们官方 macOS Sample Project 中给出的方法,但在我的情况下没有任何效果,即使他们的 示例项目成功编译并运行s好在我Xcode.
请帮我解决这个 iosMath 库 因为我真的很想用它 因为它的 Beautiful Output 和 强大的功能 或者请推荐一些其他的数学库来输入 LaTeX 在我的 Mac 应用程序中 在 macOS 上确实 运行s Swift。 非常感谢提前!!
我运行遇到了同样的问题。 我没有解决方案,但可以将 iosMath 与 MacOs 一起使用,并且 swift。 我创建了我的 Project LatexPic 并将其添加到原始 podfile。现在您可以在 macOS 应用程序中的视图控制器中使用它,例如:
let latexlabel = MTMathUILabel()
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
self.view.addSubview(latexlabel)
latexlabel.backgroundColor = .white
latexlabel.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
latexlabel.latex = "\frac{2}{3}"
}
播客文件:
workspace 'iosMath.xcworkspace'
install! 'cocoapods', :deterministic_uuids => false
target 'iosMathExample' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'iosMathTests' do
project 'iosMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'MacOSMath' do
project 'MacOSMath.xcodeproj'
pod 'iosMath', :path => './'
end
target 'LatexPic' do
use_frameworks!
project 'LatexPic.xcodeproj'
pod 'iosMath', :path => './'
end