最近需要在Cygwin平台下的Emacs Org mode中生成LaTeX数学公式的预览图片,从而得到图文并貌的笔记与任务管理文档。但当我执行org-toggle-latex-fragment命令后却出现了如下错误:

 org-compile-file: File "/tmp/orgtex5473MjV.dvi" wasn’t produced. Please adjust ’dvipng’ part of ‘org-preview-latex-process-alist’.

根据提示判断,应该是变量org-preview-latex-process-alistdvipng部分的配置出了问题。于是按C-h v查看该变量的值,并参照man手册核对了dvipng的命令行参数,并未发现什么明显的异常。之后,在网上搜索看到有人说是未安装texlive-latex-extra包的问题。然后,便转到/tmp目录下查看LaTeX编译日志文件orgtex5473MjV.log里是否有找不到相关宏包的提示。可奇怪的是,该文件根本不见踪影。这就说明很可能连latex命令的启动都未成功,以至于根本没有进入到实质的编译阶段。接下来,我便手动创建了一个简单的tex文件用latex编译,结果直接报出下面的错误:

 Running `LaTeX' on `test' with ``pdflatex  -file-line-error   -interaction=nonstopmode "\input" test.tex''
 C:/cygwin64/bin/pdftex.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
 ​
 TeX Output exited abnormally with code 127 at Wed Apr 2 20:58:49

错误信息中的error while loading shared libraries给出了明显的提示,那就是缺少了某些动态链接库。然后通过上网搜索,得知可以使用cygcheck命令检查可执行文件对于动态链接库的依赖关系。将其用于latex.exe则得到如下信息:

 $ cygcheck latex.exe
 Found: C:\cygwin64\bin\latex.exe
 Found: D:\texlive\2016\bin\win32\latex.exe
 Found: C:\cygwin64\bin\latex.exe
 C:\cygwin64\bin\latex.exe
  C:\cygwin64\bin\cygkpathsea-6.dll
    C:\cygwin64\bin\cygwin1.dll
      C:\Windows\system32\KERNEL32.dll
        C:\Windows\system32\API-MS-Win-Core-RtlSupport-L1-1-0.dll
        C:\Windows\system32\ntdll.dll
        C:\Windows\system32\KERNELBASE.dll
        C:\Windows\system32\API-MS-Win-Core-ProcessThreads-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Heap-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Memory-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Handle-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Synch-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-File-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-IO-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ThreadPool-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-LibraryLoader-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-NamedPipe-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Misc-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-SysInfo-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Localization-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-String-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Debug-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-ErrorHandling-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Fibers-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Util-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Core-Profile-L1-1-0.dll
        C:\Windows\system32\API-MS-Win-Security-Base-L1-1-0.dll
  C:\cygwin64\bin\cygpng16-16.dll
    C:\cygwin64\bin\cygz.dll
  C:\cygwin64\bin\cygpoppler-49.dll
    C:\cygwin64\bin\cygcurl-4.dll
      C:\cygwin64\bin\cyggssapi_krb5-2.dll
        C:\cygwin64\bin\cygk5crypto-3.dll
          C:\cygwin64\bin\cygkrb5support-0.dll
            C:\cygwin64\bin\cygintl-8.dll
              C:\cygwin64\bin\cygiconv-2.dll
        C:\cygwin64\bin\cygkrb5-3.dll
          C:\cygwin64\bin\cygcom_err-2.dll
            C:\cygwin64\bin\cyggcc_s-seh-1.dll
      C:\cygwin64\bin\cygidn2-0.dll
        C:\cygwin64\bin\cygunistring-2.dll
      C:\cygwin64\bin\cyglber-2-4-2.dll
      C:\cygwin64\bin\cygldap-2-4-2.dll
        C:\cygwin64\bin\cygsasl2-3.dll
      C:\cygwin64\bin\cygnghttp2-14.dll
      C:\cygwin64\bin\cygpsl-5.dll
      C:\cygwin64\bin\cygssh2-1.dll
    C:\cygwin64\bin\cygfontconfig-1.dll
      C:\cygwin64\bin\cygexpat-1.dll
      C:\cygwin64\bin\cygfreetype-6.dll
        C:\cygwin64\bin\cygbz2-1.dll
    C:\cygwin64\bin\cygjpeg-8.dll
    C:\cygwin64\bin\cyglcms2-2.dll
    C:\cygwin64\bin\cygtiff-6.dll
      C:\cygwin64\bin\cygjbig-2.dll
      C:\cygwin64\bin\cyglzma-5.dll
    C:\cygwin64\bin\cygstdc++-6.dll
 cygcheck: track_down: could not find cygcrypto-1.0.0.dll
 ​
 cygcheck: track_down: could not find cygcrypto-1.0.0.dll
 ​
 cygcheck: track_down: could not find cygssl-1.0.0.dll
 ​
 cygcheck: track_down: could not find cygcrypto-1.0.0.dll
 ​
 cygcheck: track_down: could not find cygssl-1.0.0.dll

