#!/usr/local/bin/perl # Title: extract-figures.pl # Version: 3 # Synopsis: extracts TeX figures from Texinfo files, makes JPEG files # Author: Geoffrey S. Knauth # Created: 20-May-1996 # Note: See brief documentation at bottom. # # Copyright (C) 1996 Geoffrey S. Knauth # Distribution under the terms of the GNU General Public License (see bottom). $in_tex = false; $in_tex_code = false; while (<>) { chop; $line = $_; if (/^\@tex/) { $in_tex = true; } if ($in_tex eq true && /^%\s+texpiece\s+(\S+)\s+(\d+)/) { $in_tex_code = true; $name = $1; $magstep = $2; $tex_name = $name . ".tex"; print "----- writing $tex_name\n"; open (TEX, ">$tex_name"); print TEX "% $tex_name\n"; print TEX "% This file was automatically generated by `extract-figures.pl'.\n"; print TEX "\\nopagenumbers\n\n"; next; } if ($in_tex_code eq true && /^\@end tex/) { $in_tex_code = $in_tex = false; print TEX "\n\\bye\n"; close TEX; &do_command ("tex $name.tex"); &do_command ("rm $name.tex"); &do_command ("dvips -E -x $magstep -o $name.eps $name.dvi"); &do_command ("rm $name.dvi"); &do_command ("convert -monochrome $name.eps $name.jpg"); } if ($in_tex_code eq true) { print TEX $_, "\n"; } } exit 0; sub do_command { local ($command) = $_[0]; print "$command\n"; system ($command); } __END__ HOW TO USE THIS PROGRAM Note: I am not currently using this program. But it was useful at one point, so I'm making it available to you. I used the program to embed TeX code for tables in Texinfo source. I did it like this: ...texinfo stuff @ignore % texpiece NAME1 1000 ...TeX code to generate NAME1.tex, ...leading to NAME1.eps at magstep 1000 @end ignore ...more texinfo stuff @ignore % texpiece NAME2 1440 ...TeX code to generate NAME2.tex, ...leading to NAME2.eps at magstep 1440 @end ignore ...more textinfo stuff I used `texi2html' and C-c C-t C-b (in Emacs Texinfo mode) to make HTML pages and info files, respectively, from Texinfo source. `extract-figures.pl' helped me create Encapsulated Postscript Files, which I then turned into GIF/JPEG files with `convert' so that my web pages could reference the images. The reason I stopped using this program is that my colleague Andy Lee correctly pointed out that since my graphics were just tables, I should produce HTML tables to speed downloads and improve appearances. I then wrote `gentable.pl' and `expand-tables.pl'. LICENSE TO USE THIS SOFTWARE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307 Voice: +1-617-542-5942 Fax: +1-617-542-2652