TeX - LaTeX Asked by ZHUANG on December 19, 2020
In LaTeX, usually I use
default color {color{blue}changed color.}
or
default color textcolor{blue}{changed color.}
to change the color of a certain part of the text. Now I want to change the color of the whole sentence to a determined color, say red, as follows
I tried
textcolor{red}{default color {color{blue}changed color.}}
but it just has effect on the uncolored text:
For certain reasons, I need to keep "textcolor{blue}{changed color.}" in the origial text. Is there any way of overwritting the colored text?
Building upon David Carlisle's answer, you can define a macro that will be even nestable (is that a word?) ---
documentclass{article}
usepackage{color}
newcommand{absolutetextcolor}[2]{%
textcolor{#1}{%
renewcommandcolor[2][]{}%
#2}%
}
begin{document}
absolutetextcolor{red}{default color {color{blue}changed color.}}
absolutetextcolor{red}{default color {absolutetextcolor{blue}{changed color.}}}
end{document}
Correct answer by Rmano on December 19, 2020
It would be much better not to add the nested color or to add it as a locally defined command such as mycolor
that you could define to be a color, or nothing in different places, but if you really need this you can locally define color
to do nothing.
documentclass{article}
usepackage{color}
begin{document}
textcolor{red}{renewcommandcolor[2][]{}default color {color{blue}changed color.}}
end{document}
Answered by David Carlisle on December 19, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP