Graphics, Figures & Tablespstricks grey scale?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
AliceWonder
Posts: 28
Joined: Wed Oct 31, 2012 12:04 am

pstricks grey scale?

Post by AliceWonder »

I'm using Dia to make a diagram, exporting to .tex and then using pdflatex (texlive 2012)

The diagram has colors which is what I want for viewing on screen, but for printing I don't want to pay for color and I'm never satisfied with gray scaling that b+w printers do when given a file with colors.

The output uses PSTricks and tikz to make the diagram.

Color in the diagram is defined this way:

Code: Select all

\definecolor{dialinecolor}{rgb}{0.576471, 0.576471, 0.423529}
\pgfsetstrokecolor{dialinecolor}
Is there maybe a way I could redefine definecolor before importing the .tex so that it produces gray scale instead of color when given an rgb argument? Or is there a better way all together?

Dia does not appear to have a grayscale export option.

Thanks for suggestions.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

AliceWonder
Posts: 28
Joined: Wed Oct 31, 2012 12:04 am

Re: pstricks grey scale?

Post by AliceWonder »

Don't know if this the 'proper' way, LOL, I don't think it is, but what is working nicely is to parse the file with bash line by line, when it comes upon line with color definition it averages them so they have identical rgb. That may not work so well if two distinct colors have same mean rgb values but it works for my particular figure ...
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

pstricks grey scale?

Post by hugovdberg »

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
Post Reply