Skip to content

Commit

Permalink
Fixed problem with footnotes in LaTeX tables
Browse files Browse the repository at this point in the history
The tabular environment doesn't support footnotes in LaTeX tables.
Therefore tables are now set using the longtable environment.
  • Loading branch information
gettalong committed Apr 30, 2011
1 parent 33d0759 commit 09b538a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/kramdown/document.latex
Expand Up @@ -28,9 +28,9 @@ encmap = {
<% end %>
\usepackage[T1]{fontenc}
\usepackage{listings}
\usepackage{hyperref}
<% @converter.data[:packages].each {|pkg| %>\usepackage{<%= pkg %>}
<% } %>
\usepackage{hyperref}

<% if @converter.data[:packages].include?('fancyvrb') %>
\VerbatimFootnotes
Expand Down
4 changes: 3 additions & 1 deletion doc/news/release_0_X_X.page
Expand Up @@ -10,7 +10,7 @@ modified_at: 2011-02-21 18:01:00 +02:00

## Changes

* 6 bug fixes:
* 7 bug fixes:

- Table line `` |a|`b` `` was parsed as `` |a`b` `` (patch by Masahiro Kitajima)
- Table line `` |`a` `` lead to error condition (patch by Masahiro Kitajima)
Expand All @@ -20,6 +20,8 @@ modified_at: 2011-02-21 18:01:00 +02:00
- Fixed bug in LaTeX image element converter that was introduced in a former release (reported by
Michael Franzl)
- Fixed problem with block HTML tag being treated as header text
- Fixed problem with footnotes in LaTeX tables -- now using `longtable` instead of `tabular`
environment (reported by Michael Franzl)

* 1 documentation fix:

Expand Down
3 changes: 2 additions & 1 deletion lib/kramdown/converter/latex.rb
Expand Up @@ -180,9 +180,10 @@ def convert_xml_pi(el, opts)
TABLE_ALIGNMENT_CHAR = {:default => 'l', :left => 'l', :center => 'c', :right => 'r'} # :nodoc:

def convert_table(el, opts)
@data[:packages] << 'longtable'
align = el.options[:alignment].map {|a| TABLE_ALIGNMENT_CHAR[a]}.join('|')
attrs = attribute_list(el)
"#{latex_link_target(el)}\\begin{tabular}{|#{align}|}#{attrs}\n\\hline\n#{inner(el, opts)}\\hline\n\\end{tabular}#{attrs}\n\n"
"#{latex_link_target(el)}\\begin{longtable}{|#{align}|}#{attrs}\n\\hline\n#{inner(el, opts)}\\hline\n\\end{longtable}#{attrs}\n\n"
end

def convert_thead(el, opts)
Expand Down
25 changes: 25 additions & 0 deletions test/testcases/block/14_table/table_with_footnote.html
@@ -0,0 +1,25 @@
<table>
<tbody>
<tr>
<td>this is <sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></td>
<td>a table</td>
</tr>
<tr>
<td>with a</td>
<td>footnote</td>
</tr>
</tbody>
</table>

<div class="footnotes">
<ol>
<li id="fn:1">
<p>Something</p>

<blockquote>
<p>special here</p>
</blockquote>
<p><a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>
</ol>
</div>
11 changes: 11 additions & 0 deletions test/testcases/block/14_table/table_with_footnote.latex
@@ -0,0 +1,11 @@
\begin{longtable}{|l|l|}
\hline
this is \footnote{Something

\begin{quote}
special here
\end{quote}} & a table\\
with a & footnote\\
\hline
\end{longtable}

6 changes: 6 additions & 0 deletions test/testcases/block/14_table/table_with_footnote.text
@@ -0,0 +1,6 @@
| this is [^1] | a table
| with a | footnote

[^1]: Something

> special here

0 comments on commit 09b538a

Please sign in to comment.