General ⇒ Converting colored text to Black for printing
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Converting colored text to Black for printing
I have some text/expressions in my document for which I have used colored text. I have defined custom colors in some cases and used the standard "blue" color in others. The colored expressions do not print well on the black and white printer (they are lighter than the surrounding text). I was wondering whether there was a simple command that I could use or define to convert them to black. I could then use that copy for printing and then comment out that command to get the colors back.
I have used the following command to get the colored text. In the preamble I have defined:
\newcommand{\clr}[2]{{\color{#1}#2}}
In the body I use \clr{blue}{This is blue text}.
\clr{ored}{This is orange red text. Color ored has been defined using the definecolor command.}
Thanks very much.
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
Converting colored text to Black for printing
Code: Select all
\renewcommand{\clr}[2]{{\color{black}#2}}
Converting colored text to Black for printing
Code: Select all
\usepackage[monochrome]{color}
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Re: Converting colored text to Black for printing
Juanjo, I will also try your solution. Thanks for the information about the \textcolor. I could use it for text; but I used the \clr command also for some mathematical expressions.
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Converting colored text to Black for printing
I tried both commands mentioned above and wanted to given an update:
\renewcommand{clr}[2]{\color{black}#2} worked fine and did the job.
Adding the monochrome option when loading xcolor package did not work, however, because it conflicts with the natbib package. I get the following error (copied from the log file)
I tried the command \documentclass[12pt,monochrome]{article}. But that did not work. Is there a way around this? As I said, gmedina's suggestion work out well, but it would be good to know how to make this latter solution work when there is a clash with another package. That would be helpful, for example, when I am using a package written by someone else (say a package to make exams) but want to override their color settings and print the exam in black and white.! LaTeX Error: Option clash for package xcolor.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.10 \usepackage
{natbib}
? h
The package xcolor has already been loaded with options:
[]
There has now been an attempt to load it with options
[monochrome]
Adding the global options:
,monochrome
to your \documentclass declaration may fix this.
Thanks for your help.
Re: Converting colored text to Black for printing
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Converting colored text to Black for printing
Code: Select all
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage[total={6.5in,8.5in},top=1.2in,left=1in]{geometry}%Total textwidth=6.5in, textheight=8.5in,topmargin=1.2in and leftmargin=1in
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{natbib}
\usepackage{makeidx}
\makeindex
\definecolor{dgray}{RGB}{64,64,64}
\usepackage[pdftex,pdfstartview=FitH]{hyperref}
\hypersetup{pdfpagemode=none,
colorlinks=true,
urlcolor=blue,
citecolor=dgray}
\definecolor{ored}{RGB}{178,34,34} %defining custom color (command available in the xcolor package}
\definecolor{fgreen}{RGB}{34,139,34} %Forestgreen
\setlength{\parindent}{0pt} % Zero indentation for paragraphs
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex} %Space between paragraph
%Plus and Minus allow Latex to adjust the spacing if necessary for proper alignment.
\setlength{\marginparwidth}{1in}
%BEGIN Shortcuts
\newcommand{\Pai}[1]{P_{A}(#1)}
\newcommand{\clr}[2]{{\color{#1}#2}}
\newcommand{\mymargin}[1]{\marginpar{\vskip-\baselineskip\scriptsize\raggedright\clr{fgreen}{#1}}}
%\renewcommand{\clr}[2]{{\color{black}#2}} %To convert to black color for printing.
%END Shortcuts
Converting colored text to Black for printing
Code: Select all
\usepackage[monochrome]{xcolor}
\usepackage{tikz}
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
By the way, \textcolor also works in math mode. Try this, for example:
Code: Select all
\[ \textcolor{blue}{\sum_{i=1}^n i^2}\textcolor{cyan}{{}={}}\textcolor{magenta}{\frac{n(n+1)(2n+1)}{6}} \]
-
- Posts: 105
- Joined: Fri Nov 30, 2007 11:32 pm
Converting colored text to Black for printing
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
\usepackage{xcolor}
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
\usepackage{Apackage}
Converting colored text to Black for printing
Code: Select all
\documentclass[optA]{article}
\usepackage[optB]{mypack}
We may run into problems when mypack is loaded twice. If, in the second call to the \usepackage command, there are, at most, the same local options than in the first call, nothing happens. LaTeX ignores the second call. However, if the second call introduces a new local option, LaTeX complains. It writes the option clash error message in the TeX console and stops. Fortunately, this error can be recovered. Simply press <return>. LaTeX then ignores the second \usepackage comand and concludes compilation. So, this code works:
Code: Select all
\usepackage[optA,optB]{mypack}
\usepackage[optB]{mypack}
Code: Select all
\usepackage[optA]{mypack}
\usepackage[optB]{mypack}
Now, assume that packA and packB are packages that loads mypack with options optA and optB, respectively. As before, this code fails:
Code: Select all
\usepackage{packA}
\usepackage{packB}
Code: Select all
\usepackage[optA,optB]{packA}
\usepackage{packB}
Code: Select all
\documentclass[optA,optB]{article}
\usepackage{packA}
\usepackage{packB}
So, let's return to your particular case. The code
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
\usepackage{xcolor}
Code: Select all
\documentclass[12pt,monochrome]{article}
\usepackage{tikz}
From the preceding explanation, it follows that this code may work provided that Apackage does not introduces more xcolor options. If this were the case, add them to \documentclass. Although compilation may stop, you can still get your document.curiouslearn wrote: Can you please also suggest what I may do if I have a situation such as below, where both tikz and package Apackage load xcolor? Do you think using monochrome in \documentclass will help in that case, given that it does work when xcolor is loaded twice (once in tikz and once by itself)?.Code: Select all
\documentclass[12pt,monochrome]{article} \usepackage{tikz} \usepackage{Apackage}