From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Regier Subject: Re: Force center alignment in LaTeX table export? Date: Sun, 26 Mar 2017 12:13:24 -0700 Message-ID: References: <6b2d8e5e114b4ea9accc4d28a9d98662@AM4PR01MB1891.eurprd01.prod.exchangelabs.com> <87mvc8utdq.fsf@t3610> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a114da1b6567899054ba7053e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csDbT-0003NX-2S for emacs-orgmode@gnu.org; Sun, 26 Mar 2017 15:13:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csDbR-0007MI-GM for emacs-orgmode@gnu.org; Sun, 26 Mar 2017 15:13:27 -0400 Received: from mail-yw0-x22f.google.com ([2607:f8b0:4002:c05::22f]:35643) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csDbR-0007M2-AK for emacs-orgmode@gnu.org; Sun, 26 Mar 2017 15:13:25 -0400 Received: by mail-yw0-x22f.google.com with SMTP id d191so19088858ywe.2 for ; Sun, 26 Mar 2017 12:13:25 -0700 (PDT) In-Reply-To: <87mvc8utdq.fsf@t3610> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Eric S Fraga , emacs-orgmode@gnu.org --001a114da1b6567899054ba7053e Content-Type: multipart/alternative; boundary=001a114da1b6567895054ba7053c --001a114da1b6567895054ba7053c Content-Type: text/plain; charset=UTF-8 See inline below and attached. If exporting to PDF the first table gets a prefix of "ced!10" and the second is the pale red highlight I was wanting. Here are the important lines in the LaTeX buffer export: \(\left[\begin{array}{>{\cocumncococ{ced!10}}c|ccc|ccc} vs. \(\left[\begin{array}{a|ccc|ccc} This latter only works because in my header I have \newcolumntype{a}{>{\columncolor{red!10}}c} I'm not sure I'm reading the original issue, the patch, or the surrounding code right, but is it possible the [lr]->c substitution was intended for the case where no :align was provided by the author and org generated the alignment automatically? If so, would it be appropriate to just move the substitution to the ";; Extract column groups and alignment ..." block in org-latex--align-string, which is to say the case (if I'm reading correctly) where the author has not provided an override? ox-latex.el-3154-(defun org-latex--align-string (table info) ox-latex.el-3155- "Return an appropriate LaTeX alignment string. ox-latex.el-3156-TABLE is the considered table. INFO is a plist used as ox-latex.el-3157-a communication channel." ox-latex.el:3158: (or (org-export-read-attribute :attr_latex table :align) ox-latex.el-3159- (let (align) ox-latex.el-3160- ;; Extract column groups and alignment from first (non-rule) Org file to demonstrate problem and workaround: #+latex_header: \usepackage{xcolor} #+latex_header: \usepackage{colortbl} * Non-Working Example #+ATTR_LaTeX: :mode inline-math :environment array #+attr_latex: :math-prefix \left[ :math-suffix \right] #+attr_latex: :align >{\columncolor{red!10}}c|ccc|ccc | | | * | * | | | | * | | | * | | | | \hline* | | | | * | | | | | | | * | * | * Working Example Just define a column type that doesn't use the characters 'l' or 'r' #+latex_header: \newcolumntype{a}{>{\columncolor{red!10}}c} #+ATTR_LaTeX: :mode inline-math :environment array #+attr_latex: :math-prefix \left[ :math-suffix \right] #+attr_latex: :align a|ccc|ccc | | | * | * | | | | * | | | * | | | | \hline* | | | | * | | | | | | | * | * | On Sun, Mar 26, 2017 at 5:14 AM, Eric S Fraga wrote: > Can you please post an ECM (small example) of the org table with > attributes that you are having problems with? > > -- > : Eric S Fraga (0xFFFCF67D), Emacs 26.0.50, Org release_9.0.5-385-g72fc2d > --001a114da1b6567895054ba7053c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
See inline below and attached.=C2= =A0 If exporting to PDF the first table gets a prefix of "ced!10"= and the second is the pale red highlight I was wanting.

Here = are the important lines in the LaTeX buffer export:

\(\left[\begin{a= rray}{>{\cocumncococ{ced!10}}c|ccc|ccc}

vs.

\(\left[= \begin{array}{a|ccc|ccc}

This latter only works because in my = header I have

\newcolumntype{a}{>{\columncolor{red!10}}c}

=


I'm not sure I'm reading the original issue,= the patch, or the surrounding code right, but is it possible the [lr]->= c substitution was intended for the case where no :align was provided by th= e author and org generated the alignment automatically?=C2=A0 If so, would = it be appropriate to just move the substitution to the ";; Extract col= umn groups and alignment ..." block in org-latex--align-string, which = is to say the case (if I'm reading correctly) where the author has not = provided an override?

ox-latex.el-3154-(defun org-latex--align-strin= g (table info)
ox-latex.el-3155-=C2=A0 "Return an appropriate LaTeX= alignment string.
ox-latex.el-3156-TABLE is the considered table.=C2=A0= INFO is a plist used as
ox-latex.el-3157-a communication channel."=
ox-latex.el:3158:=C2=A0 (or (org-export-read-attribute :attr_latex tabl= e :align)
ox-latex.el-3159-=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let (align)ox-latex.el-3160-=C2=A0=C2=A0=C2=A0 ;; Extract column groups and alignmen= t from first (non-rule)



Org file to demonstrate proble= m and workaround:

#+latex_header: \usepackage{xcolor}
#+latex_hea= der: \usepackage{colortbl}

* Non-Working Example
#+ATTR_LaTeX: :m= ode inline-math :environment array
#+attr_latex: :math-prefix \left[ :ma= th-suffix \right]
#+attr_latex: :align >{\columncolor{red!10}}c|ccc|c= cc
|=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 | * |= * |=C2=A0=C2=A0 |=C2=A0=C2=A0 |
| *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= |=C2=A0=C2=A0 |=C2=A0=C2=A0 | * |=C2=A0=C2=A0 |=C2=A0=C2=A0 |
| \hline*= |=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 | * |=C2=A0=C2=A0 |
|=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2= =A0=C2=A0 | * | * |


* Working Example
=C2=A0 Just define a co= lumn type that doesn't use the characters 'l' or 'r'
#+latex_header: \newcolumntype{a}{>{\columncolor{red!10}}c}

= #+ATTR_LaTeX: :mode inline-math :environment array
#+attr_latex: :math-p= refix \left[ :math-suffix \right]
#+attr_latex: :align a|ccc|ccc
|=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 | * | * |=C2=A0= =C2=A0 |=C2=A0=C2=A0 |
| *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0= =C2=A0 |=C2=A0=C2=A0 | * |=C2=A0=C2=A0 |=C2=A0=C2=A0 |
| \hline* |=C2=A0= =C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 | * |=C2=A0=C2=A0 |
|=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0= | * | * |


On Sun, Mar 26, 2017 at 5:14 AM, Eric S Fraga <e.fraga@ucl.ac= .uk> wrote:
Can you please = post an ECM (small example) of the org table with
attributes that you are having problems with?

--
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50, Org release_9.0.5-385-g72fc2d

--001a114da1b6567895054ba7053c-- --001a114da1b6567899054ba7053e Content-Type: application/vnd.lotus-organizer; name="ecm.org" Content-Disposition: attachment; filename="ecm.org" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j0r1zk3l1 IytsYXRleF9oZWFkZXI6IFx1c2VwYWNrYWdle3hjb2xvcn0KIytsYXRleF9oZWFkZXI6IFx1c2Vw YWNrYWdle2NvbG9ydGJsfQoKKiBOb24tV29ya2luZyBFeGFtcGxlCiMrQVRUUl9MYVRlWDogOm1v ZGUgaW5saW5lLW1hdGggOmVudmlyb25tZW50IGFycmF5CiMrYXR0cl9sYXRleDogOm1hdGgtcHJl Zml4IFxsZWZ0WyA6bWF0aC1zdWZ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