如何在Word 、PowerPoint 中写LaTex公式

date
Aug 25, 2021
slug
latex_in_msoffice
status
Published
tags
How To
summary
如何在word、PowerPoint 以latex语法编写公式
type
Post

Word中的公式

Word中的行内公式可以直接使用 Latex 语法来编写,只需要在编写完成后,转为 Latex 格式即可。
notion imagenotion image
行间公式推荐 Mathpix 或者 SimpleTex,这两款软件均支持 截图生成 Latex公式(Mathpix 为Ctrl+Ait+M),然后可以点击 Copy MS Word 即可把对应公式以MathML的格式复制到粘贴板中。
notion imagenotion image
此外,还可以对生成的latex公式进行编辑,然后再 Copy MS Word。
编辑截图识别到的Latex code编辑截图识别到的Latex code
编辑截图识别到的Latex code
注:Mathpix每个月有50次截图生成公式的免费次数,如果使用学生邮箱(.edu)注册,则有100次免费截图生成公式次数。SimpleTex目前为免费使用,但是识别效率上与Mathpix稍微有点差距。

Aurora插件(不推荐)

Aurora插件可以实现Word中编辑并展示Latex公式。插件下载:
说明:下载文件中包含miktexa安装包,极力不推荐。推荐自行下载安装TexLive或别的发行版。
安装方式很简单:
  1. 双击 aurora-setup.exe 安装。记得不要选择安装 miktexa
  1. 双击 Aurora.2.x.Keygen.exe 进行破解
此时打开word,在插入→对象 里面可以看到已经有Aurora Equation了
notion imagenotion image
点击确定即可输入latex公式了。

PowerPoint的Latex使用

PowerPoint中使用 lguanaTex 插件不仅可以编辑公式,还可以编辑表格、算法等内容。官网介绍为:
IguanaTex is a PowerPoint add-in which allows you to insert LaTeX  equations into your PowerPoint presentation. It is distributed completely for free, along with its source code.
lguanaTex 官网 下载完成后,按照官网下载页面的指导安装插件即可。需要注意的是,插件默认使用 DVI to PNG 的转换方式,如果想要使用矢量图片的导出,还需要安装 TeX2img,安装可参考如下官方安装指引。
Installation:
  1. Load the add-in:in "File" > "Options" > "Add-Ins" > "Manage:", choose "PowerPoint Add-Ins" then "Go...", then click "Add New", select the .ppam file in the default Add-In folder or in the folder where you downloaded it, then "Close"
  1. Create and set a temporary file folder:IguanaTex needs access to a folder with read/write permissions to store temporary files.
      • The default is "C:\Temp\". If you have write permissions under "C:\", create the folder "C:\Temp\". You're all set.
      • If you cannot create this folder, choose/create a folder with write permission at any other location. In the IguanaTex tab, choose "Main Settings" and put the path to the folder of your choice. You can also use a relative path under the presentation's folder (e.g., ".\" for the presentation folder itself).
  1. (Optional, for pdflatex/xelatex/lualatex support) Install and set path to GhostScript and ImageMagick:To use the PDF to PNG conversion (i.e., with pdflatex, xelatex and lualatex) instead of the default DVI to PNG one, you need to install GhostScript (gs9.26 is the currently recommended version, as issues with 9.27 have been reported) and ImageMagick and set the appropriate  paths to gswin32c.exe/gswin64c.exe (note the "c"!) and convert.exe in the "Main Settings" window. When installing ImageMagick, make sure to check the box to "Install development headers and libraries for C and C++" and (in recent versions) to "Install legacy utilities (e.g. convert)". Download links are provided in the Main Settings window.
  1. (Optional, for vector graphics support) Install and set path to TeX2img:To use vector graphics output, you need to install TeX2img (here is the direct download link for recommended version 2.1.0). After unpacking TeX2img somewhere on your machine, please run TeX2img.exe once to let it set the various paths to latex/ghostscript, then set the  path to TeX2imgc.exe (note the "c"!) in the "Main Settings" window.
  1. Note: in the "Main Settings" window, make sure to expand any default path including %USERPROFILE% by clicking on the "..." button and navigating to the proper location. %USERPROFILE% unfortunately leads to issues when launching processes.
安装完成后,点击IguanaTex选项卡中的 New Latex display ,就会弹出一个 Latex编辑器。
notion imagenotion image
在编辑完 Latex code之后,点击 Generae 即可生成图片。因此,内容是以图片的形式插入到 幻灯片中的,可以预先设置图片的dpi,也可以生成图片之后再调整大小。
notion imagenotion image
此外,生成的图片也支持再编辑,只需要选中对应图片,再点击 IguanaTex 选项卡中的 Edit LaTeX display。
因为幻灯片中嵌入的 Latex 内容是以图片形式展现的,因此,在没有安装 IguanaTex 插件的电脑上也可以正常显示。不过,如果需要编辑的话,就一定要安装 IguanaTex 插件。