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;

  • Curriculum Vitae (i.e. a moderncv document).

Installation

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

$ gem install condom

This command needs Rubygems (‘rubygems’ package on Ubuntu).

Usage

The condom executable

Condom gem provides a ‘condom’ shell command.

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

Available types:
    article (default)                i.e. the 'article' class
    report                           i.e. the 'report' class
    book                             i.e. the 'book' class
    presentation                     i.e. the 'beamer' class
    letter                           i.e. the 'letter' class
    cv                               i.e. the 'moderncv' 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

The type is just a shortcut (and maybe an alias) to define the LaTeX document class and choose the corresponding Condom class. The options are options common to every Condom classes. Specific options (such as “recipient” for the letter) will be prompt if –quiet option is not given.

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, if it is not already defined).

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

The Condom 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 (article, report or book) with:

doc = Condom::Classic.new

or a presentation with:

doc = Condom::Presentation.new

or a letter with:

doc = Condom::Letter.new

or a Resumé with:

doc = Condom::CV.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::Classic.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 report -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
│   ├── first-page.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

  • first-page.tex - customized first-page (only for reports)

  • 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).