From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: Are there better ways to export wide LaTeX tables/figures? Date: Thu, 9 Dec 2010 07:16:15 -1000 Message-ID: References: <20101208142507.D67F6C400B0@mx8.webfaction.com> <4D003A01.2030802@limist.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary="===============2043495867==" Return-path: Received: from [140.186.70.92] (port=47873 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQk6R-00036s-W8 for emacs-orgmode@gnu.org; Thu, 09 Dec 2010 12:16:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQk6P-0005ys-Sx for emacs-orgmode@gnu.org; Thu, 09 Dec 2010 12:16:23 -0500 Received: from cpoproxy1-pub.bluehost.com ([69.89.21.11]:33179) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PQk6P-0005y9-Ik for emacs-orgmode@gnu.org; Thu, 09 Dec 2010 12:16:21 -0500 In-Reply-To: <4D003A01.2030802@limist.com> 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: Kai Cc: emacs-orgmode@gnu.org --===============2043495867== Content-Type: multipart/alternative; boundary=Apple-Mail-36-75162945 --Apple-Mail-36-75162945 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Aloha Kai, I've just pushed one solution to the problem of wide tables up to http://orgmode.org/worg/org-tutorials/org-latex-export.php . Here it is for your convenience: The LaTeX exporter is currently able to export tabular and longtable environments. In situations where the width of the table needs to be specified, the tabularx package is a good solution, but this isn't supported by the exporter. You can get the tabularx environment with the proper setup and calling a handy function in the Library of Babel. First, load the tabularx and booktabs packages: =#+LATEX_HEADER: \usepackage{tabularx,booktabs}= Then, give your table a name, e.g., =#+tblname: test-table= and put it somewhere the LaTeX exporter won't see. Finally, create a LaTeX source block something like this: : #+source: tabularx-export : #+begin_src latex :exports results :results latex : \begin{table}[htb!] : \centering : \footnotesize : \caption{A table to test the tabularx environment} : \label{tab:test-table} : <> : \end{table} : #+end_src When you export the file to LaTeX, this code block is expanded in a =#+results:= block and wrapped in =#+BEGIN_LaTeX= ... =#+END_LaTeX=. The booktabs function does most of the work. The X alignment in the example is defined by tabularx to calculate the width of the column automatically and then wrap its contents. This works well in most cases, but you might need to define a column type that sets the contents ragged right, something like this: \newcolumntype{Y}{>{\raggedright\arraybackslash}X} This requires the array package, so you might need a line like this, too: LaTex_HEADER: \usepackage{array} hth, Tom On Dec 8, 2010, at 4:08 PM, Kai wrote: > Hi all, > > After spending a few hours experimenting with orgmode's exporting of > tables to LaTeX, I've got three problems to do with wide tables/ > figures, which I'm hoping have smarter solutions that what I could > find: > > 1) When one has a table of even moderate width it will "run off the > page" by default when exported to LaTeX and then pdf-published, > since by default LaTeX will not automatically fit the column sizes > to the page width, nor wrap text within cells to fit. As far as I > can tell, within orgmode, one has to do manual tweaking in the > +ATTR_LaTeX line of the table like: > > #+ATTR_LaTeX: tabular width=\textwidth align=|p{1.8cm}|p{1.5cm}| > p{1.5cm}|p{1.3cm}| > > ...and set the column widths manually (in the example above, > manually set four column widths). Is there a better way to do this > from within orgmode? > > > > 2) Now after one does all that hand-tweaking and trial and error of > setting the LaTeX table column widths manually, the printed table > may finally fit on the page, BUT still be wider than \textwidth, and > appear off-center (it will be aligned on the left, but extend past > the right margin). I found this technique of centering the over- > wide table/figure using \makebox: > http://texblog.net/latex-archive/layout/centering-figure-table/ > ...which basically involves wrapping the LaTeX table code with > "\noindent\makebox[\textwidth]{%" and a closing curly brace, "}". > But I could not find a way to specify that within orgmode; if I have > something like the following it will not work, the table does not > end up being exported: > > #+LaTeX: \noindent\makebox[\textwidth]{% > > #+CAPTION: A wide table. > #+LABEL: tbl:wide_table > #+ATTR_LaTeX: tabular width=\textwidth align=|p{1.8cm}|p{1.5cm}| > p{1.5cm}|p{1.3cm}|p{2cm}|p{2.25cm}|p{1.7cm}| > | Technology | Stack Efficiency | System Efficiency | Lifetime > [years] | Degradation [microV/h] | Estimated High-volume > manufacturing cost [2007 Euros/kW] | Target Sale Price [2007 Euros/ > kW] | > |------------+------------------+------------------- > +------------------+------------------------ > +---------------------------------------------------------- > +-----------------------------------| > | AFC | 0.43-0.5 | 0.27-0.32 | > 0.5-1.1 | 10-30 > | 325-675 > | 120-230 | > > #+LaTeX: %} > > Is there any way to specify from the orgmode file that the (too > wide) exported LaTeX table should be absolutely centered in the > page, so as to avoid manual fixes per table in the tex file after > exporting? Same question applies to large images that one wants > wider than \textwidth, yet centered within the page - is there a way > to do it cleanly? > > > > 3) Finally, is there a way to specify a smaller text size for tables > consistently? e.g. within the exported LaTex file, one could > manually specify \footnotesize table text like: > > \begin{table}[htb]\footnotesize > > But is there a way to specify that from orgmode, and avoid post- > export manual fixes in the tex file? > > > Thanks in advance, any and all help appreciated! > > K > > _______________________________________________ > 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 --Apple-Mail-36-75162945 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Aloha = Kai,

I've just pushed one solution to the problem of = wide tables up to http:/= /orgmode.org/worg/org-tutorials/org-latex-export.php.  Here it = is for your convenience:

The LaTeX = exporter is currently able to export tabular and = longtable
environments. In situations where the width of the = table needs to be
specified, the tabularx package is a good = solution, but this isn't
supported by the exporter.  You = can get the tabularx environment with
the proper setup and = calling a handy function in the Library of = Babel.

First, load the tabularx and booktabs = packages:

=3D#+LATEX_HEADER: = \usepackage{tabularx,booktabs}=3D

Then, give = your table a name, e.g., =3D#+tblname: test-table=3D and put = it
somewhere the LaTeX exporter won't = see.

Finally, create a LaTeX source block = something like this:

: #+source: = tabularx-export
: #+begin_src latex :exports results :results = latex
:   \begin{table}[htb!]
:   = \centering
:   \footnotesize
:   = \caption{A table to test the tabularx environment}
:   = \label{tab:test-table}
:   = <<booktabs(table=3Dtest-table,align=3D"lX",env=3D"tabularx",width=3D= "\\textwidth")>>  
:   \end{table}
: =  #+end_src

When you export the file to = LaTeX, this code block is expanded in a
=3D#+results:=3D block = and wrapped in =3D#+BEGIN_LaTeX=3D ... =3D#+END_LaTeX=3D.  The = booktabs function does most of the work.

The X = alignment in the example is defined by tabularx to calculate the width = of the column automatically and then wrap its contents. =  This works well in most cases, but you might need to define a = column type that sets the contents ragged right, something like = this:

\newcolumntype{Y}{>{\raggedright\arrayba= ckslash}X}

This requires the array = package, so you might need a line like this, = too:

LaTex_HEADER: = \usepackage{array}

hth,
Tom
<= br>
On Dec 8, 2010, at 4:08 PM, Kai = wrote:

Hi all,

After spending a few hours = experimenting with orgmode's exporting of tables to LaTeX, I've got = three problems to do with wide tables/figures, which I'm hoping have = smarter solutions that what I could find:

1) When one has a table = of even moderate width it will "run off the page" by default when = exported to LaTeX and then pdf-published, since by default LaTeX will = not automatically fit the column sizes to the page width, nor wrap text = within cells to fit.  As far as I can tell, within orgmode, one has = to do manual tweaking in the +ATTR_LaTeX line of the table = like:

