10

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: How to change color for a block of texts? http://alvinalexander.com/blog/post/latex/use-font-colors-in-latex-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/latex/colours.html

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

This question has been posted at: How to save the current colour http://latex-community.org/forum/viewtopic.php?f=44&t=25431

  • actually xcolor rather than color package (for the !50 syntax) – David Carlisle Dec 15 '14 at 16:51
14

Package xcolor has the concept of a "current color" with the dot as name. With \colorlet it can be saved:

\usepackage{xcolor}
...
\begin{document}
...
\colorlet{saved}{.}
\color{black!50}
...
\color{saved}

Or grouping can be used, which also works with LaTeX's color package:

  • small text: \textcolor{black!50}{...}

  • larger chunks including paragraphs:

    \begingroup
      \color{black!50}
      ...
    \endgroup
    

    (Also curly braces can be used for grouping.)

  • Thanks, Heiko. I didn't realize it, but our organizational template loads up the xcolor package. I thought I was using the color package. Probably I was, if xcolor loads the color package. – user36800 Dec 15 '14 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.