After a recent upgrade of my system (to Ubuntu 22.04), many of my previous files are failing to compile with undefined colors.
Please see the following self-contained examples for clarification.
The following works fine.
% 1
% Base colors (always available)
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\LaTeX
{\color{blue}\LaTeX}
\end{document}
Conclusion: The xcolor
package is working fine for the base colors.
The following works fine as well.
% 2
% Colors via dvipsnames option
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\LaTeX
{\color{Blue}\LaTeX}
\end{document}
Conclusion: The xcolor
package is working fine for the colors via option.
The following is also good.
% 3
% Base colors (always available)
\documentclass{beamer}
\begin{document}
\begin{frame}
\LaTeX
{\color{blue}\LaTeX}
\end{frame}
\end{document}
Conclusion: beamer
properly handles the base colors in the
xcolor
package.
This is where the problem starts.
% 4
% Colors via dvipsnames option
\documentclass[xcolor=dvipsnames]{beamer}
\begin{document}
\begin{frame}
\LaTeX
{\color{Blue}\LaTeX}
\end{frame}
\end{document}
We get the following error message.
! Package xcolor Error: Undefined
color `Blue'.
Conclusion: beamer
fails to handle the colors via option in
xcolor
package.
The following is likely to generate an option clash, naturally.
% 5
% Colors via dvipsnames option
\documentclass{beamer}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\begin{frame}
\LaTeX
{\color{Blue}\LaTeX}
\end{frame}
\end{document}
We get the following error message.
! LaTeX Error: Option clash for package
xcolor.
Even the following does not work when we pass the option explicitly.
% 6
% Colors via dvipsnames option
\documentclass{beamer}
\PassOptionsToPackage{dvipsnames}{xcolor}
\begin{document}
\begin{frame}
\LaTeX
{\color{Blue}\LaTeX}
\end{frame}
\end{document}
We get the following error message.
! Package xcolor Error: Undefined
color `Blue'.
Final Conclusion: Something is wrong with beamer
making it to fail to
handle the xcolor
package options.
Best Answer
This is due to a bug in
beamer
v3.65 which was fixed inbeamer
v3.66. Those who are forced to use this version (upgrades may be difficult when you install the complete system), you can use the following workaround.Load
xcolor
or use the macro\PassOptionsToPackage{...}
before\documentclass{...}
.Use either of the following before
\documentclass{...}
in your file,The second one is more modular.