最近需要在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. HNOI2018寻宝游戏

    https://www.luogu.org/problemnew/show/P4424 题解 我们首先按位考虑. 如果有一位最终的结果为1,那么我们可以把树的序列看成一个二进制数,先出现的在底位,后出 ...

  2. postman随机生成数

    postman做重复测试时,随机数就有很大的作用,不用每次都输入 在postman的Params中,输入一个左大括号,会显示三种随机数: 也可以在body中设置 随机数如下: {{$guid}}:添加 ...

  3. table的 noWrap 属性不换行

    nowrap是什么意思? HTML中td元素的nowrap属性表示禁止单元格中的文字自动换行. 但使用时要注意的是,td元素noWrap属性的行为与td元素的width属性有关. td元素中nowra ...

  4. 机器学习KNN算法

    KNN(最邻近规则分类K-Nearest-Neighibor)KNN算法 1. 综述      1.1 Cover和Hart在1968年提出了最初的邻近算法      1.2 分类(classific ...

  5. gzy的摄影梦

    好像当身高180的摄影师啊. 记录一下素材,等自己有相机了,就一一实现. 竟然有人在看哎. 一袭红衣的女子,将手伸出窗外,开心的看这漫天大雪. 今天的晚霞,近处是蓝色,颜色逐渐变淡,一直延伸到远处.( ...

  6. python之路(5)文件操作(open)

      目录 前言 文件的打开模式 文件句柄的方法 seek()方法介绍 前言 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 f = open('demo.txt','r',e ...

  7. dataTable 实战总结

    后台项目中经常会用到 dataTable 进行表格的智能绘制:总结一下项目中经常用到的 dataTable 设置 1.dataTable 属性设置: autoWidth: true, // 是否自动计 ...

  8. 乙方渗透测试之Fuzz爆破

    前言 爆破在渗透测试中,对技术的要求不高,但是对技巧和字典的要求就很高了,本篇整理下平时学到的一些爆破思路和技巧(偏web渗透登陆),当你无措可施时,暴力破解是最好的方式. 世界上最可怕的事情是你的习 ...

  9. D. Vanya and Treasure Codeforces Round #355 (Div. 2)

    http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...

  10. flask+mod_wsgi+apache在windows上的布署

    已经安装过python3.5 1.安装flask: pip install flask 2.安装apache: Apache是开源软件,针对windows环境,它不直接提供编译版本.可以在http:/ ...