emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour
@ 2016-02-05 18:59 Michael Giepen
  2016-02-06 22:24 ` Aaron Ecay
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Giepen @ 2016-02-05 18:59 UTC (permalink / raw)
  To: emacs-orgmode


* Problem with centering sidewaystable and threeparttable

#+LATEX_HEADER: \usepackage{threeparttable}

I am referring myself to an archived post about using "threeparttable" 
with org-mode syntax(!), without having to use a LaTeX code block:
https://lists.gnu.org/archive/html/emacs-orgmode/2013-12/msg00446.html

I am having trouble achieving the following goals:
- booktabs table (just mentioning, do not think that matters)
- threeparttable in org-mode syntax
- floating environment --> place threeparttable inside "table environment"
- table centered! -> here is the problem!


** threeparttable

floating threeparttable example (non-floating would not be a problem):

#+CAPTION: Here goes the caption
#+BEGIN_table
#+BEGIN_threeparttable
| An example of a \tnote{a} | threeparttable | centered table \tnote{c} |
|                         1 |              2 |                        3 |

#+BEGIN_tablenotes
\item[a] To float one has to put threeparttable (TPT) in a table environment
\item[b] With default (org-latex-tables-centered) on TPT gets exportet 
in "center" environment
\item[c] "center" environment and TPT clash, no document export
#+END_tablenotes
#+END_threeparttable
#+END_table

The LaTeX export is: (uses \begin{center}...\end{center}

# ###############################################################

\begin{table}[!htpb]
\caption{\label{tab:}
Here goes the caption}
\begin{threeparttable}

\begin{center}
\begin{tabular}{lll}
\toprule
a \tnote{a} & table \tnote{b} & example \tnote{c}\\
\bottomrule
\end{tabular}
\end{center}

\begin{tablenotes}
\item[a] To float one has to put threeparttable (TPT) in a table environment
\item[b] With default (org-latex-tables-centered) on TPT gets exportet 
in "center" environment
\item[c] "center" environment and TPT clash, no document export
\end{tablenotes}
\end{threeparttable}
\end{table}

# ###############################################################

The "center environment" within threeparttable does not export!

Just as a comparison a standard table export:

#+CAPTION: Standard table
| Standard | simple | table |

becomes exported to: (uses centering!)

\begin{table}[!htbp]
\caption{Standard table}
\centering
\begin{tabular}{lll}
\toprule
Standard & simple & table\\
\bottomrule
\end{tabular}
\end{table}

If the \centering would also be used for threeparttable or any 
environment, there would be no conflict at all (I think).  I do not 
really understand why why the center environment is used in the first 
place: it apparently causes conflicts with several environments, but in 
effect seems to be no different from the center environment.  I think 
that should be changed to always use centering.

Anyways, my workaround solution, which works nicely so far is:
'org-latex-tables-centered nil
plus adding

#+LATEX_HEADER: \makeatletter
#+LATEX_HEADER: \g@addto@macro\@floatboxreset\centering
#+LATEX_HEADER: \makeatother

so that any float becomes centered.

* sidewaystable
Now, with the threeparttable problem solved, I now get a new problem 
with sidewaystables, which are now left-aligned (bottom of the page) 
with 'org-latex-tables-centered nil.

#+CAPTION: sidewaystable
#+LABEL: tab:sidewaystable
#+ATTR_LATEX: :float sideways
| Some | random | headers |     in | sideways | table | with | random | 
content |
|------+--------+---------+--------+----------+-------+------+--------+---------|
|  4.0 |    0.4 |     1.0 |    456 |     5465 |   465 |   65 | 645 
|      46 |
|  4.0 |   0.49 |     654 | 546546 |      654 |   546 |   54 | 654 |     
654 |

To solve this I have tried:

#+BEGIN_center
#+CAPTION: sidewaystable
#+LABEL: tab:sidewaystable
#+ATTR_LATEX: :float sideways
| Some | random | headers |     in | sideways | table | with | random | 
content |
|------+--------+---------+--------+----------+-------+------+--------+---------|
|  4.0 |    0.4 |     1.0 |    456 |     5465 |   465 |   65 | 645 
|      46 |
|  4.0 |   0.49 |     654 | 546546 |      654 |   546 |   54 | 654 |     
654 |
#+END_center

--> no effect

#+CAPTION: sidewaystable
#+LABEL: tab:sidewaystable
#+ATTR_LATEX: :float sideways
#+BEGIN_center
| Some | random | headers |     in | sideways | table | with | random | 
content |
|------+--------+---------+--------+----------+-------+------+--------+---------|
|  4.0 |    0.4 |     1.0 |    456 |     5465 |   465 |   65 | 645 
|      46 |
|  4.0 |   0.49 |     654 | 546546 |      654 |   546 |   54 | 654 |     
654 |

#+END_center

--> as the table is not "connected to the header the header is not 
considered on export.

and adding

#+ATTR_LATEX: :center
--> no effect on export at all (no center command appears...). I thought 
that this one turns 'org-latex-tables-centered on a float basis...

Nothing works...

One solution would be a workaround for the sidewaystable with the 
'org-latex-tables-centered turned off. Any ideas?

If not,  would it be possible to permanently change "center environment" 
for \centering with the "org-latex-tables-centered" option turned on?  
Or would this brake something else?

P.S. details on my setup:

emacs: 24.4.1
org-mode version: 20160201  from official repository
Latex packages loaded on org-mode latex export:

# \documentclass[11pt]{scrartcl}
# \usepackage[utf8]{inputenc}
# \usepackage[T1]{fontenc}
# \usepackage{fixltx2e}
# \usepackage{graphicx}
# \usepackage{grffile}
# \usepackage{longtable}
# \usepackage{wrapfig}
# \usepackage{rotating}
# \usepackage[normalem]{ulem}
# \usepackage{amsmath}
# \usepackage{textcomp}
# \usepackage{amssymb}
# \usepackage{capt-of}
# \usepackage{hyperref}
# \usepackage{enumitem}
# \usepackage{subcaption}
# \usepackage{multirow}
# \usepackage{natbib}
# \usepackage{booktabs}
# \usepackage{authblk}
# \usepackage{afterpage}
# \usepackage{nth}
# \usepackage{makeidx}
# \usepackage{tikz}
# \usepackage{chemmacros}
# \usepackage{siunitx}
# \usepackage{chngcntr}
# \counterwithin{figure}{section}

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

* Re: Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour
  2016-02-05 18:59 Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour Michael Giepen
@ 2016-02-06 22:24 ` Aaron Ecay
  2016-02-06 22:38   ` Rasmus
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Ecay @ 2016-02-06 22:24 UTC (permalink / raw)
  To: Michael Giepen, emacs-orgmode

Hi Michael,

2016ko otsailak 5an, Michael Giepen-ek idatzi zuen:

[...]


> If the \centering would also be used for threeparttable or any 
> environment, there would be no conflict at all (I think).  I do not 
> really understand why why the center environment is used in the first 
> place: it apparently causes conflicts with several environments, but in 
> effect seems to be no different from the center environment.  

[ I assume you meant “no different from \centering” ]

This is because in your example the table is exported as non-floating.
\centering only works as intended inside a Latex group, which
non-floating tables are not (necessarily) contained in.

Perhaps we should use “{\centering” and “}” to center non-floating
tables – I’m not enough of a latex guru to know the pros and cons.  Do
you have a reference that documents how the environment version causes
problems, or are you speaking from experience?

[...]


> and adding
> 
> #+ATTR_LATEX: :center

I think this should work, except that it needs to be written:

#+ATTR_LATEX: :center t

-- 
Aaron Ecay

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

* Re: Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour
  2016-02-06 22:24 ` Aaron Ecay
