public
Description: Ruby LaTeX to PDF preprocessor (and Rails plugin)
Homepage: http://rtex.rubyforge.org
Clone URL: git://github.com/bruce/rtex.git
Click here to lend your support to: rtex and make a donation at www.pledgie.com !
rtex /
name age message
file CHANGELOG Thu Feb 26 13:29:28 -0800 2009 Release v2.1.0. Merge in rails-2.2.2 branch, mo... [bruce]
file Manifest Sun Aug 17 13:45:41 -0700 2008 Administrative Changes * Convert testing from t... [bruce]
file README.rdoc Tue May 06 19:41:25 -0700 2008 Cleanup docs for 2.0 release [bruce]
file README_RAILS.rdoc Thu Feb 26 14:31:52 -0800 2009 More little tweaks [bruce]
file Rakefile Wed Oct 08 08:35:34 -0700 2008 Support for RubyGems > 1.2 (Bad Echoe, bad!) [bruce]
directory bin/ Wed Apr 23 23:38:50 -0700 2008 Build out syntax highlighting, examples, prep f... [bruce]
file init.rb Wed Aug 27 09:20:51 -0700 2008 Fix no-op; this should be a require! [bruce]
directory lib/ Mon Apr 13 23:33:56 -0700 2009 Allow latex_escape to work in a Rails 2.2+ envi... [davec]
directory rails/ Sun Aug 17 13:18:36 -0700 2008 Support for use as a traditional vendored plugi... [bruce]
directory site/ Sun Jun 08 11:19:36 -0700 2008 Support for Rails 2.1 [bruce]
directory test/ Sat Sep 20 09:31:22 -0700 2008 Call to_s on argument to Document.escape * (Tha... [bruce]
directory vendor/ Wed Apr 23 23:38:50 -0700 2008 Build out syntax highlighting, examples, prep f... [bruce]
README_RAILS.rdoc

RTeX for Rails

Installation

  sudo gem install rtex

Rails 2.0.X, 2.1+ in vendor/plugins (not recommended):

  rtex --install /path/to/rails/app

Or, as a Rails 2.1+ gem dependency, just add the following to your config/environment.rb:

  config.gem 'rtex'

Dependencies

  • Rails >= 2.0.1

Usage

Create files pdf.rtex extensions (eg, index.pdf.rtex) using standard LaTeX markup.

  • Layouts are supported, eg: application.pdf.rtex
  • Partials are supported, eg: _item.pdf.rtex

Example

With the following:

  # In config/initializers/mime_types.rb (or environment.rb in older Rails)
  Mime::Type.register "application/pdf", :pdf

  # app/controllers/items_controller.rb
  def index
    @items = Item.find(:all)
    respond_to do |format|
      format.html # We support the normal HTML view as well
      format.pdf
    end
  end

  # app/views/items/index.pdf.rtex
  \section*{Items}
  \begin{itemize}
    <%= render :partial => @items %>
  \end{itemize}

  # app/views/items/_item.pdf.rtex
  \item <%=l item.name %> \\

  # app/layouts/application.pdf.rtex
  \documentclass[12pt]{article}
  \begin{document}
    <%= yield %>
  \end{document}

If you hit /items.pdf, you end up with a nice PDF listing of items.

Obviously a simplistic example.