0

In lieu of typing bare-bones LaTeX code, and for other advantages irrelevant to this question, I am using the memoir class from within Emacs org-mode, with larger fonts for using the output initially on transparencies and such.

#+title: Title
#+author: Author

#+LATEX_HEADER: \documentclass[letterpaper]{memoir}
#+LATEX_HEADER: \usepackage[letterpaper, mag=1200, truedimen,
#+LATEX_HEADER:     width=4.0in, left=2.5in, top=0.8in, bottom=0.8in]{geometry}
#+LATEX_HEADER: \usepackage{tgtermes}

* Preface
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum
...

* Preliminaries
** First section
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
...
** Second section
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat
at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec
...
* First Argument
** Section
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo vitae
lacus tincidunt ultrices. Lorem ipsum dolor sit amet, consectetuer
...
** Section
Fusce mauris. Vestibulum luctus nibh at lectus. Sed bibendum, nulla a
faucibus semper, leo velit ultricies tellus, ac venenatis arcu wisi vel
...

When processed to PDF (C-cC-elo) the .org file above produces

three pages from memoir through org-mode

I already get several nice features with minimal effort:

  • Although using memoir and hence defaulting (as I would like) to a book, I can set just the left margin to be much larger (for notes, etc) than the right margin, on both even and odd pages.
  • What are normally "sections" (* prefix) do get top-level numbering (1, 2, ..).
  • What are normally "subsections" (** prefix) get second-top-level numbering (1.1, 1.2, 2.1, ..).

But I am missing a few details:

  • I would like the top-level numbering to be that of chapters, to be on a new page, and to have a Chapter prefix.
  • There are currently no empty pages. I would like to force the chapters to continue leaving no empty pages, even if the preceding chapter ended on an odd-numbered page.

How can I adjust memoir to work within org-mode?

In the actual set-up the chapters will use org-mode's INCLUDE directive

#+INCLUDE: "chapters/01-prelims.org

but it appears that even though this makes a difference in LaTeX, it is irrelevant when taking the org-mode route.

1 Answer 1

1

You cannot set the document class as a #+LATEX_HEADER:, you must do it with #+LATEX_CLASS:. If you inspect the exported .tex file from your example, you'll find:

\documentclass[11pt]{article}
... the default export packages
\documentclass[letterpaper]{memoir}
... etc.

I'm actually surprised this compiles at all.

However, ox-latex.el does not know the memoir class, you can set this up with something like:

(add-to-list 'org-latex-classes
             '("memoir"
               "\\documentclass{memoir}"
               ("\\chapter{%s}" . "\\chapter*{%s}")
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))

Then you can build a consistently exported document with:

#+title: Title
#+author: Author

#+LATEX_CLASS: memoir
#+LATEX_CLASS_OPTIONS: [letterpaper]
#+LATEX_HEADER: \usepackage[letterpaper, mag=1200, truedimen,
#+LATEX_HEADER:     width=4.0in, left=2.5in, top=0.8in, bottom=0.8in]{geometry}
#+LATEX_HEADER: \usepackage{tgtermes}

* Preface
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum
...

* Preliminaries
** First section
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi.
Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis
...
** Second section
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat
at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec
...
* First Argument
** Section
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo vitae
lacus tincidunt ultrices. Lorem ipsum dolor sit amet, consectetuer
...
** Section
Fusce mauris. Vestibulum luctus nibh at lectus. Sed bibendum, nulla a
faucibus semper, leo velit ultricies tellus, ac venenatis arcu wisi vel
...

As to your specific requirements, I believe memoir fulfills them by default. But, if it you still miss something, now you can set it up to your liking, because the exported .tex makes sense.

2
  • Thanks. Curiously, it makes no difference whether I use * for chapters and ** for sections (etc) or (as in your code) ** for chapters and *** for sections.
    – Sam7919
    Feb 24 at 1:50
  • @Sam Ah, that's a leftover for when I was trying to include \part too. I'll correct it in the answer.
    – gusbrs
    Feb 24 at 2:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .