Skip to content

Commit

Permalink
To be consistent with LaTeX formatting of images as figures, wrapped …
Browse files Browse the repository at this point in the history
…tabular environment in table environment. [#115 status:resolved]
  • Loading branch information
kleb committed Mar 7, 2009
1 parent 6dc080a commit e2d48eb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
8 changes: 4 additions & 4 deletions lib/redcloth/formatters/latex.rb
Expand Up @@ -93,7 +93,7 @@ def li_open(opts)
def li_close(opts=nil)
"\n"
end

def p(opts)
opts[:text] + "\n\n"
end
Expand Down Expand Up @@ -137,11 +137,11 @@ def table_open(opts)
end

def table_close(opts)
output = "\\begin{tabular}{ #{"l " * @table[0].size }}\n"
output = "\\begin{table}[htbp]\n \\begin{tabular}{ #{"l " * @table[0].size }}\n"
@table.each do |row|
output << " #{row.join(" & ")} \\\\\n"
output << " #{row.join(" & ")} \\\\\n"
end
output << "\\end{tabular}\n"
output << " \\end{tabular}\n\\end{table}\n"
output
end

Expand Down
52 changes: 30 additions & 22 deletions test/table.yml
Expand Up @@ -19,10 +19,12 @@ html: |-
</table>
<h3>A header after the table</h3>
latex: |+
\begin{tabular}{ l l l }
a & b & c \\
1 & 2 & 3 \\
\end{tabular}
\begin{table}[htbp]
\begin{tabular}{ l l l }
a & b & c \\
1 & 2 & 3 \\
\end{tabular}
\end{table}
\subsubsection*{A header after the table}
---
Expand Down Expand Up @@ -64,10 +66,12 @@ html: |-
</tr>
</table>
latex: |+
\begin{tabular}{ l l l l l }
This & is & a & simple & table \\
This & is & a & simple & row \\
\end{tabular}
\begin{table}[htbp]
\begin{tabular}{ l l l l l }
This & is & a & simple & table \\
This & is & a & simple & row \\
\end{tabular}
\end{table}
---
in: |-
table{border:1px solid black}.
Expand Down Expand Up @@ -183,13 +187,15 @@ html: |-
</tr>
</table>
latex: |+
\begin{tabular}{ l l }
Cell with gray background & Normal cell \\
\multicolumn{2}{ l l }{Cell spanning 2 columns} \\
\multirow{2}{*}{Cell spanning 2 rows} & one \\
& two \\
Right-aligned cell & Left-aligned cell \\
\end{tabular}
\begin{table}[htbp]
\begin{tabular}{ l l }
Cell with gray background & Normal cell \\
\multicolumn{2}{ l l }{Cell spanning 2 columns} \\
\multirow{2}{*}{Cell spanning 2 rows} & one \\
& two \\
Right-aligned cell & Left-aligned cell \\
\end{tabular}
\end{table}
---
name: row spanning mid-row
in: |-
Expand Down Expand Up @@ -225,13 +231,15 @@ html: |-
</tr>
</table>
latex: |+
\begin{tabular}{ l l l }
1 & 2 & 3 \\
1 & \multirow{3}{*}{2} & 3 \\
1 & & 3 \\
1 & & 3 \\
1 & 2 & 3 \\
\end{tabular}
\begin{table}[htbp]
\begin{tabular}{ l l l }
1 & 2 & 3 \\
1 & \multirow{3}{*}{2} & 3 \\
1 & & 3 \\
1 & & 3 \\
1 & 2 & 3 \\
\end{tabular}
\end{table}
---
in: |
{background:#ddd}. |S|Target|Complete|App|Milestone|
Expand Down

0 comments on commit e2d48eb

Please sign in to comment.