Template-Plugin-Latex-3.06/0000755000175000017500000000000012353466643014542 5ustar chrischrisTemplate-Plugin-Latex-3.06/TODO0000644000175000017500000000401512302614120015205 0ustar chrischris#================================================== -*- indented-text -*- # # TODO # # DESCRIPTION # TODO list for the Template Latex plugin version 3.x, containing # known bugs, limitations, planned enhancements, long term visions # and a few whacky ideas. # # AUTHOR # Andrew Ford # #------------------------------------------------------------------------ # $Id: TODO 83 2007-10-12 23:48:30Z ford $ #======================================================================== #------------------------------------------------------------------------ # Miscellaneous #------------------------------------------------------------------------ * check the mechanism whereby latex (or pdflatex) is re-run if the document contains undefined references after the first run. Bibtex is re-run if undefined citations are reported by latex, and makeindex is run if the driver detects a ".idx" file. If bibtex or makeindex are run then latex (or pdflatex) are run up to three more times to allow forward references to stabilize. This should all be coped with now but need to check on edge cases * look at how path variables could be specified to the filter (TEXINPUTS, TEXINPUTS_latex, TEXINPUTS_pdflatex, BIBINPUTS, etc), and how these should interact with the system paths. * get the filter working on Win32 how does one set environment variables with command.exe? * write unit tests for error conditions (invalid .bib file, etc) * provide a facility for specifying pre- and post-processors, e.g. gnuplot, metapost, tpic or other graphics processors. May need to copy data files from the source location to the temporary directory. * benchmark the filter Note that the latex filter runs up to eight external programs, so it isn't very fast. But for modest documents the performance is adequate, even for interactive applications. * expand the documentation * review the security implications of allowing templates to specify program paths for latex, pdflatex and dvips. * add examples Template-Plugin-Latex-3.06/INSTALL0000644000175000017500000000001612302614120015543 0ustar chrischristo be written Template-Plugin-Latex-3.06/texinputs/0000755000175000017500000000000012353466643016605 5ustar chrischrisTemplate-Plugin-Latex-3.06/texinputs/tt2.sty0000644000175000017500000000175212302614120020037 0ustar chrischris%\iffalse \NeedsTeXFormat{LaTeX2e}[1994/12/01} \ProvidesPackage{tt2} %\fi % \title{The \textsf{tt2} package} % \author{\copyright\ 2007, Andrew Ford} % \maketitle % % \section{Overview} % % This package defines a single command, |\TTCODE|, which can be used % to identify Template Toolkit (TT2) code in a template LaTeX file. % % \section{|\TTCODE| command} % % The |\TTCODE| command is used to wrap Template Toolkit code. % % When run from the Template Toolkit LaTeX plugin the command % |\TTLATEX| is defined; in this case we define |\TTCODE| as a no-op, % taking no arguments -- the TT code will get evaluated by TT and we % typset the resulting text. % % If |\TTLATEX| is not defined then we define |\TTCODE| as a macro % taking one argument -- the TT code -- which we set in a small % typewriter font. % % \begin{macrocode} \expandafter\ifx\csname TTLATEX\endcsname\relax \newcommand{\TTCODE}[1]{\texttt{\small #1}} \else \newcommand{\TTCODE}{} \fi % \end{macrocode} % % \Finale % \endinput Template-Plugin-Latex-3.06/README0000644000175000017500000001226012302614120015376 0ustar chrischris Template Toolkit LaTeX Plugin Version 3.00_05 13 October 2007 Copyright (C) 2006-2007 Andrew Ford. All Rights Reserved Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DESCRIPTION ----------- The Template Toolkit is a collection of modules which implement a fast, flexible, powerful and extensible template processing system. The LaTeX plugin provides the facility to filter content through LaTeX, provided of course that the content is valid LaTeX source. The LaTeX plugin takes care of running and re-running latex so that forward references, tables of contents, and lists of figures and tables are resolved. It will also run bibtex and makeindex if it detects that a bibliography or in index have been specified, and will re-run latex again one or more times until the formatting of the document has stabilized. (This functionality is new in version 3.00 of the module.) QUICK START ----------- The latest version of the Template Toolkit LaTeX Plugin can be retrieved from: http://www.cpan.org/modules/by-module/Template-Latex/ Fetch and install Template Toolkit (2.16 or newer) if you don't already have it installed. Available from CPAN in: http://www.cpan.org/authors/Andy_Wardley/ To install the Template Toolkit Latex Plugin: tar zxf Template-Latex-3.00_05.tar.gz cd Template-Latex-3.00_05 perl Makefile.PL make make test make install The Makefile.PL will prompt for additional configuration options, including the installation of optional template libraries, HTML documentation and examples. You can safely answer 'n' to all of these questions for a quick and basic installation. If you're running ActivePerl on a Win32 platform then you can use the Perl Package Manager (PPM) to install the Template Toolkit. Chris Winters maintains a repository of pre-compiled PPM packages which contains the Template Toolkit, AppConfig and others. For further information, see: http://openinteract.sourceforge.net/ For further details on installation, see the separate INSTALL file. WHAT'S NEW? ----------- Version 3.00 is a complete rewrite of Template-Latex. Version 2.16 was the first release of Template-Latex. It was created by moving the code out of the core Template Toolkit distribution (version 2.15). See the Changes file for further details of the changes in these releases. GENERAL FEATURES ---------------- Some of the key features of the Template Toolkit Latex Plugin are listed below. See the documentation for further detail. DOCUMENTATION ------------- The Template Toolkit is provided with enough documentation to keep all but the most voracious reader happy for quite some time. The 'Changes' file in the distribution directory documents all visible changes between versions of the Template Toolkit. See the section 'VERSION COMPATABILITY' below for further details. The 'TODO' file, also in the distribution directory, lists known bugs, planned enhancements and possible new features for future versions. The rest of the documentation is distributed in Pod and HTML formats. The Pod pages are installed when you 'make install' and can be viewed using 'perldoc', e.g. SUPPORT ------- The Template Toolkit mailing list provides a forum for discussing issues relating to the use and abuse of the Template Toolkit. There are a number of knowledgeable and helpful individuals who frequent the list (including the author) who can often offer help or suggestions. Please respect their time and patience by checking the documentation and/or mailing list archives before asking questions that may already have been answered. To subscribe to the mailing list, send an email to: templates-request@template-toolkit.org with the message 'subscribe' in the body. You can also use the web interface to subscribe or browse the archives: http://www.template-toolkit.org/mailman/listinfo/templates A low-volume, moderated mailing list exists for announcements about new releases of the Template Toolkit and related products. To subscribe, send an email to: templates-announce-request@template-toolkit.org with the message 'subscribe' in the body. A web interface also exists for subscription and browsing the archives: http://www.template-toolkit.org/mailman/listinfo/templates-announce For information about commercial support and consultancy for the Template Toolkit, please contact the author. AUTHOR ------ The Template Toolkit Latex plugin was originally written as part of the Template Toolkit distribution by Andy Wardley with the assistance and contributions from many other people. In 2006 the Latex plugin was separated out into its own distribution and Andrew Ford the took over as maintainer. See Template::Manual::Credits for details. COPYRIGHT --------- Copyright (C) 2006-2007 Andrew Ford. All Rights Reserved. Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Template-Plugin-Latex-3.06/lib/0000755000175000017500000000000012353466643015310 5ustar chrischrisTemplate-Plugin-Latex-3.06/lib/Template/0000755000175000017500000000000012353466643017063 5ustar chrischrisTemplate-Plugin-Latex-3.06/lib/Template/Latex.pm0000644000175000017500000003354112353466471020503 0ustar chrischris#============================================================= -*-perl-*- # # Template::Latex # # DESCRIPTION # Provides an interface to Latex from the Template Toolkit. # # AUTHOR # Chris Travers (Current Maintainer) # Andrew Ford # Andy Wardley # # COPYRIGHT # Copyright (C) 2014 Chris Travers. All Rights Reserved. # Copyright (C) 2006-2014 Andrew Ford. All Rights Reserved. # Copyright (C) 1996-2006 Andy Wardley. All Rights Reserved. # # This module is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # HISTORY # * Latex plugin originally written by Craig Barratt, Apr 28 2001. # * Win32 additions by Richard Tietjen. # * Extracted into a separate Template::Latex module by Andy Wardley, # May 2006 # * Removed the functionality to specify program pathnames on the FILTER call # Andrew Ford, 05 June 2006 # * Now runs BibTeX and Makeindex if required # Andrew Ford, 05 June 2006 # * Rewritten to set up TEXINPUTS so that inclusions can be found and to run # latex, bibtex and makeindex repeatedly as needed until references stabilize # (NOT YET FINISHED) # Andrew Ford, September 2007 # #======================================================================== package Template::Latex; use strict; use warnings; use base 'Template'; use Template::Exception; use Template::Plugin::Latex; use LaTeX::Driver; our $VERSION = 3.06; our $DEBUG = 0 unless defined $DEBUG; our $ERROR = ''; our $FILTER = 'latex'; # default filter name our $FORMAT = ''; # output format (auto-detect if unset) our @PROGRAMS = qw( latex pdflatex bibtex makeindex dvips ps2pdf ); sub new { my $class = shift; my $config = @_ && ref $_[0] eq 'HASH' ? shift : { @_ }; my $self = $class->SUPER::new($config) || return; # # set default format from config option # $self->latex_format($config->{ LATEX_FORMAT }) # if $config->{ LATEX_FORMAT }; # # set latex paths from config options # $self->latex_paths({ # latex => $config->{ LATEX_PATH }, # pdflatex => $config->{ PDFLATEX_PATH }, # dvips => $config->{ DVIPS_PATH }, # ps2pdf => $config->{ PS2PDF_PATH }, # bibtex => $config->{ BIBTEX_PATH }, # makeindex => $config->{ MAKEINDEX_PATH }, # }); # install the latex filter Template::Plugin::Latex->new($self->context, {}); #$self->define_filter( $self->context() ); return $self; } #------------------------------------------------------------------------ # latex_format() # latex_path() # pdflatex_path() # dvips_path() # # Methods to get/set the $FORMAT, $LATEX, $PDFLATEX and $DVIPS package # variables that specify the default output format and the paths to # the latex, pdflatex and dvips programs. #------------------------------------------------------------------------ sub latex_format { my $class = shift; return @_ ? ($FORMAT = shift) : $FORMAT; } sub latex_path { my $class = shift; return LaTeX::Driver->program_path('latex', @_); } sub pdflatex_path { my $class = shift; return LaTeX::Driver->program_path('pdflatex', @_); } sub dvips_path { my $class = shift; return LaTeX::Driver->program_path('dvips', @_); } sub ps2pdf_path { my $class = shift; return LaTeX::Driver->program_path('ps2pdf', @_); } sub bibtex_path { my $class = shift; return LaTeX::Driver->program_path('bibtex', @_); } sub makeindex_path { my $class = shift; return LaTeX::Driver->program_path('makeindex', @_); } #------------------------------------------------------------------------ # latex_paths() # # Method to get/set the above all in one go. #------------------------------------------------------------------------ sub latex_paths { my $class = shift; if (@_) { my $args = ref $_[0] eq 'HASH' ? shift : { @_ }; LaTeX::Driver->program_path($_, $args->{$_}) for qw( latex pdflatex bibtex makeindex dvips ps2pdf ); } else { return { map { ( $_ => LaTeX::Driver->program_path($_) ) } @PROGRAMS }; } } 1; __END__ #------------------------------------------------------------------------ # define_filter($context, $config) # # This method defines the latex filter in the context specified as the # first argument. A list or hash ref of named parameters can follow # providing default configuration options. #------------------------------------------------------------------------ # sub define_filter { # my $class = shift; # my $context = shift; # my $default = @_ && ref $_[0] eq 'HASH' ? shift : { @_ }; # my $filter = $default->{ filter } || $FILTER; # # default any config item not set to values in package variables # $default->{ format } ||= $FORMAT; # $default->{ latex } ||= $LATEX; # $default->{ pdflatex } ||= $PDFLATEX; # $default->{ dvips } ||= $DVIPS; # $default->{ ps2pdf } ||= $PS2PDF; # $default->{ bibtex } ||= $BIBTEX; # $default->{ makeindex } ||= $MAKEINDEX; # # define a factory subroutine to be called when the filter is used. # my $factory = sub { # my $context = shift; # my $config = @_ && ref $_[0] eq 'HASH' ? pop : { }; # # merge any configuration parameters specified when the filter # # is used with the defaults provided when the filter was defined # $config->{ $_ } ||= $default->{ $_ } # for (qw( format latex pdflatex dvips ps2pdf bibtex makeindex )); # # output file can be specified as the first argument # $config->{ output } = shift if @_; # $config->{ DEBUG } ||= $DEBUG; # # return an anonymous filter subroutine which calls the real # # filter() method passing the context and merged config params # return sub { # Template::Latex::Driver->run(shift, $context, $config); # }; # }; # # install the filter factory in the context # $context->define_filter( $filter => $factory, 1 ); # $context->define_filter( detex => \&detex_filter ); # } 1; __END__ =head1 NAME Template::Latex - Latex support for the Template Toolkit =head1 SYNOPSIS use Template::Latex; my $tt = Template::Latex->new({ INCLUDE_PATH => '/path/to/templates', OUTPUT_PATH => '/path/to/pdf/output', LATEX_FORMAT => 'pdf', }); my $vars = { title => 'Hello World', } $tt->process('example.tt2', $vars, 'example.pdf', binmode => 1) || die $tt->error(); =head1 DESCRIPTION The Template::Latex module is a wrapper of convenience around the Template module, providing additional support for generating PDF, PostScript and DVI documents from LaTeX templates. You use the Template::Latex module exactly as you would the Template module. my $tt = Template::Latex->new(\%config); $tt->process($input, \%vars, $output) || die $t->error(); It supports a number of additional configuration parameters. The C, C and C options can be used to specify the paths to the F, F and F program on your system, respectively. These are usually hard-coded in the Template::Latex C<$LATEX>, C<$PDFLATEX> and C<$DVIPS> package variables based on the values set when you run C to configure Template::Latex at installation time. You only need to specify these paths if they've moved since you installed Template::Latex or if you want to use different versions for some reason. my $tt = Template::Latex->new({ LATEX_PATH => '/usr/bin/latex', PDFLATEX_PATH => '/usr/bin/pdflatex', DVIPS_PATH => '/usr/bin/dvips', }); It also provides the C option to specify the default output format. This can be set to C, C or C. my $tt = Template::Latex->new({ LATEX_FORMAT => 'pdf', }); The C filter is automatically defined when you use the Template::Latex module. There's no need to load the Latex plugin in this case, although you can if you want (e.g. to set some configuration defaults). If you're using the regular Template module then you should first load the Latex plugin to define the C filter. [% USE Latex %] [% FILTER latex('example.pdf') %] ...LaTeX doc... [% END %] =head1 PUBLIC METHODS The Template::Latex module is a subclass of the Template module and inherits all its methods. Please consult the documentation for the L