LaTeX export: Remove unnecessary newlines

Patches by Nicolas Girard.
This commit is contained in:
Carsten Dominik 2009-12-10 09:10:43 +01:00
parent 9f4d3e8016
commit e5942e12d6
2 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2009-12-10 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-as-latex): Cleanup forced line ends
where they are not needed.
(org-export-latex-subcontent): Remove unnecessary newlines.
2009-12-09 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-make-header): Remove \obeylines.

View File

@ -673,6 +673,13 @@ when PUB-DIR is set, use this as the publishing directory."
(and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
(replace-match "\\tableofcontents" t t)))
;; Cleanup forced line ends in itmes where they are not needed
(goto-char (point-min))
(while (re-search-forward
"^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)?\n\\\\begin"
nil t)
(delete-region (match-beginning 1) (match-end 1)))
(run-hooks 'org-export-latex-final-hook)
(or to-buffer (save-buffer))
(goto-char (point-min))
@ -855,7 +862,9 @@ If NUM, export sections as numerical sections."
label-list "\n") "\n"))
(insert (org-export-latex-content content))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent) (org-export-latex-sub subcontent)))
((listp subcontent)
(while (org-looking-back "\n\n") (backward-delete-char 1))
(org-export-latex-sub subcontent)))
(if end (insert end "\n"))))
;; At a level under the hl option: we can drop this subsection
((> level org-export-latex-sectioning-depth)
@ -864,7 +873,7 @@ If NUM, export sections as numerical sections."
(buffer-substring (point-at-bol 0) (point)))
(delete-region (point-at-bol 0) (point))
(insert "\\begin{description}\n"))
(insert (format "\n\\item[%s]%s~\n\n"
(insert (format "\n\\item[%s]%s~\n"
heading
(if label (format "\\label{%s}" label) "")))
(insert (org-export-latex-content content))
@ -877,7 +886,7 @@ If NUM, export sections as numerical sections."
(delete-region (point-at-bol 0) (point))
(insert (format "\\begin{%s}\n"
(symbol-name org-export-latex-low-levels))))
(insert (format "\n\\item %s\\\\\n%s\n"
(insert (format "\n\\item %s\\\\\n%s%%"
heading
(if label (format "\\label{%s}" label) "")))
(insert (org-export-latex-content content))