最近需要在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. MT【324】增量代换

    实数$a,b,c$满足$a^2+b^2+c^2=1$求$f=\min\{(a-b)^2,(b-c)^2,(c-a)^2\}$的最大值 分析:由对称性不妨设$c\ge b\ge a$,令$b-a=s,c ...

  2. termux

    使用http服务,链接原服务器要挂vpn. apt edit-sources 如果提示 $ apt edit-sources e: Sub-process editor returned a n er ...

  3. (双指针) leetcode 485. Max Consecutive Ones

    Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1, ...

  4. Linux uniq 命令

    Linux uniq 命令  Linux 命令大全 Linux uniq 命令用于检查及删除文本文件中重复出现的行列,一般与 sort 命令结合使用. uniq 可检查文本文件中重复出现的行列. 语法 ...

  5. DB(1):SQLAPI catch [Bind variable/parameter 'pay_acc_id' not found] !!!

    SQLAPI catch [Bind variable/parameter 'pay_acc_id' not found] !!! 出现这种报错,先检查命令类后面的参数是否混淆(SACommand s ...

  6. metasploit与Cobaltstrike互相派生shell

    msf 派生 shell 给 Cobalt strike(前提有一个meterpreter) msf exploit(handler) > use exploit/windows/local/p ...

  7. Windows Server 2016 配置 IIS 的详细步骤

    Ø  简介 本文主要记录 Windows Server 2016 环境下,安装配置 IIS 的详细步骤.需要说明的是,在选择"功能"或"角色服务"时不建议将所有 ...

  8. matlab 加根号

    text(3,0.5,'z=0.2$$\sqrt{c/h_0}$$+0.3','interpreter','latex')

  9. 关于dfs

    DFS 关于dfs,我的理解就是深度搜索,找到所有与入口相连的路径,可以用于迷宫求出口,利用递归的思想,进行搜索返回所有值. 比如,给你两个值分别表示迷宫的长和宽,迷宫有一个入口,一个出口,判断能否从 ...

  10. Git 工具总结

    初操作---设置用户名 git config --global user.name "any name"  //设置全局project的用户名 git config --globa ...