Skip to content

Instantly share code, notes, and snippets.

@drakezhard
Created October 27, 2014 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakezhard/4fe0dde21d0f73ab6ad0 to your computer and use it in GitHub Desktop.
Save drakezhard/4fe0dde21d0f73ab6ad0 to your computer and use it in GitHub Desktop.
It generates an image grid with hyperlinks in latex
#!/usr/bin/env ruby
files = File.open(ARGV.first) do|file|
Marshal.load(file)
end
latex = File.open(ARGV.last,'w')
files.each do |x|
latex.write("\\hypertarget{#{x[2]}b}{\\phantom{}}")
latex.write("\\hyperlink{#{x[2]}a}{")
latex.write("\\includegraphics[width=0.25\\textwidth]{#{x[0]}}\n")
latex.write("}\n")
end
latex.write("\\newpage\n")
files.each do |x|
latex.write("\\hypertarget{#{x[2]}a}{\\phantom{}}")
latex.write("\\hyperlink{#{x[2]}b}{")
latex.write("\\includegraphics[width=\\textwidth]{#{x[0]}}")
latex.write("}\n")
latex.write("\\newpage\n")
latex.write("\\includepdf[pages=-]{#{x[1]}}\n")
end
latex.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment