summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/ctable/doit
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-17 00:14:36 +0000
committerKarl Berry <karl@freefriends.org>2009-09-17 00:14:36 +0000
commitea6b77b4ca75244e8aea9fcecaff57fc2fd0677e (patch)
tree25fb0fc67996cb42820cfca6bf483bc919e89dfd /Master/texmf-dist/doc/latex/ctable/doit
parent8d289093dedafa414c283acce31d2d754f2eec16 (diff)
ctable 1.14 (16sep09)
git-svn-id: svn://tug.org/texlive/trunk@15322 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/ctable/doit')
-rw-r--r--Master/texmf-dist/doc/latex/ctable/doit102
1 files changed, 102 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/ctable/doit b/Master/texmf-dist/doc/latex/ctable/doit
new file mode 100644
index 00000000000..91b71e02b15
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/ctable/doit
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require 'erb'
+require 'rubygems'
+require 'rio'
+require 'session'
+
+# doit - make all or some example picture sets.
+
+# Usage: doit # make them all
+# doit nnx # make nnx.pdf and snnx.pdf
+#
+# pictures are numbered 01, 02, etc.
+# nn[a-z] has code to typeset a \ctable; for nn[k-z] page layout will be shown
+# for each nn[a-z] two pdfs are generated:
+# nn[a-z].pdf for the ctable picture
+# and snn[a-z].pdf for the source code verbatim.
+# The number of digits (nn) is set with DIGS
+# The prefix (s) for source verbatims and (empty) for result files is set by PRE
+# Windows users should replace NULL with perhaps "c:/temp/null"
+
+MYNAME = File.basename($0)
+ DIGS = 2
+ ALL = Dir["[0-9]"*DIGS+"[a-z]"].sort
+ NULL = '/dev/null'
+ PRE = ['s','']
+
+# clean up directory
+# all = false: keep pdf's
+# all = true: remove pdf's, too
+def clean(all=false)
+ ALL.map{|x| PRE.map{|y| y+x }}.flatten.each do |f|
+ exts = %w{aux tex log chk fls out}
+ exts << 'pdf' if all
+ exts.each do |e|
+ fe = "#{f}.#{e}"
+ File.delete(fe) if File.exist?(fe)
+ end
+ end
+ exit(0)
+end
+
+# call the system shell with command
+# exit on error
+def sys(command)
+ sh = Session::Bash.new
+ o,e = sh.execute(command)
+ unless sh.exit_status == 0
+ puts "error running: #{command}",
+ " exit_status: #{sh.exit_status}",
+ " output: #{o}",
+ " error: #{e}"
+
+ exit(sh.exit_status)
+ end
+end
+
+@quiet = false
+ARGV.options do |opt|
+ opt.banner = "Create example images\n"
+ opt.banner << "No arguments: create them all\n"
+ opt.banner << "Example: ./#{MYNAME} 03? # creates 03a.pdf, 03b.pdf, s03a.pdf, and s03b.pdf"
+ opt.separator ""
+ opt.on('-h','--help','print this help and exit') do puts opt.help; exit end
+ opt.on("-c","--clean","Clean up, but keep pdf files") do clean end
+ opt.on("-C","--Clean","Clean up, including pdf files") do clean(true) end
+ opt.on("-q","--quiet","Be silent") do @quiet = true end
+ opt.parse!
+end
+set = ARGV.empty? ? ALL : ARGV
+tex = DATA.readlines("\n\n") # tex[0] -> source verbatim, tex[1] -> result
+sh = Session::Shell.new
+set.each do |j|
+ puts j unless @quiet
+ 0.upto(1) do |i|
+ f = "#{PRE[i]}#{j}"
+ r = rio(f+'.tex') < ERB.new(tex[i]).result(binding)
+ sys("pdflatex --interaction=nonstopmode #{r.path}")
+ sys("pdfcrop #{f}.pdf #{f}.pdf")
+ end
+end
+# $Id: doit,v 1.6 2009-09-15 11:28:26 wybo Exp $
+__END__
+\documentclass{article}
+\usepackage[a4paper,margin=20mm,noheadfoot]{geometry}
+\pagestyle{empty}
+\begin{document}\ttfamily
+\fontsize{10}{12 pt}\selectfont
+\begin{verbatim}<%= open(j).readlines.delete_if {|x| x =~ /\$Id|remove for source/ } %>\end{verbatim}
+\end{document}
+
+\documentclass[twoside]{article}
+<% if j =~ /[k-z]$/ %>
+\usepackage[papersize={65mm,40mm},showframe,margin=5mm,noheadfoot]{geometry}
+<% end %>
+\usepackage{ctable}
+\usepackage{txfonts}
+\pagestyle{empty}
+\parindent0pt
+\begin{document}
+<%= open(j).readlines.delete_if {|x| x =~ /\$Id/ } %>
+\end{document}