emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* allow table* specification with #+ATTR_LaTeX:
@ 2010-12-15 21:33 Eric Schulte
  2010-12-16  4:27 ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2010-12-15 21:33 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

Hi,

The attached patch allows the use of table* latex tables from within Org
mode documents using the attr_latex lines, for example

#+CAPTION: A wide table
#+LABEL: tbl:wide
#+ATTR_LaTeX: table* align=l|lp{3cm}r|l
| ... | ... |
| ... | ... |

Should this be added, or should we put together a more general solution
for different types of table environments?  Currently only longtable is
supported.  Also, is there already a way to do this that I have missed?

Thanks -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: wide-tables.patch --]
[-- Type: text/x-diff, Size: 2301 bytes --]

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index a261171..b7f48d3 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
              (org-table-last-column-widths (copy-sequence
                                             org-table-last-column-widths))
              fnum fields line lines olines gr colgropen line-fmt align
-             caption shortn label attr floatp placement longtblp)
+             caption shortn label attr floatp placement longtblp tblenv)
         (if org-export-latex-tables-verbatim
             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
                                 "\\end{verbatim}\n")))
@@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                          'org-label raw-table)
                   longtblp (and attr (stringp attr)
                                 (string-match "\\<longtable\\>" attr))
+		  tblenv (if (and attr (stringp attr)
+				  (string-match (regexp-quote "table*") attr))
+			     "table*" "table")
                   align (and attr (stringp attr)
                              (string-match "\\<align=\\([^ \t\n\r]+\\)" attr)
                              (match-string 1 attr))
@@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                        (concat
                         (if longtblp
                             (concat "\\begin{longtable}{" align "}\n")
-                          (if floatp (format "\\begin{table}%s\n" placement)))
+                          (if floatp
+			      (format "\\begin{%s}%s\n" tblenv placement)))
                         (if floatp
                             (format
                              "\\caption%s{%s} %s"
@@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                                               "\n\\end{center}\n" "\n"))
                         (if longtblp
                             "\\end{longtable}"
-                          (if floatp "\\end{table}"))))
+                          (if floatp (format "\\end{%s}" tblenv)))))
                       "\n\n"))))))))
 
 (defun org-export-latex-convert-table.el-table ()

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-15 21:33 allow table* specification with #+ATTR_LaTeX: Eric Schulte
@ 2010-12-16  4:27 ` Thomas S. Dye
  2010-12-16 13:16   ` Eric Schulte
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2010-12-16  4:27 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode

Hi Eric,

It would be great to have a more general solution.  Tables are hard to  
typeset, so it might take a while to come up with a good  
specification.  Here is what I know about the LaTeX side of things.

** LaTeX destinations for an Org-mode table
*** Environments for typesetting a table
     - table placed in the output where it occurs in the input
     - all of these environments can be used on their own
**** tabular
      standard LaTeX environment, doesn't break across pages, no caption
**** tabularx
      extended environment that can automatically calculate column
      widths and wrap text within table cells, doesn't break across
      pages, no caption
**** tabulary
      like tabularx, but tries harder to come up with optimal column  
widths
**** supertabular
      extended tabular environment that breaks across pages, includes
      caption
**** supertabular*
      like supertabular, but for wide tables in a multicolumn page
      layout
**** mpsupertabular
      like supertabular, but also handles footnotes within the table
**** mpsupertabular*
      like mpsupertabular, but for multicolumn page layouts
**** longtable
      extended tabular environment that breaks across pages and
      includes a caption, but can't be used in a multicolumn page
      layout
*** Environment for floating a table and adding a caption
     floats a table typeset by some other environment to a place in the
     output that LaTeX determines appropriate, probably not where it
     occurs in the input
**** =table=, single column document
      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
**** =table*=, multi-column document
      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
*** "Typical" uses
     In our report production work we regularly use seven setups:
     - table or table* wrapped around tabularx or tabular
     - longtable
     - tabular or tabularx on their own

hth,
Tom
On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:

> Hi,
>
> The attached patch allows the use of table* latex tables from within  
> Org
> mode documents using the attr_latex lines, for example
>
> #+CAPTION: A wide table
> #+LABEL: tbl:wide
> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
> | ... | ... |
> | ... | ... |
>
> Should this be added, or should we put together a more general  
> solution
> for different types of table environments?  Currently only longtable  
> is
> supported.  Also, is there already a way to do this that I have  
> missed?
>
> Thanks -- Eric
>
> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
> index a261171..b7f48d3 100644
> --- a/lisp/org-latex.el
> +++ b/lisp/org-latex.el
> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>              (org-table-last-column-widths (copy-sequence
>                                             org-table-last-column- 
> widths))
>              fnum fields line lines olines gr colgropen line-fmt align
> -             caption shortn label attr floatp placement longtblp)
> +             caption shortn label attr floatp placement longtblp  
> tblenv)
>         (if org-export-latex-tables-verbatim
>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>                                 "\\end{verbatim}\n")))
> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                          'org-label raw-table)
>                   longtblp (and attr (stringp attr)
>                                 (string-match "\\<longtable\\>" attr))
> +		  tblenv (if (and attr (stringp attr)
> +				  (string-match (regexp-quote "table*") attr))
> +			     "table*" "table")
>                   align (and attr (stringp attr)
>                              (string-match "\\<align=\\([^ \t\n\r]+\ 
> \)" attr)
>                              (match-string 1 attr))
> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                        (concat
>                         (if longtblp
>                             (concat "\\begin{longtable}{" align "}\n")
> -                          (if floatp (format "\\begin{table}%s\n"  
> placement)))
> +                          (if floatp
> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>                         (if floatp
>                             (format
>                              "\\caption%s{%s} %s"
> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                                               "\n\\end{center}\n"  
> "\n"))
>                         (if longtblp
>                             "\\end{longtable}"
> -                          (if floatp "\\end{table}"))))
> +                          (if floatp (format "\\end{%s}" tblenv)))))
>                       "\n\n"))))))))
>
> (defun org-export-latex-convert-table.el-table ()
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-16  4:27 ` Thomas S. Dye
@ 2010-12-16 13:16   ` Eric Schulte
  2010-12-16 14:43     ` Eric Schulte
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2010-12-16 13:16 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

Hi Tom,

Thanks for the informative list.  I had no idea LaTeX supported so many
table options.  How about I update the patch so that is supports the
following sets of mutually exclusive options...
- longtable :: wraps the table in a longtable with no table or tabular
               wrappers -- already implemented
- table* :: replaces =table= wrapper with =table*= wrapper, contains an
            inner tabular wrapper
- tabular[xy] :: specifies the inner tabular wrapping environment, only
                 one can be specified

so for example, the following

#+begin_src org
  #+CAPTION: A wide table
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
  | ... | ... |
  | ... | ... |
#+end_src

results in the following

#+begin_src latex
  \begin{table*}[htb]
  \caption{A wide table} \label{tbl:wide}
  \begin{center}
  \begin{tabulary}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabulary}
  \end{center}
  \end{table*}
#+end_src

Then the next question would be how to insert a =figure*= instead of a
simple =figure= environment.

Thanks -- Eric

Thomas S. Dye <tsd@tsdye.com> writes:

> Hi Eric,
>
> It would be great to have a more general solution.  Tables are hard to
> typeset, so it might take a while to come up with a good
> specification.  Here is what I know about the LaTeX side of things.
>
> ** LaTeX destinations for an Org-mode table
> *** Environments for typesetting a table
>     - table placed in the output where it occurs in the input
>     - all of these environments can be used on their own
> **** tabular
>      standard LaTeX environment, doesn't break across pages, no caption
> **** tabularx
>      extended environment that can automatically calculate column
>      widths and wrap text within table cells, doesn't break across
>      pages, no caption
> **** tabulary
>      like tabularx, but tries harder to come up with optimal column
> widths
> **** supertabular
>      extended tabular environment that breaks across pages, includes
>      caption
> **** supertabular*
>      like supertabular, but for wide tables in a multicolumn page
>      layout
> **** mpsupertabular
>      like supertabular, but also handles footnotes within the table
> **** mpsupertabular*
>      like mpsupertabular, but for multicolumn page layouts
> **** longtable
>      extended tabular environment that breaks across pages and
>      includes a caption, but can't be used in a multicolumn page
>      layout
> *** Environment for floating a table and adding a caption
>     floats a table typeset by some other environment to a place in the
>     output that LaTeX determines appropriate, probably not where it
>     occurs in the input
> **** =table=, single column document
>      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
> **** =table*=, multi-column document
>      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
> *** "Typical" uses
>     In our report production work we regularly use seven setups:
>     - table or table* wrapped around tabularx or tabular
>     - longtable
>     - tabular or tabularx on their own
>
> hth,
> Tom
> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>
>> Hi,
>>
>> The attached patch allows the use of table* latex tables from within
>> Org
>> mode documents using the attr_latex lines, for example
>>
>> #+CAPTION: A wide table
>> #+LABEL: tbl:wide
>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>> | ... | ... |
>> | ... | ... |
>>
>> Should this be added, or should we put together a more general
>> solution
>> for different types of table environments?  Currently only longtable
>> is
>> supported.  Also, is there already a way to do this that I have
>> missed?
>>
>> Thanks -- Eric
>>
>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>> index a261171..b7f48d3 100644
>> --- a/lisp/org-latex.el
>> +++ b/lisp/org-latex.el
>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>              (org-table-last-column-widths (copy-sequence
>>                                             org-table-last-column-
>> widths))
>>              fnum fields line lines olines gr colgropen line-fmt align
>> -             caption shortn label attr floatp placement longtblp)
>> +             caption shortn label attr floatp placement longtblp
>> tblenv)
>>         (if org-export-latex-tables-verbatim
>>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>                                 "\\end{verbatim}\n")))
>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                          'org-label raw-table)
>>                   longtblp (and attr (stringp attr)
>>                                 (string-match "\\<longtable\\>" attr))
>> +		  tblenv (if (and attr (stringp attr)
>> +				  (string-match (regexp-quote "table*") attr))
>> +			     "table*" "table")
>>                   align (and attr (stringp attr)
>>                              (string-match "\\<align=\\([^ \t\n\r]+\
>> \)" attr)
>>                              (match-string 1 attr))
>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                        (concat
>>                         (if longtblp
>>                             (concat "\\begin{longtable}{" align "}\n")
>> -                          (if floatp (format "\\begin{table}%s\n"
>> placement)))
>> +                          (if floatp
>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>                         (if floatp
>>                             (format
>>                              "\\caption%s{%s} %s"
>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                                               "\n\\end{center}\n"
>> "\n"))
>>                         (if longtblp
>>                             "\\end{longtable}"
>> -                          (if floatp "\\end{table}"))))
>> +                          (if floatp (format "\\end{%s}" tblenv)))))
>>                       "\n\n"))))))))
>>
>> (defun org-export-latex-convert-table.el-table ()
>> _______________________________________________
>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-16 13:16   ` Eric Schulte
@ 2010-12-16 14:43     ` Eric Schulte
  2010-12-16 15:42       ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2010-12-16 14:43 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]

The attached patch implements the behavior described previously, so for
example the following org

#+begin_src org
  #+CAPTION: A wide table with tabulary
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |

  #+CAPTION: A normal table with tabularx
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |
#+end_src

exports to the following latex

#+begin_src latex
  \begin{table*}[htb]
  \caption{A wide table with tabulary} \label{tbl:wide}
  \begin{center}
  \begin{tabulary}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabulary}
  \end{center}
  \end{table*}


  \begin{table}[htb]
  \caption{A normal table with tabularx} \label{tbl:wide}
  \begin{center}
  \begin{tabularx}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabularx}
  \end{center}
  \end{table}
#+end_src

Does this behavior and patch look reasonable?  If I don't hear by the
end of the day I will apply this patch, I just wanted to check first on
list as the export mechanisms aren't my personal area of expertise.

Thanks -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tables.patch --]
[-- Type: text/x-diff, Size: 2571 bytes --]

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index a261171..66541de 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
              (org-table-last-column-widths (copy-sequence
                                             org-table-last-column-widths))
              fnum fields line lines olines gr colgropen line-fmt align
-             caption shortn label attr floatp placement longtblp)
+             caption shortn label attr floatp placement longtblp tblenv tblrenv)
         (if org-export-latex-tables-verbatim
             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
                                 "\\end{verbatim}\n")))
@@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                          'org-label raw-table)
                   longtblp (and attr (stringp attr)
                                 (string-match "\\<longtable\\>" attr))
+		  tblenv (if (and attr (stringp attr)
+				  (string-match (regexp-quote "table*") attr))
+			     "table*" "table")
+		  org-export-latex-tabular-environment
+		  (if (and attr (stringp attr)
+			   (string-match (regexp-quote "tabularx") attr))
+		      "tabularx"
+		    (if (string-match (regexp-quote "tabulary") attr)
+			"tabulary" org-export-latex-tabular-environment))
                   align (and attr (stringp attr)
                              (string-match "\\<align=\\([^ \t\n\r]+\\)" attr)
                              (match-string 1 attr))
@@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                        (concat
                         (if longtblp
                             (concat "\\begin{longtable}{" align "}\n")
-                          (if floatp (format "\\begin{table}%s\n" placement)))
+                          (if floatp
+			      (format "\\begin{%s}%s\n" tblenv placement)))
                         (if floatp
                             (format
                              "\\caption%s{%s} %s"
@@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                                               "\n\\end{center}\n" "\n"))
                         (if longtblp
                             "\\end{longtable}"
-                          (if floatp "\\end{table}"))))
+                          (if floatp (format "\\end{%s}" tblenv)))))
                       "\n\n"))))))))
 
 (defun org-export-latex-convert-table.el-table ()

[-- Attachment #3: Type: text/plain, Size: 6645 bytes --]


"Eric Schulte" <schulte.eric@gmail.com> writes:

> Hi Tom,
>
> Thanks for the informative list.  I had no idea LaTeX supported so many
> table options.  How about I update the patch so that is supports the
> following sets of mutually exclusive options...
> - longtable :: wraps the table in a longtable with no table or tabular
>                wrappers -- already implemented
> - table* :: replaces =table= wrapper with =table*= wrapper, contains an
>             inner tabular wrapper
> - tabular[xy] :: specifies the inner tabular wrapping environment, only
>                  one can be specified
>
> so for example, the following
>
> #+begin_src org
>   #+CAPTION: A wide table
>   #+LABEL: tbl:wide
>   #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>   | ... | ... |
>   | ... | ... |
> #+end_src
>
> results in the following
>
> #+begin_src latex
>   \begin{table*}[htb]
>   \caption{A wide table} \label{tbl:wide}
>   \begin{center}
>   \begin{tabulary}{l|lp{3cm}r|l}
>    1  &  2  &  3  \\
>    4  &  5  &  6  \\
>   \end{tabulary}
>   \end{center}
>   \end{table*}
> #+end_src
>
> Then the next question would be how to insert a =figure*= instead of a
> simple =figure= environment.
>
> Thanks -- Eric
>
> Thomas S. Dye <tsd@tsdye.com> writes:
>
>> Hi Eric,
>>
>> It would be great to have a more general solution.  Tables are hard to
>> typeset, so it might take a while to come up with a good
>> specification.  Here is what I know about the LaTeX side of things.
>>
>> ** LaTeX destinations for an Org-mode table
>> *** Environments for typesetting a table
>>     - table placed in the output where it occurs in the input
>>     - all of these environments can be used on their own
>> **** tabular
>>      standard LaTeX environment, doesn't break across pages, no caption
>> **** tabularx
>>      extended environment that can automatically calculate column
>>      widths and wrap text within table cells, doesn't break across
>>      pages, no caption
>> **** tabulary
>>      like tabularx, but tries harder to come up with optimal column
>> widths
>> **** supertabular
>>      extended tabular environment that breaks across pages, includes
>>      caption
>> **** supertabular*
>>      like supertabular, but for wide tables in a multicolumn page
>>      layout
>> **** mpsupertabular
>>      like supertabular, but also handles footnotes within the table
>> **** mpsupertabular*
>>      like mpsupertabular, but for multicolumn page layouts
>> **** longtable
>>      extended tabular environment that breaks across pages and
>>      includes a caption, but can't be used in a multicolumn page
>>      layout
>> *** Environment for floating a table and adding a caption
>>     floats a table typeset by some other environment to a place in the
>>     output that LaTeX determines appropriate, probably not where it
>>     occurs in the input
>> **** =table=, single column document
>>      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
>> **** =table*=, multi-column document
>>      typically wraps a =tabular=, =tabularx=, or =tabulary= environment
>> *** "Typical" uses
>>     In our report production work we regularly use seven setups:
>>     - table or table* wrapped around tabularx or tabular
>>     - longtable
>>     - tabular or tabularx on their own
>>
>> hth,
>> Tom
>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>
>>> Hi,
>>>
>>> The attached patch allows the use of table* latex tables from within
>>> Org
>>> mode documents using the attr_latex lines, for example
>>>
>>> #+CAPTION: A wide table
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>> | ... | ... |
>>> | ... | ... |
>>>
>>> Should this be added, or should we put together a more general
>>> solution
>>> for different types of table environments?  Currently only longtable
>>> is
>>> supported.  Also, is there already a way to do this that I have
>>> missed?
>>>
>>> Thanks -- Eric
>>>
>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>> index a261171..b7f48d3 100644
>>> --- a/lisp/org-latex.el
>>> +++ b/lisp/org-latex.el
>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>              (org-table-last-column-widths (copy-sequence
>>>                                             org-table-last-column-
>>> widths))
>>>              fnum fields line lines olines gr colgropen line-fmt align
>>> -             caption shortn label attr floatp placement longtblp)
>>> +             caption shortn label attr floatp placement longtblp
>>> tblenv)
>>>         (if org-export-latex-tables-verbatim
>>>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>                                 "\\end{verbatim}\n")))
>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                          'org-label raw-table)
>>>                   longtblp (and attr (stringp attr)
>>>                                 (string-match "\\<longtable\\>" attr))
>>> +		  tblenv (if (and attr (stringp attr)
>>> +				  (string-match (regexp-quote "table*") attr))
>>> +			     "table*" "table")
>>>                   align (and attr (stringp attr)
>>>                              (string-match "\\<align=\\([^ \t\n\r]+\
>>> \)" attr)
>>>                              (match-string 1 attr))
>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                        (concat
>>>                         (if longtblp
>>>                             (concat "\\begin{longtable}{" align "}\n")
>>> -                          (if floatp (format "\\begin{table}%s\n"
>>> placement)))
>>> +                          (if floatp
>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>                         (if floatp
>>>                             (format
>>>                              "\\caption%s{%s} %s"
>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                                               "\n\\end{center}\n"
>>> "\n"))
>>>                         (if longtblp
>>>                             "\\end{longtable}"
>>> -                          (if floatp "\\end{table}"))))
>>> +                          (if floatp (format "\\end{%s}" tblenv)))))
>>>                       "\n\n"))))))))
>>>
>>> (defun org-export-latex-convert-table.el-table ()
>>> _______________________________________________
>>> 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

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-16 14:43     ` Eric Schulte
@ 2010-12-16 15:42       ` Thomas S. Dye
  2010-12-17  0:57         ` Eric Schulte
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2010-12-16 15:42 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode

Hi Eric,

The syntax for tabularx and tabulary includes a width specification  
that is a required argument:

\begin{tabulary}{<width>}{<align>} ... \end{tabulary}
\begin{tabularx}{<width>}{<align>} ... \end{tabularx}

This is typically set to something like \linewidth, \colwidth, or  
\textwidth, but might also take an absolute length like 250pt, 5in, etc.

All the best,
Tom

On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:

> The attached patch implements the behavior described previously, so  
> for
> example the following org
>
> #+begin_src org
>  #+CAPTION: A wide table with tabulary
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  #+CAPTION: A normal table with tabularx
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
> #+end_src
>
> exports to the following latex
>
> #+begin_src latex
>  \begin{table*}[htb]
>  \caption{A wide table with tabulary} \label{tbl:wide}
>  \begin{center}
>  \begin{tabulary}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabulary}
>  \end{center}
>  \end{table*}
>
>
>  \begin{table}[htb]
>  \caption{A normal table with tabularx} \label{tbl:wide}
>  \begin{center}
>  \begin{tabularx}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabularx}
>  \end{center}
>  \end{table}
> #+end_src
>
> Does this behavior and patch look reasonable?  If I don't hear by the
> end of the day I will apply this patch, I just wanted to check first  
> on
> list as the export mechanisms aren't my personal area of expertise.
>
> Thanks -- Eric
>
> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
> index a261171..66541de 100644
> --- a/lisp/org-latex.el
> +++ b/lisp/org-latex.el
> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>              (org-table-last-column-widths (copy-sequence
>                                             org-table-last-column- 
> widths))
>              fnum fields line lines olines gr colgropen line-fmt align
> -             caption shortn label attr floatp placement longtblp)
> +             caption shortn label attr floatp placement longtblp  
> tblenv tblrenv)
>         (if org-export-latex-tables-verbatim
>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>                                 "\\end{verbatim}\n")))
> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                          'org-label raw-table)
>                   longtblp (and attr (stringp attr)
>                                 (string-match "\\<longtable\\>" attr))
> +		  tblenv (if (and attr (stringp attr)
> +				  (string-match (regexp-quote "table*") attr))
> +			     "table*" "table")
> +		  org-export-latex-tabular-environment
> +		  (if (and attr (stringp attr)
> +			   (string-match (regexp-quote "tabularx") attr))
> +		      "tabularx"
> +		    (if (string-match (regexp-quote "tabulary") attr)
> +			"tabulary" org-export-latex-tabular-environment))
>                   align (and attr (stringp attr)
>                              (string-match "\\<align=\\([^ \t\n\r]+\ 
> \)" attr)
>                              (match-string 1 attr))
> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                        (concat
>                         (if longtblp
>                             (concat "\\begin{longtable}{" align "}\n")
> -                          (if floatp (format "\\begin{table}%s\n"  
> placement)))
> +                          (if floatp
> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>                         (if floatp
>                             (format
>                              "\\caption%s{%s} %s"
> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                                               "\n\\end{center}\n"  
> "\n"))
>                         (if longtblp
>                             "\\end{longtable}"
> -                          (if floatp "\\end{table}"))))
> +                          (if floatp (format "\\end{%s}" tblenv)))))
>                       "\n\n"))))))))
>
> (defun org-export-latex-convert-table.el-table ()
>
> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Hi Tom,
>>
>> Thanks for the informative list.  I had no idea LaTeX supported so  
>> many
>> table options.  How about I update the patch so that is supports the
>> following sets of mutually exclusive options...
>> - longtable :: wraps the table in a longtable with no table or  
>> tabular
>>               wrappers -- already implemented
>> - table* :: replaces =table= wrapper with =table*= wrapper,  
>> contains an
>>            inner tabular wrapper
>> - tabular[xy] :: specifies the inner tabular wrapping environment,  
>> only
>>                 one can be specified
>>
>> so for example, the following
>>
>> #+begin_src org
>>  #+CAPTION: A wide table
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>  | ... | ... |
>>  | ... | ... |
>> #+end_src
>>
>> results in the following
>>
>> #+begin_src latex
>>  \begin{table*}[htb]
>>  \caption{A wide table} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabulary}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabulary}
>>  \end{center}
>>  \end{table*}
>> #+end_src
>>
>> Then the next question would be how to insert a =figure*= instead  
>> of a
>> simple =figure= environment.
>>
>> Thanks -- Eric
>>
>> Thomas S. Dye <tsd@tsdye.com> writes:
>>
>>> Hi Eric,
>>>
>>> It would be great to have a more general solution.  Tables are  
>>> hard to
>>> typeset, so it might take a while to come up with a good
>>> specification.  Here is what I know about the LaTeX side of things.
>>>
>>> ** LaTeX destinations for an Org-mode table
>>> *** Environments for typesetting a table
>>>    - table placed in the output where it occurs in the input
>>>    - all of these environments can be used on their own
>>> **** tabular
>>>     standard LaTeX environment, doesn't break across pages, no  
>>> caption
>>> **** tabularx
>>>     extended environment that can automatically calculate column
>>>     widths and wrap text within table cells, doesn't break across
>>>     pages, no caption
>>> **** tabulary
>>>     like tabularx, but tries harder to come up with optimal column
>>> widths
>>> **** supertabular
>>>     extended tabular environment that breaks across pages, includes
>>>     caption
>>> **** supertabular*
>>>     like supertabular, but for wide tables in a multicolumn page
>>>     layout
>>> **** mpsupertabular
>>>     like supertabular, but also handles footnotes within the table
>>> **** mpsupertabular*
>>>     like mpsupertabular, but for multicolumn page layouts
>>> **** longtable
>>>     extended tabular environment that breaks across pages and
>>>     includes a caption, but can't be used in a multicolumn page
>>>     layout
>>> *** Environment for floating a table and adding a caption
>>>    floats a table typeset by some other environment to a place in  
>>> the
>>>    output that LaTeX determines appropriate, probably not where it
>>>    occurs in the input
>>> **** =table=, single column document
>>>     typically wraps a =tabular=, =tabularx=, or =tabulary=  
>>> environment
>>> **** =table*=, multi-column document
>>>     typically wraps a =tabular=, =tabularx=, or =tabulary=  
>>> environment
>>> *** "Typical" uses
>>>    In our report production work we regularly use seven setups:
>>>    - table or table* wrapped around tabularx or tabular
>>>    - longtable
>>>    - tabular or tabularx on their own
>>>
>>> hth,
>>> Tom
>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>
>>>> Hi,
>>>>
>>>> The attached patch allows the use of table* latex tables from  
>>>> within
>>>> Org
>>>> mode documents using the attr_latex lines, for example
>>>>
>>>> #+CAPTION: A wide table
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>> | ... | ... |
>>>> | ... | ... |
>>>>
>>>> Should this be added, or should we put together a more general
>>>> solution
>>>> for different types of table environments?  Currently only  
>>>> longtable
>>>> is
>>>> supported.  Also, is there already a way to do this that I have
>>>> missed?
>>>>
>>>> Thanks -- Eric
>>>>
>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>> index a261171..b7f48d3 100644
>>>> --- a/lisp/org-latex.el
>>>> +++ b/lisp/org-latex.el
>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>             (org-table-last-column-widths (copy-sequence
>>>>                                            org-table-last-column-
>>>> widths))
>>>>             fnum fields line lines olines gr colgropen line-fmt  
>>>> align
>>>> -             caption shortn label attr floatp placement longtblp)
>>>> +             caption shortn label attr floatp placement longtblp
>>>> tblenv)
>>>>        (if org-export-latex-tables-verbatim
>>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>                                "\\end{verbatim}\n")))
>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                         'org-label raw-table)
>>>>                  longtblp (and attr (stringp attr)
>>>>                                (string-match "\\<longtable\\>"  
>>>> attr))
>>>> +		  tblenv (if (and attr (stringp attr)
>>>> +				  (string-match (regexp-quote "table*") attr))
>>>> +			     "table*" "table")
>>>>                  align (and attr (stringp attr)
>>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>>> \)" attr)
>>>>                             (match-string 1 attr))
>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                       (concat
>>>>                        (if longtblp
>>>>                            (concat "\\begin{longtable}{" align "} 
>>>> \n")
>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>> placement)))
>>>> +                          (if floatp
>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>                        (if floatp
>>>>                            (format
>>>>                             "\\caption%s{%s} %s"
>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                                              "\n\\end{center}\n"
>>>> "\n"))
>>>>                        (if longtblp
>>>>                            "\\end{longtable}"
>>>> -                          (if floatp "\\end{table}"))))
>>>> +                          (if floatp (format "\\end{%s}"  
>>>> tblenv)))))
>>>>                      "\n\n"))))))))
>>>>
>>>> (defun org-export-latex-convert-table.el-table ()
>>>> _______________________________________________
>>>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-16 15:42       ` Thomas S. Dye
@ 2010-12-17  0:57         ` Eric Schulte
  2010-12-17 16:21           ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2010-12-17  0:57 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]

