module LaTeX
Public Instance Methods
body()
click to toggle source
# File lib/ulmul.rb, line 537 def body b = @body.dup [@equations, @figures, @tables, @codes].each do |ary| ary.each_with_index do |r,i| s = r.sub(/:.*/,'') if /Eq|Fig/ =~ s then s << '.' end if /Eq/ =~ s then no = "(\\ref{#{r}})" else no = "\\ref{#{r}}" end b.gsub!(Regexp.new('(?![A-Za-z0-9_"\'#%\\\\{\=])(.)'+r+'(?![A-Za-z0-9_"\'#%}])(.)'), "\\1#{s}~#{no}\\2") end end return b end
cb_env_end2()
click to toggle source
# File lib/ulmul.rb, line 479 def cb_env_end2() case @env_label when /^Fig:/ width = EXIFR::JPEG.new(@env_file).width height = EXIFR::JPEG.new(@env_file).height @body << "\\begin{figure}\n" << " \\center\n \\includegraphics[width=5cm,bb=0 0 #{width} #{height}]{#{@env_file}}\n" @body << ' \caption{' << @subs_rules.call(@env_caption).strip << "}\n" @body << " \\label{#{@env_label}}\n" << "\\end{figure}\n" when /^Table:/ @body << "\\begin{table}\n" @body << ' \caption{' << @subs_rules.call(@env_caption).strip << "}\n" @body << " \\label{#{@env_label}}\n" @body << " \\center\n" @body << " {TABLE is not yet implemented.}\n" @body << "\\end{table}\n" when /^Code:/ @body << "\\begin{lstlisting}[caption={#{@subs_rules.call(@env_caption).strip}},label=#{@env_label}]\n" f = open(@env_file) @body << f.read f.close @body << "\\end{lstlisting}\n" end end
cb_equation_end2()
click to toggle source
# File lib/ulmul.rb, line 503 def cb_equation_end2() @body << "\\begin{equation}\n" << " \\label{#{@equation_label}}\n" @body << @equation_contents @body << "\\end{equation}\n" end
cb_heading(filename=nil, lnumber=nil, line=nil)
click to toggle source
# File lib/ulmul.rb, line 458 def cb_heading(filename=nil, lnumber=nil, line=nil) if /^(=+) (.*)$/ =~ line new_level=Regexp.last_match[1].length str=Regexp.last_match[2] elsif /^=end/ =~ line @level_of_heading=0 @toc.cb_itemize_end() return end raise 'Illegal jump of heading level' if new_level>@level_of_heading+1 @title=str if new_level==1 @body << '\section{' << str << "}\n" if new_level==2 @body << '\subsection{' << str << "}\n" if new_level==3 @body << '\subsubsection{' << str << "}\n" if new_level==4 @body << '\bf{' << str << "}\n" if new_level==5 if 2 <= new_level && new_level <= $MAX_TABLE_OF_CONTENTS @toc.cb_itemize_add_item('LaTeX Table of Contents', @i_th_heading, " "*(new_level-2) + " * " + str) end @level_of_heading=new_level end
file(packages,name)
click to toggle source
# File lib/ulmul.rb, line 509 def file(packages,name) return "\\documentclass{article} \\usepackage{graphicx} \\usepackage{bm} \\usepackage{listings} \\renewcommand{\\lstlistingname}{Code} \\lstset{language=c, % basicstyle=\\ttfamily\\scriptsize, % commentstyle=\\textit, % classoffset=1, % keywordstyle=\\bfseries, frame=shadowbox, % framesep=5pt, % showstringspaces=false, % numbers=left, % stepnumber=1, % numberstyle=\\tiny, % tabsize=2 } \\title{#{@title}} \\author{#{name}} \\begin{document} \\maketitle #{body} \\end{document} " end