N.N*_*.N. 19 emacs latex org-mode
当我C-c C-e l将Org文件导出到LaTeX时,它会生成一个带有特定前导码的文档.我希望它使用我选择的序言,而不是这个特定的序言.假设我希望它使用以下序言:
% Don't forget to qpdf --linearize the final copy
\RequirePackage[l2tabu,orthodox]{nag}% Old habits die hard. All the same, there are commands, classes and packages which are outdated and superseded. nag provides routines to warn the user about the use of those.
\immediate\write18{sh ./vc}
\input{vc}% Version control macros (for \VCDateISO in \date) http://www.ctan.org/pkg/vc
\documentclass[a4paper,12pt]{article}% pt? doublepage?
%\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}% Latin Modern (derivate of Knuth's CM)
\usepackage{fixltx2e}% \textsubscript and bugfixes for LaTeX
\usepackage{microtype}
\usepackage[strict=true]{csquotes}% Context-sensistive quotes. \enquote "" \enquote* ''. Use the integrated commands \textcquote and \blockcquote rather than biblatex internal commands to get contex sensistive quotes for them too. s/babel/autostyle in new version.
\usepackage[bookmarks,pdfborder={0 0 0}]{hyperref}% links and pdfinfo. MUST BE LOADED LAST!
\hypersetup{% Setup for hyperref
pdftitle = {[Title from #+TITLE]},
pdfauthor = {[Author from #+AUTHOR]}
}
Run Code Online (Sandbox Code Playgroud)
我知道您可以按照手册中的描述操作每个文件使用哪些包,但我希望这个序言用于所有文件,除非另有说明.我想要使用的序言包括以下内容:
geometry如上)RequirePackageinput 宏\immediate\write18 宏usepackage宏之后的评论hypersetup识别宏#+TITLE并#+AUTHOR从组织模式的文件Jon*_*pin 15
geometry如上)Org-mode识别LaTeX代码块中的LaTeX语法,以及在内容中包含LaTeX文件时.(请参阅引用LaTeX代码.)
RequirePackage如上.
如上.
\immediate\write18 宏我相信这也应该如上所述,但是有一种替代方法可以解决这个问题.如果sh使用其中的命令创建类型的源代码块,Org将在导出时对其进行评估并生成所需的行为.您必须启用它sh作为babel语言类型才能工作.
(require 'ob-shell)
Run Code Online (Sandbox Code Playgroud)
您也可以将shbabel加载的语言作为其中一种加入org-babel-load-languages
(acons 'sh 't org-babel-load-languages)
Run Code Online (Sandbox Code Playgroud)
然后使用类似于以下代码块来运行./vc
#+name: Test
#+begin_src sh :results output silent :exports results
./vc
#+end_src
Run Code Online (Sandbox Code Playgroud)
只要它出现在你的\input{vc}行之前它应该运行代码然后包含它.只需按照代码块操作即可
#+LATEX: \input{vc}
Run Code Online (Sandbox Code Playgroud)
并且应包括您的内容.
如果代码在LaTeX块中,则应将其识别为LaTeX.
hypersetup宏,用于识别组织模式文件中的#+ TITLE和#+ AUTHOR.这必须包含在每个文档中而不是分开.以下内容将提供您对宏的期望.它不会在序言中,但它最终将位于文档的顶部,并且导出确实按预期运行(但是如果通过#+INCLUDE:组织添加,它将不会按预期运行.
#+begin_latex
\hypersetup{% Setup for hyperref
pdftitle = {{{{TITLE}}}}, %Org macro to take from #+TITLE
pdfauthor = {{{{AUTHOR}}}} %Org macro to take from #+AUTHOR
}
#+end_latex
Run Code Online (Sandbox Code Playgroud)
如果您按照worg教程中的说明进行操作(请参阅Org Latex Export),您可以创建自己的导出类.如果您想完全控制前言中的包,您只需:
(add-to-list 'org-export-latex-classes
'("<CLASS NAME>"
"\\documentclass{article}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
<insert desired sectioning configuration>))
Run Code Online (Sandbox Code Playgroud)
您还可以在\\documentclass和[NO-DEFAULT-PACKAGES]行之间添加所需的包.另一种方法是使用以下方法将它们添加到文件本身:
#+LATEX_CLASS: <CLASS NAME>
#+LATEX_HEADER: \usepackage{package}
...
Run Code Online (Sandbox Code Playgroud)
作为第三种选择,您只需使用所需的包等创建自定义.sty文件,并将其作为单个包含#+LATEX_HEADER:.
这不能回答你的问题,但它确实允许你做你想做的事。
(defun headless-latex ()
"exports to a .tex file without any preamble"
(interactive)
(org-export-as-latex 3 nil nil nil t nil)
)
Run Code Online (Sandbox Code Playgroud)
此函数导出 ORG 模式文件的内容,没有任何前导。然后\input,您可以将其放入包含所需序言的文件中。进一步阅读。
| 归档时间: |
|
| 查看次数: |
13003 次 |
| 最近记录: |