\documentclass[12pt, a4paper, UTF8, scheme = plain, twoside]{ctexart}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{enumerate}
\usepackage[top=0.5cm,left=0.5cm,right=0.5cm,bottom=2.28cm]{geometry}
\usepackage{hyperref}
\usepackage{graphicx}
\pdfsuppressptexinfo=-1
\usepackage{fancyhdr}
\usepackage{totpages}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tcolorbox}
\tcbuselibrary{skins,xparse,breakable}
\tcbset{%
colback = white,
tikz = {opacity=0.8,transparency group},
colframe = black,
title filled = false,
colbacktitle = white,
breakable,
enhanced
}%%
\NewTColorBox[
]{question}{ O{}mo }{
fonttitle = \bfseries,
coltitle = black,
title = #2,
% after title = {\hfill Page~\thepage~of~10000},
after title = {Page~\thepage\ of~\pageref{TotPages}},
before lower = {\textbf{Solution\quad}},
#1
}%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\newcommand*{\mytopic}[2]{%
\clearpage
\begin{question}{Exercise \path{#1} }
\includegraphics[scale=1.18]{example-image-a.pdf}
\tcblower
#2
\end{question}
}%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
%%% DOC Begins %%%
%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%do compile%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mytopic{Q1_490}{
Blah Blah Blah Blah Blah
\lipsum[4]
\[
\lambda = 2\times10^5
\qquad
l_0 = 2
\]
\lipsum[5-8]
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
}%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%
\mytopic{test_223}{
Blah Blah Blah Blah Blah
\lipsum[20]
%% \begin{enumerate}
%% \item $mv = 50\times 10 = 500 $ Ns
%% \item $mv = 5\times10^3\times4 = 20,000$ Ns
%% \item $mv = 7000\times10^3\times40 = 2.8\times10^8$ Ns
%% \item $mv = 2\times10^{-16}\times10^{-3}\times1\times\times10^{-3} = 2 \times 10^{-22}$ Ns
%% \end{enumerate}
\lipsum[25-28]
Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah
}%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
这个 MWE 花了我两天 8 个小时才找到可能出现问题的地方.........太累了.....
问题 1- 可能与totpages
包冲突。我们似乎无法使用
after title = {Page~\thepage\ of~\pageref{TotPages}},
它无法编译并给出一个fatal error
。
问题 2- 可能与enumerate
包冲突。enumerate
环境无法使用。如果是这样,则会出现同样的错误
! pdfTeX error (ext4): link annotations cannot be inside an XForm.
<argument> ...shipout:D \box_use:N \l_shipout_box
\__shipout_drop_firstpage_...
l.75 }
有什么建议么?
答案1
您的问题与 有关transparency group
。当您使用该 tcolorbox/tikz 时,会将框放在 xform 对象中,并且不允许在此类对象中放置链接。
获取错误的一个简单示例(在第二次编译时)是这样的:
\documentclass{article}
\usepackage{hyperref}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbset{tikz={transparency group},enhanced}
\begin{document}
\section{abc}\label{sec}
\begin{tcolorbox}
hello \ref{sec}
\end{tcolorbox}
\end{document}
您在此处的选择是删除transparency group
或避免 tcolorbox 内的任何活动链接,例如通过使用\pageref*
和\ref*
,或者 - 可能更安全 - 用环境围绕框NoHyper
。