Преглед на файлове

Allow sections to be represented as environments in LaTeX export.

Carsten Dominik преди 16 години
родител
ревизия
0cfc76df3f
променени са 2 файла, в които са добавени 42 реда и са изтрити 28 реда
  1. 4 4
      doc/org.texi
  2. 38 24
      lisp/org-export-latex.el

+ 4 - 4
doc/org.texi

@@ -7786,10 +7786,10 @@ All lines between these markers are exported literally
 By default, the La@TeX{} output uses the class @code{article}.
 By default, the La@TeX{} output uses the class @code{article}.
 
 
 You can change this globally by setting a different value for
 You can change this globally by setting a different value for
-@code{org-export-latex-default-class} or locally by adding an option
-like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
-listed in @code{org-export-latex-classes}, where you can also define the
-sectioning structure for each class.
+@code{org-export-latex-default-class} or locally by adding an option like
+@code{#+LaTeX_CLASS: myclass} in your file.  The class should be listed in
+@code{org-export-latex-classes}, where you can also define the sectioning
+structure for each class, as well as defining additonal classes.
 
 
 
 
 @node XOXO export, iCalendar export, LaTeX export, Exporting
 @node XOXO export, iCalendar export, LaTeX export, Exporting

+ 38 - 24
lisp/org-export-latex.el

@@ -120,30 +120,38 @@ associated information.  Here is the structure of each cell:
 
 
   \(class-name
   \(class-name
     header-string
     header-string
-    (unnumbered-section numbered-section\)
+    (numbered-section . unnumbered-section\)
     ...\)
     ...\)
 
 
 A %s formatter is mandatory in each section string and will be
 A %s formatter is mandatory in each section string and will be
-replaced by the title of the section."
+replaced by the title of the section.
+
+Instead of a cons cell (numbered . unnumbered), you can also provide a list
+of 2-4 elements,
+
+  (numbered-open numbered-close)
+
+or
+
+  (numbered-open numbered-close unnumbered-open unnumbered-close)
+
+providing opening and closing strings for an environment that should
+represent the document section.  The opening clause should have a %s
+to represent the section title."
   :group 'org-export-latex
   :group 'org-export-latex
-  :type '(repeat
+  :type '(repeat 
 	  (list (string :tag "LaTeX class")
 	  (list (string :tag "LaTeX class")
 		(string :tag "LaTeX header")
 		(string :tag "LaTeX header")
-		(cons :tag "Level 1"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 2"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 3"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 4"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered"))
-		(cons :tag "Level 5"
-		      (string :tag "Numbered")
-		      (string :tag "Unnumbered")))))
+		(repeat :tag "Levels" :inline t
+			(choice
+			 (cons :tag "Heading"
+			       (string :tag "numbered")
+			       (string :tag "unnumbered)"))
+			 (list :tag "Environment"
+			       (string :tag "Opening (numbered)  ")
+			       (string :tag "Closing (numbered)  ")
+			       (string :tag "Opening (unnumbered)")
+			       (string :tag "Closing (unnumbered)")))))))
 
 
 (defcustom org-export-latex-emphasis-alist
 (defcustom org-export-latex-emphasis-alist
   '(("*" "\\textbf{%s}" nil)
   '(("*" "\\textbf{%s}" nil)
@@ -554,12 +562,18 @@ If NUM, export sections as numerical sections."
     (cond
     (cond
      ;; Normal conversion
      ;; Normal conversion
      ((<= level org-export-latex-sectioning-depth)
      ((<= level org-export-latex-sectioning-depth)
-      (let ((sec (nth (1- level) org-export-latex-sectioning)))
-	(insert (format (if num (car sec) (cdr sec)) heading) "\n"))
-      (when label (insert (format "\\label{%s}\n" label)))
-      (insert (org-export-latex-content content))
-      (cond ((stringp subcontent) (insert subcontent))
-	    ((listp subcontent) (org-export-latex-sub subcontent))))
+      (let* ((sec (nth (1- level) org-export-latex-sectioning))
+	     start end)
+	(if (consp (cdr sec))
+	    (setq start (nth (if num 0 2) sec)
+		  end (nth (if num 1 3) sec))
+	  (setq start (if num (car sec) (cdr sec))))
+	(insert (format start heading) "\n")
+	(when label (insert (format "\\label{%s}\n" label)))
+	(insert (org-export-latex-content content))
+	(cond ((stringp subcontent) (insert subcontent))
+	      ((listp subcontent) (org-export-latex-sub subcontent)))
+	(if end (insert end "\n"))))
      ;; At a level under the hl option: we can drop this subsection
      ;; At a level under the hl option: we can drop this subsection
      ((> level org-export-latex-sectioning-depth)
      ((> level org-export-latex-sectioning-depth)
       (cond ((eq org-export-latex-low-levels 'description)
       (cond ((eq org-export-latex-low-levels 'description)