zoukankan      html  css  js  c++  java
  • Control HTML and LaTeX export in Org mode

    Emacs Org mode is a very powerful, versatile and extensible package, which can be used for personal information management, organization and publication of blog posts, realization of a GTD system, etc. Using a simple markup grammar, we can easily obtain a nice typographical effect by exporting the text file into various formats, such as PDF, LibreOffice document, HTML, LaTeX, Freeplane mind map, TaskJuggler, iCalendar and so on. During my daily work, typesetting math with LaTeX and publishing them as blog posts are common tasks. In this post, I’ll summarize those variables provided by Org mode, which aim to finely control the behavior of LaTeX fragment processing as well as HTML and LaTeX document export.

    • org-export-with-LaTeX-fragments: when it is true, LaTeX fragments export using MathJax mode is enabled.

    • org-export-html-mathjax-options: it specifies the URL of MathJax script, scaling of all equations, alignment and indentation of display equations, and whether MathML should be enabled. A global configuration looks like this.

      (setq org-html-mathjax-options
         '((path "http://localhost/js/MathJax/MathJax.js")
           (scale "100")
           (align "center")
           (indent "2em")
           (mathml nil)))
      

      A per-file configuration can also be added to the beginning of an Org file as below.

      #+MATHJAX: path:"http://localhost/js/MathJax/MathJax.js" scale:"100" align:"center" indent:"2em" mathml:nil 
      
    • org-export-htmlize-output-type: it controls the output type used by the htmlize module for typesetting code snippets wrapped between #+BEGIN_SRC and #+END_SRC. Possible choices are

      • css: to export the CSS selectors only;
      • inline-css: to export the CSS attribute values as inline HTML.
    • org-export-with-TeX-macros: when it is non-nil, simple TeX-like macros will be interpreted in the export. For example, HTML export will convert alpha to α and AA to Å. Not only real TeX macros will work here, but also the standard HTML entities for math can be used as macro names as well. I set it to nil because I do not want to convert simple TeX-like macros into HTML.

    • org-export-html-style: this variable specifies an Org-wide CSS style for exported HTML files. It should contain the full HTML structure to provide a style, including the surrounding HTML tags. A typical configuration is as below.

      (setq org-export-html-style
        "<link rel="stylesheet" type="text/css" href="main.css">")
      

      In the above CSS file main.css, you should consider to include style definitions for the following classes: title, todo, done, timestamp, timestamp-kwd, tag, target.

    • org-export-html-style-extra: this variable holds additional style information for HTML export. The value of this variable is inserted into the HTML buffer right after the value of org-export-html-style. Use this variable for per-file settings and do not forget to surround the style settings with <style>...</style> tags.

    • org-format-latex-header: this variable stores the LaTeX header for processing LaTeX fragments not a complete LaTeX document, so the LaTeX header should include a directive pagestyle{empty} in order that the page number be disabled. A typical configuration looks like below, in which the template argument [PACKAGES] is to be replaced by the values stored in org-export-latex-default-packages-alist and org-export-latex-packages-alist.

      documentclass{article}
      usepackage{fullpage}         % do not remove
      [NO-DEFAULT-PACKAGES]
      input{generic}
      input{math}
      input{font-selection}
      [PACKAGES]
      pagestyle{empty}             % do not remove"
      
    • org-format-latex-options: this variable contains options for creating images from LaTeX fragments, such as foreground and background colors as well as scale in both Emacs editor and exported HTML, string pattern for matching the beginning of a math equation. It can be configured as below.

      (setq org-format-latex-options
        '(
          :foreground default
          :background "Transparent"
          :scale 1.2
          :html-foreground "Black"
          :html-background "Transparent"
          :html-scale 1.0 
          :matchers 
            ("begin" "$1" "$" "$$" "\(" "\[")))
      
      子曰:“君子食无求饱,居无求安,敏于事而慎于言,就有道而正焉,可谓好学也已。”
  • 相关阅读:
    使用CSS将图片转换成黑白(灰色、置灰)
    require.js
    Tortoisegit安装下载
    谷歌浏览器添加扩展程序
    IOS 照相问题
    java的interface和PHP的区别
    Object中的hashCode方法
    PHP、js、Java中的匿名函数、闭包、回调函数
    Java和PHP中的浅克隆和深克隆
    unicode字符编码中一些专业词汇的全称
  • 原文地址:https://www.cnblogs.com/quantumman/p/14460613.html
Copyright © 2011-2022 走看看