Hi Tom,

Thanks for the pointer, how about this revised version of the patch.  It
takes the following inputs

#+begin_src org
  #+CAPTION: A wide table with tabulary
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |

  #+CAPTION: A normal table with tabularx
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |
#+end_src

and yields the following output

#+begin_src latex
  \begin{table*}[htb]
  \caption{A wide table with tabulary} \label{tbl:wide}
  \begin{center}
  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabulary}
  \end{center}
  \end{table*}


  \begin{table}[htb]
  \caption{A normal table with tabularx} \label{tbl:wide}
  \begin{center}
  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabularx}
  \end{center}
  \end{table}
#+end_src

I'm not sure about the square bracket syntax, maybe curly would be
preferable.  Definitely open to suggestions.

Should this be applied?  Are there any obvious areas for improvement?

Thanks -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tables.patch --]
[-- Type: text/x-diff, Size: 3784 bytes --]

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index a261171..af0a15d 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
              (org-table-last-column-widths (copy-sequence
                                             org-table-last-column-widths))
              fnum fields line lines olines gr colgropen line-fmt align
-             caption shortn label attr floatp placement longtblp)
+             caption shortn label attr floatp placement longtblp tblenv)
         (if org-export-latex-tables-verbatim
             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
                                 "\\end{verbatim}\n")))
@@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                          'org-label raw-table)
                   longtblp (and attr (stringp attr)
                                 (string-match "\\<longtable\\>" attr))
