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