可以看出,当前的Cygwin系统缺少了cygcrypto-1.0.0.dll与cygssl-1.0.0.dll两个文件,而且在目录/bin下也确实没有这两个文件:

 $ ls /bin | grep "\(cygcrypto\)\|\(cygssl\)"
 cygcrypto-1.1.dll*
 cygssl-1.1.dll*
 cygssl3.dll*

至此,Emacs Org mode无法生成LaTeX公式预览图片的原因真相大白:并非Org mode或dvipng本身的问题,而是由于Cygwin缺少动态链接库导致的。要想解决这个问题,就需要找到它们。我们使用cygcheck-p选项,可以查询与动态链接库相关的软件包:

 $ cygcheck --help
 -p, --package-query search for REGEXP in the entire cygwin.com package
                        repository (requires internet connectivity)
                       
 $ cygcheck -p cygssl-1.0.0.dll
 Found 6 matches for cygssl-1.0.0
 libopenssl100-1.0.2p-1 - libopenssl100: A general purpose cryptography toolkit with TLS implementation (runtime)
 libopenssl100-1.0.2r-1 - libopenssl100: A general purpose cryptography toolkit with TLS implementation (runtime)
 libssl1.0-1.0.2r-2 - libssl1.0: A general purpose cryptography toolkit with TLS implementation (runtime)
 openssl-debuginfo-1.0.2p-1 - openssl-debuginfo: Debug info for openssl
 openssl-debuginfo-1.0.2r-1 - openssl-debuginfo: Debug info for openssl
 openssl10-debuginfo-1.0.2r-2 - openssl10-debuginfo: Debug info for openssl10
 ​
 $ cygcheck -p cygcrypto-1.0.0.dll
 libopenssl100-1.0.2p-1 - libopenssl100: A general purpose cryptography toolkit with TLS implementation (runtime)
 libopenssl100-1.0.2r-1 - libopenssl100: A general purpose cryptography toolkit with TLS implementation (runtime)
 libssl1.0-1.0.2r-2 - libssl1.0: A general purpose cryptography toolkit with TLS implementation (runtime)
 openssl-debuginfo-1.0.2p-1 - openssl-debuginfo: Debug info for openssl
 openssl-debuginfo-1.0.2r-1 - openssl-debuginfo: Debug info for openssl
 openssl10-debuginfo-1.0.2r-2 - openssl10-debuginfo: Debug info for openssl10

可以看出,这两个库均与openssl软件包有关。幸好,我之前从镜象服务器下载的缓存文件里有libopenssl100-1.0.2r-1.tar.xz,其中正好包含了上述两个动态链接库。将它们拷贝到C:\cygwin64\bin下,一切就恢复正常了。

从以上问题解决的过程中我学到了如下两条经验:

  1. 软件给出的错误信息并不一定反映问题的真相,而有可能是由另一个潜在的或者更深层次的问题导致的。这个时候不能拘泥于表象,要设计新的测试环境来予以探索、验证。

  2. 当遇到了异常与错误,需要使用合适的工具来搜集线索、定位问题的源头以至最终将其解决。