+		  tblenv (if (and attr (stringp attr)
+				  (string-match (regexp-quote "table*") attr))
+			     "table*" "table")
+		  org-export-latex-tabular-environment
+		  (progn
+		    (message "attr:%s" attr)
+		    (if (and attr (stringp attr)
+			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
+			(list (match-string 1 attr) (match-string 2 attr))
+		      org-export-latex-tabular-environment))
                   align (and attr (stringp attr)
                              (string-match "\\<align=\\([^ \t\n\r]+\\)" attr)
                              (match-string 1 attr))
@@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                        (concat
                         (if longtblp
                             (concat "\\begin{longtable}{" align "}\n")
-                          (if floatp (format "\\begin{table}%s\n" placement)))
+                          (if floatp
+			      (format "\\begin{%s}%s\n" tblenv placement)))
                         (if floatp
                             (format
                              "\\caption%s{%s} %s"
@@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                         (if (and org-export-latex-tables-centered (not longtblp))
                             "\\begin{center}\n")
                         (if (not longtblp)
-			    (format "\\begin{%s}{%s}\n"
-				    org-export-latex-tabular-environment align))
+			    (if (listp org-export-latex-tabular-environment)
+				(apply
+				 #'format
+				 (append
+				  (list "\\begin{%s}{%s}{%s}\n")
+				  org-export-latex-tabular-environment
+				  (list align)))
+			      (format "\\begin{%s}{%s}\n"
+				      org-export-latex-tabular-environment align)))
                         (orgtbl-to-latex
                          lines
                          `(:tstart nil :tend nil
@@ -1847,12 +1865,14 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
                                              nil)))
                         (if (not longtblp)
 			    (format "\n\\end{%s}"
-				    org-export-latex-tabular-environment))
+				    (if (listp org-export-latex-tabular-environment)
+					(car org-export-latex-tabular-environment)
+				      org-export-latex-tabular-environment)))
                         (if longtblp "\n" (if org-export-latex-tables-centered
                                               "\n\\end{center}\n" "\n"))
                         (if longtblp
                             "\\end{longtable}"
-                          (if floatp "\\end{table}"))))
+                          (if floatp (format "\\end{%s}" tblenv)))))
                       "\n\n"))))))))
 
 (defun org-export-latex-convert-table.el-table ()

[-- Attachment #3: Type: text/plain, Size: 11482 bytes --]


"Thomas S. Dye" <tsd@tsdye.com> writes:

> Hi Eric,
>
> The syntax for tabularx and tabulary includes a width specification
> that is a required argument:
>
> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>
> This is typically set to something like \linewidth, \colwidth, or
> \textwidth, but might also take an absolute length like 250pt, 5in,
> etc.
>
> All the best,
> Tom
>
> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>
>> The attached patch implements the behavior described previously, so
>> for
>> example the following org
>>
>> #+begin_src org
>>  #+CAPTION: A wide table with tabulary
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>>
>>  #+CAPTION: A normal table with tabularx
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>> #+end_src
>>
>> exports to the following latex
>>
>> #+begin_src latex
>>  \begin{table*}[htb]
>>  \caption{A wide table with tabulary} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabulary}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabulary}
>>  \end{center}
>>  \end{table*}
>>
>>
>>  \begin{table}[htb]
>>  \caption{A normal table with tabularx} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabularx}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabularx}
>>  \end{center}
>>  \end{table}
>> #+end_src
>>
>> Does this behavior and patch look reasonable?  If I don't hear by the
>> end of the day I will apply this patch, I just wanted to check first
>> on
>> list as the export mechanisms aren't my personal area of expertise.
>>
>> Thanks -- Eric
>>
>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>> index a261171..66541de 100644
>> --- a/lisp/org-latex.el
>> +++ b/lisp/org-latex.el
>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>              (org-table-last-column-widths (copy-sequence
>>                                             org-table-last-column-
>> widths))
>>              fnum fields line lines olines gr colgropen line-fmt align
>> -             caption shortn label attr floatp placement longtblp)
>> +             caption shortn label attr floatp placement longtblp
>> tblenv tblrenv)
>>         (if org-export-latex-tables-verbatim
>>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>                                 "\\end{verbatim}\n")))
>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                          'org-label raw-table)
>>                   longtblp (and attr (stringp attr)
>>                                 (string-match "\\<longtable\\>" attr))
>> +		  tblenv (if (and attr (stringp attr)
>> +				  (string-match (regexp-quote "table*") attr))
>> +			     "table*" "table")
>> +		  org-export-latex-tabular-environment
>> +		  (if (and attr (stringp attr)
>> +			   (string-match (regexp-quote "tabularx") attr))
>> +		      "tabularx"
>> +		    (if (string-match (regexp-quote "tabulary") attr)
>> +			"tabulary" org-export-latex-tabular-environment))
>>                   align (and attr (stringp attr)
>>                              (string-match "\\<align=\\([^ \t\n\r]+\
>> \)" attr)
>>                              (match-string 1 attr))
>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                        (concat
>>                         (if longtblp
>>                             (concat "\\begin{longtable}{" align "}\n")
>> -                          (if floatp (format "\\begin{table}%s\n"
>> placement)))
>> +                          (if floatp
>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>                         (if floatp
>>                             (format
>>                              "\\caption%s{%s} %s"
>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                                               "\n\\end{center}\n"
>> "\n"))
>>                         (if longtblp
>>                             "\\end{longtable}"
>> -                          (if floatp "\\end{table}"))))
>> +                          (if floatp (format "\\end{%s}" tblenv)))))
>>                       "\n\n"))))))))
>>
>> (defun org-export-latex-convert-table.el-table ()
>>
>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>
>>> Hi Tom,
>>>
>>> Thanks for the informative list.  I had no idea LaTeX supported so
>>> many
>>> table options.  How about I update the patch so that is supports the
>>> following sets of mutually exclusive options...
>>> - longtable :: wraps the table in a longtable with no table or
>>> tabular
>>>               wrappers -- already implemented
>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>> contains an
>>>            inner tabular wrapper
>>> - tabular[xy] :: specifies the inner tabular wrapping environment,
>>> only
>>>                 one can be specified
>>>
>>> so for example, the following
>>>
>>> #+begin_src org
>>>  #+CAPTION: A wide table
>>>  #+LABEL: tbl:wide
>>>  #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>  | ... | ... |
>>>  | ... | ... |
>>> #+end_src
>>>
>>> results in the following
>>>
>>> #+begin_src latex
>>>  \begin{table*}[htb]
>>>  \caption{A wide table} \label{tbl:wide}
>>>  \begin{center}
>>>  \begin{tabulary}{l|lp{3cm}r|l}
>>>   1  &  2  &  3  \\
>>>   4  &  5  &  6  \\
>>>  \end{tabulary}
>>>  \end{center}
>>>  \end{table*}
>>> #+end_src
>>>
>>> Then the next question would be how to insert a =figure*= instead
>>> of a
>>> simple =figure= environment.
>>>
>>> Thanks -- Eric
>>>
>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> It would be great to have a more general solution.  Tables are
>>>> hard to
>>>> typeset, so it might take a while to come up with a good
>>>> specification.  Here is what I know about the LaTeX side of things.
>>>>
>>>> ** LaTeX destinations for an Org-mode table
>>>> *** Environments for typesetting a table
>>>>    - table placed in the output where it occurs in the input
>>>>    - all of these environments can be used on their own
>>>> **** tabular
>>>>     standard LaTeX environment, doesn't break across pages, no
>>>> caption
>>>> **** tabularx
>>>>     extended environment that can automatically calculate column
>>>>     widths and wrap text within table cells, doesn't break across
>>>>     pages, no caption
>>>> **** tabulary
>>>>     like tabularx, but tries harder to come up with optimal column
>>>> widths
>>>> **** supertabular
>>>>     extended tabular environment that breaks across pages, includes
>>>>     caption
>>>> **** supertabular*
>>>>     like supertabular, but for wide tables in a multicolumn page
>>>>     layout
>>>> **** mpsupertabular
>>>>     like supertabular, but also handles footnotes within the table
>>>> **** mpsupertabular*
>>>>     like mpsupertabular, but for multicolumn page layouts
>>>> **** longtable
>>>>     extended tabular environment that breaks across pages and
>>>>     includes a caption, but can't be used in a multicolumn page
>>>>     layout
>>>> *** Environment for floating a table and adding a caption
>>>>    floats a table typeset by some other environment to a place in
>>>> the
>>>>    output that LaTeX determines appropriate, probably not where it
>>>>    occurs in the input
>>>> **** =table=, single column document
>>>>     typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>> environment
>>>> **** =table*=, multi-column document
>>>>     typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>> environment
>>>> *** "Typical" uses
>>>>    In our report production work we regularly use seven setups:
>>>>    - table or table* wrapped around tabularx or tabular
>>>>    - longtable
>>>>    - tabular or tabularx on their own
>>>>
>>>> hth,
>>>> Tom
>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> The attached patch allows the use of table* latex tables from
>>>>> within
>>>>> Org
>>>>> mode documents using the attr_latex lines, for example
>>>>>
>>>>> #+CAPTION: A wide table
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>> | ... | ... |
>>>>> | ... | ... |
>>>>>
>>>>> Should this be added, or should we put together a more general
>>>>> solution
>>>>> for different types of table environments?  Currently only
>>>>> longtable
>>>>> is
>>>>> supported.  Also, is there already a way to do this that I have
>>>>> missed?
>>>>>
>>>>> Thanks -- Eric
>>>>>
>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>> index a261171..b7f48d3 100644
>>>>> --- a/lisp/org-latex.el
>>>>> +++ b/lisp/org-latex.el
>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>             (org-table-last-column-widths (copy-sequence
>>>>>                                            org-table-last-column-
>>>>> widths))
>>>>>             fnum fields line lines olines gr colgropen line-fmt
>>>>> align
>>>>> -             caption shortn label attr floatp placement longtblp)
>>>>> +             caption shortn label attr floatp placement longtblp
>>>>> tblenv)
>>>>>        (if org-export-latex-tables-verbatim
>>>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>                                "\\end{verbatim}\n")))
>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                         'org-label raw-table)
>>>>>                  longtblp (and attr (stringp attr)
>>>>>                                (string-match "\\<longtable\\>"
>>>>> attr))
>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>> +			     "table*" "table")
>>>>>                  align (and attr (stringp attr)
>>>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>>>> \)" attr)
>>>>>                             (match-string 1 attr))
>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                       (concat
>>>>>                        (if longtblp
>>>>>                            (concat "\\begin{longtable}{" align "}
>>>>> \n")
>>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>>> placement)))
>>>>> +                          (if floatp
>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>                        (if floatp
>>>>>                            (format
>>>>>                             "\\caption%s{%s} %s"
>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                                              "\n\\end{center}\n"
>>>>> "\n"))
>>>>>                        (if longtblp
>>>>>                            "\\end{longtable}"
>>>>> -                          (if floatp "\\end{table}"))))
>>>>> +                          (if floatp (format "\\end{%s}"
>>>>> tblenv)))))
>>>>>                      "\n\n"))))))))
>>>>>
>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>> _______________________________________________
>>>>> 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

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17  0:57         ` Eric Schulte
@ 2010-12-17 16:21           ` Thomas S. Dye
  2010-12-17 20:39             ` Eric Schulte
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2010-12-17 16:21 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode

Hi Eric,

A syntax like this, with a width attribute, seems most like Org-mode  
to me:

#+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl

If that isn't a reasonable possibility, then, yes, the square brackets  
should be changed.  These represent optional arguments in LaTeX.  The  
width argument is required by tabularx and tabulary, not optional, so  
it looks like an error from a LaTeX point of view.  Changing the  
square brackets to curly brackets in this case would have the  
advantage of looking a lot like the underlying LaTeX.

All the best,
Tom

On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:

> Hi Tom,
>
> Thanks for the pointer, how about this revised version of the  
> patch.  It
> takes the following inputs
>
> #+begin_src org
>  #+CAPTION: A wide table with tabulary
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  #+CAPTION: A normal table with tabularx
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
> #+end_src
>
> and yields the following output
>
> #+begin_src latex
>  \begin{table*}[htb]
>  \caption{A wide table with tabulary} \label{tbl:wide}
>  \begin{center}
>  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabulary}
>  \end{center}
>  \end{table*}
>
>
>  \begin{table}[htb]
>  \caption{A normal table with tabularx} \label{tbl:wide}
>  \begin{center}
>  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabularx}
>  \end{center}
>  \end{table}
> #+end_src
>
> I'm not sure about the square bracket syntax, maybe curly would be
> preferable.  Definitely open to suggestions.
>
> Should this be applied?  Are there any obvious areas for improvement?
>
> Thanks -- Eric
>
> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
> index a261171..af0a15d 100644
> --- a/lisp/org-latex.el
> +++ b/lisp/org-latex.el
> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>              (org-table-last-column-widths (copy-sequence
>                                             org-table-last-column- 
> widths))
>              fnum fields line lines olines gr colgropen line-fmt align
> -             caption shortn label attr floatp placement longtblp)
> +             caption shortn label attr floatp placement longtblp  
> tblenv)
>         (if org-export-latex-tables-verbatim
>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>                                 "\\end{verbatim}\n")))
> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                          'org-label raw-table)
>                   longtblp (and attr (stringp attr)
>                                 (string-match "\\<longtable\\>" attr))
> +		  tblenv (if (and attr (stringp attr)
> +				  (string-match (regexp-quote "table*") attr))
> +			     "table*" "table")
> +		  org-export-latex-tabular-environment
> +		  (progn
> +		    (message "attr:%s" attr)
> +		    (if (and attr (stringp attr)
> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
> +			(list (match-string 1 attr) (match-string 2 attr))
> +		      org-export-latex-tabular-environment))
>                   align (and attr (stringp attr)
>                              (string-match "\\<align=\\([^ \t\n\r]+\ 
> \)" attr)
>                              (match-string 1 attr))
> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                        (concat
>                         (if longtblp
>                             (concat "\\begin{longtable}{" align "}\n")
> -                          (if floatp (format "\\begin{table}%s\n"  
> placement)))
> +                          (if floatp
> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>                         (if floatp
>                             (format
>                              "\\caption%s{%s} %s"
> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                         (if (and org-export-latex-tables-centered  
> (not longtblp))
>                             "\\begin{center}\n")
>                         (if (not longtblp)
> -			    (format "\\begin{%s}{%s}\n"
> -				    org-export-latex-tabular-environment align))
> +			    (if (listp org-export-latex-tabular-environment)
> +				(apply
> +				 #'format
> +				 (append
> +				  (list "\\begin{%s}{%s}{%s}\n")
> +				  org-export-latex-tabular-environment
> +				  (list align)))
> +			      (format "\\begin{%s}{%s}\n"
> +				      org-export-latex-tabular-environment align)))
>                         (orgtbl-to-latex
>                          lines
>                          `(:tstart nil :tend nil
> @@ -1847,12 +1865,14 @@ The conversion is made depending of STRING- 
> BEFORE and STRING-AFTER."
>                                              nil)))
>                         (if (not longtblp)
> 			    (format "\n\\end{%s}"
> -				    org-export-latex-tabular-environment))
> +				    (if (listp org-export-latex-tabular-environment)
> +					(car org-export-latex-tabular-environment)
> +				      org-export-latex-tabular-environment)))
>                         (if longtblp "\n" (if org-export-latex- 
> tables-centered
>                                               "\n\\end{center}\n"  
> "\n"))
>                         (if longtblp
>                             "\\end{longtable}"
> -                          (if floatp "\\end{table}"))))
> +                          (if floatp (format "\\end{%s}" tblenv)))))
>                       "\n\n"))))))))
>
> (defun org-export-latex-convert-table.el-table ()
>
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> Hi Eric,
>>
>> The syntax for tabularx and tabulary includes a width specification
>> that is a required argument:
>>
>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>
>> This is typically set to something like \linewidth, \colwidth, or
>> \textwidth, but might also take an absolute length like 250pt, 5in,
>> etc.
>>
>> All the best,
>> Tom
>>
>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>
>>> The attached patch implements the behavior described previously, so
>>> for
>>> example the following org
>>>
>>> #+begin_src org
>>> #+CAPTION: A wide table with tabulary
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>>
>>> #+CAPTION: A normal table with tabularx
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>> #+end_src
>>>
>>> exports to the following latex
>>>
>>> #+begin_src latex
>>> \begin{table*}[htb]
>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabulary}
>>> \end{center}
>>> \end{table*}
>>>
>>>
>>> \begin{table}[htb]
>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabularx}
>>> \end{center}
>>> \end{table}
>>> #+end_src
>>>
>>> Does this behavior and patch look reasonable?  If I don't hear by  
>>> the
>>> end of the day I will apply this patch, I just wanted to check first
>>> on
>>> list as the export mechanisms aren't my personal area of expertise.
>>>
>>> Thanks -- Eric
>>>
>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>> index a261171..66541de 100644
>>> --- a/lisp/org-latex.el
>>> +++ b/lisp/org-latex.el
>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>             (org-table-last-column-widths (copy-sequence
>>>                                            org-table-last-column-
>>> widths))
>>>             fnum fields line lines olines gr colgropen line-fmt  
>>> align
>>> -             caption shortn label attr floatp placement longtblp)
>>> +             caption shortn label attr floatp placement longtblp
>>> tblenv tblrenv)
>>>        (if org-export-latex-tables-verbatim
>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>                                "\\end{verbatim}\n")))
>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                         'org-label raw-table)
>>>                  longtblp (and attr (stringp attr)
>>>                                (string-match "\\<longtable\\>"  
>>> attr))
>>> +		  tblenv (if (and attr (stringp attr)
>>> +				  (string-match (regexp-quote "table*") attr))
>>> +			     "table*" "table")
>>> +		  org-export-latex-tabular-environment
>>> +		  (if (and attr (stringp attr)
>>> +			   (string-match (regexp-quote "tabularx") attr))
>>> +		      "tabularx"
>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>> +			"tabulary" org-export-latex-tabular-environment))
>>>                  align (and attr (stringp attr)
>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>> \)" attr)
>>>                             (match-string 1 attr))
>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                       (concat
>>>                        (if longtblp
>>>                            (concat "\\begin{longtable}{" align "} 
>>> \n")
>>> -                          (if floatp (format "\\begin{table}%s\n"
>>> placement)))
>>> +                          (if floatp
>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>                        (if floatp
>>>                            (format
>>>                             "\\caption%s{%s} %s"
>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                                              "\n\\end{center}\n"
>>> "\n"))
>>>                        (if longtblp
>>>                            "\\end{longtable}"
>>> -                          (if floatp "\\end{table}"))))
>>> +                          (if floatp (format "\\end{%s}"  
>>> tblenv)))))
>>>                      "\n\n"))))))))
>>>
>>> (defun org-export-latex-convert-table.el-table ()
>>>
>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>
>>>> Hi Tom,
>>>>
>>>> Thanks for the informative list.  I had no idea LaTeX supported so
>>>> many
>>>> table options.  How about I update the patch so that is supports  
>>>> the
>>>> following sets of mutually exclusive options...
>>>> - longtable :: wraps the table in a longtable with no table or
>>>> tabular
>>>>              wrappers -- already implemented
>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>> contains an
>>>>           inner tabular wrapper
>>>> - tabular[xy] :: specifies the inner tabular wrapping environment,
>>>> only
>>>>                one can be specified
>>>>
>>>> so for example, the following
>>>>
>>>> #+begin_src org
>>>> #+CAPTION: A wide table
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>> | ... | ... |
>>>> | ... | ... |
>>>> #+end_src
>>>>
>>>> results in the following
>>>>
>>>> #+begin_src latex
>>>> \begin{table*}[htb]
>>>> \caption{A wide table} \label{tbl:wide}
>>>> \begin{center}
>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>  1  &  2  &  3  \\
>>>>  4  &  5  &  6  \\
>>>> \end{tabulary}
>>>> \end{center}
>>>> \end{table*}
>>>> #+end_src
>>>>
>>>> Then the next question would be how to insert a =figure*= instead
>>>> of a
>>>> simple =figure= environment.
>>>>
>>>> Thanks -- Eric
>>>>
>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>
>>>>> Hi Eric,
>>>>>
>>>>> It would be great to have a more general solution.  Tables are
>>>>> hard to
>>>>> typeset, so it might take a while to come up with a good
>>>>> specification.  Here is what I know about the LaTeX side of  
>>>>> things.
>>>>>
>>>>> ** LaTeX destinations for an Org-mode table
>>>>> *** Environments for typesetting a table
>>>>>   - table placed in the output where it occurs in the input
>>>>>   - all of these environments can be used on their own
>>>>> **** tabular
>>>>>    standard LaTeX environment, doesn't break across pages, no
>>>>> caption
>>>>> **** tabularx
>>>>>    extended environment that can automatically calculate column
>>>>>    widths and wrap text within table cells, doesn't break across
>>>>>    pages, no caption
>>>>> **** tabulary
>>>>>    like tabularx, but tries harder to come up with optimal column
>>>>> widths
>>>>> **** supertabular
>>>>>    extended tabular environment that breaks across pages, includes
>>>>>    caption
>>>>> **** supertabular*
>>>>>    like supertabular, but for wide tables in a multicolumn page
>>>>>    layout
>>>>> **** mpsupertabular
>>>>>    like supertabular, but also handles footnotes within the table
>>>>> **** mpsupertabular*
>>>>>    like mpsupertabular, but for multicolumn page layouts
>>>>> **** longtable
>>>>>    extended tabular environment that breaks across pages and
>>>>>    includes a caption, but can't be used in a multicolumn page
>>>>>    layout
>>>>> *** Environment for floating a table and adding a caption
>>>>>   floats a table typeset by some other environment to a place in
>>>>> the
>>>>>   output that LaTeX determines appropriate, probably not where it
>>>>>   occurs in the input
>>>>> **** =table=, single column document
>>>>>    typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>> environment
>>>>> **** =table*=, multi-column document
>>>>>    typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>> environment
>>>>> *** "Typical" uses
>>>>>   In our report production work we regularly use seven setups:
>>>>>   - table or table* wrapped around tabularx or tabular
>>>>>   - longtable
>>>>>   - tabular or tabularx on their own
>>>>>
>>>>> hth,
>>>>> Tom
>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> The attached patch allows the use of table* latex tables from
>>>>>> within
>>>>>> Org
>>>>>> mode documents using the attr_latex lines, for example
>>>>>>
>>>>>> #+CAPTION: A wide table
>>>>>> #+LABEL: tbl:wide
>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>> | ... | ... |
>>>>>> | ... | ... |
>>>>>>
>>>>>> Should this be added, or should we put together a more general
>>>>>> solution
>>>>>> for different types of table environments?  Currently only
>>>>>> longtable
>>>>>> is
>>>>>> supported.  Also, is there already a way to do this that I have
>>>>>> missed?
>>>>>>
>>>>>> Thanks -- Eric
>>>>>>
>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>> index a261171..b7f48d3 100644
>>>>>> --- a/lisp/org-latex.el
>>>>>> +++ b/lisp/org-latex.el
>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>>                                           org-table-last-column-
>>>>>> widths))
>>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>>> align
>>>>>> -             caption shortn label attr floatp placement  
>>>>>> longtblp)
>>>>>> +             caption shortn label attr floatp placement longtblp
>>>>>> tblenv)
>>>>>>       (if org-export-latex-tables-verbatim
>>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>                               "\\end{verbatim}\n")))
>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                        'org-label raw-table)
>>>>>>                 longtblp (and attr (stringp attr)
>>>>>>                               (string-match "\\<longtable\\>"
>>>>>> attr))
>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>> +			     "table*" "table")
>>>>>>                 align (and attr (stringp attr)
>>>>>>                            (string-match "\\<align=\\([^ \t\n\r] 
>>>>>> +\
>>>>>> \)" attr)
>>>>>>                            (match-string 1 attr))
>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                      (concat
>>>>>>                       (if longtblp
>>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>>> \n")
>>>>>> -                          (if floatp (format "\\begin{table}%s 
>>>>>> \n"
>>>>>> placement)))
>>>>>> +                          (if floatp
>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>                       (if floatp
>>>>>>                           (format
>>>>>>                            "\\caption%s{%s} %s"
>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                                             "\n\\end{center}\n"
>>>>>> "\n"))
>>>>>>                       (if longtblp
>>>>>>                           "\\end{longtable}"
>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>> tblenv)))))
>>>>>>                     "\n\n"))))))))
>>>>>>
>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>> _______________________________________________
>>>>>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17 16:21           ` Thomas S. Dye
@ 2010-12-17 20:39             ` Eric Schulte
  2010-12-17 20:44               ` Carsten Dominik
  2010-12-18 20:18               ` Thomas S. Dye
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Schulte @ 2010-12-17 20:39 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org Mode

Hi Tom,

Thanks for all you help on this front.  I've just pushed up the patch
with your suggested syntax (which is much better than my original).  It
allows the following behavior.

The following org
#+begin_src org
  #+CAPTION: A wide table with tabulary
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table* tabulary width=\textwidth align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |

  #+CAPTION: A normal table with tabularx
  #+LABEL: tbl:wide
  #+ATTR_LaTeX: table tabularx width=\textwidth align=l|lp{3cm}r|l
  | 1 | 2 | 3 |
  | 4 | 5 | 6 |

  and now a simple table

  | 1 | 2 | 3 |
  | 4 | 5 | 6 |
#+end_src

exports to the following tex
#+begin_src latex
  \begin{table*}[htb]
  \caption{A wide table with tabulary} \label{tbl:wide}
  \begin{center}
  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabulary}
  \end{center}
  \end{table*}


  \begin{table}[htb]
  \caption{A normal table with tabularx} \label{tbl:wide}
  \begin{center}
  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabularx}
  \end{center}
  \end{table}


  and now a simple table


  \begin{center}
  \begin{tabular}{rrr}
   1  &  2  &  3  \\
   4  &  5  &  6  \\
  \end{tabular}
  \end{center}
#+end_src


Thanks -- Eric

"Thomas S. Dye" <tsd@tsdye.com> writes:

> Hi Eric,
>
> A syntax like this, with a width attribute, seems most like Org-mode
> to me:
>
> #+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl
>
> If that isn't a reasonable possibility, then, yes, the square brackets
> should be changed.  These represent optional arguments in LaTeX.  The
> width argument is required by tabularx and tabulary, not optional, so
> it looks like an error from a LaTeX point of view.  Changing the
> square brackets to curly brackets in this case would have the
> advantage of looking a lot like the underlying LaTeX.
>
> All the best,
> Tom
>
> On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:
>
>> Hi Tom,
>>
>> Thanks for the pointer, how about this revised version of the patch.
>> It
>> takes the following inputs
>>
>> #+begin_src org
>>  #+CAPTION: A wide table with tabulary
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>>
>>  #+CAPTION: A normal table with tabularx
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>> #+end_src
>>
>> and yields the following output
>>
>> #+begin_src latex
>>  \begin{table*}[htb]
>>  \caption{A wide table with tabulary} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabulary}
>>  \end{center}
>>  \end{table*}
>>
>>
>>  \begin{table}[htb]
>>  \caption{A normal table with tabularx} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabularx}
>>  \end{center}
>>  \end{table}
>> #+end_src
>>
>> I'm not sure about the square bracket syntax, maybe curly would be
>> preferable.  Definitely open to suggestions.
>>
>> Should this be applied?  Are there any obvious areas for improvement?
>>
>> Thanks -- Eric
>>
>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>> index a261171..af0a15d 100644
>> --- a/lisp/org-latex.el
>> +++ b/lisp/org-latex.el
>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>              (org-table-last-column-widths (copy-sequence
>>                                             org-table-last-column-
>> widths))
>>              fnum fields line lines olines gr colgropen line-fmt align
>> -             caption shortn label attr floatp placement longtblp)
>> +             caption shortn label attr floatp placement longtblp
>> tblenv)
>>         (if org-export-latex-tables-verbatim
>>             (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>                                 "\\end{verbatim}\n")))
>> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                          'org-label raw-table)
>>                   longtblp (and attr (stringp attr)
>>                                 (string-match "\\<longtable\\>" attr))
>> +		  tblenv (if (and attr (stringp attr)
>> +				  (string-match (regexp-quote "table*") attr))
>> +			     "table*" "table")
>> +		  org-export-latex-tabular-environment
>> +		  (progn
>> +		    (message "attr:%s" attr)
>> +		    (if (and attr (stringp attr)
>> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
>> +			(list (match-string 1 attr) (match-string 2 attr))
>> +		      org-export-latex-tabular-environment))
>>                   align (and attr (stringp attr)
>>                              (string-match "\\<align=\\([^ \t\n\r]+\
>> \)" attr)
>>                              (match-string 1 attr))
>> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                        (concat
>>                         (if longtblp
>>                             (concat "\\begin{longtable}{" align "}\n")
>> -                          (if floatp (format "\\begin{table}%s\n"
>> placement)))
>> +                          (if floatp
>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>                         (if floatp
>>                             (format
>>                              "\\caption%s{%s} %s"
>> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                         (if (and org-export-latex-tables-centered
>> (not longtblp))
>>                             "\\begin{center}\n")
>>                         (if (not longtblp)
>> -			    (format "\\begin{%s}{%s}\n"
>> -				    org-export-latex-tabular-environment align))
>> +			    (if (listp org-export-latex-tabular-environment)
>> +				(apply
>> +				 #'format
>> +				 (append
>> +				  (list "\\begin{%s}{%s}{%s}\n")
>> +				  org-export-latex-tabular-environment
>> +				  (list align)))
>> +			      (format "\\begin{%s}{%s}\n"
>> +				      org-export-latex-tabular-environment align)))
>>                         (orgtbl-to-latex
>>                          lines
>>                          `(:tstart nil :tend nil
>> @@ -1847,12 +1865,14 @@ The conversion is made depending of STRING-
>> BEFORE and STRING-AFTER."
>>                                              nil)))
>>                         (if (not longtblp)
>> 			    (format "\n\\end{%s}"
>> -				    org-export-latex-tabular-environment))
>> +				    (if (listp org-export-latex-tabular-environment)
>> +					(car org-export-latex-tabular-environment)
>> +				      org-export-latex-tabular-environment)))
>>                         (if longtblp "\n" (if org-export-latex-
>> tables-centered
>>                                               "\n\\end{center}\n"
>> "\n"))
>>                         (if longtblp
>>                             "\\end{longtable}"
>> -                          (if floatp "\\end{table}"))))
>> +                          (if floatp (format "\\end{%s}" tblenv)))))
>>                       "\n\n"))))))))
>>
>> (defun org-export-latex-convert-table.el-table ()
>>
>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>
>>> Hi Eric,
>>>
>>> The syntax for tabularx and tabulary includes a width specification
>>> that is a required argument:
>>>
>>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>>
>>> This is typically set to something like \linewidth, \colwidth, or
>>> \textwidth, but might also take an absolute length like 250pt, 5in,
>>> etc.
>>>
>>> All the best,
>>> Tom
>>>
>>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>>
>>>> The attached patch implements the behavior described previously, so
>>>> for
>>>> example the following org
>>>>
>>>> #+begin_src org
>>>> #+CAPTION: A wide table with tabulary
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>> | 1 | 2 | 3 |
>>>> | 4 | 5 | 6 |
>>>>
>>>> #+CAPTION: A normal table with tabularx
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>>> | 1 | 2 | 3 |
>>>> | 4 | 5 | 6 |
>>>> #+end_src
>>>>
>>>> exports to the following latex
>>>>
>>>> #+begin_src latex
>>>> \begin{table*}[htb]
>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>> \begin{center}
>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>  1  &  2  &  3  \\
>>>>  4  &  5  &  6  \\
>>>> \end{tabulary}
>>>> \end{center}
>>>> \end{table*}
>>>>
>>>>
>>>> \begin{table}[htb]
>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>> \begin{center}
>>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>>  1  &  2  &  3  \\
>>>>  4  &  5  &  6  \\
>>>> \end{tabularx}
>>>> \end{center}
>>>> \end{table}
>>>> #+end_src
>>>>
>>>> Does this behavior and patch look reasonable?  If I don't hear by
>>>> the
>>>> end of the day I will apply this patch, I just wanted to check first
>>>> on
>>>> list as the export mechanisms aren't my personal area of expertise.
>>>>
>>>> Thanks -- Eric
>>>>
>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>> index a261171..66541de 100644
>>>> --- a/lisp/org-latex.el
>>>> +++ b/lisp/org-latex.el
>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>             (org-table-last-column-widths (copy-sequence
>>>>                                            org-table-last-column-
>>>> widths))
>>>>             fnum fields line lines olines gr colgropen line-fmt
>>>> align
>>>> -             caption shortn label attr floatp placement longtblp)
>>>> +             caption shortn label attr floatp placement longtblp
>>>> tblenv tblrenv)
>>>>        (if org-export-latex-tables-verbatim
>>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>                                "\\end{verbatim}\n")))
>>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                         'org-label raw-table)
>>>>                  longtblp (and attr (stringp attr)
>>>>                                (string-match "\\<longtable\\>"
>>>> attr))
>>>> +		  tblenv (if (and attr (stringp attr)
>>>> +				  (string-match (regexp-quote "table*") attr))
>>>> +			     "table*" "table")
>>>> +		  org-export-latex-tabular-environment
>>>> +		  (if (and attr (stringp attr)
>>>> +			   (string-match (regexp-quote "tabularx") attr))
>>>> +		      "tabularx"
>>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>>> +			"tabulary" org-export-latex-tabular-environment))
>>>>                  align (and attr (stringp attr)
>>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>>> \)" attr)
>>>>                             (match-string 1 attr))
>>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                       (concat
>>>>                        (if longtblp
>>>>                            (concat "\\begin{longtable}{" align "}
>>>> \n")
>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>> placement)))
>>>> +                          (if floatp
>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>                        (if floatp
>>>>                            (format
>>>>                             "\\caption%s{%s} %s"
>>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                                              "\n\\end{center}\n"
>>>> "\n"))
>>>>                        (if longtblp
>>>>                            "\\end{longtable}"
>>>> -                          (if floatp "\\end{table}"))))
>>>> +                          (if floatp (format "\\end{%s}"
>>>> tblenv)))))
>>>>                      "\n\n"))))))))
>>>>
>>>> (defun org-export-latex-convert-table.el-table ()
>>>>
>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>
>>>>> Hi Tom,
>>>>>
>>>>> Thanks for the informative list.  I had no idea LaTeX supported so
>>>>> many
>>>>> table options.  How about I update the patch so that is supports
>>>>> the
>>>>> following sets of mutually exclusive options...
>>>>> - longtable :: wraps the table in a longtable with no table or
>>>>> tabular
>>>>>              wrappers -- already implemented
>>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>>> contains an
>>>>>           inner tabular wrapper
>>>>> - tabular[xy] :: specifies the inner tabular wrapping environment,
>>>>> only
>>>>>                one can be specified
>>>>>
>>>>> so for example, the following
>>>>>
>>>>> #+begin_src org
>>>>> #+CAPTION: A wide table
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>> | ... | ... |
>>>>> | ... | ... |
>>>>> #+end_src
>>>>>
>>>>> results in the following
>>>>>
>>>>> #+begin_src latex
>>>>> \begin{table*}[htb]
>>>>> \caption{A wide table} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>  1  &  2  &  3  \\
>>>>>  4  &  5  &  6  \\
>>>>> \end{tabulary}
>>>>> \end{center}
>>>>> \end{table*}
>>>>> #+end_src
>>>>>
>>>>> Then the next question would be how to insert a =figure*= instead
>>>>> of a
>>>>> simple =figure= environment.
>>>>>
>>>>> Thanks -- Eric
>>>>>
>>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>>
>>>>>> Hi Eric,
>>>>>>
>>>>>> It would be great to have a more general solution.  Tables are
>>>>>> hard to
>>>>>> typeset, so it might take a while to come up with a good
>>>>>> specification.  Here is what I know about the LaTeX side of
>>>>>> things.
>>>>>>
>>>>>> ** LaTeX destinations for an Org-mode table
>>>>>> *** Environments for typesetting a table
>>>>>>   - table placed in the output where it occurs in the input
>>>>>>   - all of these environments can be used on their own
>>>>>> **** tabular
>>>>>>    standard LaTeX environment, doesn't break across pages, no
>>>>>> caption
>>>>>> **** tabularx
>>>>>>    extended environment that can automatically calculate column
>>>>>>    widths and wrap text within table cells, doesn't break across
>>>>>>    pages, no caption
>>>>>> **** tabulary
>>>>>>    like tabularx, but tries harder to come up with optimal column
>>>>>> widths
>>>>>> **** supertabular
>>>>>>    extended tabular environment that breaks across pages, includes
>>>>>>    caption
>>>>>> **** supertabular*
>>>>>>    like supertabular, but for wide tables in a multicolumn page
>>>>>>    layout
>>>>>> **** mpsupertabular
>>>>>>    like supertabular, but also handles footnotes within the table
>>>>>> **** mpsupertabular*
>>>>>>    like mpsupertabular, but for multicolumn page layouts
>>>>>> **** longtable
>>>>>>    extended tabular environment that breaks across pages and
>>>>>>    includes a caption, but can't be used in a multicolumn page
>>>>>>    layout
>>>>>> *** Environment for floating a table and adding a caption
>>>>>>   floats a table typeset by some other environment to a place in
>>>>>> the
>>>>>>   output that LaTeX determines appropriate, probably not where it
>>>>>>   occurs in the input
>>>>>> **** =table=, single column document
>>>>>>    typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>> environment
>>>>>> **** =table*=, multi-column document
>>>>>>    typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>> environment
>>>>>> *** "Typical" uses
>>>>>>   In our report production work we regularly use seven setups:
>>>>>>   - table or table* wrapped around tabularx or tabular
>>>>>>   - longtable
>>>>>>   - tabular or tabularx on their own
>>>>>>
>>>>>> hth,
>>>>>> Tom
>>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> The attached patch allows the use of table* latex tables from
>>>>>>> within
>>>>>>> Org
>>>>>>> mode documents using the attr_latex lines, for example
>>>>>>>
>>>>>>> #+CAPTION: A wide table
>>>>>>> #+LABEL: tbl:wide
>>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>>> | ... | ... |
>>>>>>> | ... | ... |
>>>>>>>
>>>>>>> Should this be added, or should we put together a more general
>>>>>>> solution
>>>>>>> for different types of table environments?  Currently only
>>>>>>> longtable
>>>>>>> is
>>>>>>> supported.  Also, is there already a way to do this that I have
>>>>>>> missed?
>>>>>>>
>>>>>>> Thanks -- Eric
>>>>>>>
>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>> index a261171..b7f48d3 100644
>>>>>>> --- a/lisp/org-latex.el
>>>>>>> +++ b/lisp/org-latex.el
>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>>>                                           org-table-last-column-
>>>>>>> widths))
>>>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>>>> align
>>>>>>> -             caption shortn label attr floatp placement
>>>>>>> longtblp)
>>>>>>> +             caption shortn label attr floatp placement longtblp
>>>>>>> tblenv)
>>>>>>>       (if org-export-latex-tables-verbatim
>>>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>                               "\\end{verbatim}\n")))
>>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                        'org-label raw-table)
>>>>>>>                 longtblp (and attr (stringp attr)
>>>>>>>                               (string-match "\\<longtable\\>"
>>>>>>> attr))
>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>> +			     "table*" "table")
>>>>>>>                 align (and attr (stringp attr)
>>>>>>>                            (string-match "\\<align=\\([^
>>>>>>> \t\n\r]
>>>>>>> +\
>>>>>>> \)" attr)
>>>>>>>                            (match-string 1 attr))
>>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                      (concat
>>>>>>>                       (if longtblp
>>>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>>>> \n")
>>>>>>> -                          (if floatp (format "\\begin{table}%s
>>>>>>> \n"
>>>>>>> placement)))
>>>>>>> +                          (if floatp
>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>                       (if floatp
>>>>>>>                           (format
>>>>>>>                            "\\caption%s{%s} %s"
>>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                                             "\n\\end{center}\n"
>>>>>>> "\n"))
>>>>>>>                       (if longtblp
>>>>>>>                           "\\end{longtable}"
>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>> tblenv)))))
>>>>>>>                     "\n\n"))))))))
>>>>>>>
>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>> _______________________________________________
>>>>>>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17 20:39             ` Eric Schulte
@ 2010-12-17 20:44               ` Carsten Dominik
  2010-12-17 21:01                 ` Eric Schulte
  2010-12-18 20:18               ` Thomas S. Dye
  1 sibling, 1 reply; 12+ messages in thread
