搜索插件、代码仓与 APP 分类

插件详情v0.3.4

flutter_markdown_latex

一个用于 flutter_markdown 包的扩展,可渲染 Markdown 中的 LaTeX。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
5330
喜欢数
33
Pub 分数
150

安装插件

flutter pub add flutter_markdown_latex

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个扩展 flutter_markdown 的 Flutter 包,支持在 Markdown 文本中渲染 LaTeX 表达式。它可无缝集成数学符号和公式到富文本内容中,非常适合教育类应用、文档或技术博客。该包利用现有的 Flutter Markdown 渲染功能,通过兼容的后端添加 LaTeX 解析和显示能力。可在所有主要平台(包括移动、Web 和桌面)上运行。

适合场景

  • 在应用程序文档中渲染数学方程
  • 创建包含数学内容的教育类应用程序
  • 在基于 Markdown 的文章中显示科学公式
  • 将 LaTeX 集成到 Flutter 支持的博客中
  • 使用复杂符号支持技术写作

主要特点

  • 扩展 flutter_markdown 以支持 LaTeX
  • 跨平台兼容性
  • 通过 pub add 的简单集成
  • 支持内联和块级 LaTeX
  • 使用标准 LaTeX 语法

适合对象

  • 教育类应用开发者
  • 使用 Markdown 的技术作家
  • STEM内容创作者
  • 需要数学渲染的Flutter应用
  • 以文档为重点的项目

使用建议

  • LaTeX 渲染需要额外的依赖项
  • 性能可能因复杂公式而异
  • 仅限支持的 LaTeX 子集
  • 可能需要为渲染的数学公式自定义样式
  • 不适用于实时编辑

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Markdown Latex

Coverage Status Pub Version

This extension is created to enhance the functionality of the flutter_markdown package by adding support for rendering LaTeX in markdown. The rendering of LaTeX is achieved through the utilization of the flutter_math_fork package.

Rendering Samples

This is inline latex: $f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x}$

This is block level latex:

$$
c = \pm\sqrt{a^2 + b^2}
$$

This is inline latex with displayMode: $$f(x) = \sum_{i=0}^{n} \frac{a_i}{1+x}$$

The relationship between the height and the side length of an equilateral triangle is:

\[ \text{Height} = \frac{\sqrt{3}}{2} \times \text{Side Length} \]

\[ \text{X} = \frac{1}{2} \times \text{Y} \times \text{Z} = \frac{1}{2} \times 9 \times \frac{\sqrt{3}}{2} \times 9 = \frac{81\sqrt{3}}{4} \]

The basic form of the Taylor series is:

\[f(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2!}(x-a)^2 + \frac{f'''(a)}{3!}(x-a)^3 + \cdots\]

where \(f(x)\) is the function to be expanded, \(a\) is the expansion point, \(f'(a)\), \(f''(a)\), \(f'''(a)\), etc., are the first, second, third, and so on derivatives of the function at point \(a\), and \(n!\) denotes the factorial of \(n\).

In particular, when \(a=0\), this expansion is called the Maclaurin series.

Example

Getting Started

Add dependency

Add flutter_markdown_latex to your pubspec.yaml dependencies.

Import it
import 'package:flutter_markdown_latex/flutter_markdown_latex.dart';
Render it
// with default text style
MarkdownBody(
  selectable: true,
  data: 'latex: \$c = \\pm\\sqrt{a^2 + b^2}\$',
  builders: {
    'latex': LatexElementBuilder(),
  },
  extensionSet: md.ExtensionSet(
    [LatexBlockSyntax()],
    [LatexInlineSyntax()],
  ),
),

// with custom text style
MarkdownBody(
  selectable: true,
  data: 'latex: \$c = \\pm\\sqrt{a^2 + b^2}\$',
  builders: {
    'latex': LatexElementBuilder(
      textStyle: const TextStyle(color: Colors.blue),
      textScaleFactor: 1.2,
    ),
  },
  extensionSet: md.ExtensionSet(
    [LatexBlockSyntax()],
    [LatexInlineSyntax()],
  ),
),

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目