0

Possible Duplicates:
Conditional Compiling and \documentclass
Passing parameters to a document
Changing LaTeX headers via a makefile

I'm setting up a Rakefile for a LaTeX document and I'd like to be able to build different versions of the document with this script without changing the LaTeX source. The two different options that I'd like to change are:

\documentclass[draft]{memoir}

which can be changed to:

\documentclass[final]{memoir}

by invoking a different target. Is it possible to change these on-the-fly at compile time? I'm using xelatex if that makes any difference.

xoebus
  • 103

1 Answers1

3

Step 1

Create a batch file as follows, name it batch.bat for instance.

rem batch.bat takes file name without extension and the mode.
rem for example you can execute as follows.
rem batch yourtexfile final
rem or
rem batch yourtexfile draft
echo off
xelatex "\def\mode{%2}\input{%1.tex}"
acrord32 %1.pdf

Step 2

Create an input file, name it yourtexfile.tex for instance.

\documentclass[\mode]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}

Step 3

Execute the batch by supplying the file name and mode as follows.

enter image description here

Display Name
  • 46,933