7

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
    Just locally bind org-latex-title-command to include \titleGP which should be loaded in the preamble. – rasmus Jan 11 '15 at 18:45
7

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.

  • 1
    Another question, the lines looks so ugly, any way to fold them? – kuanyui Jan 17 '15 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 '15 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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