6

在 org-mode中#+AUTHOR#+LATEX在 org-mode 中有标签 - 它们被称为标签吗?我想定义我自己的标签,它调用一个函数来预处理数据然后输出它 - 如果导出目标是 LaTeX。

4

2 回答 2

5

qtree我的解决方案是为SRC块定义自己的语言 , 。

#+BEGIN_SRC qtree
[.CP [.TP [.NP [] [.N' [.N Syntax] []]] [.VP [] [.V' [.V sucks] []]]]]
#+END_SRC

并相应地处理它。我什至添加了一个 qtree 模式pareditlandscape如果树长得很大,还有一个参数。https://github.com/Tass/emacs-starter-kit/blob/master/vendor/assorted/org-babel-qtree.el

(require 'org)

(defun org-babel-execute:qtree (body params)
  "Reformat a block of lisp-edited tree to one tikz-qtree likes."
  (let (( tree
          (concat "\\begin{tikzpicture}
\\tikzset{every tree node/.style={align=center, anchor=north}}
\\Tree "
                  (replace-regexp-in-string
                   " \\_<\\w+\\_>" (lambda (x) (concat "\\\\\\\\" (substring x 1))) 
                   (replace-regexp-in-string
                    (regexp-quote "]") " ]" ; qtree needs a space
                                        ; before every closing
                                        ; bracket.
                    (replace-regexp-in-string
                     (regexp-quote "[]") "[.{}]" body)) ; empty leaf
                                        ; nodes, see
                                        ; http://tex.stackexchange.com/questions/75915
                   )                    ; For
                                        ; http://tex.stackexchange.com/questions/75217
                  "\n\\end{tikzpicture}"
                  )))
    (if (assoc :landscape params)
        (concat "\\begin{landscape}\n" tree "\n\\end{landscape}")
      tree)))

(setq org-babel-default-header-args:qtree '((:results . "latex") (:exports . "results")))
(add-to-list 'org-src-lang-modes '("qtree" . qtree))
(define-generic-mode 
    'qtree-mode                  ;; name of the mode to create
  '("%")                         ;; comments start with '%'
  '()                            ;; no keywords
  '(("[." . 'font-lock-operator) ;; some operators
    ("]" . 'font-lock-operator))
  '()                      ;; files for which to activate this mode 
  '(paredit-mode)          ;; other functions to call
  "A mode for qtree edits" ;; doc string for this mode
  )
于 2012-10-10T19:08:22.967 回答
4

它们似乎不再被称为缓冲区内设置的关键字。不管它们叫什么,它们似乎都不是用户可定义的。

您想要做的与常用的处理方式极为相关,而使用xelatexpdflatex进行导出, 如 Worg 中所述

相关部分是:

;; Originally taken from Bruno Tavernier: http://thread.gmane.org/gmane.emacs.orgmode/31150/focus=31432
(defun my-auto-tex-cmd ()
  (if (string-match "YOUR_TAG: value1" (buffer-string))
      (do something))
  (if (string-match "YOUR_TAG: value2" (buffer-string))
      (do something else))

(add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
于 2012-10-09T23:03:35.877 回答