diff --git a/lib/redcloth/formatters/latex.rb b/lib/redcloth/formatters/latex.rb index 25fcf957..78107b98 100644 --- a/lib/redcloth/formatters/latex.rb +++ b/lib/redcloth/formatters/latex.rb @@ -93,7 +93,7 @@ def li_open(opts) def li_close(opts=nil) "\n" end - + def p(opts) opts[:text] + "\n\n" end @@ -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 diff --git a/test/table.yml b/test/table.yml index c6c44e33..6d438b5a 100644 --- a/test/table.yml +++ b/test/table.yml @@ -19,10 +19,12 @@ html: |-

A header after the table

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} --- @@ -64,10 +66,12 @@ html: |- 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}. @@ -183,13 +187,15 @@ html: |- 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: |- @@ -225,13 +231,15 @@ html: |- 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|