对于非beamer文档,是否存在等效的Org-mode的b_ignoreheading?

N.N*_*.N. 9 emacs org-mode

当使用Org-mode创建投影仪演示时,可以设置标题的属性,以便不显示导出的标题,而只显示其内容.例如,以下内容

#+title: Test

#+options: toc:nil
#+latex_class: beamer
#+startup: beamer

#+BEAMER_FRAME_LEVEL: 2

* Ignored heading                                           :B_ignoreheading:
:PROPERTIES:
:BEAMER_env: ignoreheading
:END:
Text
Run Code Online (Sandbox Code Playgroud)

结果只有"文本"框架,没有标题.这种功能是否适用于非beamer文档?也就是说,是否可以告诉Org-mode不导出标题而只导出其内容?例如,是否可以使Org-mode导出以下内容

#+title: Test

* Ignored heading
Text
Run Code Online (Sandbox Code Playgroud)

没有导出标题"忽略标题"但只导出"文本"?

如果我出口

#+title: Test

* 
Text
Run Code Online (Sandbox Code Playgroud)

(注意后面的空格*)我得到以下内容(我只包括相关部分):

\section{}

Text
Run Code Online (Sandbox Code Playgroud)

但这不是我想要的.我希望在导出中完全忽略标题,以便我得到以下内容(同样我只包括相关部分):

Text
Run Code Online (Sandbox Code Playgroud)

suv*_*ayu 9

您所要求的内容没有默认支持.但是,您可以使用预处理挂钩来获得类似的输出.以下是LaTeX导出的示例:

;; backend aware export preprocess hook
(defun sa-org-export-preprocess-hook ()
  "My backend aware export preprocess hook."
  (save-excursion
    (when (eq org-export-current-backend 'latex)
      ;; ignoreheading tag for bibliographies and appendices
      (let* ((tag "ignoreheading"))
        (org-map-entries (lambda ()
                           (delete-region (point-at-bol) (point-at-eol)))
                         (concat ":" tag ":"))))))

(add-hook 'org-export-preprocess-hook 'sa-org-export-preprocess-hook)
Run Code Online (Sandbox Code Playgroud)

这是我的组织模式设置的片段.你可以在github上看到原文 .上面的代码将忽略标记的标题ignoreheading,例如

* Heading 1
* Heading 2                           :ignoreheading:
+ Some text
+ an item
Run Code Online (Sandbox Code Playgroud)

导出为:

\section{Heading 1}
\label{sec-1}

\begin{itemize}
\item Some text
\item an item
\end{itemize}
Run Code Online (Sandbox Code Playgroud)

警告:此解决方案存在已知问题.当你在第一个标题上尝试这个时它不起作用.我不明白为什么会这样,希望有一天我会有时间去调查.

需要注意的解决方法:在org文件头之后使用类似这样的行,可以规避LaTeX导出的上述限制:

\include{preamble.tex}
Run Code Online (Sandbox Code Playgroud)

preamble.tex文件可以包含抽象或确认等部分.但是,您应该注意这会使您的组织文件与导出后端紧密相关.例如,将相同的组织文件导出到HTML将变得非常简单.

注意:对于使用新导出框架(Org 8.0或更高版本)的类似设置,请使用以下命令:

(defun sa-ignore-headline (contents backend info)
  "Ignore headlines with tag `ignoreheading'."
  (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii)
          (string-match "\\`.*ignoreheading.*\n"
                (downcase contents)))
    (replace-match "" nil nil contents)))

(add-to-list 'org-export-filter-headline-functions 'sa-ignore-headline)
Run Code Online (Sandbox Code Playgroud)


joo*_*oon 6

现在您可以使用 轻松完成此操作ox-extra。将以下内容添加到您的init文件中:

(require 'ox-extra)
(ox-extras-activate '(ignore-headlines))
Run Code Online (Sandbox Code Playgroud)

然后,任何带ignore标签的标题都将被忽略,而其内容仍将被导出。