zoukankan      html  css  js  c++  java
  • Org mode无法生成LaTeX公式预览图片

    最近需要在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:cygwin64inlatex.exe
     Found: D: exlive2016inwin32latex.exe
     Found: C:cygwin64inlatex.exe
     C:cygwin64inlatex.exe
      C:cygwin64incygkpathsea-6.dll
        C:cygwin64incygwin1.dll
          C:Windowssystem32KERNEL32.dll
            C:Windowssystem32API-MS-Win-Core-RtlSupport-L1-1-0.dll
            C:Windowssystem32 tdll.dll
            C:Windowssystem32KERNELBASE.dll
            C:Windowssystem32API-MS-Win-Core-ProcessThreads-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Heap-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Memory-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Handle-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Synch-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-File-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-IO-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-ThreadPool-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-LibraryLoader-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-NamedPipe-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Misc-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-SysInfo-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Localization-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-String-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Debug-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-ErrorHandling-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Fibers-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Util-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Core-Profile-L1-1-0.dll
            C:Windowssystem32API-MS-Win-Security-Base-L1-1-0.dll
      C:cygwin64incygpng16-16.dll
        C:cygwin64incygz.dll
      C:cygwin64incygpoppler-49.dll
        C:cygwin64incygcurl-4.dll
          C:cygwin64incyggssapi_krb5-2.dll
            C:cygwin64incygk5crypto-3.dll
              C:cygwin64incygkrb5support-0.dll
                C:cygwin64incygintl-8.dll
                  C:cygwin64incygiconv-2.dll
            C:cygwin64incygkrb5-3.dll
              C:cygwin64incygcom_err-2.dll
                C:cygwin64incyggcc_s-seh-1.dll
          C:cygwin64incygidn2-0.dll
            C:cygwin64incygunistring-2.dll
          C:cygwin64incyglber-2-4-2.dll
          C:cygwin64incygldap-2-4-2.dll
            C:cygwin64incygsasl2-3.dll
          C:cygwin64incygnghttp2-14.dll
          C:cygwin64incygpsl-5.dll
          C:cygwin64incygssh2-1.dll
        C:cygwin64incygfontconfig-1.dll
          C:cygwin64incygexpat-1.dll
          C:cygwin64incygfreetype-6.dll
            C:cygwin64incygbz2-1.dll
        C:cygwin64incygjpeg-8.dll
        C:cygwin64incyglcms2-2.dll
        C:cygwin64incygtiff-6.dll
          C:cygwin64incygjbig-2.dll
          C:cygwin64incyglzma-5.dll
        C:cygwin64incygstdc++-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:cygwin64in下,一切就恢复正常了。

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

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

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

  • 相关阅读:
    从泛型类中继承
    DataGridView中的单元格提示错误信息
    C#中的转换
    C#的运算符重载
    解决android模块化升级方法
    个人总结如何在项目管理的实际软件开发工作的几个关键点和控制
    bash no such file or directory in ubuntu 1404
    java 遍历树节点 同时保留所有的从根到叶节点的路径
    ZendFramework2学习笔记 json和ajax
    POJ 2531-Network Saboteur(DFS)
  • 原文地址:https://www.cnblogs.com/quantumman/p/10651292.html
Copyright © 2011-2022 走看看