本人经常使用 reStructuredText 或者 Markdown 编写文档,且经常涉及数学公式的编写。上述两种标记语言在编写数学公式上均支持 LaTeX 语法,而手动输入 LaTeX 数学公式是一件很麻烦且很费时的事。本文档主要介绍在一款跨平台( Windows 、 macOS 、 Linux )的 OCR 工具—— Mathpix ,它能够识别复杂的数学公式,并将其转换为 LaTeX 语法。
Centos7 安装 Mathpix Snipping Tool 识别复杂的数学公式
Mathpix Snipping Tool 介绍
Mathpix 是一款跨平台( Windows 、 macOS 、 Linux )的 OCR 工具,它能够识别复杂的数学公式,并将其转换为 LaTeX 语法。注意需要使用 Mathpix 自带的 截图功能 进行截取,暂不支持使用图片。然后就可以将获得的代码贴到需要的编辑器中了。
其实支持 LaTeX 的编辑器非常多,官方就列出了:
- Typora
- StackEdit
- MacDown
- Authorea
- TeXstudio
- TeXworks
- TeXmaker
- Overleaf
Centos7 安装 Mathpix Snipping Tool
[eln@localhost ~]$ sudo yum install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* ius: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.aliyun.com
软件包 epel-release-7-11.noarch 已安装并且是最新版本
无须任何处理
[eln@localhost ~]$ sudo yum install yum-plugin-copr
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* ius: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 yum-plugin-copr.noarch.0.1.1.31-50.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
yum-plugin-copr noarch 1.1.31-50.el7 base 32 k
事务概要
================================================================================
安装 1 软件包
总下载量:32 k
安装大小:40 k
Is this ok [y/d/N]: y
Downloading packages:
yum-plugin-copr-1.1.31-50.el7.noarch.rpm | 32 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : yum-plugin-copr-1.1.31-50.el7.noarch 1/1
验证中 : yum-plugin-copr-1.1.31-50.el7.noarch 1/1
已安装:
yum-plugin-copr.noarch 0:1.1.31-50.el7
完毕!
[eln@localhost ~]$ sudo yum copr enable ngompa/snapcore-el7
已加载插件:copr, fastestmirror, langpacks
You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.
The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or securty level.
Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
Do you want to continue? [y/N]: y
copr done
安装 snap :
[eln@localhost ~]$ sudo yum -y install snapd
已加载插件:copr, fastestmirror, langpacks
ngompa-snapcore-el7 | 3.0 kB 00:00
ngompa-snapcore-el7/x86_64/primary_db | 16 kB 00:01
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* ius: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 snapd.x86_64.0.2.38-1.el7 将被 安装
--> 正在处理依赖关系 snap-confine(x86-64) = 2.38-1.el7,它被软件包 snapd-2.38-1.el7.x86_64 需要
--> 正在处理依赖关系 snapd-selinux = 2.38-1.el7,它被软件包 snapd-2.38-1.el7.x86_64 需要
--> 正在处理依赖关系 squashfs-tools,它被软件包 snapd-2.38-1.el7.x86_64 需要
--> 正在处理依赖关系 squashfuse,它被软件包 snapd-2.38-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 snap-confine.x86_64.0.2.38-1.el7 将被 安装
---> 软件包 snapd-selinux.noarch.0.2.38-1.el7 将被 安装
---> 软件包 squashfs-tools.x86_64.0.4.3-0.21.gitaae0aff4.el7 将被 安装
---> 软件包 squashfuse.x86_64.0.0.1.102-1.el7 将被 安装
--> 正在处理依赖关系 squashfuse-libs(x86-64) = 0.1.102-1.el7,它被软件包 squashfuse-0.1.102-1.el7.x86_64 需要
--> 正在处理依赖关系 libfuseprivate.so.0()(64bit),它被软件包 squashfuse-0.1.102-1.el7.x86_64 需要
--> 正在处理依赖关系 liblz4.so.1()(64bit),它被软件包 squashfuse-0.1.102-1.el7.x86_64 需要
--> 正在处理依赖关系 libsquashfuse.so.0()(64bit),它被软件包 squashfuse-0.1.102-1.el7.x86_64 需要
--> 正在处理依赖关系 libzstd.so.1()(64bit),它被软件包 squashfuse-0.1.102-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libzstd.x86_64.0.1.3.8-1.el7 将被 安装
---> 软件包 lz4.x86_64.0.1.7.5-2.el7 将被 安装
---> 软件包 squashfuse-libs.x86_64.0.0.1.102-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
snapd x86_64 2.38-1.el7 epel 14 M
为依赖而安装:
libzstd x86_64 1.3.8-1.el7 epel 247 k
lz4 x86_64 1.7.5-2.el7 base 98 k
snap-confine x86_64 2.38-1.el7 epel 3.7 M
snapd-selinux noarch 2.38-1.el7 epel 209 k
squashfs-tools x86_64 4.3-0.21.gitaae0aff4.el7 base 101 k
squashfuse x86_64 0.1.102-1.el7 epel 18 k
squashfuse-libs x86_64 0.1.102-1.el7 epel 24 k
事务概要
================================================================================
安装 1 软件包 (+7 依赖软件包)
总计:19 M
总下载量:19 M
安装大小:54 M
Downloading packages:
(1/7): libzstd-1.3.8-1.el7.x86_64.rpm | 247 kB 00:00
(2/7): snap-confine-2.38-1.el7.x86_64.rpm | 3.7 MB 00:02
(3/7): snapd-2.38-1.el7.x86_64.rpm | 14 MB 00:05
(4/7): squashfuse-0.1.102-1.el7.x86_64.rpm | 18 kB 00:00
(5/7): squashfs-tools-4.3-0.21.gitaae0aff4.el7.x86_64.rpm | 101 kB 00:00
(6/7): snapd-selinux-2.38-1.el7.noarch.rpm | 209 kB 00:00
(7/7): squashfuse-libs-0.1.102-1.el7.x86_64.rpm | 24 kB 00:00
--------------------------------------------------------------------------------
总计 3.0 MB/s | 19 MB 00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : snapd-selinux-2.38-1.el7.noarch 1/8
正在安装 : libzstd-1.3.8-1.el7.x86_64 2/8
正在安装 : lz4-1.7.5-2.el7.x86_64 3/8
正在安装 : squashfs-tools-4.3-0.21.gitaae0aff4.el7.x86_64 4/8
正在安装 : snap-confine-2.38-1.el7.x86_64 5/8
正在安装 : squashfuse-libs-0.1.102-1.el7.x86_64 6/8
正在安装 : squashfuse-0.1.102-1.el7.x86_64 7/8
正在安装 : snapd-2.38-1.el7.x86_64 8/8
验证中 : snapd-2.38-1.el7.x86_64 1/8
验证中 : squashfuse-libs-0.1.102-1.el7.x86_64 2/8
验证中 : snap-confine-2.38-1.el7.x86_64 3/8
验证中 : squashfs-tools-4.3-0.21.gitaae0aff4.el7.x86_64 4/8
验证中 : lz4-1.7.5-2.el7.x86_64 5/8
验证中 : libzstd-1.3.8-1.el7.x86_64 6/8
验证中 : squashfuse-0.1.102-1.el7.x86_64 7/8
验证中 : snapd-selinux-2.38-1.el7.noarch 8/8
已安装:
snapd.x86_64 0:2.38-1.el7
作为依赖被安装:
libzstd.x86_64 0:1.3.8-1.el7
lz4.x86_64 0:1.7.5-2.el7
snap-confine.x86_64 0:2.38-1.el7
snapd-selinux.noarch 0:2.38-1.el7
squashfs-tools.x86_64 0:4.3-0.21.gitaae0aff4.el7
squashfuse.x86_64 0:0.1.102-1.el7
squashfuse-libs.x86_64 0:0.1.102-1.el7
完毕!
[eln@localhost ~]$ sudo systemctl enable --now snapd.socket
Created symlink from /etc/systemd/system/sockets.target.wants/snapd.socket to /usr/lib/systemd/system/snapd.socket.
[eln@localhost ~]$ snap --help
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.
Usage: snap <command> [<options>...]
Commands can be classified as follows:
Basics: find, info, install, list, remove
...more: refresh, revert, switch, disable, enable
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs
Commands: alias, aliases, unalias, prefer
Configuration: get, set, wait
Account: login, logout, whoami
Permissions: connections, interfaces, interface, connect, disconnect
Snapshots: saved, save, check-snapshot, restore, forget
Other: version, warnings, okay, ack, known
Development: run, pack, try, download, prepare-image
For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.
重新打开终端,安装 mathpix :
[eln@localhost ~]$ sudo snap install mathpix-snipping-tool
[sudo] eln 的密码:
2019-04-16T09:25:24+08:00 INFO Waiting for restart...
Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not
restarted your session since you installed snapd, try doing that.
Please see https://forum.snapcraft.io/t/9469 for more details.
mathpix-snipping-tool 01.02.0029 from mathpix installed
使用 Mathpix Snipping Tool 识别数学公式
安装后重启电脑,在应用程序中的其它可以找到 Mathpix Snipping Tool ,打开后使用快捷键 Ctrl + Alt + M 可以截图 OCR 识别公式。如: