From mboxrd@z Thu Jan 1 00:00:00 1970 From: Berthold Hoellmann Subject: Re: Bug: Problem with LaTeX export, footnotes in table headers, and longtabu [8.3.4 (8.3.4-31-gcb683e-elpa @ /home/berhol/.emacs.d/elpa/org-20160404/)] Date: Thu, 14 Apr 2016 16:02:38 +0200 Message-ID: References: <87inzkzkey.fsf@nicolasgoaziou.fr> Reply-To: berthold.hoellmann@dnvgl.com Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqjJa-0000B2-Ko for emacs-orgmode@gnu.org; Thu, 14 Apr 2016 11:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqjJW-0005Zl-Dd for emacs-orgmode@gnu.org; Thu, 14 Apr 2016 11:36:18 -0400 Received: from mail-am1on0117.outbound.protection.outlook.com ([157.56.112.117]:44256 helo=emea01-am1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqjJV-0005ZZ-QJ for emacs-orgmode@gnu.org; Thu, 14 Apr 2016 11:36:14 -0400 Received: from pc130799.gl.ad.germanlloyd.org (localhost [127.0.0.1]) by pc130799.gl.ad.germanlloyd.org (Postfix) with ESMTP id 45605152C for ; Thu, 14 Apr 2016 16:02:41 +0200 (CEST) In-Reply-To: <87inzkzkey.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Thu, 14 Apr 2016 10:03:49 +0200") 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: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > Berthold H=C3=B6llmann writes: > >> I am exporting a large table from org to pdf via LaTeX. The meaning of >> some of the column headers are to be explained in footnotes. The table >> spans more than one page, so continuation headers are generated using >> longtabu. These continuation headers mangle with the footnote numbering >> as can be seen in this example: >> >> # -*- mode: org -*- >> #+STARTUP: showall >> #+LaTeX_CLASS_OPTIONS: [a5paper] >> #+LATEX_HEADER: \usepackage[T1]{fontenc} >> #+LATEX_HEADER: \usepackage[utf8x]{inputenc} >> #+LATEX_HEADER: \usepackage{tabu} >> #+TITLE: Multi page table test >> >> * Multi page table >> >> #+ATTR_LATEX: :environment longtabu >> | *Typ[fn:test]* | >> |----------------| >> | 1 | >> | 2 | >> | 3 | >> | 4 | >> | 5 | >> | 6 | >> | 7[fn:test2] | >> | 8 | >> | 9 | >> | 10 | >> |----------------| >> >> * Footnotes >> >> [fn:test] >> Testing footnotes with multi page latex tables. >> >> [fn:test2] >> Another Test > > [...] > >> \section{Multi page table} >> \label{sec:orgheadline1} >> >> \begin{longtabu}{r} >> \textbf{Typ\footnotemark}\\ >> \hline >> \endfirsthead >> \multicolumn{1}{l}{Continued from previous page} \\ >> \hline >> >> \textbf{Typ\footnotemark} \\ >> >> \hline >> \endhead >> \hline\multicolumn{1}{r}{Continued on next page} \\ >> \endfoot >> \endlastfoot >> \hline >> 1\\ >> 2\\ >> 3\\ >> 4\\ >> 5\\ >> 6\\ >> 7\footnotemark\\ >> 8\\ >> 9\\ >> 10\\ >> \hline >> \end{longtabu} >> \footnotetext[1]{Testing footnotes with multi page latex tables.}\footno= tetext[2]{Another Test} >> \end{document} >> >> >> >> [fn:test] becomes [1] in the first, and [2] in the continuation headers, >> but [2] links to the content of [fn:test2], which becomes a reference >> without target. > > Isn't it a LaTeX limitation? IIRC, footnotes support in tables is > somewhat flaky. Anyway, if you think it is Org's fault, do you know the > LaTeX code that should be produced in this case? > Actually I was able to patch `org-latex-footnote-reference' to get the results I line. The trick is to add the counter number given at the \footnotetext command to the \footnotemark command also: (defun org-latex-footnote-reference (footnote-reference contents info) "Transcode a FOOTNOTE-REFERENCE element from Org to LaTeX. CONTENTS is nil. INFO is a plist holding contextual information." (concat ;; Insert separator between two footnotes in a row. (let ((prev (org-export-get-previous-element footnote-reference info))) (when (eq (org-element-type prev) 'footnote-reference) (plist-get info :latex-footnote-separator))) (cond ;; Use \footnotemark if the footnote has already been defined. ((not (org-export-footnote-first-reference-p footnote-reference info)) (format "\\footnotemark[%s]{}" (org-export-get-footnote-number footnote-reference info))) ;; Use \footnotemark if reference is within another footnote ;; reference, footnote definition or table cell. ((org-element-lineage footnote-reference '(footnote-reference footnote-definition table-ce= ll)) (format "\\footnotemark[%s]{}" (org-export-get-footnote-number footnote-reference info))) ;; Otherwise, define it with \footnote command. (t (let ((def (org-export-get-footnote-definition footnote-reference info= ))) (concat (format "\\footnote{%s}" (org-trim (org-export-data def info))) ;; Retrieve all footnote references within the footnote and ;; add their definition after it, since LaTeX doesn't support ;; them inside. (org-latex--delayed-footnotes-definitions def info))))))) Best regards Berthold H=C3=B6llmann -- Development Eng. - Structural Methods, Information Management Research & De= velopment, Hamburg E-mail berthold.hoellmann@dnvgl.com Direct +49 40 36149 7374 www.dnvgl.com | www.linkedin.com/company/dnvgl DNV GL DNV and GL have merged to form DNV GL We are now the world's largest ship and offshore classification society, the leading technical advisor to the global oil and gas industry, and a leading expert for the energy value chain including renewables and energy efficiency. We've also taken a position as one of the top three certification bodies in the world. Read more here: www.dnvgl.com/merger. DNV GL SE, Registered Office Hamburg No. HRB 115442 =E2=80=A2 Chairman of t= he Supervisory Board: Remi Eriksen =E2=80=A2 Executive Board: Knut =C3=98rb= eck-Nilssen =E2=80=A2 Torsten Schramm =E2=80=A2 Bj=C3=B6rn-Olaf Borth =E2= =80=A2 The latest edition of the General Terms and Conditions of DNV GL SE is appl= icable. ***************************************************************************= *********** This e-mail and any attachments thereto may contain confidential informatio= n and/or information protected by intellectual property rights for the excl= usive attention of the intended addressees named above. If you have receive= d this transmission in error, please immediately notify the sender by retur= n e-mail and delete this message and its attachments. Unauthorized use, cop= ying or further full or partial distribution of this e-mail or its contents= is prohibited. ***************************************************************************= ***********