如何使用特定的序言将组织模式导出到LaTeX? [英] How can I make Org-mode export to LaTeX with a specific preamble?

查看:241
本文介绍了如何使用特定的序言将组织模式导出到LaTeX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 C-c C-e l 将组织文件导出到LaTeX时,会生成一个带有特定前导码的文档。而不是这个特定的序言,我希望它使用我选择的序言。说我想要使用以下序言:

When I do C-c C-e l to export an Org file to LaTeX it produces a document with a particular preamble. Instead of this particular preamble I would like it to use a preamble of my choice. Say that I want it to use the following preamble:

% 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]}
}

我知道你可以在每个文件的基础上操纵使用哪些软件包如手册所述,但我希望将此前导码用于所有文件除非另有说明。我要使用的序言包括以下内容:

I know that you can manipulate which packages are used on a per file basis as described in the manual but I want this preamble to be used for all files unless ) specify otherwise. The preamble I want to use includes the following:


  • 已停用的软件包(例如几何

  • RequirePackage

  • / code>宏

  • \immediate\write18

  • 之后 usepackage

  • a hypersetup 识别#+ AUTHOR 从组织模式文件

  • deactivated packages (such as geometry above)
  • packages loaded by RequirePackage
  • input macros
  • \immediate\write18 macros
  • comments after usepackage macros
  • a hypersetup macro that recognizes #+TITLE and #+AUTHOR from Org-mode files

推荐答案

已停用的软件包(如 geometry 以上)



组织模式识别LaTeX代码块中的LaTeX语法,以及在内容中包含LaTeX文件时。 (请参阅引用LaTeX代码。)

如上所述。

如上。

我相信这也应该如上所述,但是有一个替代方法来处理这个。如果您使用其中的命令创建类型为 sh 的源代码块,Org将在导出时对其进行评估并产生所需的行为。您必须启用 sh 作为一种巴贝尔语言类型才能正常工作。

I believe this should also be as above, however there is an alternate method of dealing with this. If you create a source code block of type sh with the command within it, Org will evaluate it on export and produce the desired behaviour. You have to enable sh as a babel language type for it to work however.

(require 'ob-shell)

您还可以包括 sh 作为由babel加载的语言之一,将其添加到 org-babel-load-languages

You can also include sh as one of the languages loaded by babel by adding it to org-babel-load-languages

(acons 'sh 't org-babel-load-languages)

然后使用类似于以下代码块运行./vc

Then use a code block similar to the following to run your ./vc

#+name: Test
#+begin_src sh :results output silent :exports results
  ./vc
#+end_src

只要这是在你的 \input {vc} 之前应该运行代码,然后包含它。只需按照代码块

As long as this comes before your \input{vc} line it should run the code and then include it. Simply follow the code-block with

#+LATEX: \input{vc}

您的内容应该包括在内。

And your content should be included.

如果代码在LaTeX块中,它应该将其识别为LaTeX。

If the code is within a LaTeX block it should recognize it as LaTeX.

这将必须包含在每个文档中,而不是单独的。以下将提供您对宏的期望。它不会在序言中,但是最终将在文档的顶部,导出确实按照预期的行为(但是如果通过#+ INCLUDE: from org。

This will have to be included within each document rather than separate. The following will provide what you desire for your macros. It will not be within the preamble, however it will end up at the top of the document and the export does behave as expected (however it will not behave as expected if added through #+INCLUDE: from org.

#+begin_latex
  \hypersetup{% Setup for hyperref
  pdftitle    = {{{{TITLE}}}}, %Org macro to take from #+TITLE
  pdfauthor   = {{{{AUTHOR}}}} %Org macro to take from #+AUTHOR
  }
#+end_latex



创建自己的Latex导出类



如果您遵循worg教程中的说明(请参阅组织胶乳出口),您可以创建自己的导出类。如果要完全控制序言中的包,您只需要:

Creating your own Latex export class

If you follow the instructions in the worg tutorials (See Org Latex Export) you can create your own export-class. If you want to have full control over the packages in the preamble you would simply need to:

(add-to-list 'org-export-latex-classes
             '("<CLASS NAME>"
               "\\documentclass{article}
               [NO-DEFAULT-PACKAGES]
               [NO-PACKAGES]"
               <insert desired sectioning configuration>))

您还可以在 \\documentclass 之间添加所需的软件包和 [NO-DEFAULT-PACKAGES] 行。另一种方法是将它们添加到文件本身中:

You can also add in your desired packages between the \\documentclass and [NO-DEFAULT-PACKAGES] lines. The alternative would be to add them to the file itself using:

#+LATEX_CLASS: <CLASS NAME>
#+LATEX_HEADER: \usepackage{package}
...

作为第三个选项,您可以简单地创建一个具有所需软件包等的自定义.sty文件,并将其作为单个#+ LATEX_HEADER:

As a third option, you can simply create a custom .sty file with the desired packages etc and include it as a single #+LATEX_HEADER:.

这篇关于如何使用特定的序言将组织模式导出到LaTeX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