@rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S %0 %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!perl #line 15 #!C:/Perl/bin # type 'which perl' in a terminal to see if the above is the correct path to perl # A small perl script, which takes as input a postscript figure, and prints # a tex file containing a psfrag entry for every piece of text encountered in the # figure. Usage: mypsfrag somefigure.eps use strict; # 'strict' insists that all variables be declared use diagnostics; # 'diagnostics' expands the cryptic warnings # the preamble print ' \documentclass[12pt]{article} \pagestyle{empty} % don\'t show the page number \usepackage{psfrag} \usepackage{graphicx} \begin{document} \begin{figure} '; undef $/; # enables reading all the input file in one line # read the postscript figure (which is a text file) into the variable $contents open (FILE, "<$ARGV[0]") || die "Cannot open the file \'$ARGV[0]\'. Check if the file exists and has right permissions!"; my $contents=; close(FILE); my @matches= ($contents =~ /\((..*?)\)/g); # this uses the fact that all pieces of text in a postscript figure will be in parantheses, # that is, looking like this: (some text) print '%The psfrag entries are below. They need to be modified to reflect correctly the replacements you intend.' . "\n"; # create an entry of every piece of text foreach (@matches) { print '\psfrag{' , $_ , '}[c][][1][0]{$' , $_ , '$}' , "\n"; } # one would want to modify the width of the figure (that is, the scaling) print "\n" , '\includegraphics[width=1.0\textwidth]{' , $ARGV[0] , '}' , "% to scale the picture, change width here\n"; # the end of the tex file print ' \end{figure} \end{document} '; __END__ :endofperl