lib/review/latexbuilder.rb in review-3.0.0.preview3 vs lib/review/latexbuilder.rb in review-3.0.0.preview4

- old
+ new

@@ -731,17 +731,32 @@ def flushright(lines) latex_block 'flushright', lines end - def texequation(lines) + def texequation(lines, id = nil, caption = '') blank + + if id + puts macro('begin', 'reviewequationblock') + if get_chap.nil? + puts macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header_without_chapter', [@chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + else + puts macro('reviewequationcaption', "#{I18n.t('equation')}#{I18n.t('format_number_header', [get_chap, @chapter.equation(id).number])}#{I18n.t('caption_prefix')}#{compile_inline(caption)}") + end + end + puts macro('begin', 'equation*') lines.each do |line| puts unescape(line) end puts macro('end', 'equation*') + + if id + puts macro('end', 'reviewequationblock') + end + blank end def latex_block(type, lines) blank @@ -859,9 +874,20 @@ else macro('reviewimageref', I18n.t('format_number', [get_chap(chapter), chapter.image(id).number]), image_label(id, chapter)) end rescue KeyError error "unknown image: #{id}" + end + + def inline_eq(id) + chapter, id = extract_chapter_id(id) + if get_chap(chapter).nil? + macro('reviewequationref', I18n.t('format_number_without_chapter', [chapter.equation(id).number])) + else + macro('reviewequationref', I18n.t('format_number', [get_chap(chapter), chapter.equation(id).number])) + end + rescue KeyError + error "unknown equation: #{id}" end def footnote(id, content) if @book.config['footnotetext'] || @foottext[id] puts macro("footnotetext[#{@chapter.footnote(id).number}]", compile_inline(content.strip))