emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Berthold Hoellmann <berthold.hoellmann@dnvgl.com>
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <se4mb4z3sx.fsf@pc130799.gl.ad.germanlloyd.org> (raw)
In-Reply-To: <87inzkzkey.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Thu, 14 Apr 2016 10:03:49 +0200")

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Berthold Höllmann <berthold.hoellmann@dnvgl.com> 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.}\footnotetext[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-cell))
     (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öllmann
--
Development Eng. - Structural Methods, Information Management Research & Development, 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 • Chairman of the Supervisory Board: Remi Eriksen • Executive Board: Knut Ørbeck-Nilssen • Torsten Schramm • Björn-Olaf Borth •
The latest edition of the General Terms and Conditions of DNV GL SE is applicable.

**************************************************************************************
This e-mail and any attachments thereto may contain confidential information and/or information protected by intellectual property rights for the exclusive attention of the intended addressees named above. If you have received this transmission in error, please immediately notify the sender by return e-mail and delete this message and its attachments. Unauthorized use, copying or further full or partial distribution of this e-mail or its contents is prohibited.
**************************************************************************************

  reply	other threads:[~2016-04-14 15:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12  8:54 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/)] Berthold Höllmann
2016-04-14  8:03 ` Nicolas Goaziou
2016-04-14 14:02   ` Berthold Hoellmann [this message]
2016-04-16 10:11     ` Nicolas Goaziou
2016-04-17 15:42       ` Berthold Höllmann
2016-04-19 19:26         ` Nicolas Goaziou
2016-04-19 22:11           ` Berthold Höllmann
2016-04-20 21:40             ` Nicolas Goaziou

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=se4mb4z3sx.fsf@pc130799.gl.ad.germanlloyd.org \
    --to=berthold.hoellmann@dnvgl.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).