# File ../../../../../lib/review/latexbuilder.rb, line 880 def bibpaper_bibpaper(id, caption, lines) print split_paragraph(lines).join("") puts "" end
# File ../../../../../lib/review/latexbuilder.rb, line 875 def bibpaper_header(id, caption) puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}" puts macro('label', bib_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 158 def box(lines, caption = nil) blank if caption puts macro('reviewboxcaption', "#{compile_inline(caption)}") end puts '\begin{reviewbox}' lines.each do |line| puts detab(line) end puts '\end{reviewbox}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 146 def captionblock(type, lines, caption) puts "\\begin{reviewminicolumn}\n" unless caption.nil? puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n" end blocked_lines = split_paragraph(lines) puts blocked_lines.join("\n\n") puts "\\end{reviewminicolumn}\n" end
# File ../../../../../lib/review/latexbuilder.rb, line 595 def center(lines) latex_block 'center', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 294 def cmd(lines, caption = nil, lang = nil) if highlight_listings? common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang) else blank common_code_block(nil, lines, 'reviewcmd', caption, lang) do |line, idx| detab(line) + "\n" end end end
# File ../../../../../lib/review/latexbuilder.rb, line 127 def column_begin(level, label, caption) blank puts "\\begin{reviewcolumn}\n" if label puts "\\hypertarget{#{column_label(label)}}{}" else puts "\\hypertarget{#{column_label(caption)}}{}" end puts macro('reviewcolumnhead', nil, compile_inline(caption)) if level <= @book.config["toclevel"].to_i puts "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{compile_inline(caption)}}" end end
# File ../../../../../lib/review/latexbuilder.rb, line 141 def column_end(level) puts "\\end{reviewcolumn}\n" blank end
# File ../../../../../lib/review/latexbuilder.rb, line 632 def comment(lines, comment = nil) lines ||= [] lines.unshift comment unless comment.blank? if @book.config["draft"] str = lines.join("") puts macro('pdfcomment', escape(str)) end end
# File ../../../../../lib/review/latexbuilder.rb, line 305 def common_code_block(id, lines, command, caption, lang) if caption if command =~ /emlist/ || command =~ /cmd/ puts macro(command + 'caption', "#{compile_inline(caption)}") else begin puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}") rescue KeyError error "no such list: #{id}" end end end body = "" lines.each_with_index do |line, idx| body.concat(yield(line, idx)) end puts macro('begin' ,command) print body puts macro('end' ,command) blank end
# File ../../../../../lib/review/latexbuilder.rb, line 327 def common_code_block_lst(id, lines, command, title, caption, lang) caption_str = compile_inline((caption || "")) if title == "title" && caption_str == "" caption_str = "\\relax" ## dummy charactor to remove lstname print "\\vspace{-1.5em}" end if @book.config["highlight"] && @book.config["highlight"]["lang"] lexer = @book.config["highlight"]["lang"] # default setting else lexer = "" end lexer = lang if lang.present? body = lines.inject(''){|i, j| i + detab(unescape_latex(j)) + "\n"} puts "\\begin{"+command+"}["+title+"={"+caption_str+"},language={"+ lexer+"}]" print body puts "\\end{"+ command + "}" blank end
# File ../../../../../lib/review/latexbuilder.rb, line 911 def compile_href(url, label) if /\A[a-z]+:/ =~ url if label macro("href", escape_url(url), escape(label)) else macro("url", escape_url(url)) end else macro("ref", url) end end
# File ../../../../../lib/review/latexbuilder.rb, line 903 def compile_kw(word, alt) if alt macro('reviewkw', escape(word)) + "(#{escape(alt.strip)})" else macro('reviewkw', escape(word)) end end
# File ../../../../../lib/review/latexbuilder.rb, line 734 def compile_ruby(base, ruby) macro('ruby', escape(base), escape(ruby)) end
# File ../../../../../lib/review/latexbuilder.rb, line 218 def dd(lines) puts lines.join end
# File ../../../../../lib/review/latexbuilder.rb, line 625 def direct(lines, fmt) return unless fmt == 'latex' lines.each do |line| puts line end end
# File ../../../../../lib/review/latexbuilder.rb, line 207 def dl_begin blank puts '\begin{description}' end
# File ../../../../../lib/review/latexbuilder.rb, line 222 def dl_end puts '\end{description}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 212 def dt(str) str.sub!(/\[/){'\lbrack{}'} str.sub!(/\]/){'\rbrack{}'} puts '\item[' + str + '] \mbox{} \\' end
# File ../../../../../lib/review/latexbuilder.rb, line 250 def emlist(lines, caption = nil, lang = nil) blank if highlight_listings? common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang) else common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx| detab(line) + "\n" end end end
# File ../../../../../lib/review/latexbuilder.rb, line 261 def emlistnum(lines, caption = nil, lang = nil) blank if highlight_listings? common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang) else common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx| detab((idx+1).to_s.rjust(2)+": " + line) + "\n" end end end
# File ../../../../../lib/review/latexbuilder.rb, line 29 def extname '.tex' end
# File ../../../../../lib/review/latexbuilder.rb, line 601 def flushright(lines) latex_block 'flushright', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 713 def footnote(id, content) if @book.config["footnotetext"] puts macro("footnotetext[#{@chapter.footnote(id).number}]", compile_inline(content.strip)) end end
# File ../../../../../lib/review/latexbuilder.rb, line 364 def handle_metric(str) if @book.config["image_scale2width"] && str =~ /\Ascale=([\d.]+)\Z/ return "width=#{$1}\\maxwidth" end str end
# File ../../../../../lib/review/latexbuilder.rb, line 76 def headline(level, label, caption) _, anchor = headline_prefix(level) headline_name = HEADLINE[level] if @chapter.kind_of? ReVIEW::Book::Part headline_name = "part" end prefix = "" if level > @book.config["secnolevel"] || (@chapter.number.to_s.empty? && level > 1) prefix = "*" end blank unless @output.pos == 0 puts macro(headline_name+prefix, compile_inline(caption)) if prefix == "*" && level <= @book.config["toclevel"].to_i puts "\\addcontentsline{toc}{#{headline_name}}{#{compile_inline(caption)}}" end if level == 1 puts macro('label', chapter_label) else puts macro('label', sec_label(anchor)) end rescue error "unknown level: #{level}" end
# File ../../../../../lib/review/latexbuilder.rb, line 641 def hr puts '\hrule' end
# File ../../../../../lib/review/latexbuilder.rb, line 391 def image_dummy(id, caption, lines) puts '\begin{reviewdummyimage}' path = @chapter.image(id).path puts "--[[path = #{path} (#{existence(id)})]]--" lines.each do |line| puts detab(line.rstrip) end puts macro('label', image_label(id)) puts compile_inline(caption) puts '\end{reviewdummyimage}' end
# File ../../../../../lib/review/latexbuilder.rb, line 931 def image_ext "pdf" end
# File ../../../../../lib/review/latexbuilder.rb, line 361 def image_header(id, caption) end
# File ../../../../../lib/review/latexbuilder.rb, line 375 def image_image(id, caption, metric) metrics = parse_metric("latex", metric) # image is always bound here puts '\begin{reviewimage}' if metrics.present? puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}" else puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}" end if caption.present? puts macro('caption', compile_inline(caption)) end puts macro('label', image_label(id)) puts '\end{reviewimage}' end
# File ../../../../../lib/review/latexbuilder.rb, line 555 def imgtable(lines, id, caption = nil, metric = nil) if !@chapter.image(id).bound? warn "image not bound: #{id}" image_dummy id, caption, lines return end begin if caption.present? @table_caption = true puts '\begin{table}[h]' puts macro('reviewimgtablecaption', compile_inline(caption)) end puts macro('label', table_label(id)) rescue ReVIEW::KeyError error "no such table: #{id}" end imgtable_image(id, caption, metric) puts '\end{table}' if @table_caption @table_caption = nil blank end
# File ../../../../../lib/review/latexbuilder.rb, line 579 def imgtable_image(id, caption, metric) metrics = parse_metric("latex", metric) # image is always bound here puts '\begin{reviewimage}' if metrics.present? puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}" else puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}" end puts '\end{reviewimage}' end
# File ../../../../../lib/review/latexbuilder.rb, line 442 def indepimage(id, caption=nil, metric=nil) metrics = parse_metric("latex", metric) puts '\begin{reviewimage}' if metrics.present? puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}" else puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}" end if caption.present? puts macro('reviewindepimagecaption', %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{compile_inline(caption)}]) end puts '\end{reviewimage}' end
# File ../../../../../lib/review/latexbuilder.rb, line 885 def index(str) str.sub!(/\(\)/, '') decl = '' if /@\z/ =~ str str.chop! decl = '|IndexDecl' end unless /[^ -~]/ =~ str if /\^/ =~ str macro('index', escape_index(str.gsub(/\^/, '')) + '@' + escape_index(text(str)) + decl) else '\index{' + escape_index(text(str)) + decl + '}' end else '\index{' + escape_index(@index_db[str]) + '@' + escape_index(text(str)) + '}' end end
# File ../../../../../lib/review/latexbuilder.rb, line 850 def inline_ami(str) macro('reviewami', escape(str)) end
bold
# File ../../../../../lib/review/latexbuilder.rb, line 764 def inline_b(str) macro('textbf', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 803 def inline_bib(id) macro('reviewbibref', "[#{@chapter.bibpaper(id).number}]", bib_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 730 def inline_bou(str) str.split(//).map {|c| macro('ruby', escape(c), macro('textgt', BOUTEN)) }.join('\allowbreak') end
line break
# File ../../../../../lib/review/latexbuilder.rb, line 769 def inline_br(str) "\\\\\n" end
# File ../../../../../lib/review/latexbuilder.rb, line 673 def inline_chap(id) if @book.config["chapterlink"] "\\hyperref[chap:#{id}]{#{@book.chapter_index.number(id)}}" else @book.chapter_index.number(id) end rescue KeyError error "unknown chapter: #{id}" nofunc_text("[UnknownChapter:#{id}]") end
# File ../../../../../lib/review/latexbuilder.rb, line 661 def inline_chapref(id) title = super if @book.config["chapterlink"] "\\hyperref[chap:#{id}]{#{title}}" else title end rescue KeyError error "unknown chapter: #{id}" nofunc_text("[UnknownChapter:#{id}]") end
@<code> is same as @<tt>
# File ../../../../../lib/review/latexbuilder.rb, line 779 def inline_code(str) macro('texttt', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 822 def inline_column_chap(chapter, id) macro('reviewcolumnref', "#{chapter.column(id).caption}", column_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 863 def inline_comment(str) if @book.config["draft"] macro('pdfcomment', escape(str)) else "" end end
# File ../../../../../lib/review/latexbuilder.rb, line 791 def inline_del(str) macro('reviewstrike', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 773 def inline_dtp(str) # ignore "" end
# File ../../../../../lib/review/latexbuilder.rb, line 838 def inline_em(str) macro('reviewem', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 720 def inline_fn(id) if @book.config["footnotetext"] macro("footnotemark[#{@chapter.footnote(id).number}]", "") else macro('footnote', compile_inline(@chapter.footnote(id).content.strip)) end end
# File ../../../../../lib/review/latexbuilder.rb, line 807 def inline_hd_chap(chap, id) n = chap.headline_index.number(id) if chap.number and @book.config["secnolevel"] >= n.split('.').size str = I18n.t("chapter_quote", "#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}") else str = I18n.t("chapter_quote", compile_inline(chap.headline(id).caption)) end if @book.config["chapterlink"] anchor = n.gsub(/\./, "-") macro('reviewsecref', str, sec_label(anchor)) else str end end
hidden index
# File ../../../../../lib/review/latexbuilder.rb, line 744 def inline_hi(str) index(str) end
hidden index??
# File ../../../../../lib/review/latexbuilder.rb, line 759 def inline_hidx(str) index(str) end
index -> italic
# File ../../../../../lib/review/latexbuilder.rb, line 749 def inline_i(str) macro('textit', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 854 def inline_icon(id) macro('includegraphics', @chapter.image(id).path) end
index
# File ../../../../../lib/review/latexbuilder.rb, line 754 def inline_idx(str) escape(str) + index(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 708 def inline_img(id) chapter, id = extract_chapter_id(id) macro('reviewimageref', "#{chapter.number}.#{chapter.image(id).number}", image_label(id, chapter)) end
FIXME: use TeX native label/ref.
# File ../../../../../lib/review/latexbuilder.rb, line 698 def inline_list(id) chapter, id = extract_chapter_id(id) macro('reviewlistref', "#{chapter.number}.#{chapter.list(id).number}") end
math
# File ../../../../../lib/review/latexbuilder.rb, line 739 def inline_m(str) " $#{str}$ " end
# File ../../../../../lib/review/latexbuilder.rb, line 826 def inline_raw(str) super(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 842 def inline_strong(str) macro('reviewstrong', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 830 def inline_sub(str) macro('textsubscript', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 834 def inline_sup(str) macro('textsuperscript', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 703 def inline_table(id) chapter, id = extract_chapter_id(id) macro('reviewtableref', "#{chapter.number}.#{chapter.table(id).number}", table_label(id, chapter)) end
# File ../../../../../lib/review/latexbuilder.rb, line 871 def inline_tcy(str) macro('rensuji', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 684 def inline_title(id) title = super if @book.config["chapterlink"] "\\hyperref[chap:#{id}]{#{title}}" else title end rescue KeyError error "unknown chapter: #{id}" nofunc_text("[UnknownChapter:#{id}]") end
# File ../../../../../lib/review/latexbuilder.rb, line 787 def inline_tt(str) macro('texttt', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 799 def inline_ttb(str) macro('texttt', macro('textbf', escape(str))) end
# File ../../../../../lib/review/latexbuilder.rb, line 795 def inline_tti(str) macro('texttt', macro('textit', escape(str))) end
# File ../../../../../lib/review/latexbuilder.rb, line 846 def inline_u(str) macro('reviewunderline', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 858 def inline_uchar(str) # with otf package macro('UTF', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 645 def label(id) puts macro('label', id) end
# File ../../../../../lib/review/latexbuilder.rb, line 927 def latextsize(str) @latex_tsize = str end
# File ../../../../../lib/review/latexbuilder.rb, line 653 def linebreak puts '\\' end
override ReVIEW::Builder#list
# File ../../../../../lib/review/latexbuilder.rb, line 273 def list(lines, id, caption, lang = nil) if highlight_listings? common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang) else common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx| detab(line) + "\n" end end end
override ReVIEW::Builder#listnum
# File ../../../../../lib/review/latexbuilder.rb, line 284 def listnum(lines, id, caption, lang = nil) if highlight_listings? common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang) else common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx| detab((idx+1).to_s.rjust(2)+": " + line) + "\n" end end end
# File ../../../../../lib/review/latexbuilder.rb, line 117 def nodisp_begin(level, label, caption) blank unless @output.pos == 0 puts macro('clearpage') if @output.pos == 0 puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption)) # FIXME: headings end
# File ../../../../../lib/review/latexbuilder.rb, line 124 def nodisp_end(level) end
# File ../../../../../lib/review/latexbuilder.rb, line 783 def nofunc_text(str) escape(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 657 def noindent print '\noindent' end
# File ../../../../../lib/review/latexbuilder.rb, line 100 def nonum_begin(level, label, caption) blank unless @output.pos == 0 puts macro(HEADLINE[level]+"*", compile_inline(caption)) puts macro('addcontentsline', 'toc', HEADLINE[level], compile_inline(caption)) end
# File ../../../../../lib/review/latexbuilder.rb, line 106 def nonum_end(level) end
# File ../../../../../lib/review/latexbuilder.rb, line 109 def notoc_begin(level, label, caption) blank unless @output.pos == 0 puts macro(HEADLINE[level]+"*", compile_inline(caption)) end
# File ../../../../../lib/review/latexbuilder.rb, line 114 def notoc_end(level) end
# File ../../../../../lib/review/latexbuilder.rb, line 187 def ol_begin blank puts '\begin{enumerate}' if @ol_num puts "\\setcounter{enumi}{#{@ol_num - 1}}" @ol_num = nil end end
# File ../../../../../lib/review/latexbuilder.rb, line 202 def ol_end puts '\end{enumerate}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 196 def ol_item(lines, num) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} puts '\item ' + str end
# File ../../../../../lib/review/latexbuilder.rb, line 935 def olnum(num) @ol_num = num.to_i end
# File ../../../../../lib/review/latexbuilder.rb, line 649 def pagebreak puts '\pagebreak' end
# File ../../../../../lib/review/latexbuilder.rb, line 227 def paragraph(lines) blank lines.each do |line| puts line end blank end
# File ../../../../../lib/review/latexbuilder.rb, line 235 def parasep puts '\parasep' end
# File ../../../../../lib/review/latexbuilder.rb, line 591 def quote(lines) latex_block 'quote', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 239 def read(lines) latex_block 'quotation', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 371 def result_metric(array) "#{array.join(',')}" end
# File ../../../../../lib/review/latexbuilder.rb, line 346 def source(lines, caption, lang = nil) if highlight_listings? common_code_block_lst(nil, lines, 'reviewlistlst', 'title', caption, lang) else puts '\begin{reviewlist}' puts macro('reviewlistcaption', compile_inline(caption)) lines.each do |line| puts detab(line) end puts '\end{reviewlist}' puts "" end end
# File ../../../../../lib/review/latexbuilder.rb, line 459 def table(lines, id = nil, caption = nil) rows = [] sepidx = nil lines.each_with_index do |line, idx| if /\A[\=\{\-\}]{12}/ =~ line # just ignore #error "too many table separator" if sepidx sepidx ||= idx next end rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') } end rows = adjust_n_cols(rows) begin table_header id, caption unless caption.nil? rescue KeyError error "no such table: #{id}" end return if rows.empty? table_begin rows.first.size if sepidx sepidx.times do tr rows.shift.map {|s| th(s) } end rows.each do |cols| tr cols.map {|s| td(s) } end else rows.each do |cols| h, *cs = *cols tr [th(h)] + cs.map {|s| td(s) } end end table_end end
# File ../../../../../lib/review/latexbuilder.rb, line 505 def table_begin(ncols) if @latex_tsize puts macro('begin', 'reviewtable', @latex_tsize) elsif @tsize cellwidth = @tsize.split(/\s*,\s*/) puts macro('begin', 'reviewtable', '|'+cellwidth.collect{|i| "p{#{i}mm}"}.join('|')+'|') else puts macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l')) end puts '\hline' @tsize = nil @latex_tsize = nil end
# File ../../../../../lib/review/latexbuilder.rb, line 546 def table_end puts macro('end', 'reviewtable') if @table_caption puts '\end{table}' end @table_caption = nil blank end
# File ../../../../../lib/review/latexbuilder.rb, line 496 def table_header(id, caption) if caption.present? @table_caption = true puts '\begin{table}[h]' puts macro('reviewtablecaption', compile_inline(caption)) end puts macro('label', table_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 519 def table_separator #puts '\hline' end
# File ../../../../../lib/review/latexbuilder.rb, line 532 def td(s) ## use shortstack for @<br> if /\\/ =~ s macro('shortstack[l]', s) else s end end
# File ../../../../../lib/review/latexbuilder.rb, line 605 def texequation(lines) blank puts macro('begin','equation*') lines.each do |line| puts unescape_latex(line) end puts macro('end', 'equation*') blank end
# File ../../../../../lib/review/latexbuilder.rb, line 523 def th(s) ## use shortstack for @<br> if /\\/ =~ s macro('reviewth', macro('shortstack[l]', s)) else macro('reviewth', s) end end
# File ../../../../../lib/review/latexbuilder.rb, line 541 def tr(rows) print rows.join(' & ') puts ' \\ \hline' end
# File ../../../../../lib/review/latexbuilder.rb, line 923 def tsize(str) @tsize = str end
# File ../../../../../lib/review/latexbuilder.rb, line 171 def ul_begin blank puts '\begin{itemize}' end
# File ../../../../../lib/review/latexbuilder.rb, line 182 def ul_end puts '\end{itemize}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 176 def ul_item(lines) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} puts '\item ' + str end