6

#+AUTHORorg-modeまたはorg-mode のようなタグがあり#+LATEXます - それらはタグと呼ばれますか? エクスポート ターゲットが LaTeX の場合、関数を呼び出してデータを前処理し、出力する独自のタグを定義したいと思います。

4

2 に答える 2

5

私の解決策は、ブロックqtree用に独自の言語 を定義することでした。SRC

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

そして、それに応じて処理します。で qtree-mode も追加しましたparedit。そしてlandscape、木が大きくなるかどうかのパラメータ。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

それらは、バッファ内設定のキーワードと呼ばれるようになりました。名前が何であれ、ユーザーが定義できるようには見えません。

あなたがしたいことは、 Worgで説明されているようにxelatexまたはpdflatex でエクスポートするのに対し、一般的な処理方法に非常に関連しています。

関連する部分は次のとおりです。

;; 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 に答える