[英]Org-mode strike-through on DONE headings when exporting to LaTeX
當我將文檔導出到LaTeX時,讓Emacs中的org-mode在每個標題上添加帶有“ DONE”關鍵字的刪除線的最佳方法是什么? 現在我的設置是
(defun my-latex-filter-headline-done (text backend info)
"Ensure dots in headlines."
(when (org-export-derived-backend-p backend 'latex)
(save-match-data
(when (let ((case-fold-search t))
(string-match "\\\\\\([a-z]+\\){\\(.*DONE.*\\)}"
text))
(if (not (string-match ".*hsout.*" text))
(replace-match "\\\\\\1{\\\\hsout{\\2}}"
t nil text))))))
(eval-after-load 'ox
'(progn
(add-to-list 'org-export-filter-headline-functions
'my-latex-filter-headline-done)))
在我的文件中
#+LATEX_HEADER: \DeclareRobustCommand{\hsout}[1]{\texorpdfstring{\sout{#1}}{#1}}
這樣,如果我有一個像
* DONE test
它將導出為類似
% header stuff…
\begin{document}
\section{\hsout{{\bfseries\sffamily DONE} test}}
\end{document}
雖然通常沒有刪除線
% header stuff…
\begin{document}
\section{{\bfseries\sffamily DONE} test}
\end{document}
我必須使用\\hsout
宏在標題中進行刪除線工作。 這種方法有幾個缺點:
LATEX_HEADER
。 \\section[aaaa]{bbbbbbb}
)。 如果要包括它,則必須在elisp中添加另一個難看的正則表達式,這已經非常難看了。 因此,一開始我的問題是。 有人知道更好的方法嗎?
這是局部的。 。 。 這將為您保存LATEX-HEADER
每個組織文件中的條目:
(setq org-latex-default-packages-alist
'(("AUTO" "inputenc" t)
("T1" "fontenc" t)
("" "fixltx2e" nil)
("" "graphicx" t)
("" "longtable" nil)
("" "float" nil)
("" "wrapfig" nil)
("" "rotating" nil)
("normalem" "ulem" t)
("" "amsmath" t)
("" "textcomp" t)
("" "marvosym" t)
("" "wasysym" t)
("" "amssymb" t)
("" "hyperref" nil)
"\\tolerance=1000"
"\\DeclareRobustCommand{\\hsout}[1]{\\texorpdfstring{\\sout{#1}}{#1}}"
))
另一種選擇是使用:
(setq org-latex-packages-alist
'(
"\\DeclareRobustCommand{\\hsout}[1]{\\texorpdfstring{\\sout{#1}}{#1}}"
))
添加到列表的其他方法:
(add-to-list 'org-latex-packages-alist
"\\DeclareRobustCommand{\\hsout}[1]{\\texorpdfstring{\\sout{#1}}{#1}}")
要么
(add-to-list 'org-latex-default-packages-alist
"\\DeclareRobustCommand{\\hsout}[1]{\\texorpdfstring{\\sout{#1}}{#1}}")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.