# File ../../../../../lib/review/latexbuilder.rb, line 827 def bibpaper_bibpaper(id, caption, lines) print split_paragraph(lines).join("") puts "" end
# File ../../../../../lib/review/latexbuilder.rb, line 822 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 145 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 127 def captionblock(type, lines, caption) puts "\\begin{reviewminicolumn}\n" unless caption.nil? puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n" end if @book.config["deprecated-blocklines"].nil? blocked_lines = split_paragraph(lines) puts blocked_lines.join("\n\n") else lines.each do |line| puts line end end puts "\\end{reviewminicolumn}\n" end
# File ../../../../../lib/review/latexbuilder.rb, line 540 def center(lines) latex_block 'center', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 281 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 108 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 122 def column_end(level) puts "\\end{reviewcolumn}\n" blank end
# File ../../../../../lib/review/latexbuilder.rb, line 583 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 292 def common_code_block(id, lines, command, caption, lang) buf = "" 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 315 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 858 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 850 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 685 def compile_ruby(base, ruby) macro('ruby', escape(base), escape(ruby)) end
# File ../../../../../lib/review/latexbuilder.rb, line 205 def dd(lines) puts lines.join end
# File ../../../../../lib/review/latexbuilder.rb, line 576 def direct(lines, fmt) return unless fmt == 'latex' lines.each do |line| puts line end end
# File ../../../../../lib/review/latexbuilder.rb, line 194 def dl_begin blank puts '\begin{description}' end
# File ../../../../../lib/review/latexbuilder.rb, line 209 def dl_end puts '\end{description}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 199 def dt(str) str.sub!(/\[/){'\lbrack{}'} str.sub!(/\]/){'\rbrack{}'} puts '\item[' + str + '] \mbox{} \\' end
# File ../../../../../lib/review/latexbuilder.rb, line 237 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 248 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 30 def extname '.tex' end
# File ../../../../../lib/review/latexbuilder.rb, line 546 def flushright(lines) latex_block 'flushright', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 664 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 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 592 def hr puts '\hrule' end
# File ../../../../../lib/review/latexbuilder.rb, line 372 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 878 def image_ext "pdf" end
# File ../../../../../lib/review/latexbuilder.rb, line 349 def image_header(id, caption) end
# File ../../../../../lib/review/latexbuilder.rb, line 356 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 423 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 832 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 801 def inline_ami(str) macro('reviewami', escape(str)) end
bold
# File ../../../../../lib/review/latexbuilder.rb, line 715 def inline_b(str) macro('textbf', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 754 def inline_bib(id) macro('reviewbibref', "[#{@chapter.bibpaper(id).number}]", bib_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 681 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 720 def inline_br(str) "\\\\\n" end
# File ../../../../../lib/review/latexbuilder.rb, line 624 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 612 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 730 def inline_code(str) macro('texttt', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 773 def inline_column(id) macro('reviewcolumnref', "#{@chapter.column(id).caption}", column_label(id)) end
# File ../../../../../lib/review/latexbuilder.rb, line 814 def inline_comment(str) if @book.config["draft"] macro('pdfcomment', escape(str)) else "" end end
# File ../../../../../lib/review/latexbuilder.rb, line 742 def inline_del(str) macro('reviewstrike', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 724 def inline_dtp(str) # ignore "" end
# File ../../../../../lib/review/latexbuilder.rb, line 789 def inline_em(str) macro('reviewem', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 671 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 758 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 695 def inline_hi(str) index(str) end
hidden index??
# File ../../../../../lib/review/latexbuilder.rb, line 710 def inline_hidx(str) index(str) end
index -> italic
# File ../../../../../lib/review/latexbuilder.rb, line 700 def inline_i(str) macro('textit', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 805 def inline_icon(id) macro('includegraphics', @chapter.image(id).path) end
index
# File ../../../../../lib/review/latexbuilder.rb, line 705 def inline_idx(str) escape(str) + index(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 659 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 649 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 690 def inline_m(str) " $#{str}$ " end
# File ../../../../../lib/review/latexbuilder.rb, line 777 def inline_raw(str) super(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 793 def inline_strong(str) macro('reviewstrong', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 781 def inline_sub(str) macro('textsubscript', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 785 def inline_sup(str) macro('textsuperscript', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 654 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 635 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 738 def inline_tt(str) macro('texttt', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 750 def inline_ttb(str) macro('texttt', macro('textbf', escape(str))) end
# File ../../../../../lib/review/latexbuilder.rb, line 746 def inline_tti(str) macro('texttt', macro('textit', escape(str))) end
# File ../../../../../lib/review/latexbuilder.rb, line 797 def inline_u(str) macro('Underline', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 809 def inline_uchar(str) # with otf package macro('UTF', escape(str)) end
# File ../../../../../lib/review/latexbuilder.rb, line 596 def label(id) puts macro('label', id) end
# File ../../../../../lib/review/latexbuilder.rb, line 874 def latextsize(str) @latex_tsize = str end
# File ../../../../../lib/review/latexbuilder.rb, line 604 def linebreak puts '\\' end
override ReVIEW::Builder#list
# File ../../../../../lib/review/latexbuilder.rb, line 260 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 271 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 734 def nofunc_text(str) escape(str) end
# File ../../../../../lib/review/latexbuilder.rb, line 608 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)) end
# File ../../../../../lib/review/latexbuilder.rb, line 105 def nonum_end(level) end
# File ../../../../../lib/review/latexbuilder.rb, line 174 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 189 def ol_end puts '\end{enumerate}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 183 def ol_item(lines, num) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} puts '\item ' + str end
# File ../../../../../lib/review/latexbuilder.rb, line 882 def olnum(num) @ol_num = num.to_i end
# File ../../../../../lib/review/latexbuilder.rb, line 600 def pagebreak puts '\pagebreak' end
# File ../../../../../lib/review/latexbuilder.rb, line 214 def paragraph(lines) blank lines.each do |line| puts line end blank end
# File ../../../../../lib/review/latexbuilder.rb, line 222 def parasep puts '\parasep' end
# File ../../../../../lib/review/latexbuilder.rb, line 536 def quote(lines) latex_block 'quote', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 226 def read(lines) latex_block 'quotation', lines end
# File ../../../../../lib/review/latexbuilder.rb, line 352 def result_metric(array) "#{array.join(',')}" end
# File ../../../../../lib/review/latexbuilder.rb, line 334 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 440 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 486 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 527 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 477 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 500 def table_separator #puts '\hline' end
# File ../../../../../lib/review/latexbuilder.rb, line 513 def td(s) ## use shortstack for @<br> if /\\/ =~ s macro('shortstack[l]', s) else s end end
# File ../../../../../lib/review/latexbuilder.rb, line 550 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 504 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 522 def tr(rows) print rows.join(' & ') puts ' \\ \hline' end
# File ../../../../../lib/review/latexbuilder.rb, line 870 def tsize(str) @tsize = str end
# File ../../../../../lib/review/latexbuilder.rb, line 158 def ul_begin blank puts '\begin{itemize}' end
# File ../../../../../lib/review/latexbuilder.rb, line 169 def ul_end puts '\end{itemize}' blank end
# File ../../../../../lib/review/latexbuilder.rb, line 163 def ul_item(lines) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} puts '\item ' + str end