Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b0eb959354
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (26 sloc) 0.74 kB
require "cmdnote"
require "cmdnote/export"
class PreWithVariableFontSize < CmdNote::Article::Element::PRE
def to_tex
max_width = elements[0].lines.map do |line|
line.size
end.max
verbatim = enclose_tex_environment("fverbatim", convert_by(:to_tex))
# \tiny
# \scriptsize
# \footnotesize
# 45 characters when font size is 9pt (our default size)
if max_width <= 45
verbatim
elsif max_width <= 51
"{\\small\n#{verbatim}\n}"
elsif max_width <= 56
"{\\footnotesize\n#{verbatim}\n}"
elsif max_width <= 64
"{\\scriptsize\n#{verbatim}\n}"
else
"{\\tiny\n#{verbatim}\n}"
end
end
end
CmdNote::Article::Parser.element_class[:pre] = PreWithVariableFontSize
Jump to Line
Something went wrong with that request. Please try again.