From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: latex export and booktabs tables Date: Tue, 29 Jun 2010 10:10:18 -0700 Message-ID: <87vd91aexy.fsf@gmail.com> References: <87tyouyx6b.fsf@mundaneum.com> <878w5zd9po.fsf@gmail.com> <457FCE1D-740F-4AA3-9913-E6D5117029E1@tsdye.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=37675 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTfFd-0004gV-8h for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTfFb-0001oO-85 for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:09:41 -0400 Received: from mail-px0-f169.google.com ([209.85.212.169]:63215) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTfFa-0001oG-Uw for emacs-orgmode@gnu.org; Tue, 29 Jun 2010 14:09:39 -0400 Received: by pxi17 with SMTP id 17so9372627pxi.0 for ; Tue, 29 Jun 2010 11:09:38 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: emacs-orgmode@gnu.org Hi Tom, How about the following proposed library of babel function which constructs a booktabs environment using a toprule, (conditionally) a midrule, and a bottomrule. --8<---------------cut here---------------start------------->8--- *** booktabs This block can be used to wrap a table in the latex =3Dbooktabs=3D environment, it takes the following arguments -- all but the first two are optional. | arg | description | |-------+--------------------------------------------| | table | a reference to the table | | align | optional alignment string | | env | optional environment, default to "tabular" | | width | optional width specification string | #+srcname: booktabs #+begin_src emacs-lisp :var table=3D'((:head) hline (:body)) :var align=3D'= () :var env=3D"tabular" :var width=3D'() :noweb yes :results latex (flet ((to-tab (tab) (orgtbl-to-generic (mapcar (lambda (lis) (if (listp lis) (mapcar (lambda (el) (if (stringp el) el (format "%S" el))) lis) lis)) tab) (list :lend " \\\\" :sep " & " :hline "\\hline")))) (org-fill-template " \\begin{%env}%width%align \\toprule %table \\bottomrule \\end{%env}\n" (list (cons "env" (or env "table")) (cons "width" (if width (format "{%s}" width) "")) (cons "align" (if align (format "{%s}" align) "")) (cons "table" ;; only use \midrule if it looks like there are column headers (if (equal 'hline (second table)) (concat (to-tab (list (first table))) "\n\\midrule\n" (to-tab (cddr table))) (to-tab table)))))) #+end_src --8<---------------cut here---------------end--------------->8--- once loaded it can be applied as here --8<---------------cut here---------------start------------->8--- ** booktabs #+tblname: months | num | Abbrev. | |-----+---------| | 1 | Jan. | | 2 | Feb. | | 3 | Mar. | #+call: booktabs(table=3Dmonths, align=3D"r|l") :results latex :exports res= ults --8<---------------cut here---------------end--------------->8--- Also, note that the longtable function currently in the library-of-babel does allow for replacing the global default hline value. I'm sure the above isn't perfect, however hopefully it is close enough that you could recommend how to get the rest of the way there. Thanks -- Eric "Thomas S. Dye" writes: > Hi Eric, > > This is neat, but it doesn't directly address the problem posed by the > OP. > > Currently, the LaTeX exporter uses \hline for all the horizontal rules > in a table. Booktabs defines three rules of different thickness for > use at the top of the table, after the column heads, and at the bottom > of the table. So, one would want a function that let each of the > rules take a different value. The default for each could be hline, > giving the current behavior of the exporter. Francesco Pizzolante set > this out nicely a while back: > http://www.mail-archive.com/emacs-orgmode@gnu.org/msg18311.html in a > message that Seb Vauban brought up in a slightly different context. > > All the best, > Tom > > On Jun 27, 2010, at 7:09 PM, Eric Schulte wrote: > >> One way to deal with this without adding even more complexity to the >> core of org-mode could be through the use of "Library of Babel" >> functions. >> >> The attached org-mode file provides a function for exporting to the >> longtable environment with some example usage. If this looks >> generally >> useful it (and maybe similar functions) could be added to the >> library of >> babel distributed w/Org-mode. >> >> What do you think? -- Eric >> >> >> S=C3=A9bastien Vauban writes: >> >>> Hi Erik, >>> >>> Erik Butz wrote: >>>> I found a very old thread on the list about using the booktabs >>>> package to >>>> have nicer tables in latex export. >>>> >>>> I found that, making the changes below I can use the booktab >>>> package to >>>> export tables, and using standard tables only, this seems to work >>>> fine. >>>> >>>> Can anyone advice on whether this kind of change is meaningful or >>>> if this is >>>> likely to introduce difficulties elsewhere which I did not >>>> experience due to >>>> the limited scope of usage? It should be said that I did not at >>>> all look >>>> into longtables so far. >>> >>> While trying to improve this, I think one could extend it so that >>> the table >>> environment can be changed as well, from `tabular' to `array', >>> tabular*', >>> `tabularx' or any other. >>> >>> There was a discussion on this, a while ago, by Francesco >>> Pizzolante. Have a >>> read at: >>> http://www.mail-archive.com/emacs-orgmode@gnu.org/msg18311.html >>> . >>> >>> Best regards, >>> Seb >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode