Browse Source

Fix problems with internal links for LateX export.

Carsten Dominik 16 years ago
parent
commit
5b6a8a55e8
3 changed files with 30 additions and 22 deletions
  1. 12 0
      lisp/ChangeLog
  2. 0 13
      lisp/org-exp.el
  3. 18 9
      lisp/org-export-latex.el

+ 12 - 0
lisp/ChangeLog

@@ -1,3 +1,15 @@
+2008-10-10  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org-export-latex.el (org-export-latex-subcontent): Add labels to
+	sections, to make internal links work.
+	(org-export-latex-fontify-headline): Do not remove all text
+	properties, to make sure that target properties survive this
+	process.
+
+	* org-exp.el (org-export-preprocess-string): Change sequence of
+	modifications, to make sure links are prepared before the LaTeX
+	conversions do happen.
+
 2008-10-09  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-attach.el (org-attach-delete-all): Renamed from

+ 0 - 13
lisp/org-exp.el

@@ -1457,10 +1457,6 @@ on this string to produce the exported version."
       (org-export-remove-comment-blocks-and-subtrees)
 
 
-
-
-
-
       ;; Find matches for radio targets and turn them into internal links
       (org-export-mark-radio-links)
 
@@ -1481,15 +1477,6 @@ on this string to produce the exported version."
 	(org-export-concatenate-multiline-emphasis))
 
 
-
-
-
-
-
-
-
-
-
       ;; Remove special table lines
       (when org-export-table-remove-special-lines
 	(org-export-remove-special-table-lines))

+ 18 - 9
lisp/org-export-latex.el

@@ -543,31 +543,36 @@ and its content."
 (defun org-export-latex-subcontent (subcontent num)
   "Export each cell of SUBCONTENT to LaTeX.
 If NUM, export sections as numerical sections."
-  (let ((heading (org-export-latex-fontify-headline
-		  (cdr (assoc 'heading subcontent))))
-	(level (- (cdr (assoc 'level subcontent))
-		  org-export-latex-add-level))
-	(occur (number-to-string (cdr (assoc 'occur subcontent))))
-	(content (cdr (assoc 'content subcontent)))
-	(subcontent (cadr (assoc 'subcontent subcontent))))
+  (let* ((heading (org-export-latex-fontify-headline
+		   (cdr (assoc 'heading subcontent))))
+	 (level (- (cdr (assoc 'level subcontent))
+		   org-export-latex-add-level))
+	 (occur (number-to-string (cdr (assoc 'occur subcontent))))
+	 (content (cdr (assoc 'content subcontent)))
+	 (subcontent (cadr (assoc 'subcontent subcontent)))
+	 (label (org-get-text-property-any 0 'target heading)))
     (cond
      ;; Normal conversion
      ((<= 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))))
      ;; At a level under the hl option: we can drop this subsection
      ((> level org-export-latex-sectioning-depth)
       (cond ((eq org-export-latex-low-levels 'description)
-	     (insert (format "\\begin{description}\n\n\\item[%s]\n\n" heading))
+	     (insert (format "\\begin{description}\n\n\\item[%s]%s\n\n"
+			     heading
+			     (if label (format "\\label{%s}" label) "")))
 	     (insert (org-export-latex-content content))
 	     (cond ((stringp subcontent) (insert subcontent))
 		   ((listp subcontent) (org-export-latex-sub subcontent)))
 	     (insert "\\end{description}\n"))
 	    ((stringp org-export-latex-low-levels)
 	     (insert (format org-export-latex-low-levels 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)))))))))
@@ -767,7 +772,8 @@ links, keywords, lists, tables, fixed-width"
     (org-export-latex-special-chars
      (plist-get org-export-latex-options-plist :sub-superscript))
     (org-export-latex-links)
-    (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+;    (org-trim (buffer-substring-no-properties (point-min) (point-max)))))
+    (org-trim (buffer-string))))
 
 (defun org-export-latex-quotation-marks ()
   "Export quotation marks depending on language conventions."
@@ -1071,6 +1077,9 @@ If TIMESTAMPS, convert timestamps, otherwise delete them."
 			      (expand-file-name raw-path))))
 	     (radiop (insert (format "\\hyperref[%s]{%s}"
 				     (org-solidify-link-text raw-path) desc)))
+	     ((not type)
+	      (insert (format "\\hyperref[%s]{%s}"
+			      (org-solidify-link-text raw-path) desc)))
 	     (path (insert (format "\\href{%s}{%s}" path desc)))
 	     (t (insert "\\texttt{" desc "}")))))))