class ReVIEW::LATEXBuilder
Constants
- BOUTEN
- HEADLINE
Public Instance Methods
bibpaper(lines, id, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 890 def bibpaper(lines, id, caption) buf = "" buf << bibpaper_header(id, caption) if lines.empty? buf << "\n" else buf << "\n" buf << bibpaper_bibpaper(id, caption, lines) end buf << "\n" buf end
bibpaper_bibpaper(id, caption, lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 908 def bibpaper_bibpaper(id, caption, lines) lines.join("") end
bibpaper_header(id, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 903 def bibpaper_header(id, caption) "[#{@chapter.bibpaper(id).number}] #{caption}\n" + macro('label', bib_label(id)) end
box(lines, caption = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 140 def box(lines, caption = nil) buf = "\n" if caption buf << macro('reviewboxcaption', "#{caption}") << "\n" end buf << '\begin{reviewbox}' << "\n" lines.each do |line| buf << detab(line) << "\n" end< buf << '\end{reviewbox}' << "\n" end
captionblock(type, lines, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 123 def captionblock(type, lines, caption) buf = "" buf << "\\begin{reviewminicolumn}\n" unless caption.nil? buf << "\\reviewminicolumntitle{#{caption}}" end if @book.config["deprecated-blocklines"].nil? buf << lines.join("") else error "deprecated-blocklines is obsoleted." end buf << "\\end{reviewminicolumn}\n" buf end
center(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 577 def center(lines) latex_block 'center', lines end
Also aliased as: centering
cmd(lines, caption = nil, lang = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 281 def cmd(lines, caption = nil, lang = nil) buf = "" if highlight_listings? buf << common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang) else buf << "\n" buf << common_code_block(nil, lines, 'reviewcmd', caption, lang) do |line, idx| detab(line) + "\n" end end buf end
column_begin(level, label, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 96 def column_begin(level, label, caption) buf = "" blank if @blank_needed buf << "\n" blank_reset end buf << "\\begin{reviewcolumn}\n" if label buf << "\\hypertarget{#{column_label(label)}}{}\n" else buf << "\\hypertarget{#{column_label(caption)}}{}\n" end buf << macro('reviewcolumnhead', nil, caption) << "\n" if level <= @book.config["toclevel"].to_i buf << "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{caption}}" << "\n" end buf end
column_end(level)
click to toggle source
# File lib/review/latexbuilder.rb, line 116 def column_end(level) buf = "" buf << "\\end{reviewcolumn}\n" blank buf end
comment(lines, comment = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 620 def comment(lines, comment = nil) buf = "" lines ||= [] lines.unshift comment unless comment.blank? if @book.config["draft"] str = lines.join("") buf << macro('pdfcomment', str) << "\n" end buf end
common_code_block(id, lines, command, caption, lang) { |line, idx| ... }
click to toggle source
# File lib/review/latexbuilder.rb, line 294 def common_code_block(id, lines, command, caption, lang) buf = "" if caption if command =~ /emlist/ || command =~ /cmd/ buf << macro(command + 'caption', "#{caption}") + "\n" else begin buf << "\n" buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n" rescue KeyError error "no such list: #{id}" end end end body = "" lines.each_with_index do |line, idx| body.concat(yield(line, idx)) end buf << macro('begin' ,command) + "\n" buf << body buf << macro('end' ,command) + "\n" buf end
common_code_block_lst(id, lines, command, title, caption, lang)
click to toggle source
# File lib/review/latexbuilder.rb, line 318 def common_code_block_lst(id, lines, command, title, caption, lang) buf = "" caption_str = (caption || "") if title == "title" && caption_str == "" caption_str = "\\relax" ## dummy charactor to remove lstname buf << "\\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"} buf << "\\begin{"+command+"}["+title+"={"+caption_str+"},language={"+ lexer+"}]" + "\n" buf << body buf << "\\end{"+ command + "}" + "\n" buf end
compile_href(url, label)
click to toggle source
# File lib/review/latexbuilder.rb, line 924 def compile_href(url, label) if /\A[a-z]+:/ =~ url if label macro("href", escape_url(url), label) else macro("url", escape_url(url)) end else macro("ref", url) end end
compile_kw(word, alt)
click to toggle source
# File lib/review/latexbuilder.rb, line 916 def compile_kw(word, alt) if alt macro('reviewkw', word) + "(#{alt.strip})" else macro('reviewkw', word) end end
compile_ruby(base, ruby)
click to toggle source
# File lib/review/latexbuilder.rb, line 736 def compile_ruby(base, ruby) macro('ruby', base, ruby) end
dd(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 198 def dd(lines) lines.join + "\n" end
direct(lines, fmt)
click to toggle source
# File lib/review/latexbuilder.rb, line 611 def direct(lines, fmt) buf = "" return buf unless fmt == 'latex' lines.each do |line| buf << line << "\n" end buf end
dl_begin()
click to toggle source
# File lib/review/latexbuilder.rb, line 188 def dl_begin "\n" + '\begin{description}' + "\n" end
dl_end()
click to toggle source
# File lib/review/latexbuilder.rb, line 202 def dl_end '\end{description}' + "\n" end
dt(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 192 def dt(str) str.sub!(/\[/){'\lbrack{}'} str.sub!(/\]/){'\rbrack{}'} '\item[' + str + '] \mbox{} \\\\' + "\n" end
emlist(lines, caption = nil, lang = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 230 def emlist(lines, caption = nil, lang = nil) buf = "\n" if highlight_listings? buf << common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang) else buf << common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx| detab(line) + "\n" end end buf end
emlistnum(lines, caption = nil, lang = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 242 def emlistnum(lines, caption = nil, lang = nil) buf = "\n" if highlight_listings? buf << common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang) else buf << common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx| detab((idx+1).to_s.rjust(2)+": " + line) + "\n" end end buf end
extname()
click to toggle source
# File lib/review/latexbuilder.rb, line 31 def extname '.tex' end
flushright(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 583 def flushright(lines) latex_block 'flushright', lines end
footnote(id, content)
click to toggle source
# File lib/review/latexbuilder.rb, line 714 def footnote(id, content) if @book.config["footnotetext"] macro("footnotetext[#{@chapter.footnote(id).number}]", content.strip) + "\n" end end
headline(level, label, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 64 def headline(level, label, caption) buf = "" _, 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 buf << macro(headline_name+prefix, caption) << "\n" if prefix == "*" && level <= @book.config["toclevel"].to_i buf << "\\addcontentsline{toc}{#{headline_name}}{#{caption}}\n" end if level == 1 buf << macro('label', chapter_label) << "\n" else buf << macro('label', sec_label(anchor)) << "\n" end buf rescue error "unknown level: #{level}" end
hr()
click to toggle source
# File lib/review/latexbuilder.rb, line 631 def hr '\hrule' + "\n" end
image_dummy(id, caption, lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 390 def image_dummy(id, caption, lines) buf << '\begin{reviewdummyimage}' << "\n" path = @chapter.image(id).path buf << "--[[path = #{path} (#{existence(id)})]]--\n" lines.each do |line| buf << detab(line.rstrip) << "\n" end buf << macro('label', image_label(id)) << "\n" buf << caption << "\n" buf << '\end{reviewdummyimage}' << "\n" buf end
image_ext()
click to toggle source
# File lib/review/latexbuilder.rb, line 944 def image_ext "pdf" end
image_header(id, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 365 def image_header(id, caption) end
image_image(id, caption, metric)
click to toggle source
# File lib/review/latexbuilder.rb, line 372 def image_image(id, caption, metric) buf = "" metrics = parse_metric("latex", metric) # image is always bound here buf << '\begin{reviewimage}' << "\n" if metrics.present? buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n" else buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n" end if caption.present? buf << macro('caption', caption) << "\n" end buf << macro('label', image_label(id)) << "\n" buf << '\end{reviewimage}' << "\n" buf end
indepimage(id, caption=nil, metric=nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 442 def indepimage(id, caption=nil, metric=nil) buf = "" metrics = parse_metric("latex", metric) buf << '\begin{reviewimage}' << "\n" if metrics.present? buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n" else buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n" end if caption.present? buf << macro('reviewindepimagecaption', %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{caption}]) << "\n" end buf << '\end{reviewimage}' << "\n" buf end
Also aliased as: numberlessimage
index(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 912 def index(str) "\\index{" + str + "}" end
inline_ami(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 868 def inline_ami(str) macro('reviewami', str) end
inline_b(str)
click to toggle source
bold
# File lib/review/latexbuilder.rb, line 780 def inline_b(str) macro('textbf', str) end
inline_bou(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 732 def inline_bou(str) str.split(//).map {|c| macro('ruby', escape(c), macro('textgt', BOUTEN)) }.join('\allowbreak') end
inline_br(str)
click to toggle source
line break
# File lib/review/latexbuilder.rb, line 785 def inline_br(str) "\\\\\n" end
inline_code(str)
click to toggle source
@<code> is same as @<tt>
# File lib/review/latexbuilder.rb, line 795 def inline_code(str) macro('texttt', str) end
inline_comment(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 882 def inline_comment(str) if @book.config["draft"] macro('pdfcomment', escape(str)) else "" end end
inline_del(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 807 def inline_del(str) macro('reviewstrike', str) end
inline_dtp(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 789 def inline_dtp(str) # ignore "" end
inline_em(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 856 def inline_em(str) macro('reviewem', str) end
inline_hd_chap(chap, id)
click to toggle source
# File lib/review/latexbuilder.rb, line 824 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)} #{chap.headline(id).caption}") else str = I18n.t("chapter_quote", chap.headline(id).caption) end if @book.config["chapterlink"] anchor = n.gsub(/\./, "-") macro('reviewsecref', escape(str), sec_label(anchor)) else escape(str) end end
inline_hi(str)
click to toggle source
hidden index
# File lib/review/latexbuilder.rb, line 750 def inline_hi(str) index(str) end
inline_hidx(str)
click to toggle source
hidden index??
# File lib/review/latexbuilder.rb, line 770 def inline_hidx(str) index(str) end
inline_i(str)
click to toggle source
index -> italic
# File lib/review/latexbuilder.rb, line 755 def inline_i(str) macro('textit', str) end
inline_idx(str)
click to toggle source
index
# File lib/review/latexbuilder.rb, line 760 def inline_idx(str) escape(str) + index(str) end
inline_raw(str)
click to toggle source
Calls superclass method
ReVIEW::Builder#inline_raw
# File lib/review/latexbuilder.rb, line 844 def inline_raw(str) super(str) end
inline_strong(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 860 def inline_strong(str) macro('reviewstrong', str) end
inline_sub(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 848 def inline_sub(str) macro('textsubscript', str) end
inline_sup(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 852 def inline_sup(str) macro('textsuperscript', str) end
inline_tt(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 803 def inline_tt(str) macro('texttt', str) end
inline_ttb(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 815 def inline_ttb(str) macro('texttt', macro('textbf', str)) end
inline_tti(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 811 def inline_tti(str) macro('texttt', macro('textit', str)) end
inline_u(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 864 def inline_u(str) macro('Underline', str) end
inline_uchar(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 877 def inline_uchar(str) # with otf package macro('UTF', str) end
label(id)
click to toggle source
# File lib/review/latexbuilder.rb, line 635 def label(id) macro('label', id) + "\n" end
latextsize(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 940 def latextsize(str) @latex_tsize = str end
linebreak()
click to toggle source
# File lib/review/latexbuilder.rb, line 648 def linebreak '\\\\' + "\n" end
list(lines, id, caption = nil, lang = nil)
click to toggle source
override Builder#list
# File lib/review/latexbuilder.rb, line 255 def list(lines, id, caption = nil, lang = nil) buf = "" if highlight_listings? buf << common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang) else buf << common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx| detab(line) + "\n" end end buf end
listnum(lines, id, caption = nil, lang = nil)
click to toggle source
override Builder#listnum
# File lib/review/latexbuilder.rb, line 269 def listnum(lines, id, caption = nil, lang = nil) buf = "" if highlight_listings? buf << common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang) else buf << common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx| detab((idx+1).to_s.rjust(2)+": " + line) + "\n" end end buf end
node_inline_bib(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 819 def node_inline_bib(node) id = node[0].to_raw macro('reviewbibref', "[#{@chapter.bibpaper(id).number}]", bib_label(id)) end
node_inline_chap(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 669 def node_inline_chap(node) id = node[0].to_raw 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
node_inline_chapref(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 656 def node_inline_chapref(node) id = node[0].to_raw title = @book.chapter_index.display_string(id) if @book.config["chapterlink"] "\\hyperref[chap:#{id}]{#{title}}" else title end rescue KeyError error "unknown chapter: #{id}" nofunc_text("[UnknownChapter:#{id}]") end
node_inline_column(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 839 def node_inline_column(node) id = node[0].to_raw macro('reviewcolumnref', "#{@chapter.column(id).caption}", column_label(id)) end
node_inline_fn(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 721 def node_inline_fn(node) id = node[0].to_raw if @book.config["footnotetext"] macro("footnotemark[#{@chapter.footnote(id).number}]", "") else macro('footnote', @chapter.footnote(id).content.strip) end end
node_inline_hidx(nodelist)
click to toggle source
# File lib/review/latexbuilder.rb, line 774 def node_inline_hidx(nodelist) content = nodelist[0].to_raw index(content) end
node_inline_icon(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 872 def node_inline_icon(node) id = node[0].to_raw macro('includegraphics', @chapter.image(id).path) end
node_inline_idx(nodelist)
click to toggle source
# File lib/review/latexbuilder.rb, line 764 def node_inline_idx(nodelist) content = nodelist[0].to_raw escape(content) + index(content) end
node_inline_img(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 708 def node_inline_img(node) id = node[0].to_raw chapter, id = extract_chapter_id(id) macro('reviewimageref', "#{chapter.number}.#{chapter.image(id).number}", image_label(id, chapter)) end
node_inline_list(node)
click to toggle source
FIXME: use TeX native label/ref.
# File lib/review/latexbuilder.rb, line 696 def node_inline_list(node) id = node[0].to_raw chapter, id = extract_chapter_id(id) macro('reviewlistref', "#{chapter.number}.#{chapter.list(id).number}") end
node_inline_m(node)
click to toggle source
math
def inline_m(str) " $#{str}$ " end
# File lib/review/latexbuilder.rb, line 745 def node_inline_m(node) " $#{node[0].to_raw}$ " end
node_inline_table(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 702 def node_inline_table(node) id = node[0].to_raw chapter, id = extract_chapter_id(id) macro('reviewtableref', "#{chapter.number}.#{chapter.table(id).number}", table_label(id, chapter)) end
node_inline_title(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 681 def node_inline_title(node) id = node[0].to_raw title = @book.chapter_index.title(id) if @book.config["chapterlink"] "\\hyperref[chap:#{id}]{#{title}}" else title end rescue KeyError error "unknown chapter: #{id}" nofunc_text("[UnknownChapter:#{id}]") end
node_label(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 639 def node_label(node) id = node.args[0].to_raw macro('label', id) + "\n" end
node_table(node)
click to toggle source
# File lib/review/latexbuilder.rb, line 461 def node_table(node) id = node.args[0].to_raw caption = node.args[1].to_doc lines = [] node.content.each do |line| lines << line.to_doc end buf = "" 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 buf << table_header(id, caption) unless caption.nil? rescue KeyError error "no such table: #{id}" end return buf if rows.empty? buf << table_begin(rows.first.size) if sepidx sepidx.times do buf << tr(rows.shift.map {|s| th(s) }) end rows.each do |cols| buf << tr(cols.map {|s| td(s) }) end else rows.each do |cols| h, *cs = *cols buf << tr([th(h)] + cs.map {|s| td(s) }) end end buf << table_end buf end
nofunc_text(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 799 def nofunc_text(str) escape(str) end
noindent()
click to toggle source
# File lib/review/latexbuilder.rb, line 652 def noindent '\noindent' end
nonum_begin(level, label, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 89 def nonum_begin(level, label, caption) "\n" + macro(HEADLINE[level]+"*", caption) + "\n" end
nonum_end(level)
click to toggle source
# File lib/review/latexbuilder.rb, line 93 def nonum_end(level) end
ol_begin()
click to toggle source
# File lib/review/latexbuilder.rb, line 168 def ol_begin buf = "\n" buf << '\begin{enumerate}' << "\n" if @ol_num buf << "\\setcounter{enumi}{#{@ol_num - 1}}\n" @ol_num = nil end buf end
ol_end()
click to toggle source
# File lib/review/latexbuilder.rb, line 184 def ol_end '\end{enumerate}' + "\n" end
ol_item(lines, num)
click to toggle source
# File lib/review/latexbuilder.rb, line 178 def ol_item(lines, num) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} '\item ' + str + "\n" end
olnum(num)
click to toggle source
# File lib/review/latexbuilder.rb, line 948 def olnum(num) @ol_num = num.to_i end
pagebreak()
click to toggle source
# File lib/review/latexbuilder.rb, line 644 def pagebreak '\pagebreak' + "\n" end
paragraph(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 206 def paragraph(lines) buf = "\n" lines.each do |line| buf << line end buf << "\n" buf end
parasep()
click to toggle source
# File lib/review/latexbuilder.rb, line 215 def parasep '\\parasep' + "\n" end
quote(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 573 def quote(lines) latex_block 'quote', lines end
read(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 219 def read(lines) latex_block 'quotation', lines end
Also aliased as: lead
result_metric(array)
click to toggle source
# File lib/review/latexbuilder.rb, line 368 def result_metric(array) "#{array.join(',')}" end
source(lines, caption = nil, lang = nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 338 def source(lines, caption = nil, lang = nil) if highlight_listings? common_code_block_lst(nil, lines, 'reviewlistlst', 'title', caption, lang) else buf = "\n" buf << '\begin{reviewlist}' << "\n" buf << source_header(caption) buf << source_body(lines) buf << '\end{reviewlist}' << "\n" buf << "\n" buf end end
source_body(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 356 def source_body(lines) buf = "" lines.each do |line| buf << detab(line) << "\n" end buf end
source_header(caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 352 def source_header(caption) macro('reviewlistcaption', caption) + "\n" end
table_begin(ncols)
click to toggle source
# File lib/review/latexbuilder.rb, line 517 def table_begin(ncols) buf = "" if @latex_tsize buf << macro('begin', 'reviewtable', @latex_tsize) << "\n" elsif @tsize cellwidth = @tsize.split(/\s*,\s*/) buf << macro('begin', 'reviewtable', '|'+(cellwidth.collect{|i| "p{#{i}mm}"}.join('|'))+'|') << "\n" else buf << macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l')) << "\n" end buf << '\hline' << "\n" @tsize = nil @latex_tsize = nil buf end
table_end()
click to toggle source
# File lib/review/latexbuilder.rb, line 562 def table_end buf = "" buf << macro('end', 'reviewtable') << "\n" if @table_caption buf << '\end{table}' << "\n" end @table_caption = nil buf << "\n" buf end
table_header(id, caption)
click to toggle source
# File lib/review/latexbuilder.rb, line 506 def table_header(id, caption) buf = "" if caption.present? @table_caption = true buf << '\begin{table}[h]' << "\n" buf << macro('reviewtablecaption', caption) << "\n" end buf << macro('label', table_label(id)) << "\n" buf end
table_separator()
click to toggle source
# File lib/review/latexbuilder.rb, line 533 def table_separator #puts '\hline' end
td(s)
click to toggle source
# File lib/review/latexbuilder.rb, line 546 def td(s) ## use shortstack for @<br> if /\\\\/ =~ s macro('shortstack[l]', s) else s end end
texequation(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 587 def texequation(lines) buf = "\n" buf << macro('begin','equation*') << "\n" lines.each do |line| buf << unescape_latex(line) << "\n" end buf << macro('end', 'equation*') << "\n" buf << "\n" buf end
th(s)
click to toggle source
# File lib/review/latexbuilder.rb, line 537 def th(s) ## use shortstack for @<br> if /\\\\/i =~ s macro('reviewth', macro('shortstack[l]', s)) else macro('reviewth', s) end end
tr(rows)
click to toggle source
# File lib/review/latexbuilder.rb, line 555 def tr(rows) buf = "" buf << rows.join(' & ') buf << ' \\\\ \hline' << "\n" buf end
tsize(str)
click to toggle source
# File lib/review/latexbuilder.rb, line 936 def tsize(str) @tsize = str end
ul_begin()
click to toggle source
# File lib/review/latexbuilder.rb, line 152 def ul_begin buf = "\n" buf << '\begin{itemize}' << "\n" buf end
ul_end()
click to toggle source
# File lib/review/latexbuilder.rb, line 164 def ul_end '\end{itemize}' + "\n" end
ul_item(lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 158 def ul_item(lines) str = lines.join str.sub!(/\A(\[)/){'\lbrack{}'} '\item ' + str + "\n" end
Private Instance Methods
bib_label(id)
click to toggle source
# File lib/review/latexbuilder.rb, line 430 def bib_label(id) "bib:#{id}" end
blank()
click to toggle source
# File lib/review/latexbuilder.rb, line 45 def blank @blank_needed = true end
blank_reset()
click to toggle source
# File lib/review/latexbuilder.rb, line 50 def blank_reset @blank_needed = false end
builder_init_file()
click to toggle source
# File lib/review/latexbuilder.rb, line 35 def builder_init_file @blank_needed = false @latex_tsize = nil @tsize = nil @table_caption = nil @ol_num = nil @sec_counter = SecCounter.new(5, @chapter) end
chapter_label()
click to toggle source
# File lib/review/latexbuilder.rb, line 414 def chapter_label "chap:#{@chapter.id}" end
column_label(id)
click to toggle source
# File lib/review/latexbuilder.rb, line 435 def column_label(id) filename = @chapter.id num = @chapter.column(id).number "column:#{filename}:#{num}" end
existence(id)
click to toggle source
# File lib/review/latexbuilder.rb, line 403 def existence(id) @chapter.image(id).bound? ? 'exist' : 'not exist' end
highlight_listings?()
click to toggle source
# File lib/review/latexbuilder.rb, line 225 def highlight_listings? @book.config["highlight"] && @book.config["highlight"]["latex"] == "listings" end
image_label(id, chapter=nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 408 def image_label(id, chapter=nil) chapter ||= @chapter "image:#{chapter.id}:#{id}" end
latex_block(type, lines)
click to toggle source
# File lib/review/latexbuilder.rb, line 598 def latex_block(type, lines) buf = "\n" buf << macro('begin', type) if @book.config["deprecated-blocklines"].nil? buf << lines.join("") else error "deprecated-blocklines is obsoleted." end buf << macro('end', type) << "\n" buf end
sec_label(sec_anchor)
click to toggle source
# File lib/review/latexbuilder.rb, line 419 def sec_label(sec_anchor) "sec:#{sec_anchor}" end
table_label(id, chapter=nil)
click to toggle source
# File lib/review/latexbuilder.rb, line 424 def table_label(id, chapter=nil) chapter ||= @chapter "table:#{chapter.id}:#{id}" end