在标准乳胶中,人们可以使用像...
\section[short head]{A longer and more meaningful heading version for the section}
Run Code Online (Sandbox Code Playgroud)
......既提供了一个部分的长版本和短版本(或其他切片命令)因此,允许有意义的切片'标题',以及合理的运行头,TOC,投影仪导航等.
有没有办法在组织模式下轻松实现这一目标?(那就是没有对LATEX片段中的分段命令进行硬编码,因此,在一开始就失去了更改分区级别和重新定位beamer,book和article类内容的大部分灵活性,这是我想要尝试orgmode的理由? )
我尝试了一种不起作用的"解决方法".我尝试通过添加另一个类来编辑可能的乳胶导出类org-export-latex-classes.这个新类将分段命令更改\section{%s}为\section%s(EDIT-Fixed typo in slashes).然后我测试[short]{longer version}了在文件的orgmode部分.它起作用了,除了它表现得好像较长版本部分标题只是"{"而"更长版本"是正文!怎么了?
小智 6
从8.0版开始,"org-export-latex-classes"策略将不再适用.
相反,我敢说得更优雅,你可以为标题设置ALT_TITLE属性.
见http://orgmode.org/manual/Table-of-contents.html.
以下组织代码:
* The Long Title of Section 1
:PROPERTIES:
:ALT_TITLE: Section 1
:END:
Lorem ipsum.
** The Long Title of Subsection 1-1
:PROPERTIES:
:ALT_TITLE: Subsection 1-1
:END:
Dolor sit amet.
Run Code Online (Sandbox Code Playgroud)
将导出到LaTeX:
[...]
\section[Section 1]{The Long Title of Section 1}
\label{sec-1}
Lorem ipsum.
\subsection[Subsection 1-1]{The Long Title of Subsection 1-1}
\label{sec-1-1}
Dolor sit amet.
Run Code Online (Sandbox Code Playgroud)
您创建自己的 LaTeX 类的想法是正确的。问题在于默认函数填充模板的方式org-fill-template。我不太擅长 Lisp,但是这个 hack 可以解决问题。将以下内容添加到您的.emacs文件中:
(defun my-section (level text)
(let* ((in "") (out "")
(short-title (if (string-match "\\[.*\\]" text)
(substring text (match-beginning 0)
(match-end 0))
nil)))
(if short-title (setq text (substring text (match-end 0) -1)))
(setq in (org-fill-template
"\\section%S{%s}"
(list (cons "S" (or short-title ""))
(cons "s" (or text ""))))
out (copy-sequence "\\end{section}"))
(cons text (list in out in out))))
(add-to-list 'org-export-latex-classes
'("test"
"\\documentclass{article}"
my-section))
Run Code Online (Sandbox Code Playgroud)
这通过将“测试”类添加到org-export-latex-classes. 在这里,我们声明一个函数,而不是普通的\\section{%s}东西,它接受两个参数——当前级别和标题文本——并返回修改后的 cons 单元格。此信息的一些详细信息可以在org-latex-export.el中找到。
在添加到列表的上方是我们实际定义函数的地方。老实说,这是一个 hacky 版本,我从org-beamer.elorg-beamer-sectioning文件中的函数中提取了很多内容。该函数基本上在标题中搜索任何类似于 LaTeX 短标签(即)的内容,将其从标题中删除并将其粘贴在实际部分标签之前。现在这个 hack 只会生成语句,无论级别有多深 - 如果你想要一些更智能的东西,比如甚至是未编号的项目,你需要做更多的 Lisping;再次,请参阅org-beamer.el寻求帮助。 [....]\section\chapter\subsection
这段org-mode代码
#+latex_class: test
* [short 1] this is 1 star
test
** this is a 2 star
test
*** [short 3] this is a 3 star
test
**** what happens
Run Code Online (Sandbox Code Playgroud)
导出到 LaTeX 为(此处仅显示相关部分):
\section[short 1]{ this is 1 star}
\label{sec-1}
test
\section{ this is a 2 star }
\label{sec-1-1}
test
\section[short 3]{ this is a 3 star}
\label{sec-1-1-1}
test
\section{ what happens }
\label{sec-1-1-1-1}
\end{section}
\end{section}
\end{section}
\end{section}
Run Code Online (Sandbox Code Playgroud)
尽管这不是一个直接的org-mode解决方案,但它似乎有效并且可以作为您的起点。有一天我可能会尝试正确地编写它并将其合并到org-mode发行版中。