Org mode无法生成LaTeX公式预览图片的更多相关文章

  1. html生成缩略图来预览解决方案

    html生成缩略图来预览解决方案 一.总结 一句话总结:先将html转化为canvas,然后将canvas生成图片ajax上传到服务器,就可以了 html 转化 canvas 图片 上传 html2c ...

  2. JS实现图片base64转blob对象,压缩图片,预览图片,图片旋转到正确角度

    base64转blob对象 /** 将base64转换为文件对象 * @param {String} base64 base64字符串 * */ var convertBase64ToBlob = f ...

  3. file上传图片,base64转换、压缩图片、预览图片、将图片旋转到正确的角度

    /** * 将base64转换为文件对象 * (即用文件上传输入框上传文件得到的对象) * @param {String} base64 base64字符串 */ function convertBa ...

  4. 微信开发中使用微信JSSDK和使用URL.createObjectURL上传预览图片的不同处理对比

    在做微信公众号或者企业微信开发业务应用的时候,我们常常会涉及到图片预览.上传等的处理,往往业务需求不止一张图片,因此相对来说,需要考虑的全面一些,用户还需要对图片进行预览和相应的处理,在开始的时候我使 ...

  5. 富文本编辑器handyeditor,上传和预览图片的host地址不一样

    使用富文本编辑器(官网)时,大多时候都会用到图片上传,但是下载的富文本编辑器的默认配置是只有一个上传地址的host的. var he = HE.getEditor('editor', { autoHe ...

  6. hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images

    hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images, 本例子主要是使用HTML5 的File API,建立一個可存取到该file的url, 一个空的img标签,ID为img0,把 ...

  7. [js/jquery]移动端手势拖动,放大,缩小预览图片

    摘要 有这样的需求需要在手机端预览图片的时候,实现图片的手势拖动,放大缩小功能.最终通过touch.js这个插件实现了效果. touch.js Touch.js是移动设备上的手势识别与事件库, 由百度 ...

  8. ftp如何预览图片 解决方案

    下载使用 server-U ,开启 HTTP 服务,输入 http://ip:端口 后,登录ftp账号密码,可选使用 基于java的应用 web client 或 FTP Voyager JV,来预览 ...

  9. 本地预览图片html和js例子

    本地预览图片html和js例子,直接上代码吧. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

随机推荐

  1. jquery 设置 transform/translate 获取 transform/translate 的值

    //获取 transform 值 var reg=/matrix.(((-)?([0-9]+.)?\d+([, ]+)?){6})./g; var str= progressUI.css(" ...

  2. 快速去水印(win10换图3D工具)

    之前抠图都用ps啥的,后来发现win10自带的工具画图3D可以直接扣简单的图案,达到去水印的效果 1.将图片放入软件中 2.使用神奇选择工具,调整大小,框出图标 3.点击下一步,将没选上的或选多的进行 ...

  3. Linux-存储管理

    存储基础知识 从工作原理区分: 机械   HDD 固态   SSD SSD的优势: SSD是摒弃传统磁介质,采用电子存储介质进行数据存储和读取的一种技术,突破了传统机械硬盘的性能瓶颈,拥有极高的存储性 ...

  4. Chart控件,鼠标选择区域,可以局部放大缩小

    例子: 代码设置部分: chartArea1.CursorX.Interval = 0D; chartArea1.CursorX.IntervalOffsetType = System.Windows ...

  5. 20175209 《Java程序设计》第九周学习总结

    20175209 <Java程序设计>第九周学习总结 一.教材知识点总结 有关数据库下载中存在可能出现的问题已经在博客<数据库安装和使用过程中出现的一些问题>给出了相应的解决办 ...

  6. linux下mysql的数据库简单备份脚本

    应用于整个库的备份. #!/bin/bash PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/sbin # 数据库名称 databases=(myna ...

  7. .NET框架 - NETCORE部署IIS

    .NET框架 - NETCORE部署IIS 1. 发布NETCORE项目. 2. 发布IIS 添加 网站 修改对应的程序池 为 ”无托管代码“. 3. 浏览网站. IIS 需提前安装好 .netcor ...

  8. 《Java》第九周学习总结

    下载mysql 选择mysql的管理软件 idea可以直接连接 然后用库运行程序,但是没有截图,,因为想在navicat上试试,可惜速度太慢了 打开idea又很慢,所以明天再更新

  9. ajax跨域例子

    例子 https://github.com/ruanyf/react-demos/blob/master/demo12/index.html 此网页代码运行在本地, 是可以访问 github 数据的. ...

  10. (二)初探Maven之设置代理和阿里云镜像

    引言:           在许多公司,可能因为安全性的要求配置了代理服务器,用户无法直接访问外网,所以在项目中使用Maven必须设置好代理才能下载依赖.           并且直接从中央仓库下载依 ...