From mboxrd@z Thu Jan 1 00:00:00 1970 From: Myles English Subject: Re: [PATCH] org-e-latex: Tables get correct amount of vertical space Date: Tue, 13 Nov 2012 21:31:31 +0000 Message-ID: <877gppqjf0.fsf@gmail.com> References: <87d2zhr2ym.fsf@gmail.com>, <80a9ulsgdv.fsf@somewhere.org>, <87a9ulr19m.fsf@gmail.com>, <11825.1352822198@alphaville>, <801ufxscmi.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYO4y-0000wj-Hf for emacs-orgmode@gnu.org; Tue, 13 Nov 2012 16:31:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYO4v-0006WA-FR for emacs-orgmode@gnu.org; Tue, 13 Nov 2012 16:31:32 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:59808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYO4v-0006VW-5i for emacs-orgmode@gnu.org; Tue, 13 Nov 2012 16:31:29 -0500 Received: by mail-we0-f169.google.com with SMTP id u3so4138881wey.0 for ; Tue, 13 Nov 2012 13:31:28 -0800 (PST) In-reply-to: <801ufxscmi.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 , Nick Dokos Cc: emacs-orgmode@gnu.org Sebastien Vauban writes: > Hi Myles and Nick, > > Nick Dokos wrote: >> Myles English wrote: >>> Sebastien Vauban writes: >>> > Myles English wrote: >>> >> This patch replaces every occurence of the \begin{center} environment >>> >> with \centering in the file contrib/lisp/org-e-latex.el. >>> >> ... >>> >> - (format "\\begin{center}\n%s\\end{center}" contents))) >>> >> + (format "\\centering\n%s" contents))) >>> > >>> > Wouldn't you have to replace >>> > >>> > \begin{center} >>> > ... >>> > \end{center} >>> > >>> > by >>> > >>> > {\centering >>> > ... >>> > } >>> > >>> > ? That is, add a group around? >>> >>> I don't think so, at least I have not come across that usage, and it >>> seems to work without. Do you know different? >> >> If a \centering occurs at top-level in a latex document, >> then *everything* after it will be centered: it's a declaration that >> remains in force for the current group (which is the rest of the >> document if it occurs at top-level). > > As confirmed by Nick, \centering just changes the layout for ever... up to the > end of the document. > > Why does it work? I guess because there are grouping commands inserted by Org > at other places, that stop the propagation of the centering that far... But > it's dangerous to count on them, IMHO. > >> \begin{center}...\end{center} is essentially {\centering ...} except >> that it also starts a new paragraph. >From within a figure or table environment, that new paragraph shows up as uneeded vertical space, see the example I give lower down. >> >> >> It's not clear to me at least, that wholesale replacement is the correct >> thing to do: it needs to be looked at on a case-by-case basis I >> think. Nick, I think you are right about this, the modified patch at the end of this email makes only the replacements that are necessary just to replace the center environment within table blocks. The other \begin{center}'s in the org-e-latex.el file may be changed some other time, if needed. > I think that's a safe replacement (_with_ the grouping), and with something I > forgot about (well seen Nick!): the \par. I don't think the grouping is necessary because the implied group will be closed when the table environment is ended. Likewise, I don't think the \par is necessary. If you compile this this latex it illustrates the problem, and the solution: %______________________________begin example.tex_______________ \documentclass[11pt]{article} \usepackage{float} \begin{document} Before.------------------------------- \begin{table}[htb] \caption{\label{tab:progress}Summary} \begin{center} \begin{tabular}{ll} A & B\\ \end{tabular} \end{center} \end{table} After.-------------------------------- Before.------------------------------- \begin{table}[htb] \caption{\label{tab:progress}Summary} \centering \begin{tabular}{ll} A & B\\ \end{tabular} \end{table} After.------------------------------- \end{document} %______________________________end example.tex_______________ > See, for example, > https://groups.google.com/forum/?fromgroups=#!topic/fr.comp.text.tex/0s4WfsIfmy8 > for the answer of Manuel Pégourié-Gonnard, one reference wrt LaTeX > questions: My French, and my browser apparently, is not good enough to understand that thread. Sorry. Please translate if it is still relevant to this discussion. > > "replace the environment by {\centering ... \par}" [answered above] > > Best regards, > Seb Myles >From 51686ada4cb2560eb5dfb6b445af547eccff8bff Mon Sep 17 00:00:00 2001 From: Myles English Date: Tue, 13 Nov 2012 21:04:16 +0000 Subject: [PATCH] org-e-latex: Tables get correct amount of vertical space * contrib/lisp/org-e-latex.el: Replaced a set of \begin{center} and \end{center} environment markers with a \centering declaration. Using both \begin{table} and \being{center} environments leads to double the vertical space around the float, whereas \centering adds none. TINYCHANGE --- contrib/lisp/org-e-latex.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/lisp/org-e-latex.el b/contrib/lisp/org-e-latex.el index 165beb3..5635c6a 100644 --- a/contrib/lisp/org-e-latex.el +++ b/contrib/lisp/org-e-latex.el @@ -2302,14 +2302,13 @@ This function assumes TABLE has `org' as its `:type' attribute." (concat (format "\\begin{%s}%s\n" float-env placement) (if org-e-latex-table-caption-above caption ""))) - (when org-e-latex-tables-centered "\\begin{center}\n") + (when org-e-latex-tables-centered "\\centering\n") (format "\\begin{%s}%s{%s}\n%s\\end{%s}" table-env (if width (format "{%s}" width) "") alignment contents table-env) - (when org-e-latex-tables-centered "\n\\end{center}") (when float-env (concat (if org-e-latex-table-caption-above "" caption) (format "\n\\end{%s}" float-env)))))))) -- 1.8.0