module NbUtil
Constants
- VERSION
Public Instance Methods
combine(argv0, argv1, argv2)
click to toggle source
# File lib/nb_util/combine.rb, line 10 def combine(argv0, argv1, argv2) ipynb0 = JSON.load(File.read(ARGV[1])) ipynb1 = JSON.load(File.read(ARGV[2])) output_filename = ARGV[3] p output_filename ipynb0["cells"].each do |cell| pp cell ipynb1["cells"] << cell end File.open(output_filename + ".ipynb", 'w') do |target| JSON.dump(ipynb1,target) end end
delete_folder(target)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 157 def delete_folder(target) loop do print "Are you sure?: " input = STDIN.gets.to_s.chomp if input == 'Y' || input == 'y' mk_latex = File.join(File.absolute_path("../", target), '/mk_latex') old = File.join(File.absolute_path("../", target), '/old') if Dir.exist?(mk_latex) && Dir.exist?(old) print "\e[31mdelete: \e[0m" FileUtils.rm_r(mk_latex) puts "\e[31m#{mk_latex}\e[0m" print "\e[31mdelete: \e[0m" FileUtils.rm_r(old) puts "\e[31m#{old}\e[0m" break elsif Dir.exist?(mk_latex) print "\e[31mdelete: \e[0m" FileUtils.rm_r(mk_latex) puts "\e[31m#{mk_latex}\e[0m" break elsif Dir.exist?(old) print "\e[31mdelete: \e[0m" FileUtils.rm_r(old) puts "\e[31m#{old}\e[0m" break else puts "\e[31mNo such file or directory\e[0m" break end elsif input == 'N' || input == 'n' puts break end end end
flatten_hash_from(hash)
click to toggle source
nest hash to single hash
# File lib/nb_util/yaml2ipynb.rb, line 172 def flatten_hash_from hash hash.each_with_object({}) do |(key, value), memo| next flatten_hash_from(value).each do |k, v| memo["#{key}.#{k}".intern] = v end if value.is_a? Hash memo[key] = value end end
get_name(str)
click to toggle source
# File lib/nb_util.rb, line 12 def get_name(str) str.delete(' ').split(/[\/]/) end
getcode(argv0)
click to toggle source
# File lib/nb_util/getcode.rb, line 8 def getcode(argv0) input_filename = ARGV[1] ipynb = JSON.parse(File.read(input_filename)) ipynb_filename = ARGV[2] || input_filename.gsub(/(.ipynb)$/, '') hash = {} i = 0 ipynb["cells"].each do |k, v| hash[i.to_s] = k i += 1 end for j in 0..i-1 do var="@hash#{j}" eval("#{var}={}") hash[j.to_s].each do |k, v| eval("#{var}[k] = v") end end flag = 0 source_count = 0 @getcode = "" for i in 0..j - 1 do eval("if @hash#{i}[\"cell_type\"] != \"code\" then flag = 1 end") if flag == 0 then eval("puts @getcode = @hash#{i}[\"source\"]") source_count = source_count + 1 output_filename = ipynb_filename + source_count.to_s + ipynb["metadata"]["language_info"]["file_extension"] File.open(output_filename, 'w+') do |f| f.puts(@getcode) end end flag = 0 end end
iputs(argv0)
click to toggle source
# File lib/nb_util/iputs.rb, line 7 def iputs(argv0) ipynb = JSON.load(File.read(ARGV[1])) ipynb.each do |cells| next unless cells.include?("cells") cells[1].each do |cell| cell["source"].each do |line| print line end end end end
ipynb2tex_handout(target)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 84 def ipynb2tex_handout(target) loop do target_parent = File.dirname(target) exist_info = File.join(target_parent, 'mk_latex/split_files/informations/informations.tex') if File.exist?(exist_info) FileUtils.mkdir_p(target_parent + '/split_files/informations') FileUtils.cp(exist_info, target_parent) else your_informations(ARGV[1], "handout") end print "Are you ok with it?: " input = STDIN.gets.to_s.chomp if input == 'Y' || input == 'y' location = Open3.capture3("gem environment gemdir") versions = Open3.capture3("gem list nb_util") latest_version = versions[0].split(",") cp_lib_data_handout_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout") cp_lib_data_handout_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout_pieces") cp_lib_data_handout_bundle = File.join(Dir.pwd, '/lib/data/handout') cp_lib_data_handout_pieces_bundle = File.join(Dir.pwd, '/lib/data/handout_pieces') re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/ print "\e[32minputfile: \e[0m" target = File.expand_path(ARGV[1]) print "\e[32m#{target}\n\e[0m" print "\e[32moutputfile: \e[0m" tex_src = target.sub('.ipynb', '.tex') print "\e[32m#{tex_src}\n\e[0m" target_parent = File.dirname(target) target_basename = File.basename(tex_src) Open3.capture3("jupyter nbconvert --to latex #{target}") lines = File.readlines(tex_src) lines.each_with_index do |line, i| line.sub!("\documentclass[11pt]{article}", "\documentclass[11pt,dvipdfmx]{jsarticle}") print "\e[32m#{line}\n\e[0m" if line =~ re_fig #redにする"\e[31m\e[0m" line.sub!(line, '%' + line) if line.include?('.svg') end File.open(tex_src, 'w') { |file| file.print lines.join } FileUtils.mkdir_p(target_parent + '/latex') FileUtils.mv(tex_src, target_parent + '/latex') replace_figs(File.join(target_parent + '/latex', target_basename), "handout") revise_lines(File.join(target_parent + '/latex', target_basename)) split_files(File.join(target_parent + '/latex', target_basename), target, "handout") FileUtils.mv(target_parent + '/tmp.tex', target_parent + '/split_files/tmp') FileUtils.mv(target_parent + '/informations.tex', target_parent + '/split_files/informations') mk_thesis_location(target, "handout") FileUtils.mv(target_parent + '/.splits_location.tex', target_parent + '/handout') mk_xbb(target, re_fig) if Dir.exist?(cp_lib_data_handout_pieces_bundle.to_s) && Dir.exist?(cp_lib_data_handout_bundle.to_s) FileUtils.cp_r(cp_lib_data_handout_pieces_bundle, target_parent) FileUtils.cp_r(cp_lib_data_handout_bundle, target_parent) else FileUtils.cp_r(cp_lib_data_handout_pieces_gem, target_parent) FileUtils.cp_r(cp_lib_data_handout_gem, target_parent) end mk_latex_and_mv_to_latex(target, target_parent, "handout") Open3.capture3("open #{target_parent}") Open3.capture3("open #{target_parent}/mk_latex/handout/handout.tex/") exit break elsif input == 'N' || input == 'n' target_parent = File.dirname(target) FileUtils.rm_r(File.join(target_parent.to_s, '/informations.tex')) break end end end
ipynb2tex_thesis(target)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 10 def ipynb2tex_thesis(target) loop do target_parent = File.dirname(target) exist_info = File.join(target_parent, 'mk_latex/split_files/informations/informations.tex') if File.exist?(exist_info) FileUtils.mkdir_p(target_parent + '/split_files/informations') FileUtils.cp(exist_info, target_parent) else your_informations(ARGV[1], "thesis") end print "Are you ok with it?: " input = STDIN.gets.to_s.chomp if input == 'Y' || input == 'y' location = Open3.capture3("gem environment gemdir") versions = Open3.capture3("gem list nb_util") latest_version = versions[0].split(",") cp_lib_data_thesis_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/thesis") cp_lib_data_thesis_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/thesis_pieces") cp_lib_data_thesis_bundle = File.join(Dir.pwd, '/lib/data/thesis') cp_lib_data_thesis_pieces_bundle = File.join(Dir.pwd, '/lib/data/thesis_pieces') re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/ print "\e[32minputfile: \e[0m" target = File.expand_path(ARGV[1]) print "\e[32m#{target}\n\e[0m" print "\e[32moutputfile: \e[0m" tex_src = target.sub('.ipynb', '.tex') print "\e[32m#{tex_src}\n\e[0m" target_parent = File.dirname(target) target_basename = File.basename(tex_src) Open3.capture3("jupyter nbconvert --to latex #{target}") lines = File.readlines(tex_src) lines.each_with_index do |line, i| line.sub!("\documentclass[11pt]{article}", "\documentclass[11pt,dvipdfmx]{jsarticle}") print "\e[32m#{line}\n\e[0m" if line =~ re_fig #redにする"\e[31m\e[0m" line.sub!(line, '%' + line) if line.include?('.svg') end File.open(tex_src, 'w') { |file| file.print lines.join } FileUtils.mkdir_p(target_parent + '/latex') FileUtils.mv(tex_src, target_parent + '/latex') replace_figs(File.join(target_parent + '/latex', target_basename), "thesis") revise_lines(File.join(target_parent + '/latex', target_basename)) split_files(File.join(target_parent + '/latex', target_basename), target, "thesis") FileUtils.mv(target_parent + '/tmp.tex', target_parent + '/split_files/tmp') FileUtils.mv(target_parent + '/informations.tex', target_parent + '/split_files/informations') mk_thesis_location(target, "thesis") FileUtils.mv(target_parent + '/.splits_location.tex', target_parent + '/thesis') mk_xbb(target, re_fig) if Dir.exist?(cp_lib_data_thesis_pieces_bundle.to_s) && Dir.exist?(cp_lib_data_thesis_bundle.to_s) FileUtils.cp_r(cp_lib_data_thesis_pieces_bundle, target_parent) FileUtils.cp_r(cp_lib_data_thesis_bundle, target_parent) else FileUtils.cp_r(cp_lib_data_thesis_pieces_gem, target_parent) FileUtils.cp_r(cp_lib_data_thesis_gem, target_parent) end mk_latex_and_mv_to_latex(target, target_parent, "thesis") Open3.capture3("open #{target_parent}") # p File.join(target_parent,"mk_latex/thesis") Open3.capture3("open #{target_parent}/mk_latex/thesis/thesis.tex/") exit break elsif input == 'N' || input == 'n' target_parent = File.dirname(target) FileUtils.rm_r(File.join(target_parent.to_s, '/informations.tex')) break end end end
mk_latex_and_mv_to_latex(target, target_parent, thesis_or_handout)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 374 def mk_latex_and_mv_to_latex(target, target_parent, thesis_or_handout) mk_latex = FileUtils.mkdir_p(File.join(File.dirname(target),'/mk_latex')) d = DateTime.now if thesis_or_handout == "thesis" if Dir.exist?(File.join(mk_latex[0].to_s, '/thesis')) old_file = File.join(File.dirname(target),"/old/thesis/#{d.year}#{d.month}#{d.day}#{d.hour}#{d.min}") FileUtils.mkdir_p(old_file) FileUtils.cp_r(mk_latex[0], old_file) FileUtils.rm_r(mk_latex[0]) elsif Dir.exist?(File.join(mk_latex[0].to_s, '/handout')) old_file = File.join(File.dirname(target),"/old/handout/#{d.year}#{d.month}#{d.day}#{d.hour}#{d.min}") FileUtils.mkdir_p(old_file) FileUtils.cp_r(mk_latex[0], old_file) FileUtils.rm_r(mk_latex[0]) end mk_latex = FileUtils.mkdir_p(File.join(File.dirname(target), '/mk_latex')) split_files = File.join(target_parent, '/split_files') thesis_pieces = File.join(target_parent, '/thesis_pieces') FileUtils.mv(thesis_pieces, mk_latex[0]) thesis = File.join(target_parent, '/thesis') latex = File.join(target_parent, '/latex') FileUtils.mv(split_files, File.join(mk_latex[0], "/split_files")) FileUtils.mv(latex, mk_latex[0]) FileUtils.mv(thesis, mk_latex[0]) end if thesis_or_handout == "handout" if Dir.exist?(File.join(mk_latex[0].to_s, '/thesis')) old_file = File.join(File.dirname(target),"/old/thesis/#{d.year}#{d.month}#{d.day}#{d.hour}#{d.min}") FileUtils.mkdir_p(old_file) FileUtils.cp_r(mk_latex[0], old_file) FileUtils.rm_r(mk_latex[0]) elsif Dir.exist?(File.join(mk_latex[0].to_s, '/handout')) old_file = File.join(File.dirname(target),"/old/handout/#{d.year}#{d.month}#{d.day}#{d.hour}#{d.min}") FileUtils.mkdir_p(old_file) FileUtils.cp_r(mk_latex[0], old_file) FileUtils.rm_r(mk_latex[0]) end mk_latex = FileUtils.mkdir_p(File.join(File.dirname(target), '/mk_latex')) split_files = File.join(target_parent, '/split_files') handout_pieces = File.join(target_parent, '/handout_pieces') FileUtils.mv(handout_pieces, mk_latex[0]) handout = File.join(target_parent, '/handout') latex = File.join(target_parent, '/latex') FileUtils.mv(split_files, File.join(mk_latex[0], "/split_files")) FileUtils.mv(latex, mk_latex[0]) FileUtils.mv(handout, mk_latex[0]) end end
mk_thesis_location(input_ipynb, thesis_or_handout)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 424 def mk_thesis_location(input_ipynb, thesis_or_handout) target_parent = File.dirname(input_ipynb) ipynb = JSON.parse(File.read(input_ipynb)) pickup_ipynb = ipynb["cells"].to_s.split(",") chapter = pickup_ipynb.grep(/"# /).map{ |i| i.gsub(/.*# /, '').gsub(/".*/, '') } chapter_size = chapter.size if thesis_or_handout == "thesis" FileUtils.mkdir_p(target_parent + '/thesis') end if thesis_or_handout == "handout" FileUtils.mkdir_p(target_parent + '/handout') end File.open(target_parent + '/.splits_location.tex', "w") do |f| for num in 0..chapter_size-1 do f.print("\\input{../split_files/chapter#{num+1}/chapter#{num+1}}\n") end end end
mk_xbb(target, re_fig)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 314 def mk_xbb(target, re_fig) target_parent = File.absolute_path("../..", target) FileUtils.mkdir_p(target_parent + '/figs') FileUtils.cd(target_parent + '/figs') Dir.entries('.').each do |file| next unless file =~ re_fig m = file.split('.')[0..-2] next if File.exist?(m.join('.') + '.xbb') command = "extractbb #{file}" p command system command end end
replace_figs(target, thesis_or_handout)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 269 def replace_figs(target, thesis_or_handout) lines = File.readlines(target) counter = -1 # settings of each data = [["This", 150, -4, 0]] lines.each_with_index do |line, i| lines[i] = " \\usepackage{wrapfig}\n"+line if line.include?("\\usepackage{graphicx}") lines[i] = '%' + line if line.include?("\\renewcommand{\\includegraphics}") lines[i] = '%' + line if line.include?("\\DeclareCaptionLabelFormat") lines[i] = '%' + line if line.include?("\\captionsetup{labelformat=nolabel}") if m = line.match(/\\includegraphics\{(.+)\}/) counter += 1 file_name, label, size, top, bottom = [m[1], data[counter]].flatten caption = lines[i + 1] label_name = file_name.to_s.gsub('figs', '').gsub('.png', '').gsub('/', '') if thesis_or_handout == "thesis" thesis_wrap_figs = <<"EOS" \\begin{center} \\includegraphics[width=150mm]{../../#{file_name}} \\end{center} #{caption} \\label{fig:#{label}} EOS end if thesis_or_handout == "handout" thesis_wrap_figs = <<"EOS" \\begin{center} \\includegraphics[width=80mm]{../../#{file_name}} \\end{center} #{caption} \\label{fig:#{label}} EOS end lines[i] lines[i] = thesis_wrap_figs lines.delete_at(i + 1) # if no caption, comment out here end end File.open(target, 'w') do |f| lines.each do |line| f.print line.to_s.gsub(/begin{figure}/, "begin{figure}[H]") end end end
revise_lines(target)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 194 def revise_lines(target) bugs = [['\end{quote}',:chomp]] lines = File.readlines(target) lines.each do |line| bugs.each do |bug| if line.include?(bug[0]) p line line.chomp! end end end File.open(target,'w') do |f| lines.each{|line| f.print line} end end
split_files(target, input_ipynb, thesis_or_handout)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 211 def split_files(target, input_ipynb, thesis_or_handout) target_parent = File.absolute_path("../..", target) ipynb = JSON.parse(File.read(input_ipynb)) pickup_ipynb = ipynb["cells"].to_s.split(",") chapter = pickup_ipynb.grep(/"# +/).map{ |i| i.gsub(/.*# +/, '').gsub(/".*/, '').gsub(/\\n/, '') } if thesis_or_handout == "thesis" chapter_size = chapter.size p chapter for num in 0..chapter_size-1 do splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")], ["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]] cont = File.read(target) splitters.reverse.each do |splitter| split = cont.split(splitter[0]) split[1].to_s.gsub!(/subsection/, 'section') split[1].to_s.gsub!(/subsubsection/, 'subsection') split[1].to_s.gsub!(/paragraph/, 'subsubsection') cont = split[0] File.open(splitter[1], 'w') do |f| f.print splitter[0].sub(/section/, 'chapter').gsub(/_/,'\_') if num+1 != chapter_size f.print split[1].to_s.sub(/\\section{#{chapter[num+1]}}\\label.*/m, '') end if num+1 == chapter_size f.print split[1].to_s end end end FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}") end end if thesis_or_handout == "handout" section_size = chapter.size p chapter for num in 0..section_size-1 do splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")], ["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]] cont = File.read(target) splitters.reverse.each do |splitter| split = cont.split(splitter[0]) cont = split[0] File.open(splitter[1], 'w') do |f| f.print splitter[0] if num+1 != section_size f.print split[1].to_s.sub!(/ \\section{#{chapter[num+1]}}\\label.*/m, '') end if num+1 == section_size f.print split[1].to_s end end end FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}") end end end
yaml2ipynb(argv0)
click to toggle source
# File lib/nb_util/yaml2ipynb.rb, line 9 def yaml2ipynb(argv0) input_filename = ARGV[1] output_filename = ARGV[2] || input_filename.gsub(/(yml|yaml)$/, 'ipynb') cont = YAML.load(File.read(ARGV[1])) contsinglehash = flatten_hash_from cont #pp contsinglehash contsinglehashneed = contsinglehash.select{|k, v| k.match(/title/) || k.match(/cont/) } pp contsinglehashneed contdiffstring = contsinglehashneed.to_s contdiffstring.gsub!(/=>/,'') str = contsinglehashneed.keys contnum=str.count for i in 0..contnum do ignore = str[i].to_s p ignore contdiffstring.sub!(/#{ignore}/,'') end contdiffstring.gsub!(/:\"\"\"/,'# ') contdiffstring.gsub!(/\[/,'') contdiffstring.gsub!(/\]/,'') contdiffstring.gsub!(/{/,'') contdiffstring.gsub!(/}/,'') contdiffstring.gsub!(/\", :\"\"\"/,'\n') contdiffstring.gsub!(/\"/,'') contdiffstring.gsub!(/,/,'\n') pp contdiffstring #cellのデータ cellsData = <<EOS { "cell_type": "markdown", "metadata": {}, "source": [ "#{contdiffstring}" ] } EOS meta = <<-EOS { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "test code" ] }, #{cellsData} ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "nbTranslate": { "displayLangs": [ "*" ], "hotkey": "alt-t", "langInMainMenu": true, "sourceLang": "en", "targetLang": "fr", "useGoogleTranslate": true }, "toc": { "colors": { "hover_highlight": "#DAA520", "navigate_num": "#000000", "navigate_text": "#333333", "running_highlight": "#FF0000", "selected_highlight": "#FFD700", "sidebar_border": "#EEEEEE", "wrapper_background": "#FFFFFF" }, "moveMenuLeft": true, "nav_menu": { "height": "12px", "width": "252px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": false, "toc_section_display": "block", "toc_window_display": true, "widenNotebook": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 } EOS File.open(output_filename, 'w+') do |f| f.print(meta) end end
your_informations(target, thesis_or_handout)
click to toggle source
# File lib/nb_util/ipynb2tex.rb, line 328 def your_informations(target, thesis_or_handout) info = Array.new(7) print "thesis title: " info[0] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "student number(eight-digit): " info[1] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "your name: " info[2] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "your university: " info[3] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "your major: " info[4] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "your subject: " info[5] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') print "your labo: " info[6] = STDIN.gets.to_s.chomp.gsub(/_/,'\_') target_parent = File.dirname(target) d = Date.today thesis_infomations = <<"EOS" \\title{卒業論文\\\\#{info[0]}} \\author{#{info[3]}#{info[4]}\\\\#{info[5]}学科 #{info[6]}研究室\\\\#{info[1]} #{info[2]}} \\date{#{d.year}年3月} \\begin{document} \\maketitle \\newpage EOS handout_infomations = <<"EOS" \\title{{\\large#{d.year}年度 卒業論文審査}\\\\#{info[0]}} \\author{#{info[3]}#{info[4]}\\\\#{info[5]}学科 #{info[6]}研究室 #{info[1]} #{info[2]}} \\date{} \\begin{document} \\maketitle EOS FileUtils.mkdir_p(target_parent + '/split_files/informations') File.open(target_parent + '/informations.tex', "w") do |f| if thesis_or_handout == "thesis" f.print(thesis_infomations) end if thesis_or_handout == "handout" f.print(handout_infomations) end end end