lib/polytexnic/preprocessors/polytex.rb
# Converts \includegraphics to \image inside figures.
# The reason is that raw \includegraphics is almost always too wide
# in the PDF. Instead, we use the custom-defined \image command, which
# is specifically designed to fix this issue.
Converts \includegraphics to \image inside figures.
The reason is that raw \includegraphics is almost always too wide
in the PDF. Instead, we use the custom-defined \image command, which
is specifically designed to fix this issue.
Converts \ includegraphics to \ image inside figures . The reason is that raw \ includegraphics is almost always too wide in the PDF . Instead we use the custom - defined \ image command which is specifically designed to fix this issue .
def convert_includegraphics(text)
        in_figure = false
        newtext = text.split("\n").map do |line|
          line.gsub!('\includegraphics', '\image') if in_figure
          if line =~ /^\s*\\begin\{figure\}/
            in_figure = true
          elsif line =~ /^\s*\\end\{figure\}/
            in_figure = false
          end
          line
        end.join("\n")
        text.replace(newtext)
      end
def convert_includegraphics ( text ) in_figure = false newtext = text . split ( "\n" ) . map do | line | line . gsub! ( '\includegraphics' , '\image' ) if in_figure if line =~ / ^ \s * \\ begin \{ figure \} / in_figure = true elsif line =~ / ^ \s * \\ end \{ figure \} / in_figure = false end line end . join ( "\n" ) text . replace ( newtext ) end
Converts \includegraphics to \image inside figures.
Converts \ includegraphics to \ image inside figures .
text