emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Org equivalent to \chapter*


From: Rasmus
Subject: Re: [O] Org equivalent to \chapter*
Date: Wed, 06 Aug 2014 11:18:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Alan L Tyree <address@hidden> writes:

> I'm sure this has been asked before, but I can't seem to find it. Is
> there an org markup that produces a starred latex heading?
>
> In a book, for example, I want the Preface to be at chapter level, but
> not included in the numbering. Same for HTML export, of course.

You would probably need some sort of filter for this.  Most certainly
you will be able to find implementations on this list.

Here's something from my init file that works with LaTeX.  Other
formats such as txt and html are harder since Org generates section
numbers and the TOC.

The filter will translate this file

     #+OPTIONS: tags:nil
     * preface                                                        :nonum:
       my preface
     * introduction
       this is numbered. 

To something like this:

    \section*{preface}
    \label{sec-1}
    my preface
    \section{introduction}
    \label{sec-2}
    this is numbered. 

If your other filters require #+OPTIONS: tags:t then you will have to
manually clean up the tag remedies.  I will not work on verbatim-only
headlines.

  (defun rasmus/get-org-headline-string-element  (headline backend info)
    "Return the org element representation of an element.  Does not
    work with verbatim only headlines, e.g. \"* ~Verb~.\""
    (let ((prop-point (next-property-change 0 headline)))
      (if prop-point (plist-get (text-properties-at prop-point headline) 
:parent))))


  (defun rasmus/org-export-nonum (headline backend info)
    "Remove the number from LaTeX headlines with the tag \"nonum\""
    (when (org-export-derived-backend-p backend 'latex 'ascii)
      (let* ((e (rasmus/get-org-headline-string-element headline backend info))
             (tags (org-element-property :tags e))
             (level (org-element-property :level e))
             (class (assoc (plist-get info :latex-class) org-latex-classes)))
        (when  (and level (member-ignore-case "nonum" tags))
          (string-match
           (format "\\(\\%s\\)" (replace-regexp-in-string "{.*?}" "" (car (nth 
(1+ level) class))))
           headline)
          (replace-match (replace-regexp-in-string "{.*?}" "" (concat "\\" (cdr 
(nth (1+  level) class)))) nil nil headline 0)))))

  (add-to-list 'org-export-filter-headline-functions 'rasmus/org-export-nonum)


-- 
Governments should be afraid of their people




reply via email to

[Prev in Thread] Current Thread [Next in Thread]