13.12.5 Applying custom styles

ODT 导出后端内置多种开放文档样式(参见 Working with OpenDocument style files)。如需扩展或进一步自定义内置样式表,可直接编辑样式表,或使用 LibreOffice 等应用生成。以下示例展示通过 LibreOffice 创建样式的方法。

Applying custom styles: the easy way

  1. 创建示例文件 ‘example.org’ ,按如下所示配置并导出为 ODT 格式。
    #+OPTIONS: H:10 num:t
    
  2. Open the above ‘example.odt’ using LibreOffice. Use the Stylist to locate the target styles, which typically have the “Org” prefix. Open one, modify, and save as either OpenDocument Text (ODT) or OpenDocument Template (OTT) file.
  3. 自定义变量 org-odt-styles-file 并指向新创建的文件。更多配置选项参见 Overriding factory styles

    若要为特定文件应用 ODT 样式,可按如下示例使用 ‘ODT_STYLES_FILE’ 关键字:

    #+ODT_STYLES_FILE: "/path/to/example.ott"
    

    #+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
    

Using third-party styles and templates

ODT 导出后端依赖大量模板与样式名称,使用第三方样式和模板可能导致不兼容。基于内置 ODT 模板与样式衍生的模板通常问题更少。