9

I want to add a front cover for my Org document which will export as a PDF (#+LaTeX_CLASS: article). I don't want to modify my org-latex-classes and apply globally.

I tried to add the following block before first outline of the Org document, but it will insert the cover under the contents.

Is there any way to insert a LaTeX block to generate front cover for an individual Org article?

#+BEGIN_LaTeX latex
\newcommand*{\titleGP}{\begingroup % Create the command for including the title page in the document
\centering % Center all text
\vspace*{\baselineskip} % White space at the top of the page

\rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt} % Thick horizontal line
\rule{\textwidth}{0.4pt}\\[\baselineskip] % Thin horizontal line

{\LARGE THE BIG BOOK\\ OF \\[0.3\baselineskip] \LaTeX ~TEMPLATES}\\[0.2\baselineskip] % Title

\rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt} % Thin horizontal line
\rule{\textwidth}{1.6pt}\\[\baselineskip] % Thick horizontal line

\scshape % Small caps
A number of fascinating and life-changing templates \\ % Tagline(s) or further description
presented  in a clear and useable way \\[\baselineskip] % Tagline(s) or further description
New Zealand,  2011--2012\par % Location and year

\vspace*{2\baselineskip} % Whitespace between location/year and editors

Edited by \\[\baselineskip]
{\Large JOHN SMITH \\ JANE SMITH \\ JAMES SMITH\par} % Editor list
{\itshape The University of California \\ Berkeley\par} % Editor affiliation

\vfill % Whitespace between editor names and publisher logo

{\scshape 2012} \\[0.3\baselineskip] % Year published
{\large THE PUBLISHER}\par % Publisher

\endgroup}
\titleGP % This command includes the title page
#+END_LaTeX
1
  • 1
    Just locally bind org-latex-title-command to include \titleGP which should be loaded in the preamble.
    – rasmus
    Jan 11, 2015 at 18:45

2 Answers 2

8

As @ramus suggested, you can set org-latex-title-command to a custom macro and have it used in place of \maketitle. If you set org-export-allow-bind-keywords to t you can do this per file using #+BIND org-latex-title-command "\\titleGP", but Emacs will start bugging you about" unsafe variables". This will insert \titleGP immediately after \begin{document}.

Then you just have to make sure the \titleGP macro is defined in the preamble, which we do with #+LATEX_HEADER. A complete example is

#+BIND: org-latex-title-command "\\titleGP"

#+LATEX_HEADER: \newcommand*{\titleGP}{\begingroup % Create the command for including the title page in the document
#+LATEX_HEADER: \centering % Center all text
#+LATEX_HEADER: \vspace*{\baselineskip} % White space at the top of the page
#+LATEX_HEADER:  
#+LATEX_HEADER: \rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt} % Thick horizontal line
#+LATEX_HEADER: \rule{\textwidth}{0.4pt}\\[\baselineskip] % Thin horizontal line
#+LATEX_HEADER:  
#+LATEX_HEADER: {\LARGE THE BIG BOOK\\ OF \\[0.3\baselineskip] \LaTeX ~TEMPLATES}\\[0.2\baselineskip] % Title
#+LATEX_HEADER:  
#+LATEX_HEADER: \rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt} % Thin horizontal line
#+LATEX_HEADER: \rule{\textwidth}{1.6pt}\\[\baselineskip] % Thick horizontal line
#+LATEX_HEADER:  
#+LATEX_HEADER: \scshape % Small caps
#+LATEX_HEADER: A number of fascinating and life-changing templates \\ % Tagline(s) or further description
#+LATEX_HEADER: presented  in a clear and useable way \\[\baselineskip] % Tagline(s) or further description
#+LATEX_HEADER: New Zealand,  2011--2012\par % Location and year
#+LATEX_HEADER:  
#+LATEX_HEADER: \vspace*{2\baselineskip} % Whitespace between location/year and editors
#+LATEX_HEADER:  
#+LATEX_HEADER: Edited by \\[\baselineskip]
#+LATEX_HEADER: {\Large JOHN SMITH \\ JANE SMITH \\ JAMES SMITH\par} % Editor list
#+LATEX_HEADER: {\itshape The University of California \\ Berkeley\par} % Editor affiliation
#+LATEX_HEADER:  
#+LATEX_HEADER: \vfill % Whitespace between editor names and publisher logo
#+LATEX_HEADER:  
#+LATEX_HEADER: {\scshape 2012} \\[0.3\baselineskip] % Year published
#+LATEX_HEADER: {\large THE PUBLISHER}\par % Publisher
#+LATEX_HEADER:  
#+LATEX_HEADER: \endgroup}

* first section
some content

If you don't want to mess with setting org-export-allow-bind-keywords you could always just call your macro \maketitle instead of \titleGP, clobbering the old definition. You'll need to use \renewcommand instead of \newcommand.

2
  • 1
    Another question, the lines looks so ugly, any way to fold them?
    – kuanyui
    Jan 17, 2015 at 16:05
  • 3
    You can put them inside a headline and fold that. I usually call it "* Configuration" and but a :ARCHIVE: tag on it to make sure it doesn't get exported.
    – erikstokes
    Jan 17, 2015 at 22:05
1

In order to have the following document structure :

  1. Cover page
  2. Table of content (on a new page)
  3. Begining of the content (on a new page)

You can do the following:

#+OPTIONS: num:1 toc:nil % toc is nil to set \tableofcontents manually
#+LATEX_HEADER: ADDITIONAL PACKAGE
#+LATEX_HEADER: PACKAGE CONFIG
#+begin_export latex
\begin{titlepage}
DEFINE YOUR COVER PAGE HERE
\end{titlepage}
\newpage
\tableofcontents
\newpage
#+end_export
YOUR CONTENT IN ORG STARTS HERE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.