alex-ball / beamerswitch

Convenient mode selection in Beamer documents
22 stars 0 forks source link

Loading of named colors with xcolor package #5

Closed jlconlin closed 6 years ago

jlconlin commented 6 years ago

I'm trying to convert to beamerswitch and I'm struggling a little bit because I am using the xcolor package. My preamble looks like:

\PassOptionsToClass{aspectratio=169,xcolor={usenames,dvipsnames}}{beamer}
\documentclass{beamerswitch}
\usepackage{isotope}
\renewcommand{\isotopestyle}{\sf}

I have several \include statements in my main document

I'm getting the error:

! Package xcolor Error: Undefined color `ForestGreen'

It seems that my xcolor options are being lost somewhere. Am I missing something?

jlconlin commented 6 years ago

By the way, this compiles fine with the command:

latexmk -pdf -pvc -jobname=Workshop-slides

but fails with the command:

latexmk -pdf -pvc -jobname=Workshop-article
alex-ball commented 6 years ago

Beamer has several options, the only effect of which is to pass options to other packages; glancing through I can spot color, hyperref, and xcolor. There are certain others (e.g. ucs) that simply load packages.

I will need a careful think about whether to improve the documentation or add features to handle these options.

In the meantime, instead of

\PassOptionsToClass{aspectratio=169,xcolor={usenames,dvipsnames}}{beamer}

Try

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\PassOptionsToClass{aspectratio=169}{beamer}
jlconlin commented 6 years ago

So I tried this, but it didn't help 😢. Now this fails when trying to compile either the slides or the article version. Somehow, the options are not getting passed to xcolor.

alex-ball commented 6 years ago

Could you provide a minimal (non-)working example?

I have, for example, tried this:

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\PassOptionsToClass{aspectratio=169}{beamer}
\documentclass[also=article]{beamerswitch}
\usepackage{isotope}
\renewcommand{\isotopestyle}{\sf}
\begin{document}
\begin{frame}
\textcolor{ForestGreen}{Some green text}
\end{frame}
\end{document}

and everything compiles normally in both forms.

jlconlin commented 6 years ago

Well, I'm struggling to find something that fails. I'll look through my non-minimal example and try to find out what the problem is.

jlconlin commented 6 years ago

My preamble looks like this:

\PassOptionsToClass{aspectratio=169,xcolor={usenames,dvipsnames}}{beamer}
\documentclass{beamerswitch}

Note, I've removed my custom style file and still have a problem. I use the metropolis theme, with a few minor modifications like this:

% All beamer-related commands should go here. 

\mode<presentation>
\usetheme[block=fill,progressbar=foot]{metropolis}
% \usecolortheme{wolverine}

% \setbeamercolor{progress bar}{fg=red}
\setbeamercolor{alerted text}{fg=red}

\setbeamersize{description width=1em}
% \setlength{\leftmargini}{1em}
\setlength{\leftmarginii}{1em}

When I compile with -jobname=Workshop-article I get this message in the log file:

Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Package option `override' ignored on input line 216.
Package xcolor Info: Driver file: pdftex.def on input line 225.

(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
)

When compiling with -jobname=Workshop-slides I get this message in the log file:

File: pgfsysprotocol.code.tex 2006/10/16  (rcs-revision 1.4)
)) (/usr/local/texlive/2017/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

(/usr/local/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)

It seems that when I compile the article version, the color options are not being passed to the xcolor package. I'm not sure why the options are not being passed to the xcolor package. This is really beyond my LaTeX capabilities.

alex-ball commented 6 years ago

Please excuse any of the following that is already familiar to you.

Beamerswitch normally loads the beamer class, but in article mode loads the article class instead. So while the following line normally works, it does nothing in article mode:

\PassOptionsToClass{aspectratio=169,xcolor={usenames,dvipsnames}}{beamer}

Literally all that beamer does with that xcolor option is convert it to the following line:

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}

(Package, you notice, not Class.) Now you want these options passed to the xcolor package regardless of whether the beamer or article class is being used, so instead of relying on beamer to do it, you can do it yourself.

\PassOptionsToPackage{usenames,dvipsnames}{xcolor}
\PassOptionsToClass{aspectratio=169}{beamer}

If you get errors replacing your \PassOptionsToClass line with the two lines above, then something else (probably not xcolor related) is going wrong.

jlconlin commented 6 years ago

Ah, that solves the problem. I didn't notice the difference between \PassOptionsToPackage vs \PassOptionsToClass. Now I have \PassOptionsToPackage and it seems to work rather well.

Thanks for your help!