LaTeX forum ⇒ Text FormattingHow to save the current colour Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
JustA_LaTeXusr
Posts: 42
Joined: Tue Jul 23, 2013 6:48 pm

How to save the current colour

Postby JustA_LaTeXusr » Mon Dec 15, 2014 7:02 pm

If I want to gray out large swaths of text in a report, I know that I can use the xcolor package's \color{black!50} command:
http://tex.stackexchange.com/questions/ ... k-of-texts
http://alvinalexander.com/blog/post/lat ... -documents

Is there any way to confirm that the default color is indeed black before I issue the above command?

In a related search, I found that I can even push the current colour onto a stack:
http://www.cs.stir.ac.uk/~kjt/software/ ... lours.html

However, that page is from 1997, targets slides, and uses a different package. I am currently very bound to the color package.

This question has been posted at:
http://tex.stackexchange.com/questions/ ... ent-colour
viewtopic.php?f=44&t=25431

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 4030
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Dec 15, 2014 7:07 pm

Hi, you already got a pretty good answer by Heiko Oberdiek. I would stick to that. ;-)

To sum it up, use either groups (compatible with package color) or save the current color using the single dot:
  1. \documentclass{article}
  2. \usepackage[x11names]{xcolor}
  3. \usepackage{blindtext}
  4. \begin{document}
  5. \blindtext
  6. \begingroup\color{Blue3} You can use groups to locally switch the
  7. color \blindtext\endgroup
  8.  
  9. you can also save the current color, with a single dot. Just like
  10. unix uses the single dot for the current directory.
  11.  
  12. \colorlet{colorsave}{.}
  13. \color{Brown4}\blindtext
  14.  
  15. and later restore the savedcolor \color{colorsave} \blindtext
  16. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

JustA_LaTeXusr
Posts: 42
Joined: Tue Jul 23, 2013 6:48 pm

Postby JustA_LaTeXusr » Mon Dec 15, 2014 8:31 pm

Thanks, Johannes. Interesting example you provided, educating me on the blindtext package.

User avatar
Johannes_B
Site Moderator
Posts: 4030
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Dec 15, 2014 8:55 pm

On the one side there are people saying this is lazyness, others called it efficiency. I think you need to be both to get the work done. ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests