在 ifacconf 类中使用 hyperref 时出现非法度量单位错误

在 ifacconf 类中使用 hyperref 时出现非法度量单位错误

我正在尝试使用他们的模板向 IFAC 会议提交一篇文章:https://www.ifac-control.org/events/author-guide/copy_of_ifacconf_latex.zip/viewhyperref。除了宏之外,我还想使用该包向文档添加链接以及其他功能。在添加包之前,autoref我的文档编译得很好,但添加包时会产生以下错误:latexmkhyperref

Errors:

./mwe-delete.tex:33: Illegal unit of measure (pt inserted). [\begin{ack}]
./mwe-delete.bbl:1: Illegal unit of measure (pt inserted). [\begin{thebibliography}{1}]

为了清楚起见,我使用以下文件:

  • mwe-delete.texMWE 主 tex 文件。
  • refs-test-delete.bibMWE 书目文件。

此外,该文件mwe-delete.bbl由 生成natbib

这些是的内容mwe-delete.tex

\documentclass{ifacconf}
\usepackage{natbib}
\usepackage{hyperref}

\begin{document}
\begin{frontmatter}
\title{Paper Title\thanksref{titlenote}}

\thanks[titlenote]{
    Titlenote.
}

\author[First]{First Author}

\address[First]{First Author contact info.}

\begin{abstract}
The abstract.
\end{abstract}

\begin{keyword}
Keyword
\end{keyword}

\end{frontmatter}

\section{Introduction}
\label{sec:introduction}

Introduction.
This is based on the work of \citet{bibref1}.

\begin{ack}
Acknowledgement.
\end{ack}

\bibliography{refs-test-delete}

\end{document}

内容refs-test-delete.bib

@Article{bibref1,
  author    = {Firstname M. Lastname},
  title     = {PaperTitle},
  journal   = {Journal of Journals},
  year      = {2009},
  volume    = {32},
  number    = {3},
  pages     = {1039--1045},
  month     = {5},
  publisher = {Publisher},
}

生成的内容在mwe-delete.bbl

\begin{thebibliography}{1}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\providecommand{\urlprefix}{URL }
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{doi:\discretionary{}{}{}#1}\else
  \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup
  \urlstyle{rm}\Url}\fi

\bibitem[{Lastname(2009)}]{bibref1}
Lastname, F.M. (2009).
\newblock Papertitle.
\newblock \emph{Journal of Journals}, 32(3), 1039--1045.

\end{thebibliography}

有人有将 IFAC 模板与 一起使用的经验吗hyperref?我正在使用 TexLive 2017 和最新更新的软件包。 的内容ifacconf.cls位于此处(直接链接至 460 kB 的 .zip 文件)

答案1

这里的根本区别在于ifacconf通过引入新的内部参数来更新章节的格式/呈现方式,旨在区分某些标题。具体来说,“低于 1 级的标题”采用一种格式,而“1 级或更高级别的标题”采用不同的格式。而且,由于hyperref负载nameref为了夺取部门单位头衔,有些方法与常规方法相混淆ifacconf

更直接的解释:LaTeX\section*通过宏处理\@ssect

\def\@ssect#1#2#3#4#5{%
  \@tempskipa #3\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #4{%
        \@hangfrom{\hskip #1}%
          \interlinepenalty \@M #5\@@par}%
    \endgroup
  \else
    \def\@svsechd{#4{\hskip #1\relax #5}}%
  \fi
  \@xsect{#3}}

请注意,它有/接受 5 个参数。ifacconf重新定义\@ssect为接受 6 个参数:

\def\@ssect#1#2#3#4#5#6{%
  \@tempskipa #4\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #5{%
        \@hangfrom{\hskip #2}%
          \interlinepenalty \@M \head@format{#1}{#6}\@@par}%
    \endgroup
  \else
    \def\@svsechd{#5{\hskip #2\relax \head@format{#1}{#6}}}%
  \fi
  \@xsect{#4}}

hyperref不知道这一点,因为它假设常规协议(5 个参数)存在,即使包/类可以(重新)定义自己的分段单元样式。容纳所有可能版本的函数(重新)定义将是一项无法完成的任务。

以下方法\@ssecthyperref重新定义之前进行存储。然后在加载之后恢复hyperref,并插入以适应nameref的标题 gab:

在此处输入图片描述

\documentclass{ifacconf}

\usepackage{filecontents}
\begin{filecontents*}{refs-test-delete.bib}
@Article{bibref1,
  author    = {Firstname M. Lastname},
  title     = {PaperTitle},
  journal   = {Journal of Journals},
  year      = {2009},
  volume    = {32},
  number    = {3},
  pages     = {1039--1045},
  month     = {5},
  publisher = {Publisher},
}
\end{filecontents*}

\makeatletter
\let\old@ssect\@ssect % Store how ifacconf defines \@ssect
\makeatother

\usepackage{natbib}
\usepackage{hyperref}

\makeatletter
\def\@ssect#1#2#3#4#5#6{%
  \NR@gettitle{#6}% Insert key \nameref title grab
  \old@ssect{#1}{#2}{#3}{#4}{#5}{#6}% Restore ifacconf's \@ssect
}
\makeatother

\begin{document}

\begin{frontmatter}

\title{Paper Title\thanksref{titlenote}}

\thanks[titlenote]{
    Titlenote.
}

\author[First]{First Author}

\address[First]{First Author contact info.}

\begin{abstract}
The abstract.
\end{abstract}

\begin{keyword}
Keyword
\end{keyword}

\end{frontmatter}

\section{Introduction}
\label{sec:introduction}

Introduction.
This is based on the work of \citet{bibref1}.

\begin{ack}
Acknowledgement.
\end{ack}

\bibliography{refs-test-delete}

\end{document}

相关内容