[framemethod=tikz]{mdframed} & [draft]{graphicx} 的选项冲突 | [demo]{graphicx} 的相同冲突

[framemethod=tikz]{mdframed} & [draft]{graphicx} 的选项冲突 | [demo]{graphicx} 的相同冲突

以下选项和包的组合给出了Option clash,从而禁止任何人编译代码:

  • \usepackage[framemethod=tikz]{mdframed}
  • \usepackage[demo]{graphicx}(或者\usepackage[draft]{graphicx}

谁知道如何省略Option clash,但仍在同一个文档中继续使用两行代码?

\documentclass{article}

\usepackage[framemethod=tikz]{mdframed} % only 1 of them can be loaded
\usepackage[demo]{graphicx} % only 1 of them can be loaded (regardless of whether you use the "demo" or "draft" optional argument)

\begin{document}

If you try to include both of the lines (the ones commented above), the error is: \textbf{LaTeX Error Option clash for package graphicx.}

\end{document}

答案1

将对 graphicx 的调用移到 mdframed 之前:

\documentclass{article}
\usepackage[demo]{graphicx} 
\usepackage[framemethod=tikz]{mdframed} % 


\begin{document}

\includegraphics{blub}

\end{document}

或者传递选项:

\documentclass{article}

\PassOptionsToPackage{demo}{graphicx}
\usepackage[framemethod=tikz]{mdframed} % 

\begin{document}

\includegraphics{blub}

\end{document}

或者使用 documentclass 选项:

\documentclass[demo]{article}

\usepackage[framemethod=tikz]{mdframed} % 


\begin{document}

\includegraphics{blub}

\end{document}

答案2

您可以将demo其用作类的选项article。由于mdframed加载,graphicx您不需要加载graphicx(这就是最初发生冲突的原因)

无论如何,在与其他(冲突的)选项一起加载之前,demo必须先知道该选项。mdframedgraphicx

这是一般规则,不限于graphicx等等。

另一个例子可能是的选项xcolor,有时也会引起麻烦!

\documentclass[demo]{article}

\usepackage[framemethod=tikz]{mdframed} % only 1 of them can be loaded
%\usepackage{graphicx} % only 1 of them can be loaded (regardless of whether you use the "demo" or "draft" optional argument)


\begin{document}

If you try to include both of the lines (the ones commented above), the error is: \textbf{LaTeX Error Option clash for package graphicx.}

\includegraphics{ente}

\end{document}

相关内容