From: Carsten Dominik @ 2010-12-17 20:44 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode

This is great, I like it.  Maybe a change to the manual
would be appropriate?

Best wishes

- Carsten

On Dec 17, 2010, at 9:39 PM, Eric Schulte wrote:

> Hi Tom,
>
> Thanks for all you help on this front.  I've just pushed up the patch
> with your suggested syntax (which is much better than my original).   
> It
> allows the following behavior.
>
> The following org
> #+begin_src org
>  #+CAPTION: A wide table with tabulary
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table* tabulary width=\textwidth align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  #+CAPTION: A normal table with tabularx
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table tabularx width=\textwidth align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  and now a simple table
>
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
> #+end_src
>
> exports to the following tex
> #+begin_src latex
>  \begin{table*}[htb]
>  \caption{A wide table with tabulary} \label{tbl:wide}
>  \begin{center}
>  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabulary}
>  \end{center}
>  \end{table*}
>
>
>  \begin{table}[htb]
>  \caption{A normal table with tabularx} \label{tbl:wide}
>  \begin{center}
>  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabularx}
>  \end{center}
>  \end{table}
>
>
>  and now a simple table
>
>
>  \begin{center}
>  \begin{tabular}{rrr}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabular}
>  \end{center}
> #+end_src
>
>
> Thanks -- Eric
>
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> Hi Eric,
>>
>> A syntax like this, with a width attribute, seems most like Org-mode
>> to me:
>>
>> #+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl
>>
>> If that isn't a reasonable possibility, then, yes, the square  
>> brackets
>> should be changed.  These represent optional arguments in LaTeX.  The
>> width argument is required by tabularx and tabulary, not optional, so
>> it looks like an error from a LaTeX point of view.  Changing the
>> square brackets to curly brackets in this case would have the
>> advantage of looking a lot like the underlying LaTeX.
>>
>> All the best,
>> Tom
>>
>> On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:
>>
>>> Hi Tom,
>>>
>>> Thanks for the pointer, how about this revised version of the patch.
>>> It
>>> takes the following inputs
>>>
>>> #+begin_src org
>>> #+CAPTION: A wide table with tabulary
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>>
>>> #+CAPTION: A normal table with tabularx
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>> #+end_src
>>>
>>> and yields the following output
>>>
>>> #+begin_src latex
>>> \begin{table*}[htb]
>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabulary}
>>> \end{center}
>>> \end{table*}
>>>
>>>
>>> \begin{table}[htb]
>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabularx}
>>> \end{center}
>>> \end{table}
>>> #+end_src
>>>
>>> I'm not sure about the square bracket syntax, maybe curly would be
>>> preferable.  Definitely open to suggestions.
>>>
>>> Should this be applied?  Are there any obvious areas for  
>>> improvement?
>>>
>>> Thanks -- Eric
>>>
>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>> index a261171..af0a15d 100644
>>> --- a/lisp/org-latex.el
>>> +++ b/lisp/org-latex.el
>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>             (org-table-last-column-widths (copy-sequence
>>>                                            org-table-last-column-
>>> widths))
>>>             fnum fields line lines olines gr colgropen line-fmt  
>>> align
>>> -             caption shortn label attr floatp placement longtblp)
>>> +             caption shortn label attr floatp placement longtblp
>>> tblenv)
>>>        (if org-export-latex-tables-verbatim
>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>                                "\\end{verbatim}\n")))
>>> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                         'org-label raw-table)
>>>                  longtblp (and attr (stringp attr)
>>>                                (string-match "\\<longtable\\>"  
>>> attr))
>>> +		  tblenv (if (and attr (stringp attr)
>>> +				  (string-match (regexp-quote "table*") attr))
>>> +			     "table*" "table")
>>> +		  org-export-latex-tabular-environment
>>> +		  (progn
>>> +		    (message "attr:%s" attr)
>>> +		    (if (and attr (stringp attr)
>>> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
>>> +			(list (match-string 1 attr) (match-string 2 attr))
>>> +		      org-export-latex-tabular-environment))
>>>                  align (and attr (stringp attr)
>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>> \)" attr)
>>>                             (match-string 1 attr))
>>> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                       (concat
>>>                        (if longtblp
>>>                            (concat "\\begin{longtable}{" align "} 
>>> \n")
>>> -                          (if floatp (format "\\begin{table}%s\n"
>>> placement)))
>>> +                          (if floatp
>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>                        (if floatp
>>>                            (format
>>>                             "\\caption%s{%s} %s"
>>> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                        (if (and org-export-latex-tables-centered
>>> (not longtblp))
>>>                            "\\begin{center}\n")
>>>                        (if (not longtblp)
>>> -			    (format "\\begin{%s}{%s}\n"
>>> -				    org-export-latex-tabular-environment align))
>>> +			    (if (listp org-export-latex-tabular-environment)
>>> +				(apply
>>> +				 #'format
>>> +				 (append
>>> +				  (list "\\begin{%s}{%s}{%s}\n")
>>> +				  org-export-latex-tabular-environment
>>> +				  (list align)))
>>> +			      (format "\\begin{%s}{%s}\n"
>>> +				      org-export-latex-tabular-environment align)))
>>>                        (orgtbl-to-latex
>>>                         lines
>>>                         `(:tstart nil :tend nil
>>> @@ -1847,12 +1865,14 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                                             nil)))
>>>                        (if (not longtblp)
>>> 			    (format "\n\\end{%s}"
>>> -				    org-export-latex-tabular-environment))
>>> +				    (if (listp org-export-latex-tabular-environment)
>>> +					(car org-export-latex-tabular-environment)
>>> +				      org-export-latex-tabular-environment)))
>>>                        (if longtblp "\n" (if org-export-latex-
>>> tables-centered
>>>                                              "\n\\end{center}\n"
>>> "\n"))
>>>                        (if longtblp
>>>                            "\\end{longtable}"
>>> -                          (if floatp "\\end{table}"))))
>>> +                          (if floatp (format "\\end{%s}"  
>>> tblenv)))))
>>>                      "\n\n"))))))))
>>>
>>> (defun org-export-latex-convert-table.el-table ()
>>>
>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> The syntax for tabularx and tabulary includes a width specification
>>>> that is a required argument:
>>>>
>>>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>>>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>>>
>>>> This is typically set to something like \linewidth, \colwidth, or
>>>> \textwidth, but might also take an absolute length like 250pt, 5in,
>>>> etc.
>>>>
>>>> All the best,
>>>> Tom
>>>>
>>>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>>>
>>>>> The attached patch implements the behavior described previously,  
>>>>> so
>>>>> for
>>>>> example the following org
>>>>>
>>>>> #+begin_src org
>>>>> #+CAPTION: A wide table with tabulary
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>>
>>>>> #+CAPTION: A normal table with tabularx
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>> #+end_src
>>>>>
>>>>> exports to the following latex
>>>>>
>>>>> #+begin_src latex
>>>>> \begin{table*}[htb]
>>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabulary}
>>>>> \end{center}
>>>>> \end{table*}
>>>>>
>>>>>
>>>>> \begin{table}[htb]
>>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabularx}
>>>>> \end{center}
>>>>> \end{table}
>>>>> #+end_src
>>>>>
>>>>> Does this behavior and patch look reasonable?  If I don't hear by
>>>>> the
>>>>> end of the day I will apply this patch, I just wanted to check  
>>>>> first
>>>>> on
>>>>> list as the export mechanisms aren't my personal area of  
>>>>> expertise.
>>>>>
>>>>> Thanks -- Eric
>>>>>
>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>> index a261171..66541de 100644
>>>>> --- a/lisp/org-latex.el
>>>>> +++ b/lisp/org-latex.el
>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>                                           org-table-last-column-
>>>>> widths))
>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>> align
>>>>> -             caption shortn label attr floatp placement longtblp)
>>>>> +             caption shortn label attr floatp placement longtblp
>>>>> tblenv tblrenv)
>>>>>       (if org-export-latex-tables-verbatim
>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>                               "\\end{verbatim}\n")))
>>>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                        'org-label raw-table)
>>>>>                 longtblp (and attr (stringp attr)
>>>>>                               (string-match "\\<longtable\\>"
>>>>> attr))
>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>> +			     "table*" "table")
>>>>> +		  org-export-latex-tabular-environment
>>>>> +		  (if (and attr (stringp attr)
>>>>> +			   (string-match (regexp-quote "tabularx") attr))
>>>>> +		      "tabularx"
>>>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>>>> +			"tabulary" org-export-latex-tabular-environment))
>>>>>                 align (and attr (stringp attr)
>>>>>                            (string-match "\\<align=\\([^ \t\n\r]+\
>>>>> \)" attr)
>>>>>                            (match-string 1 attr))
>>>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                      (concat
>>>>>                       (if longtblp
>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>> \n")
>>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>>> placement)))
>>>>> +                          (if floatp
>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>                       (if floatp
>>>>>                           (format
>>>>>                            "\\caption%s{%s} %s"
>>>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                                             "\n\\end{center}\n"
>>>>> "\n"))
>>>>>                       (if longtblp
>>>>>                           "\\end{longtable}"
>>>>> -                          (if floatp "\\end{table}"))))
>>>>> +                          (if floatp (format "\\end{%s}"
>>>>> tblenv)))))
>>>>>                     "\n\n"))))))))
>>>>>
>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>
>>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>>
>>>>>> Hi Tom,
>>>>>>
>>>>>> Thanks for the informative list.  I had no idea LaTeX supported  
>>>>>> so
>>>>>> many
>>>>>> table options.  How about I update the patch so that is supports
>>>>>> the
>>>>>> following sets of mutually exclusive options...
>>>>>> - longtable :: wraps the table in a longtable with no table or
>>>>>> tabular
>>>>>>             wrappers -- already implemented
>>>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>>>> contains an
>>>>>>          inner tabular wrapper
>>>>>> - tabular[xy] :: specifies the inner tabular wrapping  
>>>>>> environment,
>>>>>> only
>>>>>>               one can be specified
>>>>>>
>>>>>> so for example, the following
>>>>>>
>>>>>> #+begin_src org
>>>>>> #+CAPTION: A wide table
>>>>>> #+LABEL: tbl:wide
>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>> | ... | ... |
>>>>>> | ... | ... |
>>>>>> #+end_src
>>>>>>
>>>>>> results in the following
>>>>>>
>>>>>> #+begin_src latex
>>>>>> \begin{table*}[htb]
>>>>>> \caption{A wide table} \label{tbl:wide}
>>>>>> \begin{center}
>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>> 1  &  2  &  3  \\
>>>>>> 4  &  5  &  6  \\
>>>>>> \end{tabulary}
>>>>>> \end{center}
>>>>>> \end{table*}
>>>>>> #+end_src
>>>>>>
>>>>>> Then the next question would be how to insert a =figure*= instead
>>>>>> of a
>>>>>> simple =figure= environment.
>>>>>>
>>>>>> Thanks -- Eric
>>>>>>
>>>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>>>
>>>>>>> Hi Eric,
>>>>>>>
>>>>>>> It would be great to have a more general solution.  Tables are
>>>>>>> hard to
>>>>>>> typeset, so it might take a while to come up with a good
>>>>>>> specification.  Here is what I know about the LaTeX side of
>>>>>>> things.
>>>>>>>
>>>>>>> ** LaTeX destinations for an Org-mode table
>>>>>>> *** Environments for typesetting a table
>>>>>>>  - table placed in the output where it occurs in the input
>>>>>>>  - all of these environments can be used on their own
>>>>>>> **** tabular
>>>>>>>   standard LaTeX environment, doesn't break across pages, no
>>>>>>> caption
>>>>>>> **** tabularx
>>>>>>>   extended environment that can automatically calculate column
>>>>>>>   widths and wrap text within table cells, doesn't break across
>>>>>>>   pages, no caption
>>>>>>> **** tabulary
>>>>>>>   like tabularx, but tries harder to come up with optimal column
>>>>>>> widths
>>>>>>> **** supertabular
>>>>>>>   extended tabular environment that breaks across pages,  
>>>>>>> includes
>>>>>>>   caption
>>>>>>> **** supertabular*
>>>>>>>   like supertabular, but for wide tables in a multicolumn page
>>>>>>>   layout
>>>>>>> **** mpsupertabular
>>>>>>>   like supertabular, but also handles footnotes within the table
>>>>>>> **** mpsupertabular*
>>>>>>>   like mpsupertabular, but for multicolumn page layouts
>>>>>>> **** longtable
>>>>>>>   extended tabular environment that breaks across pages and
>>>>>>>   includes a caption, but can't be used in a multicolumn page
>>>>>>>   layout
>>>>>>> *** Environment for floating a table and adding a caption
>>>>>>>  floats a table typeset by some other environment to a place in
>>>>>>> the
>>>>>>>  output that LaTeX determines appropriate, probably not where it
>>>>>>>  occurs in the input
>>>>>>> **** =table=, single column document
>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>> environment
>>>>>>> **** =table*=, multi-column document
>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>> environment
>>>>>>> *** "Typical" uses
>>>>>>>  In our report production work we regularly use seven setups:
>>>>>>>  - table or table* wrapped around tabularx or tabular
>>>>>>>  - longtable
>>>>>>>  - tabular or tabularx on their own
>>>>>>>
>>>>>>> hth,
>>>>>>> Tom
>>>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> The attached patch allows the use of table* latex tables from
>>>>>>>> within
>>>>>>>> Org
>>>>>>>> mode documents using the attr_latex lines, for example
>>>>>>>>
>>>>>>>> #+CAPTION: A wide table
>>>>>>>> #+LABEL: tbl:wide
>>>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>>>> | ... | ... |
>>>>>>>> | ... | ... |
>>>>>>>>
>>>>>>>> Should this be added, or should we put together a more general
>>>>>>>> solution
>>>>>>>> for different types of table environments?  Currently only
>>>>>>>> longtable
>>>>>>>> is
>>>>>>>> supported.  Also, is there already a way to do this that I have
>>>>>>>> missed?
>>>>>>>>
>>>>>>>> Thanks -- Eric
>>>>>>>>
>>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>>> index a261171..b7f48d3 100644
>>>>>>>> --- a/lisp/org-latex.el
>>>>>>>> +++ b/lisp/org-latex.el
>>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>           (org-table-last-column-widths (copy-sequence
>>>>>>>>                                          org-table-last-column-
>>>>>>>> widths))
>>>>>>>>           fnum fields line lines olines gr colgropen line-fmt
>>>>>>>> align
>>>>>>>> -             caption shortn label attr floatp placement
>>>>>>>> longtblp)
>>>>>>>> +             caption shortn label attr floatp placement  
>>>>>>>> longtblp
>>>>>>>> tblenv)
>>>>>>>>      (if org-export-latex-tables-verbatim
>>>>>>>>          (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>>                              "\\end{verbatim}\n")))
>>>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                       'org-label raw-table)
>>>>>>>>                longtblp (and attr (stringp attr)
>>>>>>>>                              (string-match "\\<longtable\\>"
>>>>>>>> attr))
>>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>>> +			     "table*" "table")
>>>>>>>>                align (and attr (stringp attr)
>>>>>>>>                           (string-match "\\<align=\\([^
>>>>>>>> \t\n\r]
>>>>>>>> +\
>>>>>>>> \)" attr)
>>>>>>>>                           (match-string 1 attr))
>>>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                     (concat
>>>>>>>>                      (if longtblp
>>>>>>>>                          (concat "\\begin{longtable}{" align "}
>>>>>>>> \n")
>>>>>>>> -                          (if floatp (format "\\begin{table}%s
>>>>>>>> \n"
>>>>>>>> placement)))
>>>>>>>> +                          (if floatp
>>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>>                      (if floatp
>>>>>>>>                          (format
>>>>>>>>                           "\\caption%s{%s} %s"
>>>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                                            "\n\\end{center}\n"
>>>>>>>> "\n"))
>>>>>>>>                      (if longtblp
>>>>>>>>                          "\\end{longtable}"
>>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>>> tblenv)))))
>>>>>>>>                    "\n\n"))))))))
>>>>>>>>
>>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>>> _______________________________________________
>>>>>>>> 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
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17 20:44               ` Carsten Dominik
@ 2010-12-17 21:01                 ` Eric Schulte
  2010-12-17 21:04                   ` Carsten Dominik
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Schulte @ 2010-12-17 21:01 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org Mode

Ah! you caught me :)

I've just pushed up documentation. -- Eric

Carsten Dominik <carsten.dominik@gmail.com> writes:

> This is great, I like it.  Maybe a change to the manual
> would be appropriate?
>
> Best wishes
>
> - Carsten
>
> On Dec 17, 2010, at 9:39 PM, Eric Schulte wrote:
>
>> Hi Tom,
>>
>> Thanks for all you help on this front.  I've just pushed up the patch
>> with your suggested syntax (which is much better than my original).
>> It
>> allows the following behavior.
>>
>> The following org
>> #+begin_src org
>>  #+CAPTION: A wide table with tabulary
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table* tabulary width=\textwidth align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>>
>>  #+CAPTION: A normal table with tabularx
>>  #+LABEL: tbl:wide
>>  #+ATTR_LaTeX: table tabularx width=\textwidth align=l|lp{3cm}r|l
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>>
>>  and now a simple table
>>
>>  | 1 | 2 | 3 |
>>  | 4 | 5 | 6 |
>> #+end_src
>>
>> exports to the following tex
>> #+begin_src latex
>>  \begin{table*}[htb]
>>  \caption{A wide table with tabulary} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabulary}
>>  \end{center}
>>  \end{table*}
>>
>>
>>  \begin{table}[htb]
>>  \caption{A normal table with tabularx} \label{tbl:wide}
>>  \begin{center}
>>  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabularx}
>>  \end{center}
>>  \end{table}
>>
>>
>>  and now a simple table
>>
>>
>>  \begin{center}
>>  \begin{tabular}{rrr}
>>   1  &  2  &  3  \\
>>   4  &  5  &  6  \\
>>  \end{tabular}
>>  \end{center}
>> #+end_src
>>
>>
>> Thanks -- Eric
>>
>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>
>>> Hi Eric,
>>>
>>> A syntax like this, with a width attribute, seems most like Org-mode
>>> to me:
>>>
>>> #+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl
>>>
>>> If that isn't a reasonable possibility, then, yes, the square
>>> brackets
>>> should be changed.  These represent optional arguments in LaTeX.  The
>>> width argument is required by tabularx and tabulary, not optional, so
>>> it looks like an error from a LaTeX point of view.  Changing the
>>> square brackets to curly brackets in this case would have the
>>> advantage of looking a lot like the underlying LaTeX.
>>>
>>> All the best,
>>> Tom
>>>
>>> On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:
>>>
>>>> Hi Tom,
>>>>
>>>> Thanks for the pointer, how about this revised version of the patch.
>>>> It
>>>> takes the following inputs
>>>>
>>>> #+begin_src org
>>>> #+CAPTION: A wide table with tabulary
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>>>> | 1 | 2 | 3 |
>>>> | 4 | 5 | 6 |
>>>>
>>>> #+CAPTION: A normal table with tabularx
>>>> #+LABEL: tbl:wide
>>>> #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>>>> | 1 | 2 | 3 |
>>>> | 4 | 5 | 6 |
>>>> #+end_src
>>>>
>>>> and yields the following output
>>>>
>>>> #+begin_src latex
>>>> \begin{table*}[htb]
>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>> \begin{center}
>>>> \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>>>  1  &  2  &  3  \\
>>>>  4  &  5  &  6  \\
>>>> \end{tabulary}
>>>> \end{center}
>>>> \end{table*}
>>>>
>>>>
>>>> \begin{table}[htb]
>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>> \begin{center}
>>>> \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>>>  1  &  2  &  3  \\
>>>>  4  &  5  &  6  \\
>>>> \end{tabularx}
>>>> \end{center}
>>>> \end{table}
>>>> #+end_src
>>>>
>>>> I'm not sure about the square bracket syntax, maybe curly would be
>>>> preferable.  Definitely open to suggestions.
>>>>
>>>> Should this be applied?  Are there any obvious areas for
>>>> improvement?
>>>>
>>>> Thanks -- Eric
>>>>
>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>> index a261171..af0a15d 100644
>>>> --- a/lisp/org-latex.el
>>>> +++ b/lisp/org-latex.el
>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>             (org-table-last-column-widths (copy-sequence
>>>>                                            org-table-last-column-
>>>> widths))
>>>>             fnum fields line lines olines gr colgropen line-fmt
>>>> align
>>>> -             caption shortn label attr floatp placement longtblp)
>>>> +             caption shortn label attr floatp placement longtblp
>>>> tblenv)
>>>>        (if org-export-latex-tables-verbatim
>>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>                                "\\end{verbatim}\n")))
>>>> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                         'org-label raw-table)
>>>>                  longtblp (and attr (stringp attr)
>>>>                                (string-match "\\<longtable\\>"
>>>> attr))
>>>> +		  tblenv (if (and attr (stringp attr)
>>>> +				  (string-match (regexp-quote "table*") attr))
>>>> +			     "table*" "table")
>>>> +		  org-export-latex-tabular-environment
>>>> +		  (progn
>>>> +		    (message "attr:%s" attr)
>>>> +		    (if (and attr (stringp attr)
>>>> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
>>>> +			(list (match-string 1 attr) (match-string 2 attr))
>>>> +		      org-export-latex-tabular-environment))
>>>>                  align (and attr (stringp attr)
>>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>>> \)" attr)
>>>>                             (match-string 1 attr))
>>>> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                       (concat
>>>>                        (if longtblp
>>>>                            (concat "\\begin{longtable}{" align "}
>>>> \n")
>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>> placement)))
>>>> +                          (if floatp
>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>                        (if floatp
>>>>                            (format
>>>>                             "\\caption%s{%s} %s"
>>>> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                        (if (and org-export-latex-tables-centered
>>>> (not longtblp))
>>>>                            "\\begin{center}\n")
>>>>                        (if (not longtblp)
>>>> -			    (format "\\begin{%s}{%s}\n"
>>>> -				    org-export-latex-tabular-environment align))
>>>> +			    (if (listp org-export-latex-tabular-environment)
>>>> +				(apply
>>>> +				 #'format
>>>> +				 (append
>>>> +				  (list "\\begin{%s}{%s}{%s}\n")
>>>> +				  org-export-latex-tabular-environment
>>>> +				  (list align)))
>>>> +			      (format "\\begin{%s}{%s}\n"
>>>> +				      org-export-latex-tabular-environment align)))
>>>>                        (orgtbl-to-latex
>>>>                         lines
>>>>                         `(:tstart nil :tend nil
>>>> @@ -1847,12 +1865,14 @@ The conversion is made depending of STRING-
>>>> BEFORE and STRING-AFTER."
>>>>                                             nil)))
>>>>                        (if (not longtblp)
>>>> 			    (format "\n\\end{%s}"
>>>> -				    org-export-latex-tabular-environment))
>>>> +				    (if (listp org-export-latex-tabular-environment)
>>>> +					(car org-export-latex-tabular-environment)
>>>> +				      org-export-latex-tabular-environment)))
>>>>                        (if longtblp "\n" (if org-export-latex-
>>>> tables-centered
>>>>                                              "\n\\end{center}\n"
>>>> "\n"))
>>>>                        (if longtblp
>>>>                            "\\end{longtable}"
>>>> -                          (if floatp "\\end{table}"))))
>>>> +                          (if floatp (format "\\end{%s}"
>>>> tblenv)))))
>>>>                      "\n\n"))))))))
>>>>
>>>> (defun org-export-latex-convert-table.el-table ()
>>>>
>>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>>
>>>>> Hi Eric,
>>>>>
>>>>> The syntax for tabularx and tabulary includes a width specification
>>>>> that is a required argument:
>>>>>
>>>>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>>>>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>>>>
>>>>> This is typically set to something like \linewidth, \colwidth, or
>>>>> \textwidth, but might also take an absolute length like 250pt, 5in,
>>>>> etc.
>>>>>
>>>>> All the best,
>>>>> Tom
>>>>>
>>>>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>>>>
>>>>>> The attached patch implements the behavior described previously,
>>>>>> so
>>>>>> for
>>>>>> example the following org
>>>>>>
>>>>>> #+begin_src org
>>>>>> #+CAPTION: A wide table with tabulary
>>>>>> #+LABEL: tbl:wide
>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>> | 1 | 2 | 3 |
>>>>>> | 4 | 5 | 6 |
>>>>>>
>>>>>> #+CAPTION: A normal table with tabularx
>>>>>> #+LABEL: tbl:wide
>>>>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>>>>> | 1 | 2 | 3 |
>>>>>> | 4 | 5 | 6 |
>>>>>> #+end_src
>>>>>>
>>>>>> exports to the following latex
>>>>>>
>>>>>> #+begin_src latex
>>>>>> \begin{table*}[htb]
>>>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>>>> \begin{center}
>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>> 1  &  2  &  3  \\
>>>>>> 4  &  5  &  6  \\
>>>>>> \end{tabulary}
>>>>>> \end{center}
>>>>>> \end{table*}
>>>>>>
>>>>>>
>>>>>> \begin{table}[htb]
>>>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>>>> \begin{center}
>>>>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>>>> 1  &  2  &  3  \\
>>>>>> 4  &  5  &  6  \\
>>>>>> \end{tabularx}
>>>>>> \end{center}
>>>>>> \end{table}
>>>>>> #+end_src
>>>>>>
>>>>>> Does this behavior and patch look reasonable?  If I don't hear by
>>>>>> the
>>>>>> end of the day I will apply this patch, I just wanted to check
>>>>>> first
>>>>>> on
>>>>>> list as the export mechanisms aren't my personal area of
>>>>>> expertise.
>>>>>>
>>>>>> Thanks -- Eric
>>>>>>
>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>> index a261171..66541de 100644
>>>>>> --- a/lisp/org-latex.el
>>>>>> +++ b/lisp/org-latex.el
>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>>                                           org-table-last-column-
>>>>>> widths))
>>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>>> align
>>>>>> -             caption shortn label attr floatp placement longtblp)
>>>>>> +             caption shortn label attr floatp placement longtblp
>>>>>> tblenv tblrenv)
>>>>>>       (if org-export-latex-tables-verbatim
>>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>                               "\\end{verbatim}\n")))
>>>>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                        'org-label raw-table)
>>>>>>                 longtblp (and attr (stringp attr)
>>>>>>                               (string-match "\\<longtable\\>"
>>>>>> attr))
>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>> +			     "table*" "table")
>>>>>> +		  org-export-latex-tabular-environment
>>>>>> +		  (if (and attr (stringp attr)
>>>>>> +			   (string-match (regexp-quote "tabularx") attr))
>>>>>> +		      "tabularx"
>>>>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>>>>> +			"tabulary" org-export-latex-tabular-environment))
>>>>>>                 align (and attr (stringp attr)
>>>>>>                            (string-match "\\<align=\\([^ \t\n\r]+\
>>>>>> \)" attr)
>>>>>>                            (match-string 1 attr))
>>>>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                      (concat
>>>>>>                       (if longtblp
>>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>>> \n")
>>>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>>>> placement)))
>>>>>> +                          (if floatp
>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>                       (if floatp
>>>>>>                           (format
>>>>>>                            "\\caption%s{%s} %s"
>>>>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>>>>>> BEFORE and STRING-AFTER."
>>>>>>                                             "\n\\end{center}\n"
>>>>>> "\n"))
>>>>>>                       (if longtblp
>>>>>>                           "\\end{longtable}"
>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>> tblenv)))))
>>>>>>                     "\n\n"))))))))
>>>>>>
>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>
>>>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>>>
>>>>>>> Hi Tom,
>>>>>>>
>>>>>>> Thanks for the informative list.  I had no idea LaTeX supported
>>>>>>> so
>>>>>>> many
>>>>>>> table options.  How about I update the patch so that is supports
>>>>>>> the
>>>>>>> following sets of mutually exclusive options...
>>>>>>> - longtable :: wraps the table in a longtable with no table or
>>>>>>> tabular
>>>>>>>             wrappers -- already implemented
>>>>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>>>>> contains an
>>>>>>>          inner tabular wrapper
>>>>>>> - tabular[xy] :: specifies the inner tabular wrapping
>>>>>>> environment,
>>>>>>> only
>>>>>>>               one can be specified
>>>>>>>
>>>>>>> so for example, the following
>>>>>>>
>>>>>>> #+begin_src org
>>>>>>> #+CAPTION: A wide table
>>>>>>> #+LABEL: tbl:wide
>>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>>> | ... | ... |
>>>>>>> | ... | ... |
>>>>>>> #+end_src
>>>>>>>
>>>>>>> results in the following
>>>>>>>
>>>>>>> #+begin_src latex
>>>>>>> \begin{table*}[htb]
>>>>>>> \caption{A wide table} \label{tbl:wide}
>>>>>>> \begin{center}
>>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>>> 1  &  2  &  3  \\
>>>>>>> 4  &  5  &  6  \\
>>>>>>> \end{tabulary}
>>>>>>> \end{center}
>>>>>>> \end{table*}
>>>>>>> #+end_src
>>>>>>>
>>>>>>> Then the next question would be how to insert a =figure*= instead
>>>>>>> of a
>>>>>>> simple =figure= environment.
>>>>>>>
>>>>>>> Thanks -- Eric
>>>>>>>
>>>>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>>>>
>>>>>>>> Hi Eric,
>>>>>>>>
>>>>>>>> It would be great to have a more general solution.  Tables are
>>>>>>>> hard to
>>>>>>>> typeset, so it might take a while to come up with a good
>>>>>>>> specification.  Here is what I know about the LaTeX side of
>>>>>>>> things.
>>>>>>>>
>>>>>>>> ** LaTeX destinations for an Org-mode table
>>>>>>>> *** Environments for typesetting a table
>>>>>>>>  - table placed in the output where it occurs in the input
>>>>>>>>  - all of these environments can be used on their own
>>>>>>>> **** tabular
>>>>>>>>   standard LaTeX environment, doesn't break across pages, no
>>>>>>>> caption
>>>>>>>> **** tabularx
>>>>>>>>   extended environment that can automatically calculate column
>>>>>>>>   widths and wrap text within table cells, doesn't break across
>>>>>>>>   pages, no caption
>>>>>>>> **** tabulary
>>>>>>>>   like tabularx, but tries harder to come up with optimal column
>>>>>>>> widths
>>>>>>>> **** supertabular
>>>>>>>>   extended tabular environment that breaks across pages,
>>>>>>>> includes
>>>>>>>>   caption
>>>>>>>> **** supertabular*
>>>>>>>>   like supertabular, but for wide tables in a multicolumn page
>>>>>>>>   layout
>>>>>>>> **** mpsupertabular
>>>>>>>>   like supertabular, but also handles footnotes within the table
>>>>>>>> **** mpsupertabular*
>>>>>>>>   like mpsupertabular, but for multicolumn page layouts
>>>>>>>> **** longtable
>>>>>>>>   extended tabular environment that breaks across pages and
>>>>>>>>   includes a caption, but can't be used in a multicolumn page
>>>>>>>>   layout
>>>>>>>> *** Environment for floating a table and adding a caption
>>>>>>>>  floats a table typeset by some other environment to a place in
>>>>>>>> the
>>>>>>>>  output that LaTeX determines appropriate, probably not where it
>>>>>>>>  occurs in the input
>>>>>>>> **** =table=, single column document
>>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>>> environment
>>>>>>>> **** =table*=, multi-column document
>>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>>> environment
>>>>>>>> *** "Typical" uses
>>>>>>>>  In our report production work we regularly use seven setups:
>>>>>>>>  - table or table* wrapped around tabularx or tabular
>>>>>>>>  - longtable
>>>>>>>>  - tabular or tabularx on their own
>>>>>>>>
>>>>>>>> hth,
>>>>>>>> Tom
>>>>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> The attached patch allows the use of table* latex tables from
>>>>>>>>> within
>>>>>>>>> Org
>>>>>>>>> mode documents using the attr_latex lines, for example
>>>>>>>>>
>>>>>>>>> #+CAPTION: A wide table
>>>>>>>>> #+LABEL: tbl:wide
>>>>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>>>>> | ... | ... |
>>>>>>>>> | ... | ... |
>>>>>>>>>
>>>>>>>>> Should this be added, or should we put together a more general
>>>>>>>>> solution
>>>>>>>>> for different types of table environments?  Currently only
>>>>>>>>> longtable
>>>>>>>>> is
>>>>>>>>> supported.  Also, is there already a way to do this that I have
>>>>>>>>> missed?
>>>>>>>>>
>>>>>>>>> Thanks -- Eric
>>>>>>>>>
>>>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>>>> index a261171..b7f48d3 100644
>>>>>>>>> --- a/lisp/org-latex.el
>>>>>>>>> +++ b/lisp/org-latex.el
>>>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of
>>>>>>>>> STRING-
>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>           (org-table-last-column-widths (copy-sequence
>>>>>>>>>                                          org-table-last-column-
>>>>>>>>> widths))
>>>>>>>>>           fnum fields line lines olines gr colgropen line-fmt
>>>>>>>>> align
>>>>>>>>> -             caption shortn label attr floatp placement
>>>>>>>>> longtblp)
>>>>>>>>> +             caption shortn label attr floatp placement
>>>>>>>>> longtblp
>>>>>>>>> tblenv)
>>>>>>>>>      (if org-export-latex-tables-verbatim
>>>>>>>>>          (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>>>                              "\\end{verbatim}\n")))
>>>>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of
>>>>>>>>> STRING-
>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>                       'org-label raw-table)
>>>>>>>>>                longtblp (and attr (stringp attr)
>>>>>>>>>                              (string-match "\\<longtable\\>"
>>>>>>>>> attr))
>>>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>>>> +			     "table*" "table")
>>>>>>>>>                align (and attr (stringp attr)
>>>>>>>>>                           (string-match "\\<align=\\([^
>>>>>>>>> \t\n\r]
>>>>>>>>> +\
>>>>>>>>> \)" attr)
>>>>>>>>>                           (match-string 1 attr))
>>>>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of
>>>>>>>>> STRING-
>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>                     (concat
>>>>>>>>>                      (if longtblp
>>>>>>>>>                          (concat "\\begin{longtable}{" align "}
>>>>>>>>> \n")
>>>>>>>>> -                          (if floatp (format "\\begin{table}%s
>>>>>>>>> \n"
>>>>>>>>> placement)))
>>>>>>>>> +                          (if floatp
>>>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>>>                      (if floatp
>>>>>>>>>                          (format
>>>>>>>>>                           "\\caption%s{%s} %s"
>>>>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of
>>>>>>>>> STRING-
>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>                                            "\n\\end{center}\n"
>>>>>>>>> "\n"))
>>>>>>>>>                      (if longtblp
>>>>>>>>>                          "\\end{longtable}"
>>>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>>>> tblenv)))))
>>>>>>>>>                    "\n\n"))))))))
>>>>>>>>>
>>>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>>>> _______________________________________________
>>>>>>>>> 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
>>
>> _______________________________________________
>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17 21:01                 ` Eric Schulte
@ 2010-12-17 21:04                   ` Carsten Dominik
  0 siblings, 0 replies; 12+ messages in thread
From: Carsten Dominik @ 2010-12-17 21:04 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode


On Dec 17, 2010, at 10:01 PM, Eric Schulte wrote:

> Ah! you caught me :)
>
> I've just pushed up documentation. -- Eric

Thank you, Eric.

- Carsten

>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> This is great, I like it.  Maybe a change to the manual
>> would be appropriate?
>>
>> Best wishes
>>
>> - Carsten
>>
>> On Dec 17, 2010, at 9:39 PM, Eric Schulte wrote:
>>
>>> Hi Tom,
>>>
>>> Thanks for all you help on this front.  I've just pushed up the  
>>> patch
>>> with your suggested syntax (which is much better than my original).
>>> It
>>> allows the following behavior.
>>>
>>> The following org
>>> #+begin_src org
>>> #+CAPTION: A wide table with tabulary
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table* tabulary width=\textwidth align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>>
>>> #+CAPTION: A normal table with tabularx
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table tabularx width=\textwidth align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>>
>>> and now a simple table
>>>
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>> #+end_src
>>>
>>> exports to the following tex
>>> #+begin_src latex
>>> \begin{table*}[htb]
>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabulary}
>>> \end{center}
>>> \end{table*}
>>>
>>>
>>> \begin{table}[htb]
>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabularx}
>>> \end{center}
>>> \end{table}
>>>
>>>
>>> and now a simple table
>>>
>>>
>>> \begin{center}
>>> \begin{tabular}{rrr}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabular}
>>> \end{center}
>>> #+end_src
>>>
>>>
>>> Thanks -- Eric
>>>
>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> A syntax like this, with a width attribute, seems most like Org- 
>>>> mode
>>>> to me:
>>>>
>>>> #+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl
>>>>
>>>> If that isn't a reasonable possibility, then, yes, the square
>>>> brackets
>>>> should be changed.  These represent optional arguments in LaTeX.   
>>>> The
>>>> width argument is required by tabularx and tabulary, not  
>>>> optional, so
>>>> it looks like an error from a LaTeX point of view.  Changing the
>>>> square brackets to curly brackets in this case would have the
>>>> advantage of looking a lot like the underlying LaTeX.
>>>>
>>>> All the best,
>>>> Tom
>>>>
>>>> On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:
>>>>
>>>>> Hi Tom,
>>>>>
>>>>> Thanks for the pointer, how about this revised version of the  
>>>>> patch.
>>>>> It
>>>>> takes the following inputs
>>>>>
>>>>> #+begin_src org
>>>>> #+CAPTION: A wide table with tabulary
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>>
>>>>> #+CAPTION: A normal table with tabularx
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>> #+end_src
>>>>>
>>>>> and yields the following output
>>>>>
>>>>> #+begin_src latex
>>>>> \begin{table*}[htb]
>>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabulary}
>>>>> \end{center}
>>>>> \end{table*}
>>>>>
>>>>>
>>>>> \begin{table}[htb]
>>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabularx}
>>>>> \end{center}
>>>>> \end{table}
>>>>> #+end_src
>>>>>
>>>>> I'm not sure about the square bracket syntax, maybe curly would be
>>>>> preferable.  Definitely open to suggestions.
>>>>>
>>>>> Should this be applied?  Are there any obvious areas for
>>>>> improvement?
>>>>>
>>>>> Thanks -- Eric
>>>>>
>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>> index a261171..af0a15d 100644
>>>>> --- a/lisp/org-latex.el
>>>>> +++ b/lisp/org-latex.el
>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>                                           org-table-last-column-
>>>>> widths))
>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>> align
>>>>> -             caption shortn label attr floatp placement longtblp)
>>>>> +             caption shortn label attr floatp placement longtblp
>>>>> tblenv)
>>>>>       (if org-export-latex-tables-verbatim
>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>                               "\\end{verbatim}\n")))
>>>>> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                        'org-label raw-table)
>>>>>                 longtblp (and attr (stringp attr)
>>>>>                               (string-match "\\<longtable\\>"
>>>>> attr))
>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>> +			     "table*" "table")
>>>>> +		  org-export-latex-tabular-environment
>>>>> +		  (progn
>>>>> +		    (message "attr:%s" attr)
>>>>> +		    (if (and attr (stringp attr)
>>>>> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
>>>>> +			(list (match-string 1 attr) (match-string 2 attr))
>>>>> +		      org-export-latex-tabular-environment))
>>>>>                 align (and attr (stringp attr)
>>>>>                            (string-match "\\<align=\\([^ \t\n\r]+\
>>>>> \)" attr)
>>>>>                            (match-string 1 attr))
>>>>> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                      (concat
>>>>>                       (if longtblp
>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>> \n")
>>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>>> placement)))
>>>>> +                          (if floatp
>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>                       (if floatp
>>>>>                           (format
>>>>>                            "\\caption%s{%s} %s"
>>>>> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                       (if (and org-export-latex-tables-centered
>>>>> (not longtblp))
>>>>>                           "\\begin{center}\n")
>>>>>                       (if (not longtblp)
>>>>> -			    (format "\\begin{%s}{%s}\n"
>>>>> -				    org-export-latex-tabular-environment align))
>>>>> +			    (if (listp org-export-latex-tabular-environment)
>>>>> +				(apply
>>>>> +				 #'format
>>>>> +				 (append
>>>>> +				  (list "\\begin{%s}{%s}{%s}\n")
>>>>> +				  org-export-latex-tabular-environment
>>>>> +				  (list align)))
>>>>> +			      (format "\\begin{%s}{%s}\n"
>>>>> +				      org-export-latex-tabular-environment align)))
>>>>>                       (orgtbl-to-latex
>>>>>                        lines
>>>>>                        `(:tstart nil :tend nil
>>>>> @@ -1847,12 +1865,14 @@ The conversion is made depending of  
>>>>> STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                                            nil)))
>>>>>                       (if (not longtblp)
>>>>> 			    (format "\n\\end{%s}"
>>>>> -				    org-export-latex-tabular-environment))
>>>>> +				    (if (listp org-export-latex-tabular-environment)
>>>>> +					(car org-export-latex-tabular-environment)
>>>>> +				      org-export-latex-tabular-environment)))
>>>>>                       (if longtblp "\n" (if org-export-latex-
>>>>> tables-centered
>>>>>                                             "\n\\end{center}\n"
>>>>> "\n"))
>>>>>                       (if longtblp
>>>>>                           "\\end{longtable}"
>>>>> -                          (if floatp "\\end{table}"))))
>>>>> +                          (if floatp (format "\\end{%s}"
>>>>> tblenv)))))
>>>>>                     "\n\n"))))))))
>>>>>
>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>
>>>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>>>
>>>>>> Hi Eric,
>>>>>>
>>>>>> The syntax for tabularx and tabulary includes a width  
>>>>>> specification
>>>>>> that is a required argument:
>>>>>>
>>>>>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>>>>>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>>>>>
>>>>>> This is typically set to something like \linewidth, \colwidth, or
>>>>>> \textwidth, but might also take an absolute length like 250pt,  
>>>>>> 5in,
>>>>>> etc.
>>>>>>
>>>>>> All the best,
>>>>>> Tom
>>>>>>
>>>>>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>>>>>
>>>>>>> The attached patch implements the behavior described previously,
>>>>>>> so
>>>>>>> for
>>>>>>> example the following org
>>>>>>>
>>>>>>> #+begin_src org
>>>>>>> #+CAPTION: A wide table with tabulary
>>>>>>> #+LABEL: tbl:wide
>>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>>> | 1 | 2 | 3 |
>>>>>>> | 4 | 5 | 6 |
>>>>>>>
>>>>>>> #+CAPTION: A normal table with tabularx
>>>>>>> #+LABEL: tbl:wide
>>>>>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>>>>>> | 1 | 2 | 3 |
>>>>>>> | 4 | 5 | 6 |
>>>>>>> #+end_src
>>>>>>>
>>>>>>> exports to the following latex
>>>>>>>
>>>>>>> #+begin_src latex
>>>>>>> \begin{table*}[htb]
>>>>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>>>>> \begin{center}
>>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>>> 1  &  2  &  3  \\
>>>>>>> 4  &  5  &  6  \\
>>>>>>> \end{tabulary}
>>>>>>> \end{center}
>>>>>>> \end{table*}
>>>>>>>
>>>>>>>
>>>>>>> \begin{table}[htb]
>>>>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>>>>> \begin{center}
>>>>>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>>>>> 1  &  2  &  3  \\
>>>>>>> 4  &  5  &  6  \\
>>>>>>> \end{tabularx}
>>>>>>> \end{center}
>>>>>>> \end{table}
>>>>>>> #+end_src
>>>>>>>
>>>>>>> Does this behavior and patch look reasonable?  If I don't hear  
>>>>>>> by
>>>>>>> the
>>>>>>> end of the day I will apply this patch, I just wanted to check
>>>>>>> first
>>>>>>> on
>>>>>>> list as the export mechanisms aren't my personal area of
>>>>>>> expertise.
>>>>>>>
>>>>>>> Thanks -- Eric
>>>>>>>
>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>> index a261171..66541de 100644
>>>>>>> --- a/lisp/org-latex.el
>>>>>>> +++ b/lisp/org-latex.el
>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of  
>>>>>>> STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>           (org-table-last-column-widths (copy-sequence
>>>>>>>                                          org-table-last-column-
>>>>>>> widths))
>>>>>>>           fnum fields line lines olines gr colgropen line-fmt
>>>>>>> align
>>>>>>> -             caption shortn label attr floatp placement  
>>>>>>> longtblp)
>>>>>>> +             caption shortn label attr floatp placement  
>>>>>>> longtblp
>>>>>>> tblenv tblrenv)
>>>>>>>      (if org-export-latex-tables-verbatim
>>>>>>>          (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>                              "\\end{verbatim}\n")))
>>>>>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of  
>>>>>>> STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                       'org-label raw-table)
>>>>>>>                longtblp (and attr (stringp attr)
>>>>>>>                              (string-match "\\<longtable\\>"
>>>>>>> attr))
>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>> +			     "table*" "table")
>>>>>>> +		  org-export-latex-tabular-environment
>>>>>>> +		  (if (and attr (stringp attr)
>>>>>>> +			   (string-match (regexp-quote "tabularx") attr))
>>>>>>> +		      "tabularx"
>>>>>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>>>>>> +			"tabulary" org-export-latex-tabular-environment))
>>>>>>>                align (and attr (stringp attr)
>>>>>>>                           (string-match "\\<align=\\([^ \t\n\r] 
>>>>>>> +\
>>>>>>> \)" attr)
>>>>>>>                           (match-string 1 attr))
>>>>>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of  
>>>>>>> STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                     (concat
>>>>>>>                      (if longtblp
>>>>>>>                          (concat "\\begin{longtable}{" align "}
>>>>>>> \n")
>>>>>>> -                          (if floatp (format "\\begin{table}%s 
>>>>>>> \n"
>>>>>>> placement)))
>>>>>>> +                          (if floatp
>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>                      (if floatp
>>>>>>>                          (format
>>>>>>>                           "\\caption%s{%s} %s"
>>>>>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of  
>>>>>>> STRING-
>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>                                            "\n\\end{center}\n"
>>>>>>> "\n"))
>>>>>>>                      (if longtblp
>>>>>>>                          "\\end{longtable}"
>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>> tblenv)))))
>>>>>>>                    "\n\n"))))))))
>>>>>>>
>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>>
>>>>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>>>>
>>>>>>>> Hi Tom,
>>>>>>>>
>>>>>>>> Thanks for the informative list.  I had no idea LaTeX supported
>>>>>>>> so
>>>>>>>> many
>>>>>>>> table options.  How about I update the patch so that is  
>>>>>>>> supports
>>>>>>>> the
>>>>>>>> following sets of mutually exclusive options...
>>>>>>>> - longtable :: wraps the table in a longtable with no table or
>>>>>>>> tabular
>>>>>>>>            wrappers -- already implemented
>>>>>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>>>>>> contains an
>>>>>>>>         inner tabular wrapper
>>>>>>>> - tabular[xy] :: specifies the inner tabular wrapping
>>>>>>>> environment,
>>>>>>>> only
>>>>>>>>              one can be specified
>>>>>>>>
>>>>>>>> so for example, the following
>>>>>>>>
>>>>>>>> #+begin_src org
>>>>>>>> #+CAPTION: A wide table
>>>>>>>> #+LABEL: tbl:wide
>>>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>>>> | ... | ... |
>>>>>>>> | ... | ... |
>>>>>>>> #+end_src
>>>>>>>>
>>>>>>>> results in the following
>>>>>>>>
>>>>>>>> #+begin_src latex
>>>>>>>> \begin{table*}[htb]
>>>>>>>> \caption{A wide table} \label{tbl:wide}
>>>>>>>> \begin{center}
>>>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>>>> 1  &  2  &  3  \\
>>>>>>>> 4  &  5  &  6  \\
>>>>>>>> \end{tabulary}
>>>>>>>> \end{center}
>>>>>>>> \end{table*}
>>>>>>>> #+end_src
>>>>>>>>
>>>>>>>> Then the next question would be how to insert a =figure*=  
>>>>>>>> instead
>>>>>>>> of a
>>>>>>>> simple =figure= environment.
>>>>>>>>
>>>>>>>> Thanks -- Eric
>>>>>>>>
>>>>>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>>>>>
>>>>>>>>> Hi Eric,
>>>>>>>>>
>>>>>>>>> It would be great to have a more general solution.  Tables are
>>>>>>>>> hard to
>>>>>>>>> typeset, so it might take a while to come up with a good
>>>>>>>>> specification.  Here is what I know about the LaTeX side of
>>>>>>>>> things.
>>>>>>>>>
>>>>>>>>> ** LaTeX destinations for an Org-mode table
>>>>>>>>> *** Environments for typesetting a table
>>>>>>>>> - table placed in the output where it occurs in the input
>>>>>>>>> - all of these environments can be used on their own
>>>>>>>>> **** tabular
>>>>>>>>>  standard LaTeX environment, doesn't break across pages, no
>>>>>>>>> caption
>>>>>>>>> **** tabularx
>>>>>>>>>  extended environment that can automatically calculate column
>>>>>>>>>  widths and wrap text within table cells, doesn't break across
>>>>>>>>>  pages, no caption
>>>>>>>>> **** tabulary
>>>>>>>>>  like tabularx, but tries harder to come up with optimal  
>>>>>>>>> column
>>>>>>>>> widths
>>>>>>>>> **** supertabular
>>>>>>>>>  extended tabular environment that breaks across pages,
>>>>>>>>> includes
>>>>>>>>>  caption
>>>>>>>>> **** supertabular*
>>>>>>>>>  like supertabular, but for wide tables in a multicolumn page
>>>>>>>>>  layout
>>>>>>>>> **** mpsupertabular
>>>>>>>>>  like supertabular, but also handles footnotes within the  
>>>>>>>>> table
>>>>>>>>> **** mpsupertabular*
>>>>>>>>>  like mpsupertabular, but for multicolumn page layouts
>>>>>>>>> **** longtable
>>>>>>>>>  extended tabular environment that breaks across pages and
>>>>>>>>>  includes a caption, but can't be used in a multicolumn page
>>>>>>>>>  layout
>>>>>>>>> *** Environment for floating a table and adding a caption
>>>>>>>>> floats a table typeset by some other environment to a place in
>>>>>>>>> the
>>>>>>>>> output that LaTeX determines appropriate, probably not where  
>>>>>>>>> it
>>>>>>>>> occurs in the input
>>>>>>>>> **** =table=, single column document
>>>>>>>>>  typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>>>> environment
>>>>>>>>> **** =table*=, multi-column document
>>>>>>>>>  typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>>>> environment
>>>>>>>>> *** "Typical" uses
>>>>>>>>> In our report production work we regularly use seven setups:
>>>>>>>>> - table or table* wrapped around tabularx or tabular
>>>>>>>>> - longtable
>>>>>>>>> - tabular or tabularx on their own
>>>>>>>>>
>>>>>>>>> hth,
>>>>>>>>> Tom
>>>>>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> The attached patch allows the use of table* latex tables from
>>>>>>>>>> within
>>>>>>>>>> Org
>>>>>>>>>> mode documents using the attr_latex lines, for example
>>>>>>>>>>
>>>>>>>>>> #+CAPTION: A wide table
>>>>>>>>>> #+LABEL: tbl:wide
>>>>>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>>>>>> | ... | ... |
>>>>>>>>>> | ... | ... |
>>>>>>>>>>
>>>>>>>>>> Should this be added, or should we put together a more  
>>>>>>>>>> general
>>>>>>>>>> solution
>>>>>>>>>> for different types of table environments?  Currently only
>>>>>>>>>> longtable
>>>>>>>>>> is
>>>>>>>>>> supported.  Also, is there already a way to do this that I  
>>>>>>>>>> have
>>>>>>>>>> missed?
>>>>>>>>>>
>>>>>>>>>> Thanks -- Eric
>>>>>>>>>>
>>>>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>>>>> index a261171..b7f48d3 100644
>>>>>>>>>> --- a/lisp/org-latex.el
>>>>>>>>>> +++ b/lisp/org-latex.el
>>>>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of
>>>>>>>>>> STRING-
>>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>>          (org-table-last-column-widths (copy-sequence
>>>>>>>>>>                                         org-table-last- 
>>>>>>>>>> column-
>>>>>>>>>> widths))
>>>>>>>>>>          fnum fields line lines olines gr colgropen line-fmt
>>>>>>>>>> align
>>>>>>>>>> -             caption shortn label attr floatp placement
>>>>>>>>>> longtblp)
>>>>>>>>>> +             caption shortn label attr floatp placement
>>>>>>>>>> longtblp
>>>>>>>>>> tblenv)
>>>>>>>>>>     (if org-export-latex-tables-verbatim
>>>>>>>>>>         (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>>>>                             "\\end{verbatim}\n")))
>>>>>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of
>>>>>>>>>> STRING-
>>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>>                      'org-label raw-table)
>>>>>>>>>>               longtblp (and attr (stringp attr)
>>>>>>>>>>                             (string-match "\\<longtable\\>"
>>>>>>>>>> attr))
>>>>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>>>>> +			     "table*" "table")
>>>>>>>>>>               align (and attr (stringp attr)
>>>>>>>>>>                          (string-match "\\<align=\\([^
>>>>>>>>>> \t\n\r]
>>>>>>>>>> +\
>>>>>>>>>> \)" attr)
>>>>>>>>>>                          (match-string 1 attr))
>>>>>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of
>>>>>>>>>> STRING-
>>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>>                    (concat
>>>>>>>>>>                     (if longtblp
>>>>>>>>>>                         (concat "\\begin{longtable}{" align  
>>>>>>>>>> "}
>>>>>>>>>> \n")
>>>>>>>>>> -                          (if floatp (format "\ 
>>>>>>>>>> \begin{table}%s
>>>>>>>>>> \n"
>>>>>>>>>> placement)))
>>>>>>>>>> +                          (if floatp
>>>>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>>>>                     (if floatp
>>>>>>>>>>                         (format
>>>>>>>>>>                          "\\caption%s{%s} %s"
>>>>>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of
>>>>>>>>>> STRING-
>>>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>>>                                           "\n\\end{center}\n"
>>>>>>>>>> "\n"))
>>>>>>>>>>                     (if longtblp
>>>>>>>>>>                         "\\end{longtable}"
>>>>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>>>>> tblenv)))))
>>>>>>>>>>                   "\n\n"))))))))
>>>>>>>>>>
>>>>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>>>>> _______________________________________________
>>>>>>>>>> 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
>>>
>>> _______________________________________________
>>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: allow table* specification with #+ATTR_LaTeX:
  2010-12-17 20:39             ` Eric Schulte
  2010-12-17 20:44               ` Carsten Dominik
