# Org-mode problem exporting to LaTeX

I'm getting weird results on exporting Org files to LaTeX. The following Org code produces blank pages and the resulting PDF terminates before the fifth heading and subheadings are printed:

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line

* First Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line
** Second Line


I see nothing unusual in the generated LaTeX code. Any assistance greatly appreciated. Will be glad to post further info, but not sure what else I should post.

This is actually a LaTeX problem. But maybe it only occurs in the context of Orgmode.

LaTeX does not like to break a line after a heading. So the whole text appears on one page and most of it is cut off.

You can avoid the problem by inserting some invisible paragraph in each section.

The following LATEX_HEADER setting in your Org file would do that:

#+LATEX_HEADER:\let\oldsection\section\def\section{\mypagebreak\oldsection}\def\mypagebreak{\def\mypagebreak{\par\mbox{}\par\mbox{}}}


Maybe an even better method is to reduce the penalty for breaking pages after headings to zero:

#+LATEX_HEADER:\let\oldsection\section\def\section{\mypagebreak\oldsection}\makeatletter\def\mypagebreak{\@secpenalty0}\makeatother

• Tobias: thank you. I will try your suggestions and post with the results. – msakkas Jan 29 '19 at 19:05