Generalcolordvi package doesn't work with pdflatex

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

colordvi package doesn't work with pdflatex

Post by leo simon »

Hi

I'm finding that the colordvi package doesn't work with pdflatex. Nobody else seems to have complained about this on the web, as far as I can tell. The code below displays in red when I use latex, but in black when I use pdflatex.

Code: Select all

\documentclass{article}%
\usepackage{colordvi}
\begin{document}

\Red{should be red}

\end{document}
Could somebody please tell me what I'm doing wrong? If I'm not doing anything wrong, what's the easiest way to get color in pdflatex?

Thanks very much for any help.
Last edited by cgnieder on Mon Aug 12, 2013 2:11 pm, edited 1 time in total.

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

colordvi package doesn't work with pdflatex

Post by cgnieder »

The colordvi package is quite old (last version from 1992) while pdftex was first released (please correct me if I'm wrong) in 2001. It doesn't surprise me that there is no pdftex support.

Why do you want to use it, anyway? There is the powerful xcolor package that works nicely with pdftex:

Code: Select all

\documentclass{article}%
\usepackage{xcolor}
\begin{document}

\textcolor{red}{\emph{is} red}

\end{document}
Regards
site moderator & package author
leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

colordvi package doesn't work with pdflatex

Post by leo simon »

Thanks for the response, Clemens. I have a pretty strong preference for colordvi because \Red{text} it's a bit less cumbersome than \textcolor{red}{text}, but more important, because colordvi gives me a whole range of colors pre-made, like \BrickRed, \BurntOrange, etc. I presume xcolor gives me a way to make my own colors, but it would be nice to have easy access to a wide range of colors.
Last edited by cgnieder on Mon Aug 12, 2013 4:59 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

colordvi package doesn't work with pdflatex

Post by cgnieder »

leo simon wrote:I have a pretty strong preference for colordvi because \Red{text} it's a bit less cumbersome than \textcolor{red}{text}
Well, given that one should use semantic markup in a LaTeX document and such color declarations usually only are part of custom commands I don't think that this is much of a trouble. Anyway, it's easy to define:

Code: Select all

\newcommand*\Red[1]{\textcolor{red}{#1}}
leo simon wrote:colordvi gives me a whole range of colors pre-made, like \BrickRed, \BurntOrange
xcolor has those, too, via the dvipsnames option. Did you have a look at its manual xcolor?

Code: Select all

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\begin{document}

\textcolor{BrickRed}{BrickRed}\par
\textcolor{BurntOrange}{BurntOrange}\par
\textcolor{OliveGreen}{OliveGreen}

\end{document}
You can even automate the defining of commands having the names of the colors:

Code: Select all

\documentclass{article}
\usepackage[dvipsnames]{xcolor}

\usepackage{trimspaces}
\makeatletter
% the command \DefineColorCommands will take a comma-separated list of color names
% and will build commands from them using the corresponding color on their
% arguments:
\newcommand*\DefineColorCommands[1]{\@define@color@commands{#1}}

\def\@define@color@commands#1{%
  \@define@color@commands@aux#1,\relax\q@stop
}
\def\@define@color@commands@aux#1,#2\q@stop{%
  \@ifundefined{#1}{%
    \expandafter\edef\csname\trim@spaces{#1}\endcsname##1{%
      \noexpand\textcolor{\trim@spaces{#1}}{##1}%
    }%
    \ifx\relax#2\else
      \@define@color@commands@aux#2\q@stop
    \fi
  }{}%
}
\makeatother

\DefineColorCommands{
  BrickRed,
  BurntOrange,
  OliveGreen
}

\begin{document}

\BrickRed{BrickRed}\par
\BurntOrange{BurntOrange}\par
\OliveGreen{OliveGreen}

\end{document}
Regards
site moderator & package author
leo simon
Posts: 17
Joined: Wed Aug 19, 2009 5:41 pm

Re: colordvi package doesn't work with pdflatex

Post by leo simon »

This is wonderful thanks, I'm now a total convert to xcolor. Thanks very much in particular for the \DefineColor macro.
Post Reply