@ 2010-12-18 20:18               ` Thomas S. Dye
  1 sibling, 0 replies; 12+ messages in thread
From: Thomas S. Dye @ 2010-12-18 20:18 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org Mode

Hi Eric,

This is a very nice addition to the LaTeX exporter.   It opens up a  
lot of LaTeX to Org-mode users.

Users unfamiliar with LaTeX might be interested to know that standard  
LaTeX typesets captions as if they are beneath the captioned item.   
This means that the vertical spacing is wrong for captions set above  
tables.  The last time I checked, the correction in standard LaTeX  
involved a separate macro, topcaption, to use only with captions set  
above the item.

The Koma scripts solve this problem in a way that is convenient for  
Org-mode.  The option captions=tableheading causes the script to make  
the caption macro aware of its position relative to the captioned  
item, so that the proper vertical spacing can be applied in every case.

All the best,
Tom

On Dec 17, 2010, at 10:39 AM, Eric Schulte wrote:

> Hi Tom,
>
> Thanks for all you help on this front.  I've just pushed up the patch
> with your suggested syntax (which is much better than my original).   
> It
> allows the following behavior.
>
> The following org
> #+begin_src org
>  #+CAPTION: A wide table with tabulary
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table* tabulary width=\textwidth align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  #+CAPTION: A normal table with tabularx
>  #+LABEL: tbl:wide
>  #+ATTR_LaTeX: table tabularx width=\textwidth align=l|lp{3cm}r|l
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
>
>  and now a simple table
>
>  | 1 | 2 | 3 |
>  | 4 | 5 | 6 |
> #+end_src
>
> exports to the following tex
> #+begin_src latex
>  \begin{table*}[htb]
>  \caption{A wide table with tabulary} \label{tbl:wide}
>  \begin{center}
>  \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabulary}
>  \end{center}
>  \end{table*}
>
>
>  \begin{table}[htb]
>  \caption{A normal table with tabularx} \label{tbl:wide}
>  \begin{center}
>  \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabularx}
>  \end{center}
>  \end{table}
>
>
>  and now a simple table
>
>
>  \begin{center}
>  \begin{tabular}{rrr}
>   1  &  2  &  3  \\
>   4  &  5  &  6  \\
>  \end{tabular}
>  \end{center}
> #+end_src
>
>
> Thanks -- Eric
>
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>
>> Hi Eric,
>>
>> A syntax like this, with a width attribute, seems most like Org-mode
>> to me:
>>
>> #+ATTR_LaTeX table* tabularx width=\textwidth align=llXrl
>>
>> If that isn't a reasonable possibility, then, yes, the square  
>> brackets
>> should be changed.  These represent optional arguments in LaTeX.  The
>> width argument is required by tabularx and tabulary, not optional, so
>> it looks like an error from a LaTeX point of view.  Changing the
>> square brackets to curly brackets in this case would have the
>> advantage of looking a lot like the underlying LaTeX.
>>
>> All the best,
>> Tom
>>
>> On Dec 16, 2010, at 2:57 PM, Eric Schulte wrote:
>>
>>> Hi Tom,
>>>
>>> Thanks for the pointer, how about this revised version of the patch.
>>> It
>>> takes the following inputs
>>>
>>> #+begin_src org
>>> #+CAPTION: A wide table with tabulary
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table* tabulary[\textwidth] align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>>
>>> #+CAPTION: A normal table with tabularx
>>> #+LABEL: tbl:wide
>>> #+ATTR_LaTeX: table tabularx[\textwidth] align=l|lp{3cm}r|l
>>> | 1 | 2 | 3 |
>>> | 4 | 5 | 6 |
>>> #+end_src
>>>
>>> and yields the following output
>>>
>>> #+begin_src latex
>>> \begin{table*}[htb]
>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabulary}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabulary}
>>> \end{center}
>>> \end{table*}
>>>
>>>
>>> \begin{table}[htb]
>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>> \begin{center}
>>> \begin{tabularx}{\textwidth}{l|lp{3cm}r|l}
>>>  1  &  2  &  3  \\
>>>  4  &  5  &  6  \\
>>> \end{tabularx}
>>> \end{center}
>>> \end{table}
>>> #+end_src
>>>
>>> I'm not sure about the square bracket syntax, maybe curly would be
>>> preferable.  Definitely open to suggestions.
>>>
>>> Should this be applied?  Are there any obvious areas for  
>>> improvement?
>>>
>>> Thanks -- Eric
>>>
>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>> index a261171..af0a15d 100644
>>> --- a/lisp/org-latex.el
>>> +++ b/lisp/org-latex.el
>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>             (org-table-last-column-widths (copy-sequence
>>>                                            org-table-last-column-
>>> widths))
>>>             fnum fields line lines olines gr colgropen line-fmt  
>>> align
>>> -             caption shortn label attr floatp placement longtblp)
>>> +             caption shortn label attr floatp placement longtblp
>>> tblenv)
>>>        (if org-export-latex-tables-verbatim
>>>            (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>                                "\\end{verbatim}\n")))
>>> @@ -1758,6 +1758,16 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                         'org-label raw-table)
>>>                  longtblp (and attr (stringp attr)
>>>                                (string-match "\\<longtable\\>"  
>>> attr))
>>> +		  tblenv (if (and attr (stringp attr)
>>> +				  (string-match (regexp-quote "table*") attr))
>>> +			     "table*" "table")
>>> +		  org-export-latex-tabular-environment
>>> +		  (progn
>>> +		    (message "attr:%s" attr)
>>> +		    (if (and attr (stringp attr)
>>> +			     (string-match "\\(tabular.*\\)\\[\\(.+\\)\\]" attr))
>>> +			(list (match-string 1 attr) (match-string 2 attr))
>>> +		      org-export-latex-tabular-environment))
>>>                  align (and attr (stringp attr)
>>>                             (string-match "\\<align=\\([^ \t\n\r]+\
>>> \)" attr)
>>>                             (match-string 1 attr))
>>> @@ -1821,7 +1831,8 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                       (concat
>>>                        (if longtblp
>>>                            (concat "\\begin{longtable}{" align "} 
>>> \n")
>>> -                          (if floatp (format "\\begin{table}%s\n"
>>> placement)))
>>> +                          (if floatp
>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>                        (if floatp
>>>                            (format
>>>                             "\\caption%s{%s} %s"
>>> @@ -1832,8 +1843,15 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                        (if (and org-export-latex-tables-centered
>>> (not longtblp))
>>>                            "\\begin{center}\n")
>>>                        (if (not longtblp)
>>> -			    (format "\\begin{%s}{%s}\n"
>>> -				    org-export-latex-tabular-environment align))
>>> +			    (if (listp org-export-latex-tabular-environment)
>>> +				(apply
>>> +				 #'format
>>> +				 (append
>>> +				  (list "\\begin{%s}{%s}{%s}\n")
>>> +				  org-export-latex-tabular-environment
>>> +				  (list align)))
>>> +			      (format "\\begin{%s}{%s}\n"
>>> +				      org-export-latex-tabular-environment align)))
>>>                        (orgtbl-to-latex
>>>                         lines
>>>                         `(:tstart nil :tend nil
>>> @@ -1847,12 +1865,14 @@ The conversion is made depending of STRING-
>>> BEFORE and STRING-AFTER."
>>>                                             nil)))
>>>                        (if (not longtblp)
>>> 			    (format "\n\\end{%s}"
>>> -				    org-export-latex-tabular-environment))
>>> +				    (if (listp org-export-latex-tabular-environment)
>>> +					(car org-export-latex-tabular-environment)
>>> +				      org-export-latex-tabular-environment)))
>>>                        (if longtblp "\n" (if org-export-latex-
>>> tables-centered
>>>                                              "\n\\end{center}\n"
>>> "\n"))
>>>                        (if longtblp
>>>                            "\\end{longtable}"
>>> -                          (if floatp "\\end{table}"))))
>>> +                          (if floatp (format "\\end{%s}"  
>>> tblenv)))))
>>>                      "\n\n"))))))))
>>>
>>> (defun org-export-latex-convert-table.el-table ()
>>>
>>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>>
>>>> Hi Eric,
>>>>
>>>> The syntax for tabularx and tabulary includes a width specification
>>>> that is a required argument:
>>>>
>>>> \begin{tabulary}{<width>}{<align>} ... \end{tabulary}
>>>> \begin{tabularx}{<width>}{<align>} ... \end{tabularx}
>>>>
>>>> This is typically set to something like \linewidth, \colwidth, or
>>>> \textwidth, but might also take an absolute length like 250pt, 5in,
>>>> etc.
>>>>
>>>> All the best,
>>>> Tom
>>>>
>>>> On Dec 16, 2010, at 4:43 AM, Eric Schulte wrote:
>>>>
>>>>> The attached patch implements the behavior described previously,  
>>>>> so
>>>>> for
>>>>> example the following org
>>>>>
>>>>> #+begin_src org
>>>>> #+CAPTION: A wide table with tabulary
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>>
>>>>> #+CAPTION: A normal table with tabularx
>>>>> #+LABEL: tbl:wide
>>>>> #+ATTR_LaTeX: table tabularx align=l|lp{3cm}r|l
>>>>> | 1 | 2 | 3 |
>>>>> | 4 | 5 | 6 |
>>>>> #+end_src
>>>>>
>>>>> exports to the following latex
>>>>>
>>>>> #+begin_src latex
>>>>> \begin{table*}[htb]
>>>>> \caption{A wide table with tabulary} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabulary}
>>>>> \end{center}
>>>>> \end{table*}
>>>>>
>>>>>
>>>>> \begin{table}[htb]
>>>>> \caption{A normal table with tabularx} \label{tbl:wide}
>>>>> \begin{center}
>>>>> \begin{tabularx}{l|lp{3cm}r|l}
>>>>> 1  &  2  &  3  \\
>>>>> 4  &  5  &  6  \\
>>>>> \end{tabularx}
>>>>> \end{center}
>>>>> \end{table}
>>>>> #+end_src
>>>>>
>>>>> Does this behavior and patch look reasonable?  If I don't hear by
>>>>> the
>>>>> end of the day I will apply this patch, I just wanted to check  
>>>>> first
>>>>> on
>>>>> list as the export mechanisms aren't my personal area of  
>>>>> expertise.
>>>>>
>>>>> Thanks -- Eric
>>>>>
>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>> index a261171..66541de 100644
>>>>> --- a/lisp/org-latex.el
>>>>> +++ b/lisp/org-latex.el
>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>            (org-table-last-column-widths (copy-sequence
>>>>>                                           org-table-last-column-
>>>>> widths))
>>>>>            fnum fields line lines olines gr colgropen line-fmt
>>>>> align
>>>>> -             caption shortn label attr floatp placement longtblp)
>>>>> +             caption shortn label attr floatp placement longtblp
>>>>> tblenv tblrenv)
>>>>>       (if org-export-latex-tables-verbatim
>>>>>           (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>                               "\\end{verbatim}\n")))
>>>>> @@ -1758,6 +1758,15 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                        'org-label raw-table)
>>>>>                 longtblp (and attr (stringp attr)
>>>>>                               (string-match "\\<longtable\\>"
>>>>> attr))
>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>> +			     "table*" "table")
>>>>> +		  org-export-latex-tabular-environment
>>>>> +		  (if (and attr (stringp attr)
>>>>> +			   (string-match (regexp-quote "tabularx") attr))
>>>>> +		      "tabularx"
>>>>> +		    (if (string-match (regexp-quote "tabulary") attr)
>>>>> +			"tabulary" org-export-latex-tabular-environment))
>>>>>                 align (and attr (stringp attr)
>>>>>                            (string-match "\\<align=\\([^ \t\n\r]+\
>>>>> \)" attr)
>>>>>                            (match-string 1 attr))
>>>>> @@ -1821,7 +1830,8 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                      (concat
>>>>>                       (if longtblp
>>>>>                           (concat "\\begin{longtable}{" align "}
>>>>> \n")
>>>>> -                          (if floatp (format "\\begin{table}%s\n"
>>>>> placement)))
>>>>> +                          (if floatp
>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>                       (if floatp
>>>>>                           (format
>>>>>                            "\\caption%s{%s} %s"
>>>>> @@ -1852,7 +1862,7 @@ The conversion is made depending of STRING-
>>>>> BEFORE and STRING-AFTER."
>>>>>                                             "\n\\end{center}\n"
>>>>> "\n"))
>>>>>                       (if longtblp
>>>>>                           "\\end{longtable}"
>>>>> -                          (if floatp "\\end{table}"))))
>>>>> +                          (if floatp (format "\\end{%s}"
>>>>> tblenv)))))
>>>>>                     "\n\n"))))))))
>>>>>
>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>
>>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:
>>>>>
>>>>>> Hi Tom,
>>>>>>
>>>>>> Thanks for the informative list.  I had no idea LaTeX supported  
>>>>>> so
>>>>>> many
>>>>>> table options.  How about I update the patch so that is supports
>>>>>> the
>>>>>> following sets of mutually exclusive options...
>>>>>> - longtable :: wraps the table in a longtable with no table or
>>>>>> tabular
>>>>>>             wrappers -- already implemented
>>>>>> - table* :: replaces =table= wrapper with =table*= wrapper,
>>>>>> contains an
>>>>>>          inner tabular wrapper
>>>>>> - tabular[xy] :: specifies the inner tabular wrapping  
>>>>>> environment,
>>>>>> only
>>>>>>               one can be specified
>>>>>>
>>>>>> so for example, the following
>>>>>>
>>>>>> #+begin_src org
>>>>>> #+CAPTION: A wide table
>>>>>> #+LABEL: tbl:wide
>>>>>> #+ATTR_LaTeX: table* tabulary align=l|lp{3cm}r|l
>>>>>> | ... | ... |
>>>>>> | ... | ... |
>>>>>> #+end_src
>>>>>>
>>>>>> results in the following
>>>>>>
>>>>>> #+begin_src latex
>>>>>> \begin{table*}[htb]
>>>>>> \caption{A wide table} \label{tbl:wide}
>>>>>> \begin{center}
>>>>>> \begin{tabulary}{l|lp{3cm}r|l}
>>>>>> 1  &  2  &  3  \\
>>>>>> 4  &  5  &  6  \\
>>>>>> \end{tabulary}
>>>>>> \end{center}
>>>>>> \end{table*}
>>>>>> #+end_src
>>>>>>
>>>>>> Then the next question would be how to insert a =figure*= instead
>>>>>> of a
>>>>>> simple =figure= environment.
>>>>>>
>>>>>> Thanks -- Eric
>>>>>>
>>>>>> Thomas S. Dye <tsd@tsdye.com> writes:
>>>>>>
>>>>>>> Hi Eric,
>>>>>>>
>>>>>>> It would be great to have a more general solution.  Tables are
>>>>>>> hard to
>>>>>>> typeset, so it might take a while to come up with a good
>>>>>>> specification.  Here is what I know about the LaTeX side of
>>>>>>> things.
>>>>>>>
>>>>>>> ** LaTeX destinations for an Org-mode table
>>>>>>> *** Environments for typesetting a table
>>>>>>>  - table placed in the output where it occurs in the input
>>>>>>>  - all of these environments can be used on their own
>>>>>>> **** tabular
>>>>>>>   standard LaTeX environment, doesn't break across pages, no
>>>>>>> caption
>>>>>>> **** tabularx
>>>>>>>   extended environment that can automatically calculate column
>>>>>>>   widths and wrap text within table cells, doesn't break across
>>>>>>>   pages, no caption
>>>>>>> **** tabulary
>>>>>>>   like tabularx, but tries harder to come up with optimal column
>>>>>>> widths
>>>>>>> **** supertabular
>>>>>>>   extended tabular environment that breaks across pages,  
>>>>>>> includes
>>>>>>>   caption
>>>>>>> **** supertabular*
>>>>>>>   like supertabular, but for wide tables in a multicolumn page
>>>>>>>   layout
>>>>>>> **** mpsupertabular
>>>>>>>   like supertabular, but also handles footnotes within the table
>>>>>>> **** mpsupertabular*
>>>>>>>   like mpsupertabular, but for multicolumn page layouts
>>>>>>> **** longtable
>>>>>>>   extended tabular environment that breaks across pages and
>>>>>>>   includes a caption, but can't be used in a multicolumn page
>>>>>>>   layout
>>>>>>> *** Environment for floating a table and adding a caption
>>>>>>>  floats a table typeset by some other environment to a place in
>>>>>>> the
>>>>>>>  output that LaTeX determines appropriate, probably not where it
>>>>>>>  occurs in the input
>>>>>>> **** =table=, single column document
>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>> environment
>>>>>>> **** =table*=, multi-column document
>>>>>>>   typically wraps a =tabular=, =tabularx=, or =tabulary=
>>>>>>> environment
>>>>>>> *** "Typical" uses
>>>>>>>  In our report production work we regularly use seven setups:
>>>>>>>  - table or table* wrapped around tabularx or tabular
>>>>>>>  - longtable
>>>>>>>  - tabular or tabularx on their own
>>>>>>>
>>>>>>> hth,
>>>>>>> Tom
>>>>>>> On Dec 15, 2010, at 11:33 AM, Eric Schulte wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> The attached patch allows the use of table* latex tables from
>>>>>>>> within
>>>>>>>> Org
>>>>>>>> mode documents using the attr_latex lines, for example
>>>>>>>>
>>>>>>>> #+CAPTION: A wide table
>>>>>>>> #+LABEL: tbl:wide
>>>>>>>> #+ATTR_LaTeX: table* align=l|lp{3cm}r|l
>>>>>>>> | ... | ... |
>>>>>>>> | ... | ... |
>>>>>>>>
>>>>>>>> Should this be added, or should we put together a more general
>>>>>>>> solution
>>>>>>>> for different types of table environments?  Currently only
>>>>>>>> longtable
>>>>>>>> is
>>>>>>>> supported.  Also, is there already a way to do this that I have
>>>>>>>> missed?
>>>>>>>>
>>>>>>>> Thanks -- Eric
>>>>>>>>
>>>>>>>> diff --git a/lisp/org-latex.el b/lisp/org-latex.el
>>>>>>>> index a261171..b7f48d3 100644
>>>>>>>> --- a/lisp/org-latex.el
>>>>>>>> +++ b/lisp/org-latex.el
>>>>>>>> @@ -1741,7 +1741,7 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>           (org-table-last-column-widths (copy-sequence
>>>>>>>>                                          org-table-last-column-
>>>>>>>> widths))
>>>>>>>>           fnum fields line lines olines gr colgropen line-fmt
>>>>>>>> align
>>>>>>>> -             caption shortn label attr floatp placement
>>>>>>>> longtblp)
>>>>>>>> +             caption shortn label attr floatp placement  
>>>>>>>> longtblp
>>>>>>>> tblenv)
>>>>>>>>      (if org-export-latex-tables-verbatim
>>>>>>>>          (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
>>>>>>>>                              "\\end{verbatim}\n")))
>>>>>>>> @@ -1758,6 +1758,9 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                       'org-label raw-table)
>>>>>>>>                longtblp (and attr (stringp attr)
>>>>>>>>                              (string-match "\\<longtable\\>"
>>>>>>>> attr))
>>>>>>>> +		  tblenv (if (and attr (stringp attr)
>>>>>>>> +				  (string-match (regexp-quote "table*") attr))
>>>>>>>> +			     "table*" "table")
>>>>>>>>                align (and attr (stringp attr)
>>>>>>>>                           (string-match "\\<align=\\([^
>>>>>>>> \t\n\r]
>>>>>>>> +\
>>>>>>>> \)" attr)
>>>>>>>>                           (match-string 1 attr))
>>>>>>>> @@ -1821,7 +1824,8 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                     (concat
>>>>>>>>                      (if longtblp
>>>>>>>>                          (concat "\\begin{longtable}{" align "}
>>>>>>>> \n")
>>>>>>>> -                          (if floatp (format "\\begin{table}%s
>>>>>>>> \n"
>>>>>>>> placement)))
>>>>>>>> +                          (if floatp
>>>>>>>> +			      (format "\\begin{%s}%s\n" tblenv placement)))
>>>>>>>>                      (if floatp
>>>>>>>>                          (format
>>>>>>>>                           "\\caption%s{%s} %s"
>>>>>>>> @@ -1852,7 +1856,7 @@ The conversion is made depending of  
>>>>>>>> STRING-
>>>>>>>> BEFORE and STRING-AFTER."
>>>>>>>>                                            "\n\\end{center}\n"
>>>>>>>> "\n"))
>>>>>>>>                      (if longtblp
>>>>>>>>                          "\\end{longtable}"
>>>>>>>> -                          (if floatp "\\end{table}"))))
>>>>>>>> +                          (if floatp (format "\\end{%s}"
>>>>>>>> tblenv)))))
>>>>>>>>                    "\n\n"))))))))
>>>>>>>>
>>>>>>>> (defun org-export-latex-convert-table.el-table ()
>>>>>>>> _______________________________________________
>>>>>>>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-12-18 20:18 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-15 21:33 allow table* specification with #+ATTR_LaTeX: Eric Schulte
2010-12-16  4:27 ` Thomas S. Dye
2010-12-16 13:16   ` Eric Schulte
2010-12-16 14:43     ` Eric Schulte
2010-12-16 15:42       ` Thomas S. Dye
2010-12-17  0:57         ` Eric Schulte
2010-12-17 16:21           ` Thomas S. Dye
2010-12-17 20:39             ` Eric Schulte
2010-12-17 20:44               ` Carsten Dominik
2010-12-17 21:01                 ` Eric Schulte
2010-12-17 21:04                   ` Carsten Dominik
2010-12-18 20:18               ` Thomas S. Dye

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).