@ 2016-02-06 22:38   ` Rasmus
  0 siblings, 0 replies; 3+ messages in thread
From: Rasmus @ 2016-02-06 22:38 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Aaron Ecay <aaronecay@gmail.com> writes:

>> If the \centering would also be used for threeparttable or any 
>> environment, there would be no conflict at all (I think).  I do 
>> not  really understand why why the center environment is used 
>> in the first  place: it apparently causes conflicts with 
>> several environments, but in  effect seems to be no different 
>> from the center environment.   
> 
> [ I assume you meant “no different from \centering” ] 
> 
> This is because in your example the table is exported as 
> non-floating.  \centering only works as intended inside a Latex 
> group, which non-floating tables are not (necessarily) contained 
> in. 
> 
> Perhaps we should use “{\centering” and “}” to center 
> non-floating tables – I’m not enough of a latex guru to know the 
> pros and cons.  Do you have a reference that documents how the 
> environment version causes problems, or are you speaking from 
> experience? 

I'd not like that.  As I recall vertical spacing is often off when 
you do this.

threeparttable seems ill-suited for Org IMO.  The syntax is just 
too specialized.  E.g. tablenotes block also does not support 
itemize so you have to insert @@latex:\item @@.

Perhaps one of the alternative packages mentioned here¹ could be 
used. 

bidiftnxtra² might also be interesting (I haven’t tested).  From 
the manual:

    In standard LaTeX you can not use footnotes inside \chapter, 
    \part, \section, \subsection, \subsection and any other 
    section-like commands, \caption and tabular environment. bidi 
    package provides bidiftnxtra package that solves the issue of 
    footnote in standard LaTeX.

Rasmus
 
Footnotes:  ¹ 
http://tex.stackexchange.com/questions/1583/footnotes-in-tables  ² 
http://ftp.snt.utwente.nl/pub/software/tex/macros/xetex/latex/bidi/bidi.pdf 
-- 
Warning: Everything saved will be lost

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

end of thread, other threads:[~2016-02-06 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-05 18:59 Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour Michael Giepen
2016-02-06 22:24 ` Aaron Ecay
2016-02-06 22:38   ` Rasmus

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).