Perhaps a somewhat nicer way to this than by bash-scripting is using the flexibility of latex. It is perfectly fine to define some commands before your
\documentclass
, therefore this might be a nice way to go:
File main.color.tex:
Code: Select all
\newcommand{\definemycolors}{\definecolor{dialinecolor}{rgb}{1.0, 0.0, 0.0}}
\input{main}
File main.grayscale.tex:
Code: Select all
\newcommand{\definemycolors}{\definecolor{dialinecolor}{rgb}{0.5, 0.5, 0.5}}
\input{main}
And finally main.tex:
Code: Select all
\documentclass{article}
\usepackage{tikz}
\definemycolors
\begin{document}
\begin{tikzpicture}
\pgfsetstrokecolor{dialinecolor}
\draw (0,0) -- (1,1);
\end{tikzpicture}
\end{document}
Now by compiling either main.color.tex or main.grayscale.tex you can automatically set all colors to the correct value. As you can see the new command
\definemycolors
is only expanded when it is called so it is fine that
\definecolor
is not yet defined when calling
\newcommand
.
Perhaps a more useful naming scheme would be main.screen.tex and main.print.tex since that would better reflect the intentions of the output files. You could also change other options in the "configuration"-files such as page layout (for example,
twoside
with bindingcorrection for print and
oneside
for screen version, although to my knowledge that would require to move the
\documentclass
to the configuration files).
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit