最近需要在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. CSS3基础入门02

    CSS3 基础入门02 边框相关属性 border-radius 通过这个属性我们可以设置边框圆角,即可以将四个角设置为统一的圆角,也可以单独的设置具体的某一个角的圆角. grammer: borde ...

  2. 关于概率dp的HINT

    摘自shadowice1984的blog 这里想讲一个关于概率题的小技巧,就是关于如何求某个事件发生的概率PP,事实上大家也清楚,除了一些特殊的近似算法之外,我们在程序中计算概率的方法无非就是加减乘除 ...

  3. 【BZOJ4013】[HNOI2015]实验比较(动态规划)

    [BZOJ4013][HNOI2015]实验比较(动态规划) 题面 BZOJ 洛谷 题解 看题目意思就是给你一棵树,连边表示强制顺序关系.然后你要给点染色,在满足顺序关系的情况下,将序列染成若干个颜色 ...

  4. go实现dgraph的各种操作

    go实现dgraph的各种操作 import "github.com/dgraph-io/dgo" import "github.com/dgraph-io/dgo/pr ...

  5. WAMP中的MySQL设置用户、密码 及 phpmyadmin的配置

    打开localhost和phpadmin时注意是否改过端口(这两个的默认端口是80) 初始用户名:root   密码为空 改密后使用新密码. WAMP中的 mysql设置密码(默认密码为空)及 php ...

  6. JavaEESpringMVC基础整理

    1.什么是 SpringMVC ? 在介绍什么是 SpringMVC 之前,我们先看看 Spring 的基本架构.如下图: 我们可以看到,在 Spring 的基本架构中,红色圈起来的 Spring W ...

  7. jvm 字节码执行 (二)动态类型支持与基于栈的字节码解释执行

    动态类型语言 动态类型语言的关键特征是它的类型检查的主体过程是在运行期而不是编译期. 举例子解释“类型检查”,例如代码: obj.println("hello world"); 假 ...

  8. sed命令(二)

    转自:https://www.cnblogs.com/maxincai/p/5146338.html sed命令用法 sed是一种流编辑器,它是文本处理中非常有用的工具,能够完美的配合正则表达式使用, ...

  9. 第二章,循环结构,输入输出,clock

    计时 计时函数: clock() 返回目前为止运行的时间 注意要除以常数 CLOCKS_PER_SEC, 才能得到以秒为单位. 头文件 time.h 管道 在windows命令行下执行echo 20| ...

  10. vue swiper中的大坑

    mounted() { var self = this; for (var i = 0; i < self.$refs.mySwiper.swiper.pagination.bullets.le ...