lib/polytexnic/preprocessors/polytex.rb in polytexnic-1.0.2 vs lib/polytexnic/preprocessors/polytex.rb in polytexnic-1.0.3

- old
+ new

@@ -30,12 +30,10 @@ else "\\href{#{url}}{#{inner(el, opts)}}" end end - alias_method :original_convert_standalone_image, :convert_standalone_image - # Uses figures for images only when label is present. # This allows users to put raw (centered) images in their documents. # The default behavior of kramdown is to wrap such images in a figure # environment, which causes LaTeX to (a) treat them as floats and (b) # include a caption. This may not be what the user wants, and it's also @@ -44,10 +42,13 @@ # compromise we use Markdown behavior by default and kramdown behavior # if the alt text contains a '\label' element. def convert_standalone_image(el, opts, img) alt_text = el.children.first.attr['alt'] if has_label?(alt_text) - original_convert_standalone_image(el, opts, img) + attrs = attribute_list(el) + # Override the kramdown default by adding "here" placement. + # Authors who want a different behavior can always use raw LaTeX. + "\\begin{figure}[h]#{attrs}\n\\begin{center}\n#{img}\n\\end{center}\n\\caption{#{escape(el.children.first.attr['alt'])}}\n#{latex_link_target(el, true)}\n\\end{figure}#{attrs}\n" else img.gsub('\includegraphics', '\image') + "\n" end end