LaTeX versions - conditionally control your output

The "versions" package (versions.sty) can be very useful in conditionally controlling your output in LaTeX PDF and HTML documents.

LaTeX conditional output

Here's a very simple example of how you can use this package to conditionally control what is output by the LaTeX processor:

\author{Al Alexander}



% if "PDF" has been included, do this:
\processifversion{PDF}{Hello PDF world!}

% if "HTML" has been included, do this:
\processifversion{HTML}{Hello HTML world!}


In this example, with the current parameters selected, the LaTeX PDF document that results when I run pdflatex has this output:

Hello PDF world!

This is because the command "\includeversion{PDF}" is set at the beginning of the file. Note that the "Hello HTML world!" string is specifically NOT included in the output document.

Now, if we turn this around and change the include/exclude commands to this:


the output will look like this instead:

Hello HTML world!

You can use any string you want in your include/exclude statements. The only thing that's important is that whatever text you use in the initial include/exclude statement also needs to be used later in your \processifversion command.

When your output is longer than you might want to include in a simple command, you may want to use the environment equivalent commands, like this:

Some more text here.
Something longer than you want to include in a 
simple command, something like this
multiline example.

One last note: If your only reason for doing this is to control LaTeX PDF and LaTeX HTML processing you're better off using the "html" package (html.sty) and it's associated commands.