1

I use the preview package to export a pdf containing only my equations by putting the following in the preamble

\usepackage[active,tightpage,displaymath,textmath]{preview}
\setlength\PreviewBorder{2pt}
\PreviewEnvironment{equation*}
\makeatletter\renewcommand\@eqnnum{}\makeatother

I would like to set the colour of the exported equations. How can I specify the colour such that the preview package will see it?

1 Answer 1

2

It isn't clear what specific document class you are using, but I am able to get (for example) red equations by using the color package and setting the color within the equation environment.

\ifPreview can be used as shown to turn coloring off when not in preview mode. The package should be disabled by removing the active option to \usepackage so as to keep \ifPreview defined (as opposed to disabling the entire package, which would break things).

A MWE:

\documentclass[12pt]{article}

\usepackage[active,tightpage,displaymath,textmath]{preview}
\setlength\PreviewBorder{2pt}
\PreviewEnvironment{equation*}
\makeatletter\renewcommand\@eqnnum{}\makeatother

\usepackage{color}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\begin{equation}
\ifPreview\color{red}\fi
a^2 + b^2 = \frac{1}{\sqrt{\pi r^3}}
\end{equation}

\lipsum[2]

\end{document}

Gives previews as:

preview eq

But when disabled, appears as:

regular eq

1
  • \ifPreview works well. To avoid rewriting all my equations and because I'm actually using Lyx, I put this in the preamble \ifPreview\usepackage{etoolbox}\AtBeginEnvironment{equation}{\color{red}}\fi I suspect if may be incorrect/fragile but seems to work for me.
    – howecome
    Mar 19, 2014 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.