\usepackage
我有一個 LaTeX 文件,其中包含一些適用於我的 TeX 文件(以及此類內容)的指令。現在我想在不同的組織模式檔案中重複使用此檔案。我知道我可以包含文件#+include: 'path/to/some/file.tex'
,但這會將文件的內容放在\begin{document}
.
我可以以某種方式將文件包含到標頭中嗎?
根據建議,這裡有一個例子:
A範本文件儲存標題的文件:
\documentclass[a4paper]{customClass}
\usepackage{etex}
\title{Some Title}
\supervisor{Someone}
正如這裡所示,這使用了自訂文件類,這就是我只想包含它的原因之一。
然後我有一個包含所有內容的文件(內容網站):
#+INCLUDE: template.tex
* Chapter 1
** Subchapter 1
Some content
** Subchapter 2
More content
當前輸出(內容.tex):
\documentclass[11pt]{article}
\usepackage[latin1]{inputenc}
% a lot more org-mode standard header stuff
% ...
\begin{document}
\maketitle
\setcounter{tocdepth}{3}
\tableofcontents
\vspace*{1cm}
% my template.tex file
% not where I wanted it
\documentclass[a4paper]{customClass}
\usepackage{etex}
\title{Some Title}
\supervisor{Someone}
\section{Chapter 1}
% rest of the document
% ...
\end{document}
簡而言之:我想template.tex
在一些組織文件中重複使用我的文件以獲得一致的格式。這可能嗎?
答案1
雖然我不知道如何使用 LaTeX 檔案執行此操作,但您可以使用#+SETUPFILE: file
(http://orgmode.org/manual/In_002dbuffer-settings.html) 以在匯出中包含外部組織文件。然後就可以#+LaTeX_HEADER:
在外部org文件中使用了。
例如,在 中包含以下內容content.org
:
#+SETUPFILE: template.org
並包含以下內容template.org
:
#+LaTeX_CLASS: customClass
#+LaTeX_CLASS_OPTIONS: [a4paper]
#+LaTeX_HEADER: \usepackage{etex}
#+LaTeX_HEADER: \title{Some Title}
#+LaTeX_HEADER: \supervisor{Someone}
當您匯出時content.org
,它們將作為 的序言的一部分包含在內content.tex
。
答案2
org 用於匯出的 Latex 標頭儲存在 中org-format-latex-header
,您可以根據需要進行修改。根據幫助:
此標題必須確保頁面上不會出現頁碼。變數 org-latex-packages-alist' 中定義的套件
org-latex-default-packages-alist' and
將取代此標頭中的佔位符“[PACKAGES]”,或將附加它們。
答案3
您可以在您的組織文件中建立文件局部變數來停用預設標頭,然後就沒有它自己的標頭輸出來混淆您想要的乳膠程式碼。
# Local Variables:
# org-latex-default-packages-alist: nil
# org-latex-with-hyperref: nil
# org-latex-packages-alist: nil
# End: