定义颜色选项与包 xcolor 冲突

定义颜色选项与包 xcolor 冲突

已在我的样式文件中包含以下内容

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{andromeda}[2022/10/03 Andromeda Package]

\newif\ifCountryMaps
\CountryMapsfalse

\newif\ifScienTech
\ScienTechfalse

%% Options set boolean flags to true
\DeclareOption{CountryMaps}{\CountryMapstrue}
\DeclareOption{ScienTech}{\ScienTechtrue}

%% process the options before checking if the booleans are true
\ProcessOptions

%% Load Country Maps
\ifCountryMaps
  \RequirePackage{countriesofeurope}
\fi

%% Load Science and Technology Packages
\ifScienTech
  \RequirePackage{gensymb}
  \RequirePackage{wasysym}
  \RequirePackage{ifsym}
  \RequirePackage{textcomp}
  \RequirePackage{steinmetz}
  \RequirePackage{emf}
  \RequirePackage{fontawesome}
  \RequirePackage{utfsym}
  \RequirePackage{keystroke}
  \RequirePackage{svrsymbols}
\fi

\RequirePackage{etoolbox} % Programming tools

%% Deferred colours (with asterisk) for dvipsnames
\RequirePackage[dvipsnames*,svgnames,x11names]{xcolor}
\definecolors{Lavender}

%% Bold typeface
\renewcommand{\seriesdefault}{\bfdefault}
\boldmath

并且得到

! LaTeX Error: Option clash for package xcolor.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.110 \definecolors
                 {Lavender}

答案1

你没有提供测试文件,但是

\documentclass{article}
\usepackage[ScienTech]{andromeda}
\begin{document}

\end{document}

日志中显示:

 (/usr/local/texlive/2022/texmf-dist/tex/latex/utfsym/utfsym.sty
Package: utfsym 2022/04/17 Use TikZ to support icons from Unicode blocks

(/usr/local/texlive/2022/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-09-28 L3 programming layer (loader) 

(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2022-09-28 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count198
\l__pdf_internal_box=\box52
))
Package: l3keys2e 2022-06-22 LaTeX2e option processing using LaTeX3 keys
) (/usr/local/texlive/2022/texmf-dist/tex/latex/xcolor/xcolor.sty

显示xcolor已经加载(没有选项)utfym.sty

因此,你会面临来自

\RequirePackage[dvipsnames*,svgnames,x11names]{xcolor}

你可以xcolor尽早加载选项,或者最好少加载一些可能冲突的包,

相关内容