emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Giepen <giepen.m@googlemail.com>
To: emacs-orgmode@gnu.org
Subject: Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour
Date: Fri, 5 Feb 2016 19:59:42 +0100	[thread overview]
Message-ID: <56B4F11E.9030600@gmail.com> (raw)


* 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}

             reply	other threads:[~2016-02-05 18:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 18:59 Michael Giepen [this message]
2016-02-06 22:24 ` Problem with threeparttable and sidewaystable, or: change request for (org-latex-tables-centered) behaviour Aaron Ecay
2016-02-06 22:38   ` Rasmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56B4F11E.9030600@gmail.com \
    --to=giepen.m@googlemail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).