Sha256: b4269aa388020aa136fe38b82347d69e1e6672b34324ba9130d50a049bad5b2f
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
module Numerals class Format class LatexNotation < Notation def assemble(output, text_parts) # 1.23\overline{456}\times10^{9} # TODO: padding if text_parts.special? output << text_parts.special else output << text_parts.sign if format.symbols.base_prefix output << format.symbols.base_prefix end output << text_parts.integer # or decide here if empty integer part is shown as 0? if text_parts.show_point?(format) output << format.symbols.point end output << text_parts.fractional if text_parts.repeat? output << "\\overline{#{text_parts.repeat}}" end if format.symbols.base_suffix || format.base != 10 if format.symbols.base_prefix output << format.symbols.base_suffix else # show base suffix as a subscript subscript = format.symbols.base_suffix || base.to_s output << "_{#{subscript}}" end end if text_parts.exponent_value != 0 || format.mode.mode == :scientific output << "\\times" output << text_parts.exponent_base output << "^" output << "{#{text_parts.exponent}}" end end end private def escape(text) text.gsub('\\', '\\\\') end def unescape(text) text.gsub('\\\\', '\\') end end define_notation :latex, LatexNotation end end
Version data entries
4 entries across 4 versions & 1 rubygems