On 04/09/2025 20:26, Eric S Fraga wrote:
Response below/inline for email Max Nikulin wrote:
(original email sent  4 Sep 2025 at 19:35)

I can not find that thread, but almost certainly something similar has
been discussed earlier. What you observed may be related to penalty
that LaTeX adds after \section and similar commands to prevent page
breaks between headings and their text bodies. So just sectioning
commands without any text in between leads to trouble.

Yes, that's definitely the case.  For something like the test document,
lists and sub-lists would probably be the better way to go, depending on
the eventual desired content of each list entry.  And org mode is very
good at handling lists within lists...

Perhaps Org still should gracefully handle a case of early draft of long document with outline and nothing more. I consider the attached diff as a dirty hack. Unfortunately I can not figure out if it has undesired consequences and if there is a better way to suppress penalties added by sections. Just \break instead of \leavevmode causes excessive page breaks.

If nested lists are acceptable then the following may be a workaround for specific documents:

    #+options: H:0
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 6442ff20b..dbdbc0f01 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2428,7 +2428,7 @@ (defun org-latex-headline (headline contents info)
 	      ;; Maybe end local TOC (see `org-latex-keyword').
 	      (contents
 	       (concat
-		contents
+		(or contents "\\leavevmode")
 		(let ((case-fold-search t)
 		      (section
 		       (let ((first (car (org-element-contents headline))))

Reply via email to