#+ATTR_LaTeX: tabular width=3D\textwidth = align=3D|p{1.8cm}|p{1.5cm}|p{1.5cm}|p{1.3cm}|

...and set the = column widths manually (in the example above, manually set four column = widths).  Is there a better way to do this from within = orgmode?



2) Now after one does all that hand-tweaking and = trial and error of setting the LaTeX table column widths manually, the = printed table may finally fit on the page, BUT still be wider than = \textwidth, and appear off-center (it will be aligned on the left, but = extend past the right margin).  I found this technique of centering = the over-wide table/figure using \makebox:
h= ttp://texblog.net/latex-archive/layout/centering-figure-table/
...w= hich basically involves wrapping the LaTeX table code with =  "\noindent\makebox[\textwidth]{%" and a closing curly brace, "}". =  But I could not find a way to specify that within orgmode; if I = have something like the following it will not work, the table does not = end up being exported:

#+LaTeX: = \noindent\makebox[\textwidth]{%

#+CAPTION: A wide = table.
#+LABEL: tbl:wide_table
#+ATTR_LaTeX: tabular = width=3D\textwidth = align=3D|p{1.8cm}|p{1.5cm}|p{1.5cm}|p{1.3cm}|p{2cm}|p{2.25cm}|p{1.7cm}|| Technology | Stack Efficiency | System Efficiency | Lifetime [years] = | Degradation [microV/h] | Estimated High-volume manufacturing cost = [2007 Euros/kW] | Target Sale Price [2007 Euros/kW] = |
|------------+------------------+-------------------+----------------= --+------------------------+----------------------------------------------= ------------+-----------------------------------|
| AFC =        | =         0.43-0.5 | =         0.27-0.32 | =          0.5-1.1 | =             &n= bsp;    10-30 | =             &n= bsp;           &nbs= p;            =             32= 5-675 | =             &n= bsp;           &nbs= p; 120-230 |

#+LaTeX: %}

Is there any way to specify = from the orgmode file that the (too wide) exported LaTeX table should be = absolutely centered in the page, so as to avoid manual fixes per table = in the tex file after exporting?  Same question applies to large = images that one wants wider than \textwidth, yet centered within the = page - is there a way to do it cleanly?



3) Finally, is = there a way to specify a smaller text size for tables consistently? =  e.g. within the exported LaTex file, one could manually specify = \footnotesize table text = like:

\begin{table}[htb]\footnotesize

But is there a way = to specify that from orgmode, and avoid post-export manual fixes in the = tex file?


Thanks in advance, any and all help = appreciated!

K

_____________________________________________= __
Emacs-orgmode mailing list
Please use `Reply All' to send = replies to the = list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/em= acs-orgmode

= --Apple-Mail-36-75162945-- --===============2043495867== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============2043495867==--