From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Controlling pagination on headings in Latex/PDF export? Date: Thu, 16 Feb 2012 16:02:40 -0500 Message-ID: <24985.1329426160@alphaville> References: <44B0EAE8544C834188E8790873CDE1CC3E11EA@ARCEXCHANGE.arc.local> <16733.1329416454@alphaville> <44B0EAE8544C834188E8790873CDE1CC3E154C@ARCEXCHANGE.arc.local> <80obsyr2b7.fsf@somewhere.org> <44B0EAE8544C834188E8790873CDE1CC3E15DA@ARCEXCHANGE.arc.local> <44B0EAE8544C834188E8790873CDE1CC3E15F0@ARCEXCHANGE.arc.local> <807gzmr0f6.fsf@somewhere.org> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry8Tf-0005Th-0i for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 16:03:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ry8TV-0005fV-5O for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 16:02:54 -0500 Received: from g1t0029.austin.hp.com ([15.216.28.36]:5688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry8TU-0005eF-Km for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 16:02:44 -0500 In-Reply-To: Message from "Sebastien Vauban" of "Thu\, 16 Feb 2012 21\:25\:01 +0100." <807gzmr0f6.fsf@somewhere.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sebastien Vauban Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org Sebastien Vauban wrote: > Jos'h, >=20 > Jos'h Fuller wrote: > > OK, I'm an idiot. I forgot to put in the ":" after the "#+latex", so it > > didn't get processed correctly. >=20 > That happens to everybody... No need to be an idiot=C2=A0;-) >=20 > > However, once I did put it in, it does work to keep the headings togeth= er with > > the table data. However... it also seems to embed the spurious word > > "afterheading" (in italics) after most (but not all) of the top level h= eadings > > in the file. > > > > So, it totally works to keep the headings and tables together, but the > > /afterheading/ thing is very strange. > > > > I've probably still done something wrong. Any ideas? >=20 > Strange. Maybe, you could send here an ECM (Minimal Complete Example) that > shows the bug without the \mykeepwithnextpar and shows the afterheading > problem with it... >=20 > So that one can try to reproduce your problem without loosing too much ti= me, > in order to help you better and quicker. >=20 > BTW, you should put \mykeepwithnextpar after the heading "DEPARTMENT A", = not > before (as I wrote)... >=20 > >> > I have written such a thing, years ago, first for LaTeX, now for Org: > >> > > >> > --8<---------------cut here---------------start------------->8--- > >> > % how not to have a page break with what is following? > >> > \def\mykeepwithnextpar{\par\nobreak\@afterheading} > >> > --8<---------------cut here---------------end--------------->8--- > >> > > >> > and I put whereever it's needed > >> > > >> > --8<---------------cut here---------------start------------->8--- > >> > ** Asset > >> > #+latex: \mykeepwithnextpar{} > >> > *** DEPARTMENT A > >> > | Table | Data | Here. | > >> > | Table | Data | Here. | > >> > | Table | Data | Here. | > >> > *** DEPARTMENT B > >> > --8<---------------cut here---------------end--------------->8--- >=20 @ is a character that is reserved for .sty files: it's basically used as a mechanism to manufacture private names that are not going to conflict with other names. If you want to use @ in a macro in your .tex file, then you have to do something like this: #+LaTeX_HEADER: \makeatletter #+LaTeX_HEADER: \def\mykeepwithnextpar{\par\nobreak\@afterheading} #+LaTeX_HEADER: \makeatother However the best thing is to put the definition in a .sty file: --8<---------------keeper.sty---------------start------------->8--- \def\mykeepwithnextpar{\par\nobreak\@afterheading} --8<---------------keeper.sty---------------end--------------->8--- and then use --8<---------------cut here---------------start------------->8--- #+LaTeX_HEADER: \usepackage{keeper} --8<---------------cut here---------------end--------------->8--- in your .org file. However, I find it exceedingly difficult to manufacture an example that will produce the bad break that the OP reports: LaTeX seems very reluctant to break after the headline. E.g. in the appended file, I can vary the number of foo lines from 0 to enough to fill the page and I cannot split the DEPARTMENT headline from the table. I also tried various lengths for the table (not very systematically, I must admit) and I still cannot get the default settings to misbehave. This leads me to believe that there are those "other" factors that affect badness: LaTeX thinks that there is something so severely out of whack in the "other" factors that it is willing to make the supreme sacrifice of splitting the headline from the table. So if the OP can provide a misbehaving example, that could help clarify things. Nick PS. Note that the call to \mykeewithnextpar is disabled in the file below. If I enable it, I actually get a foo line at the top of the second page before the DEPARTMENT headline, so it certainly affects the output, but not in a good way. --8<---------------cut here---------------start------------->8--- #+LaTeX_HEADER: \usepackage{keeper} * Period 2012-02-06 to 2012-02-12 ** Asset foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo foo foo foo foo foo foo foo foo foo foo foo foo foo foofoo foo foo foo foo = foo ##+LATEX: \mykeepwithnextpar{} *** DEPARTMENT | Data | Data | Data | Data | |-------------+------+------+------| | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | | XXXXXX | 1 | 1 | 0 | | YYYYYY | 5 | 4 | 0 | --8<---------------cut here---------------end--------------->8---