I have a LaTeX file with some directives for my TeX documents (\usepackage
and such things). Now I want to reuse this file in different org-mode files. I know I can include files with #+include: 'path/to/some/file.tex'
, but this puts the content of the file after \begin{document}
.
Can I somehow include a file into the header?
As suggested, here an example:
A template.tex file that holds the header:
\documentclass[a4paper]{customClass}
\usepackage{etex}
\title{Some Title}
\supervisor{Someone}
As also shown here, this uses a custom document class, which is one of the reasons why I just want to be able to include it.
Then I have a file which contains all the content (content.org):
#+INCLUDE: template.tex
* Chapter 1
** Subchapter 1
Some content
** Subchapter 2
More content
Which currently outputs (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}
So in short: I want to reuse my template.tex
file in a few org documents to have consistent formatting. Is this possible?
Best Answer
While I do not know a way to do this with a LaTeX file, you can use
#+SETUPFILE: file
(http://orgmode.org/manual/In_002dbuffer-settings.html) to include an external org file in exporting. Then you can use#+LaTeX_HEADER:
in the external org file.For example, with the following in
content.org
:and with the following in
template.org
:When you export
content.org
, they will be included as a part of the preamble ofcontent.tex
.