34

By default Org-mode exports to numbered LaTeX headings. For example, the following

#+title: Test

* Introduction
* Heading
* Heading
* References

exports to

\section{Introduction}
\label{sec-1}
\section{Heading}
\label{sec-2}
\section{Heading}
\label{sec-3}
\section{References}
\label{sec-4}

It is possible to disable numbering for all LaTeX headings by adding #+options: num:nil as in

#+title: Test
#+options: num:nil

* Introduction
* Heading
* Heading
* References

which exports to

\section*{Introduction}
\label{sec-1}
\section*{Heading}
\label{sec-2}
\section*{Heading}
\label{sec-3}
\section*{References}
\label{sec-4}

Note that \section* is a LaTeX macro for unnumbered section.

Is it possible to tell Org-mode to not number particular headings, i.e. via editing the properties of headings? For example, is it possible to get the following LaTeX exported from Org-mode:

\section*{Introduction}
\label{sec-1}
\section{Heading}
\label{sec-2}
\section{Heading}
\label{sec-3}
\section*{References}
\label{sec-4}

I am running Org-mode 7.6 in Emacs 23.3.1.

8
  • 2
    It is a common misperception that all and everything you can do with LaTeX should be possible by using Org-mode and exporting to LaTeX. No! Write your document in LaTeX and link into it from your Org-mode file.
    – Keks Dose
    May 2, 2012 at 11:45
  • 11
    @KeksDose I do not expect to do everything in Org-mode that I can do with LaTeX. I do however expect to do some basic and useful things in Org-mode that are also possible with LaTeX. This issue is one of them and it is something that can be handy also when exporting from Org-mode to other formats such as html. Also, I do not think it is effective to write directly in LaTeX. I prefer to draft in Org-mode.
    – N.N.
    May 2, 2012 at 11:52
  • 1
    There are gazillions of things which are considered as basic and usefull, depends on whom you ask. Go and draft your document in Org-mode, I admit to do so as well, but in LaTeX you will have to give some finishing touches to the *.tex-file. I'm impressed about the features of Org-mode as well, it even can calculate (have you noticed the radiotables? Incredible!), but what you and many other people ask, seems the direct highway to hell for Org-mode. Besides that: All those features would destroy the clean outline of Org-mode files.
    – Keks Dose
    May 2, 2012 at 12:00
  • 4
    @KeksDose As said, controlling heading numbering for particular headers is useful not only for LaTeX. Also, it would not interfere with the clean outline of Org file because it can be implemented via properties which are already in Org-mode. Org-mode already does something similar with properties to handle beamer export.
    – N.N.
    May 2, 2012 at 12:08
  • I searched through stackoverflow and found some of your questions related to exporting. Would you mind to give a résumé on all your specific solutions you found? Maybe you can share a link here at tex.stackexchange. Probably many people would find that usefull!
    – Keks Dose
    May 2, 2012 at 12:49

3 Answers 3

32

You need org-mode 8.3 to do this.

From ORG-NEWS

* Version 8.3
[...]
** New features
[...]
*** Export unnumbered headlines
Headlines, for which the property ~UNNUMBERED~ is non-nil, are now
exported without section numbers irrespective of their levels.  The
property is inherited by children.

For example

(with-temp-buffer
  (require 'ox-latex)
  (insert "
* numbered
** subnumbered
* unnumbered
:PROPERTIES:
:UNNUMBERED: t
:END:
** also unnumbered
")
  (org-latex-export-as-latex nil nil nil t))

produces

\section{numbered}
\label{sec-1}
\subsection{subnumbered}
\label{sec-1-1}
\section*{unnumbered}
\label{unnumbered-1}
\subsection*{also unnumbered}
\label{unnumbered-2}

Edit: Since I wrote this the naming scheme of labels changed, so labels would look different these days.

Edit2: One can set headline properties easily with C-c C-x p.

13

Note: This answer is now outdated; see here.


Selective numbering is not supported at the moment (even in Org-mode master). However you can choose to not number headings beyond a certain depth by specifying something like this:

#+OPTIONS: H:3 num:2

* Introduction

* Heading
** Something 1
*** Something 2

* Heading
** Something 1
*** Something 2

* References

The above will export up to 3 levels of headlines but will number only up to level 2.

\section{Introduction}
\label{sec-1}

\section{Heading}
\label{sec-2}
\subsection{Something 1}
\label{sec-2-1}
\subsubsection*{Something 2}
\label{sec-2-1-1}

\section{Heading}
\label{sec-3}
\subsection{Something 1}
\label{sec-3-1}
\subsubsection*{Something 2}
\label{sec-3-1-1}
\section{References}
\label{sec-4}

PS: I don't see how this is more appropriate in tex rather than stackoverflow.

2
  • 1
    Indeed, this is not exactly what I want. I want to be able to have numbered and unnumbered headings of the same level. Strange way of supporting numbering depth. A more elegant solution for Org-mode would be to add \setcounter{secnumdepth}{2} to the preamble when #+OPTIONS: H:3 num:2 rather than adding \section*s. I have flagged for migration back to SO. Do not understand why it got migrated here in the first place.
    – N.N.
    Apr 19, 2012 at 19:03
  • @N.N. I think it's done this way because Org-mode tries to be export backend agnostic. So every time you enter a latex snippet, the disparity between exported files with different backends increase. That said, I believe it could be more configurable after the new export engine is in place.
    – suvayu
    Apr 20, 2012 at 11:21
6

I think there is still not an option in org-mode. One work around I used recently to use ignoreheading for required node and give latex command explicitly for unnumbered section.

* Abstract                                                   :ignoreheading:
\section*{Abstract}
blah 

ofcourse you should have a filter defined in your init.el for ignoreheading to work.

;;; Nicolas Goaziou, http://article.gmane.org/gmane.emacs.orgmode/67692
(defun org-latex-ignore-heading-filter-headline (headline backend info)
  "Strip headline from HEADLINE. Ignore BACKEND and INFO."
  (when (and (org-export-derived-backend-p backend 'latex)
             (string-match "\\`.*ignoreheading.*\n" headline))
    (replace-match "" nil nil headline)))
(add-to-list 'org-export-filter-headline-functions
             'org-latex-ignore-heading-filter-headline)
0

You must log in to answer this question.

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