#!/usr/bin/perl #------------------------------------------------------------------------------ # LaTeX Template Module # filename: latex_new.pl # # by Jeremy Webb # # Rev 1.1, April 1, 2007 # # This utility is intended to create a top-level LaTeX template. # # Revision History: # 1.0 06/29/2006 Initial release # 1.1 04/01/2007 Changed company header. # # Please report bugs, errors, etc. #------------------------------------------------------------------------------ # Retrieve command line argument use strict; my $file = $ARGV[0]; # check to see if the user entered a file name. die "syntax: latex_new.pl new_file\n" if ($file eq ""); # check to make sure that the file doesn't exist. die "Oops! A file called '$file' already exists.\n" if -e $file; open(my $inF, ">", $file); # Strip the .tex from the file name and use for the module name: $file =~ s/\.tex$//; # Make Date int MM/DD/YYYY my $year = 0; my $month = 0; my $day = 0; ($day, $month, $year) = (localtime)[3,4,5]; # Grab username from PC: my $author= "$^O user"; if ($^O =~ /mswin/i) { $author= $ENV{USERNAME} if defined $ENV{USERNAME}; } else { $author = getlogin(); } #Module Template: printf($inF "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); printf($inF "%\n"); printf($inF "%\% $file.tex document\n"); printf($inF "%\n"); printf($inF "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); printf($inF "%\n"); printf($inF "%\% UC Davis Confidential Copyright © %04d \n", $year+1900); printf($inF "%\n"); printf($inF "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); printf($inF "%\n"); printf($inF "%\% created on:\t%02d/%02d/%04d \n", $month+1, $day, $year+1900); printf($inF "%\% created by: $author\n"); printf($inF "%\% last edit on:\t%02d/%02d/%04d \n", $month+1, $day, $year+1900); printf($inF "%\% last edit by: $author\n"); printf($inF "%\% revision: 001\n"); printf($inF "%\% comments:\t\n"); printf($inF "%\n"); printf($inF "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); printf($inF "% //Project// (//Number//)\n"); printf($inF "%\n"); printf($inF "%\% This LaTeX document describes ...\n"); printf($inF "%\n"); printf($inF "%\n"); printf($inF "%\% The sub-documents included in this design are:\n"); printf($inF "%\n"); printf($inF "%\t// enter sub-modules here;\n"); printf($inF "%\n"); printf($inF "%\n"); printf($inF "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); printf($inF "\n"); printf($inF "\\documentclass[legal,10pt]{report}\n"); printf($inF "\\usepackage{graphicx}\n"); printf($inF "\\usepackage[dvips, pdfpagemode = none,\n"); printf($inF " bookmarks = true, colorlinks = true,\n"); printf($inF " linkcolor = black, citecolor = black,\n"); printf($inF " urlcolor = black]{hyperref}\n"); printf($inF "\n"); printf($inF "\\usepackage{geometry}\n"); printf($inF "\\geometry{verbose,letterpaper,tmargin=1in,bmargin=1in,lmargin=0.9in,rmargin=1in,footskip=0.525in}\n"); printf($inF "\\graphicspath{{figures/}}\n"); printf($inF "\\usepackage{moreverb}\n"); printf($inF "\\usepackage{setspace}\n"); printf($inF "\\usepackage{listings}\n"); printf($inF "\n"); printf($inF "\\begin{document}\n"); printf($inF "\n"); printf($inF "\% \\textbf{enter} \\LaTeX document here.\n"); printf($inF "\n"); printf($inF "\n"); printf($inF "\\end{document}\n"); close(inF); print("\n"); print("The script has finished successfully! You can now use $file.tex."); print("\n"); print("\n"); exit; #------------------------------------------------------------------------------ # Generic Error and Exit routine #------------------------------------------------------------------------------ sub dienice { my($errmsg) = @_; print"$errmsg\n"; exit; }