Class: ReVIEW::LATEXBuilder
Constant Summary
collapse
- HEADLINE =
{
1 => 'chapter',
2 => 'section',
3 => 'subsection',
4 => 'subsubsection',
5 => 'paragraph',
6 => 'subparagraph'
}
- BOUTEN =
"・"
Constants included
from LaTeXUtils
ReVIEW::LaTeXUtils::METACHARS, ReVIEW::LaTeXUtils::METACHARS_INVERT, ReVIEW::LaTeXUtils::METACHARS_RE
Constants inherited
from Builder
Builder::CAPTION_TITLES
Instance Method Summary
collapse
-
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
-
#bibpaper_header(id, caption) ⇒ Object
-
#box(lines, caption = nil) ⇒ Object
-
#captionblock(type, lines, caption) ⇒ Object
-
#center(lines) ⇒ Object
(also: #centering)
-
#cmd(lines, caption = nil) ⇒ Object
-
#column_begin(level, label, caption) ⇒ Object
-
#column_end(level) ⇒ Object
-
#comment(lines, comment = nil) ⇒ Object
-
#compile_href(url, label) ⇒ Object
-
#compile_kw(word, alt) ⇒ Object
-
#dd(lines) ⇒ Object
-
#direct(lines, fmt) ⇒ Object
-
#dl_begin ⇒ Object
-
#dl_end ⇒ Object
-
#dt(str) ⇒ Object
-
#emlist(lines, caption = nil) ⇒ Object
-
#emlistnum(lines, caption = nil) ⇒ Object
-
#extname ⇒ Object
-
#flushright(lines) ⇒ Object
-
#footnote(id, content) ⇒ Object
-
#headline(level, label, caption) ⇒ Object
-
#hr ⇒ Object
-
#image_dummy(id, caption, lines) ⇒ Object
-
#image_ext ⇒ Object
-
#image_header(id, caption) ⇒ Object
-
#image_image(id, caption, metric) ⇒ Object
-
#indepimage(id, caption = nil, metric = nil) ⇒ Object
(also: #numberlessimage)
-
#index(str) ⇒ Object
-
#inline_ami(str) ⇒ Object
-
#inline_b(str) ⇒ Object
-
#inline_bib(id) ⇒ Object
-
#inline_bou(str) ⇒ Object
-
#inline_br(str) ⇒ Object
-
#inline_chap(id) ⇒ Object
-
#inline_chapref(id) ⇒ Object
-
#inline_code(str) ⇒ Object
@<code> is same as @<tt>.
-
#inline_comment(str) ⇒ Object
-
#inline_del(str) ⇒ Object
-
#inline_dtp(str) ⇒ Object
-
#inline_em(str) ⇒ Object
-
#inline_fn(id) ⇒ Object
-
#inline_hd_chap(chap, id) ⇒ Object
-
#inline_hi(str) ⇒ Object
-
#inline_hidx(str) ⇒ Object
-
#inline_i(str) ⇒ Object
-
#inline_icon(id) ⇒ Object
-
#inline_idx(str) ⇒ Object
-
#inline_img(id) ⇒ Object
-
#inline_list(id) ⇒ Object
FIXME: use TeX native label/ref.
-
#inline_m(str) ⇒ Object
-
#inline_raw(str) ⇒ Object
-
#inline_ruby(str) ⇒ Object
-
#inline_strong(str) ⇒ Object
-
#inline_sub(str) ⇒ Object
-
#inline_sup(str) ⇒ Object
-
#inline_table(id) ⇒ Object
-
#inline_title(id) ⇒ Object
-
#inline_tt(str) ⇒ Object
-
#inline_ttb(str) ⇒ Object
-
#inline_tti(str) ⇒ Object
-
#inline_u(str) ⇒ Object
-
#inline_uchar(str) ⇒ Object
-
#label(id) ⇒ Object
-
#latextsize(str) ⇒ Object
-
#linebreak ⇒ Object
-
#list_body(id, lines) ⇒ Object
-
#list_header(id, caption) ⇒ Object
-
#listnum_body(lines) ⇒ Object
-
#nofunc_text(str) ⇒ Object
-
#noindent ⇒ Object
-
#nonum_begin(level, label, caption) ⇒ Object
-
#nonum_end(level) ⇒ Object
-
#ol_begin ⇒ Object
-
#ol_end ⇒ Object
-
#ol_item(lines, num) ⇒ Object
-
#olnum(num) ⇒ Object
-
#pagebreak ⇒ Object
-
#paragraph(lines) ⇒ Object
-
#parasep ⇒ Object
-
#quote(lines) ⇒ Object
-
#read(lines) ⇒ Object
(also: #lead)
-
#result_metric(array) ⇒ Object
-
#source(lines, caption) ⇒ Object
-
#source_body(lines) ⇒ Object
-
#source_header(caption) ⇒ Object
-
#table(lines, id = nil, caption = nil) ⇒ Object
-
#table_begin(ncols) ⇒ Object
-
#table_end ⇒ Object
-
#table_header(id, caption) ⇒ Object
-
#table_separator ⇒ Object
-
#td(s) ⇒ Object
-
#texequation(lines) ⇒ Object
-
#th(s) ⇒ Object
-
#tr(rows) ⇒ Object
-
#tsize(str) ⇒ Object
-
#ul_begin ⇒ Object
-
#ul_end ⇒ Object
-
#ul_item(lines) ⇒ Object
Methods included from TextUtils
#convert_inencoding, #convert_outencoding, #detab, #split_paragraph
Methods included from LaTeXUtils
#escape_index, #escape_latex, #escape_url, #macro, #unescape_latex
Methods inherited from Builder
#bibpaper, #bind, #compile_inline, #detab, #entries, #error, #extract_chapter_id, #find_pathes, #get_chap, #graph, #handle_metric, #image, #include, #initialize, #inline_hd, #inline_href, #inline_include, #inline_kw, #list, #listnum, #parse_metric, #post_paragraph, #pre_paragraph, #raw, #result, #text, #ul_item_begin, #ul_item_end, #warn
Instance Method Details
#bibpaper_bibpaper(id, caption, lines) ⇒ Object
748
749
750
|
# File 'lib/review/latexbuilder.rb', line 748
def bibpaper_bibpaper(id, caption, lines)
print split_paragraph(lines).join("")
end
|
743
744
745
746
|
# File 'lib/review/latexbuilder.rb', line 743
def (id, caption)
puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
puts macro('label', bib_label(id))
end
|
#box(lines, caption = nil) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/review/latexbuilder.rb', line 132
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
|
#captionblock(type, lines, caption) ⇒ Object
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/review/latexbuilder.rb', line 114
def captionblock(type, lines, caption)
puts "\\begin{reviewminicolumn}\n"
unless caption.nil?
puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n"
end
if ReVIEW.book.param["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
|
#center(lines) ⇒ Object
Also known as:
centering
477
478
479
|
# File 'lib/review/latexbuilder.rb', line 477
def center(lines)
latex_block 'center', lines
end
|
#cmd(lines, caption = nil) ⇒ Object
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/review/latexbuilder.rb', line 255
def cmd(lines, caption = nil)
blank
if caption
puts macro('reviewcmdcaption', "#{compile_inline(caption)}")
end
puts '\begin{reviewcmd}'
lines.each do |line|
puts detab(line)
end
puts '\end{reviewcmd}'
blank
end
|
#column_begin(level, label, caption) ⇒ Object
102
103
104
105
106
107
|
# File 'lib/review/latexbuilder.rb', line 102
def column_begin(level, label, caption)
blank
puts "\\begin{reviewcolumn}\n"
puts macro('reviewcolumnhead', nil, compile_inline(caption))
end
|
#column_end(level) ⇒ Object
109
110
111
112
|
# File 'lib/review/latexbuilder.rb', line 109
def column_end(level)
puts "\\end{reviewcolumn}\n"
blank
end
|
520
521
522
523
524
525
526
527
|
# File 'lib/review/latexbuilder.rb', line 520
def (lines, = nil)
lines ||= []
lines.unshift unless .blank?
if ReVIEW.book.param["draft"]
str = lines.join("")
puts macro('pdfcomment', escape(str))
end
end
|
#compile_href(url, label) ⇒ Object
778
779
780
781
782
783
784
785
786
787
788
|
# File 'lib/review/latexbuilder.rb', line 778
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
|
#compile_kw(word, alt) ⇒ Object
770
771
772
773
774
775
776
|
# File 'lib/review/latexbuilder.rb', line 770
def compile_kw(word, alt)
if alt
macro('reviewkw', escape(word)) + "(#{escape(alt.strip)})"
else
macro('reviewkw', escape(word))
end
end
|
#dd(lines) ⇒ Object
192
193
194
|
# File 'lib/review/latexbuilder.rb', line 192
def dd(lines)
puts lines.join
end
|
#direct(lines, fmt) ⇒ Object
513
514
515
516
517
518
|
# File 'lib/review/latexbuilder.rb', line 513
def direct(lines, fmt)
return unless fmt == 'latex'
lines.each do |line|
puts line
end
end
|
181
182
183
184
|
# File 'lib/review/latexbuilder.rb', line 181
def dl_begin
blank
puts '\begin{description}'
end
|
196
197
198
199
|
# File 'lib/review/latexbuilder.rb', line 196
def dl_end
puts '\end{description}'
blank
end
|
186
187
188
189
190
|
# File 'lib/review/latexbuilder.rb', line 186
def dt(str)
str.sub!(/\[/){'\lbrack{}'}
str.sub!(/\]/){'\rbrack{}'}
puts '\item[' + str + '] \mbox{} \\\\'
end
|
#emlist(lines, caption = nil) ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/review/latexbuilder.rb', line 219
def emlist(lines, caption = nil)
blank
if caption
puts macro('reviewemlistcaption', "#{compile_inline(caption)}")
end
puts '\begin{reviewemlist}'
lines.each do |line|
puts detab(line)
end
puts '\end{reviewemlist}'
blank
end
|
#emlistnum(lines, caption = nil) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
|
# File 'lib/review/latexbuilder.rb', line 232
def emlistnum(lines, caption = nil)
blank
if caption
puts macro('reviewemlistcaption', "#{compile_inline(caption)}")
end
puts '\begin{reviewemlist}'
lines.each_with_index do |line, i|
puts detab((i+1).to_s.rjust(2) + ": " + line)
end
puts '\end{reviewemlist}'
blank
end
|
31
32
33
|
# File 'lib/review/latexbuilder.rb', line 31
def extname
'.tex'
end
|
#flushright(lines) ⇒ Object
483
484
485
|
# File 'lib/review/latexbuilder.rb', line 483
def flushright(lines)
latex_block 'flushright', lines
end
|
599
600
601
602
603
604
|
# File 'lib/review/latexbuilder.rb', line 599
def (id, content)
if ReVIEW.book.param["footnotetext"]
puts macro("footnotetext[#{@chapter.(id).number}]",
compile_inline(content.strip))
end
end
|
#headline(level, label, caption) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/review/latexbuilder.rb', line 77
def headline(level, label, caption)
prefix = ""
if level > ReVIEW.book.param["secnolevel"] || (@chapter.number.to_s.empty? && level > 1)
prefix = "*"
end
blank unless @output.pos == 0
puts macro(HEADLINE[level]+prefix, compile_inline(caption))
if prefix == "*" && level <= ReVIEW.book.param["toclevel"].to_i
puts "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{compile_inline(caption)}}"
end
if level == 1
puts macro('label', chapter_label)
end
rescue
error "unknown level: #{level}"
end
|
529
530
531
|
# File 'lib/review/latexbuilder.rb', line 529
def hr
puts '\hrule'
end
|
#image_dummy(id, caption, lines) ⇒ Object
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/review/latexbuilder.rb', line 323
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
|
#image_ext ⇒ Object
798
799
800
|
# File 'lib/review/latexbuilder.rb', line 798
def image_ext
"svg"
end
|
300
301
|
# File 'lib/review/latexbuilder.rb', line 300
def (id, caption)
end
|
#image_image(id, caption, metric) ⇒ Object
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
# File 'lib/review/latexbuilder.rb', line 307
def image_image(id, caption, metric)
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('caption', compile_inline(caption))
end
puts macro('label', image_label(id))
puts '\end{reviewimage}'
end
|
#indepimage(id, caption = nil, metric = nil) ⇒ Object
Also known as:
numberlessimage
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
# File 'lib/review/latexbuilder.rb', line 360
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
|
#index(str) ⇒ Object
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
# File 'lib/review/latexbuilder.rb', line 752
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
|
#inline_ami(str) ⇒ Object
722
723
724
|
# File 'lib/review/latexbuilder.rb', line 722
def inline_ami(str)
macro('reviewami', escape(str))
end
|
#inline_b(str) ⇒ Object
651
652
653
|
# File 'lib/review/latexbuilder.rb', line 651
def inline_b(str)
macro('textbf', escape(str))
end
|
#inline_bib(id) ⇒ Object
690
691
692
|
# File 'lib/review/latexbuilder.rb', line 690
def inline_bib(id)
macro('reviewbibref', "[#{@chapter.bibpaper(id).number}]", bib_label(id))
end
|
#inline_bou(str) ⇒ Object
616
617
618
|
# File 'lib/review/latexbuilder.rb', line 616
def inline_bou(str)
str.split(//).map {|c| macro('ruby', escape(c), macro('textgt', BOUTEN)) }.join('\allowbreak')
end
|
#inline_br(str) ⇒ Object
656
657
658
|
# File 'lib/review/latexbuilder.rb', line 656
def inline_br(str)
"\\\\\n"
end
|
#inline_chap(id) ⇒ Object
560
561
562
563
564
565
566
567
568
569
|
# File 'lib/review/latexbuilder.rb', line 560
def inline_chap(id)
if ReVIEW.book.param["chapterlink"]
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.number(id)}}"
else
@chapter.env.chapter_index.number(id)
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_chapref(id) ⇒ Object
549
550
551
552
553
554
555
556
557
558
|
# File 'lib/review/latexbuilder.rb', line 549
def inline_chapref(id)
if ReVIEW.book.param["chapterlink"]
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.display_string(id)}}"
else
@chapter.env.chapter_index.display_string(id)
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_code(str) ⇒ Object
666
667
668
|
# File 'lib/review/latexbuilder.rb', line 666
def inline_code(str)
macro('texttt', escape(str))
end
|
735
736
737
738
739
740
741
|
# File 'lib/review/latexbuilder.rb', line 735
def (str)
if ReVIEW.book.param["draft"]
macro('pdfcomment', escape(str))
else
""
end
end
|
#inline_del(str) ⇒ Object
678
679
680
|
# File 'lib/review/latexbuilder.rb', line 678
def inline_del(str)
macro('reviewstrike', escape(str))
end
|
#inline_dtp(str) ⇒ Object
660
661
662
663
|
# File 'lib/review/latexbuilder.rb', line 660
def inline_dtp(str)
""
end
|
#inline_em(str) ⇒ Object
710
711
712
|
# File 'lib/review/latexbuilder.rb', line 710
def inline_em(str)
macro('reviewem', escape(str))
end
|
#inline_fn(id) ⇒ Object
606
607
608
609
610
611
612
|
# File 'lib/review/latexbuilder.rb', line 606
def inline_fn(id)
if ReVIEW.book.param["footnotetext"]
macro("footnotemark[#{@chapter.(id).number}]", "")
else
macro('footnote', compile_inline(@chapter.(id).content.strip))
end
end
|
#inline_hd_chap(chap, id) ⇒ Object
694
695
696
|
# File 'lib/review/latexbuilder.rb', line 694
def inline_hd_chap(chap, id)
"「#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}」"
end
|
#inline_hi(str) ⇒ Object
631
632
633
|
# File 'lib/review/latexbuilder.rb', line 631
def inline_hi(str)
index(str)
end
|
#inline_hidx(str) ⇒ Object
646
647
648
|
# File 'lib/review/latexbuilder.rb', line 646
def inline_hidx(str)
index(str)
end
|
#inline_i(str) ⇒ Object
636
637
638
|
# File 'lib/review/latexbuilder.rb', line 636
def inline_i(str)
macro('textit', escape(str))
end
|
#inline_icon(id) ⇒ Object
726
727
728
|
# File 'lib/review/latexbuilder.rb', line 726
def inline_icon(id)
macro('includegraphics', @chapter.image(id).path)
end
|
#inline_idx(str) ⇒ Object
641
642
643
|
# File 'lib/review/latexbuilder.rb', line 641
def inline_idx(str)
text(str) + index(str)
end
|
#inline_img(id) ⇒ Object
594
595
596
597
|
# File 'lib/review/latexbuilder.rb', line 594
def inline_img(id)
chapter, id = (id)
macro('reviewimageref', "#{chapter.number}.#{chapter.image(id).number}", image_label(id))
end
|
#inline_list(id) ⇒ Object
FIXME: use TeX native label/ref.
584
585
586
587
|
# File 'lib/review/latexbuilder.rb', line 584
def inline_list(id)
chapter, id = (id)
macro('reviewlistref', "#{chapter.number}.#{chapter.list(id).number}")
end
|
#inline_m(str) ⇒ Object
626
627
628
|
# File 'lib/review/latexbuilder.rb', line 626
def inline_m(str)
" $#{str}$ "
end
|
#inline_raw(str) ⇒ Object
698
699
700
|
# File 'lib/review/latexbuilder.rb', line 698
def inline_raw(str)
super(str)
end
|
#inline_ruby(str) ⇒ Object
620
621
622
623
|
# File 'lib/review/latexbuilder.rb', line 620
def inline_ruby(str)
base, ruby = *str.split(/,/)
macro('ruby', base, ruby)
end
|
#inline_strong(str) ⇒ Object
714
715
716
|
# File 'lib/review/latexbuilder.rb', line 714
def inline_strong(str)
macro('reviewstrong', escape(str))
end
|
#inline_sub(str) ⇒ Object
702
703
704
|
# File 'lib/review/latexbuilder.rb', line 702
def inline_sub(str)
macro('textsubscript', escape(str))
end
|
#inline_sup(str) ⇒ Object
706
707
708
|
# File 'lib/review/latexbuilder.rb', line 706
def inline_sup(str)
macro('textsuperscript', escape(str))
end
|
#inline_table(id) ⇒ Object
589
590
591
592
|
# File 'lib/review/latexbuilder.rb', line 589
def inline_table(id)
chapter, id = (id)
macro('reviewtableref', "#{chapter.number}.#{chapter.table(id).number}", table_label(id))
end
|
#inline_title(id) ⇒ Object
571
572
573
574
575
576
577
578
579
580
|
# File 'lib/review/latexbuilder.rb', line 571
def inline_title(id)
if ReVIEW.book.param["chapterlink"]
"\\hyperref[chap:#{id}]{#{@chapter.env.chapter_index.title(id)}}"
else
@chapter.env.chapter_index.title(id)
end
rescue KeyError
error "unknown chapter: #{id}"
nofunc_text("[UnknownChapter:#{id}]")
end
|
#inline_tt(str) ⇒ Object
674
675
676
|
# File 'lib/review/latexbuilder.rb', line 674
def inline_tt(str)
macro('texttt', escape(str))
end
|
#inline_ttb(str) ⇒ Object
686
687
688
|
# File 'lib/review/latexbuilder.rb', line 686
def inline_ttb(str)
macro('texttt', macro('textbf', escape(str)))
end
|
#inline_tti(str) ⇒ Object
682
683
684
|
# File 'lib/review/latexbuilder.rb', line 682
def inline_tti(str)
macro('texttt', macro('textit', escape(str)))
end
|
#inline_u(str) ⇒ Object
718
719
720
|
# File 'lib/review/latexbuilder.rb', line 718
def inline_u(str)
macro('Underline', escape(str))
end
|
#inline_uchar(str) ⇒ Object
730
731
732
733
|
# File 'lib/review/latexbuilder.rb', line 730
def inline_uchar(str)
macro('UTF', escape(str))
end
|
#label(id) ⇒ Object
533
534
535
|
# File 'lib/review/latexbuilder.rb', line 533
def label(id)
puts macro('label', id)
end
|
#latextsize(str) ⇒ Object
794
795
796
|
# File 'lib/review/latexbuilder.rb', line 794
def latextsize(str)
@latex_tsize = str
end
|
#linebreak ⇒ Object
541
542
543
|
# File 'lib/review/latexbuilder.rb', line 541
def linebreak
puts '\\\\'
end
|
#list_body(id, lines) ⇒ Object
272
273
274
275
276
277
278
279
|
# File 'lib/review/latexbuilder.rb', line 272
def list_body(id, lines)
puts '\begin{reviewlist}'
lines.each do |line|
puts detab(line)
end
puts '\end{reviewlist}'
puts ""
end
|
268
269
270
|
# File 'lib/review/latexbuilder.rb', line 268
def (id, caption)
puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}")
end
|
#listnum_body(lines) ⇒ Object
245
246
247
248
249
250
251
252
253
|
# File 'lib/review/latexbuilder.rb', line 245
def listnum_body(lines)
puts '\begin{reviewlist}'
lines.each_with_index do |line, i|
puts detab((i+1).to_s.rjust(2) + ": " + line)
end
puts '\end{reviewlist}'
blank
end
|
#nofunc_text(str) ⇒ Object
670
671
672
|
# File 'lib/review/latexbuilder.rb', line 670
def nofunc_text(str)
escape(str)
end
|
545
546
547
|
# File 'lib/review/latexbuilder.rb', line 545
def noindent
print '\noindent'
end
|
#nonum_begin(level, label, caption) ⇒ Object
94
95
96
97
|
# File 'lib/review/latexbuilder.rb', line 94
def nonum_begin(level, label, caption)
blank unless @output.pos == 0
puts macro(HEADLINE[level]+"*", compile_inline(caption))
end
|
#nonum_end(level) ⇒ Object
99
100
|
# File 'lib/review/latexbuilder.rb', line 99
def nonum_end(level)
end
|
161
162
163
164
165
166
167
168
|
# File 'lib/review/latexbuilder.rb', line 161
def ol_begin
blank
puts '\begin{enumerate}'
if @ol_num
puts "\\setcounter{enumi}{#{@ol_num - 1}}"
@ol_num = nil
end
end
|
176
177
178
179
|
# File 'lib/review/latexbuilder.rb', line 176
def ol_end
puts '\end{enumerate}'
blank
end
|
#ol_item(lines, num) ⇒ Object
170
171
172
173
174
|
# File 'lib/review/latexbuilder.rb', line 170
def ol_item(lines, num)
str = lines.join
str.sub!(/\A(\[)/){'\lbrack{}'}
puts '\item ' + str
end
|
#olnum(num) ⇒ Object
802
803
804
|
# File 'lib/review/latexbuilder.rb', line 802
def olnum(num)
@ol_num = num.to_i
end
|
#pagebreak ⇒ Object
537
538
539
|
# File 'lib/review/latexbuilder.rb', line 537
def pagebreak
puts '\pagebreak'
end
|
#paragraph(lines) ⇒ Object
201
202
203
204
205
206
207
|
# File 'lib/review/latexbuilder.rb', line 201
def paragraph(lines)
blank
lines.each do |line|
puts line
end
blank
end
|
209
210
211
|
# File 'lib/review/latexbuilder.rb', line 209
def parasep()
puts '\\parasep'
end
|
#quote(lines) ⇒ Object
473
474
475
|
# File 'lib/review/latexbuilder.rb', line 473
def quote(lines)
latex_block 'quote', lines
end
|
#read(lines) ⇒ Object
Also known as:
lead
213
214
215
|
# File 'lib/review/latexbuilder.rb', line 213
def read(lines)
latex_block 'quotation', lines
end
|
#result_metric(array) ⇒ Object
303
304
305
|
# File 'lib/review/latexbuilder.rb', line 303
def result_metric(array)
"#{array.join(',')}"
end
|
#source(lines, caption) ⇒ Object
281
282
283
284
285
286
287
|
# File 'lib/review/latexbuilder.rb', line 281
def source(lines, caption)
puts '\begin{reviewlist}'
caption
source_body lines
puts '\end{reviewlist}'
puts ""
end
|
#source_body(lines) ⇒ Object
293
294
295
296
297
|
# File 'lib/review/latexbuilder.rb', line 293
def source_body(lines)
lines.each do |line|
puts detab(line)
end
end
|
289
290
291
|
# File 'lib/review/latexbuilder.rb', line 289
def (caption)
puts macro('reviewlistcaption', compile_inline(caption))
end
|
#table(lines, id = nil, caption = nil) ⇒ Object
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
# File 'lib/review/latexbuilder.rb', line 377
def table(lines, id = nil, caption = nil)
rows = []
sepidx = nil
lines.each_with_index do |line, idx|
if /\A[\=\{\-\}]{12}/ =~ line
sepidx ||= idx
next
end
rows.push line.strip.split(/\t+/).map {|s| s.sub(/\A\./, '') }
end
rows = adjust_n_cols(rows)
begin
id, caption unless caption.nil?
rescue KeyError => err
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
|
#table_begin(ncols) ⇒ Object
423
424
425
426
427
428
429
430
431
432
433
434
435
|
# File 'lib/review/latexbuilder.rb', line 423
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
|
#table_end ⇒ Object
464
465
466
467
468
469
470
471
|
# File 'lib/review/latexbuilder.rb', line 464
def table_end
puts macro('end', 'reviewtable')
if @table_caption
puts '\end{table}'
end
@table_caption = nil
blank
end
|
414
415
416
417
418
419
420
421
|
# File 'lib/review/latexbuilder.rb', line 414
def (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
|
#table_separator ⇒ Object
437
438
439
|
# File 'lib/review/latexbuilder.rb', line 437
def table_separator
end
|
450
451
452
453
454
455
456
457
|
# File 'lib/review/latexbuilder.rb', line 450
def td(s)
if /\\\\/ =~ s
macro('shortstack[l]', s)
else
s
end
end
|
#texequation(lines) ⇒ Object
487
488
489
490
491
492
493
494
495
|
# File 'lib/review/latexbuilder.rb', line 487
def texequation(lines)
blank
puts macro('begin','equation*')
lines.each do |line|
puts unescape_latex(line)
end
puts macro('end', 'equation*')
blank
end
|
441
442
443
444
445
446
447
448
|
# File 'lib/review/latexbuilder.rb', line 441
def th(s)
if /\\\\/i =~ s
macro('reviewth', macro('shortstack[l]', s))
else
macro('reviewth', s)
end
end
|
459
460
461
462
|
# File 'lib/review/latexbuilder.rb', line 459
def tr(rows)
print rows.join(' & ')
puts ' \\\\ \hline'
end
|
#tsize(str) ⇒ Object
790
791
792
|
# File 'lib/review/latexbuilder.rb', line 790
def tsize(str)
@tsize = str
end
|
145
146
147
148
|
# File 'lib/review/latexbuilder.rb', line 145
def ul_begin
blank
puts '\begin{itemize}'
end
|
156
157
158
159
|
# File 'lib/review/latexbuilder.rb', line 156
def ul_end
puts '\end{itemize}'
blank
end
|
#ul_item(lines) ⇒ Object
150
151
152
153
154
|
# File 'lib/review/latexbuilder.rb', line 150
def ul_item(lines)
str = lines.join
str.sub!(/\A(\[)/){'\lbrack{}'}
puts '\item ' + str
end
|