![[framemethod=tikz]{mdframed} & [draft]{graphicx} 的选项冲突 | [demo]{graphicx} 的相同冲突](https://linux22.com/image/332529/%5Bframemethod%3Dtikz%5D%7Bmdframed%7D%20%26%20%5Bdraft%5D%7Bgraphicx%7D%20%E7%9A%84%E9%80%89%E9%A1%B9%E5%86%B2%E7%AA%81%20%7C%20%5Bdemo%5D%7Bgraphicx%7D%20%E7%9A%84%E7%9B%B8%E5%90%8C%E5%86%B2%E7%AA%81.png)
以下选项和包的组合给出了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
必须先知道该选项。mdframed
graphicx
这是一般规则,不限于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}