Both color.sty
and xcolor.sty
contain the following two lines:
\def\normalcolor{\let\current@color\default@color\set@color}
\AtBeginDocument{\let\default@color\current@color}
So at the beginning of the document (after the preamble), \default@color
is set to \current@color
. Then \normalcolor
returns the colour to whatever it was set to in the preamble (or DeviceGray Black if nothing is set in the preamble).
If neither color
nor xcolor
are loaded then \normalcolor
is defined in latex.ltx
as \relax
, so it does nothing.
MWE
\documentclass{article}
\usepackage{color}
\color{red}
\begin{document}
\color{blue}
Blue
\normalcolor
Normal Colour (Red as set in preamble)
\end{document}
This also works in beamer
when the default text colour is set using \setbeamercolor{normal text}{fg=...}
.
MWE
\documentclass{beamer}
\setbeamercolor{normal text}{fg=red}
\begin{document}
\begin{frame}
\color{blue}
Blue
\normalcolor
Normal Colour (Red as set in preamble)
\end{frame}
\end{document}
\def\defaultcolor{black}
(for example)? – John Kormylo Jan 6 '19 at 19:48xcolor
. You didn't specify which package you are getting color from. Withxcolor
, you could define a default color with\definecolor{default}{rgb}{0,0,0}
(which is black, in this case) – whatisit Jan 6 '19 at 19:49\textcolor
nor last\color
. Default color is the color that would show when not using any\textcolor
nor\color
. I don't want to set somedefaultcolor
variable. I want to get the information about the currently set default color, and use it. – root Jan 6 '19 at 19:57\usebeamercolor[fg]{normal text}
(or\color{normal text.fg}
if you prefer this syntax) – samcarter_is_at_topanswers.xyz Jan 6 '19 at 20:31