在org-mode中,如何为LaTeX和HTML指定不同的导出选项?

 yangaien 发布于 2023-02-06 17:10

在组织模式中,我想为不同的导出类型指定不同的导出选项,即编号标题和导出到LaTeX/PDF的目录,没有编号,也没有用于导出到HTML的目录.

是否可以在不必每次手动编辑导出选项的情况下执行此操作?

1 个回答
  • ox.el(组织模式的通用导出引擎)中有一个过滤系统:

    过滤器允许最终用户轻松调整转码输出.它们是钩子的功能对应物,因为集合中的每个过滤器都应用于前一个过滤器的返回值.

    其中一个过滤器是:filter-options:

    `:filter-options' applies to the property list containing export
    options.  Unlike to other filters, functions in this list accept
    two arguments instead of three: the property list containing
    export options and the back-end.  Users can set its value through
    `org-export-filter-options-functions' variable.
    

    这意味着你可以定义一个类似于这个的函数:

    (defun my-org-export-change-options (plist backend)
      (cond 
        ((equal backend 'html)
         (plist-put plist :with-toc nil)
         (plist-put plist :section-numbers nil))
        ((equal backend 'latex)
         (plist-put plist :with-toc t)
         (plist-put plist :section-numbers t)))
      plist)
    

    并将其添加到导出过滤器:

    (add-to-list 'org-export-filter-options-functions 'my-org-export-change-options)
    

    该函数将由导出调用,并根据后端启用或禁用toc/section-numbers.

    2023-02-06 17:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有