emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: Problem with LaTeX export, footnotes in table headers, and


From: Berthold Hoellmann
Subject: Re: [O] 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Nicolas Goaziou <address@hidden> writes:

> Hello,
>
> Berthold Höllmann <address@hidden> 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 address@hidden
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 via email to

[Prev in Thread] Current Thread [Next in Thread]