如何防止从库中导入宏?

如何防止从库中导入宏?

为了提供更多背景信息,我试图覆盖\state来自 cryptocode 的宏,因为它与\state下面的关联相冲突。不幸的是,我大量使用了来自 的其他宏cryptocode。因此,我无法跳过使用cryptocode。以下是示例代码:

\documentclass[sigconf]{acmart}

\title{The Name of the Title Is Hope}

\usepackage[n,advantage,operators,sets,adversary,landau,probability,notions,logic,ff,mm,primitives,events,complexity,asymptotics,keys]{cryptocode}

\author{Huifen Chan}
\affiliation{%
    \institution{Tsinghua University}
    \city{Haidian Qu}
    \state{Beijing Shi}
    \country{China}
}

\begin{document}

\maketitle

\end{document}

有没有办法防止从库中导入宏?

答案1

\state是 中的主要宏之一cryptocode。另一方面,仅在处理标题栏时\state使用。acmart

cryptocode我们可以在两种含义之间进行权衡,执行 之后恢复 的含义\maketitle

不幸的是,cryptocode存在滥用\def,因此很难找出其他可能的不兼容问题。

\documentclass[sigconf]{acmart}

% save a copy of \state as defined by acmart
\NewCommandCopy{\acmstate}{\state}
% undefine \state for safety
\let\state\relax

\usepackage[
  n,
  advantage,
  operators,
  sets,
  adversary,
  landau,
  probability,
  notions,
  logic,
  ff,
  mm,
  primitives,
  events,
  complexity,
  asymptotics,
  keys,
]{cryptocode}

% cryptocode redefines \state, save its meaning
\NewCommandCopy{\cryptocodestate}{\state}
% restore acmart's \state
\RenewCommandCopy{\state}{\acmstate}

\title{The Name of the Title Is Hope}

\author{Huifen Chan}
\affiliation{%
    \institution{Tsinghua University}
    \city{Haidian Qu}
    \state{Beijing Shi}
    \country{China}
}

\begin{document}

\maketitle
% restore cryptocode's \state
\RenewCommandCopy{\state}{\cryptocodestate}

\end{document}

相关内容