• No results found

The purpose of cachepic package is to simplify and automate conversion of docu- ment fragments into external eps or pdf file(s). The package consists of two parts:

N/A
N/A
Protected

Academic year: 2021

Share "The purpose of cachepic package is to simplify and automate conversion of docu- ment fragments into external eps or pdf file(s). The package consists of two parts:"

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The cachepic package

Tomasz M. Trzeciak t34www@gmail.com September 23, 2009

1 Introduction

It might be sometimes desirable to convert fragments of your document, e.g. draw- ings or diagrams, into external graphic files. Such a need may arise when you want to use some specialised package but your document have to compile on a system without said package.

The purpose of cachepic package is to simplify and automate conversion of docu- ment fragments into external eps or pdf file(s). The package consists of two parts:

the L

A

TEX 2ε style implementing the document level interface and a command line tool (written in Lua) for generation of external graphics.

2 Requirements

The inclusion of already generated graphics requires only the cachepic.sty style file and two standard packages: graphicx (obviously) and verbatim (for its comment environment). Both should be present in every L

A

TEX distribution.

The graphics generation step requires the full cachepic package, the preview package and a Lua interpreter to execute the conversion script. For Windows platform there is also a batch script wrapper provided for command line use.

3 Document interface

The package is loaded with the usual \usepackage{cachepic}. Currently there are no package specific options available. There are two commands and one envi- ronment provided for marking-up document fragments intended for externalization as graphic files.

The main command of this package is \cachepic{hfile namei}{hfragment i}. It

\cachepic

takes a balanced L

A

TEX code hfragmenti, which is typeset and output to a file hfile namei during the post-processing run as described in Section 4.

1

(2)

Table 1: Options of cachepic command line tool.

option description

pdf graphics will be output in (e)pdf format; this is the default option

eps graphics will be output in eps format

all recreate all graphics, already existing ones will be overwritten

multi keep all graphics in a sigle file hmain filei-cachepic.pdf rather then produce sep- arate files (but graphics in separate files take precedence); this option cannot be used together with -eps

tight no 0.5 bp margin around the graphic

notex don’t do any typesetting, only graphic postpro- cessing; the typesetting has to be done separately and requires the preview package with at least the active and cachepic options

nopic generate no graphics, only hmain filei.cachepic file

help,h,? display help message

The second command, \cacheinput{hfile namei}, is just a shorthand for

\cacheinput

\cachepic{hfile namei}{\input{hfile namei}}.

Finally, for longer stretches of code there is an environment analogue of the cachepicture

\cachepic command:

\begin{cachepicture}{hfile namei}

hfragment i

\end{cachepicture}

During normal document compilation each hfragment i is typeset as usual unless there exists a file hfile namei.eps (in dvi mode) or hfile namei.pdf (in pdf mode).

If such a file exists, it will be included (with the standard \includegraphics command) and it will be used in place of the corresponding hfragment i.

4 Graphics generation

Graphics files are produced by running a command line tool called (unsurprisingly) cachepic. This tool automates the whole process of graphic generation. It can be called from the command line (or through appropriately configured TEX editor) as follows:

2

(3)

cachepic [options] hmain filei

All available options are gathered in Table 1. Options start with “-” or “--” and can be passed in any order.

Apart from graphic files there is also an auxiliary hmain filei.cachepic file cre- ated. It contains additional information used for graphics inclusion such as the page number (used only in pdf mode with multi-graphics file), margins and the depth of the graphics box. This file is not strictly required but without it some features are not available as explained below.

As mentioned in Section 2, the preview package is required for graphics generation but it should not be specified with options in the document preamble or this will likely lead to option clash. To use this package together with cachepic, pass cachepic option to the preview package and compile the document separately.

Then run the cachepic tool with -notex option.

Once all the graphics are generated, only the style file cachepic.sty is needed to compile the document. If you want to avoid using even this file, you can add the following definitions the document preamble:

\newcommand\cachepic[2]{\includegraphics{#1}}

\newcommand\cacheinput[1]{\includegraphics{#1}}

\newenvironment{cachepicture}[1]{%

\includegraphics{#1}\comment}{\endcomment}

However, since the above definitions don’t use the additional information in the hmain filei.cachepic file, this comes with some limitations. Firstly, informa- tion about the graphic’s depth, i.e. how much it is lowered below the text base- line, is not preserved. Secondly, graphics stored in a single pdf file cannot be used, because the page number with the graphic is not known. Finally, the de- fault small margin around the graphics is not corrected for, but you can gener- ate the graphics without the margin (see the -tight option in Table 1) or use

\includegraphics[trim=0.5bp 0.5bp 0.5bp 0.5bp]{#1} in the above defini- tions to correct for that.

3

Referenties

GERELATEERDE DOCUMENTEN

If the option foot was passed to the package, you may consider numbering authors’ names so that you can use numbered footnotes for the affiliations. \author{author one$^1$ and

This would declare a default rule, such that all unknown extensions would be treated as EPS files, and the graphic file would be read for a BoundingBox com- ment.. If the driver

For example, the code point U+006E (the Latin lowercase ”n”) followed by U+0303 (the combining tilde) is defined by Unicode to be canonically equivalent to the single code point

The default values for the items in the \paperref environment are the following command punctation begin commands end commands.. \by ,

The EASYBMAT package is a macro package for supporting block matri- ces having equal column widths or equal rows heights or both, and support- ing various kinds of rules (lines)

The EASYMAT package is a macro package for supporting block matrices having equal column widths or equal rows heights or both, and supporting various kinds of rules (lines) between

In the first case, it creates the new command (macro) \cmd which executes \cmda when in scalar mode and \cmdb when in vector mode. In the second case it creates a new command \cmd

The package then stores the dates of files and packages loaded after itself including its own