Condom

A Ruby lib to prepare the skeleton of a LaTeX document

This lib requires that you know the LaTeX language.

Its purpose is not to write a whole document for you, but to facilitate the preparation of a LaTeX document, that is to say to create a set of files to easily start it. So you won’t have to care about packages to import, configuration, etc. The compilation, cleanup and interaction with the sources are facilitated by the usage of a Makefile (see the Usage section below).

The document types supported for the moment are:

  • Any classic type (article, report, book, …)

  • Presentation (i.e. a beamer document)

  • Letter

Installation

Condom is available on Rubygems.org and can be installed with:

$ gem install condom

This command needs Rubygems (rubygems package on Ubuntu).

Usage

Executable

Condom gem provides a ‘condom’ shell command.

$ condom --help
Usage: condom [type] [options]

Available types:
    document                         'article', 'report' or other classes
    presentation                     'beamer' class
    letter                           'letter' class

Available options:
    -n, --filename=FILENAME          Define a file name
    -a, --author=AUTHOR              Define the author
    -t, --title=TITLE                Define the title
    -d, --date=DATE                  Define the date
    -c, --document-class=CLASS       Define the document class
    -l, --language=LANGUAGE          Define the language
    -p, --package=PACKAGE            Add another package
    -o, --directory=DIRECTORY        Define the output directory
    -q, --quiet                      Don't ask any question
    -v, --version                    Print Condom version

For example, you can easily generate a set of files for a presentation in a folder named ‘My Presentation’ using:

condom presentation -o "My Presentation"

Unless the –quiet option is used, every options will be prompted for confirmation until the validation of the user (the type will be prompted just one time).

In generated files, there is a Makefile (see the Technique section below for more information about the file organization). Just use your document (from the source folder) with the following commands.

compile with:

$ make

or compile and open with:

$ make view

clean sources (remove .out, .toc, etc. files) with:

$ make clean

archive the whole document with:

$ make archive

Lib

You can use the lib to create your document (e.g. using IRB). Here’s a quick overview of its operation.

Create a document with:

doc = Condom::Document.new

or a presentation with:

doc = Condom::Presentation.new

or a letter with:

doc = Condom::Letter.new

All constructors of these classes will use default values, but also accept:

  • no argument

  • a String: will be the title of the document

  • a Hash of options. Keys of the options hash should be symbols with the same name than the attributes of the class.

i.e.:

doc = Condom::Document.new(:document_class => "report", :math => true, :directory => "here")

You can get all options with:

doc.get_options

All attributes can be accessed by classic methods:

doc.title = "My Title"
doc.title # => "My Title"

Then, once your document is ready to be generated, create it with:

doc.create

This method will generate all files in the output directory.

Technique

The following command:

$ condom document -t "Condom makes LaTeX easier" -o here

may result the creation of these folders/files:

$ tree here/
here/
├── fig
├── fig.tex
├── inc
│   ├── colors.tex
│   ├── commands.tex
│   ├── listings.tex
│   └── packages.tex
├── main.tex
├── Makefile
└── src

fig/

This is the folder where you should put your images.

inc/

This folder has all configuration tex files:

  • colors.tex - customized colors

  • commands.tex - customized commands

  • listings.tex - configuration file for the listings package

  • packages - all needed packages

main.tex

The main tex file. If you specify a filename with -n option, then the generated pdf file will have this name, not the main tex file.

Makefile

Makefile to manage your document sources easily (see the usage above).

src/

This is the folder where to put listings (a result of -l option).