如何在带有 hyperref 的期刊样式文件中使用 newlabel

如何在带有 hyperref 的期刊样式文件中使用 newlabel

我正在使用 OUP 的 bio.cls 样式文件。但是,当我使用 hyperref 时会发生冲突。

我用:

 \usepackage[colorlinks=true]{hyperref}

编译时会出现以下常见错误参见此链接这里也是

hyperref 和 newlabel 之间。

Runaway argument?
{{}{1}{}{page.
! Paragraph ended before \@newl@bel was complete.
<to be read again> 
                   \par 
l.20 \newlabel{firstpage}{{}{1}{}{page.\par
                                            }{}}

据我所知,这是由 hyperref 引起的。有没有办法保护 newlabel(我似乎无法控制)并仍然使用 hyperref?

这是一种 MWE。

这是使用此处提供的期刊样式文件的示例。

\documentclass[oupdraft]{bio}
\usepackage[colorlinks=true, urlcolor=citecolor, linkcolor=citecolor, citecolor=citecolor]{hyperref}

% Add history information for the article if required
\history{Received August 1, 2010;
revised October 1, 2010;
accepted for publication November 1, 2010}

\begin{document}

% Title of paper
\title{Exploration of empirical Bayes hierarchical modeling for the
analysis of genome-wide association study data}

% List of authors, with corresponding author marked by asterisk
\author{ELIZABETH A. HERON$^\ast$, COLM O'DUSHLAINE, RICARDO SEGURADO,\\
LOUISE GALLAGHER, MICHAEL GILL\\[4pt]
% Author addresses
\textit{Neuropsychiatric Genetics Research Group and Department of Psychiatry,
Trinity College Dublin,
Trinity Centre for Health Sciences,
James's Street, Dublin 8,
Ireland}
\\[2pt]
% E-mail address for correspondence
{[email protected]}}

% Running headers of paper:
\markboth%
% First field is the short list of authors
{E. A. Heron and others}
% Second field is the short title of the paper
{Empirical Bayes hierarchical modeling for GWAS}

\maketitle

% Add a footnote for the corresponding author if one has been
% identified in the author list
\footnotetext{To whom correspondence should be addressed.}

\begin{abstract}
{Jus some text.}
{Coronary artery disease; Crohn's disease; Multilevel model;
Rheumatoid arthritis; Semi-Bayes; Type 2 diabetes.}
\end{abstract}


\section{Introduction}
\label{sec1}
Not important

\end{document}

这是 bio.cls 文件: 生物分类

因此,latexmk -pdf samplebibtex.text(包含该 MWE 的文件)给出....

......
(/usr/share/texlive/texmf-dist/tex/latex/atveryend/atveryend.sty)
(/usr/share/texlive/texmf-dist/tex/latex/rerunfilecheck/rerunfilecheck.sty
(/usr/share/texlive/texmf-dist/tex/generic/uniquecounter/uniquecounter.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def)
(./samplebibtex.aux
Runaway argument?
{{}{1}{}{page.
! Paragraph ended before \@newl@bel was complete.
<to be read again> 
                   \par 
l.19 \newlabel{firstpage}{{}{1}{}{page.\par
                                            }{}}
? 

按 Enter 键进入:

! Extra }, or forgotten \endgroup.
l.19 \newlabel{firstpage}{{}{1}{}{page.\par }

但是,注释掉 hyperref 包可以使其编译正常。

%\usepackage[colorlinks=true, urlcolor=citecolor, linkcolor=citecolor, citecolor=citecolor]{hyperref}

这是输出的结束。

...
(see the transcript file for additional information){/usr/share/texlive/texmf-d
ist/fonts/enc/dvips/cm-super/cm-super-ts1.enc}</usr/share/texlive/texmf-dist/fo
nts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/ty
pe1/public/amsfonts/cm/cmbx9.pfb></usr/share/texlive/texmf-dist/fonts/type1/pub
lic/amsfonts/cm/cmcsc10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/a
msfonts/cm/cmr10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts
/cm/cmr6.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr8
.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr9.pfb></u
sr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></usr/shar
e/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/share/texl
ive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti9.pfb></usr/share/texlive/tex
mf-dist/fonts/type1/public/cm-super/sfrm0600.pfb>
Output written on samplebibtex.pdf (1 page, 123097 bytes).
Transcript written on samplebibtex.log.
Latexmk: Examining 'samplebibtex.log'
=== TeX engine is 'pdfTeX'
Latexmk: Log file says output to 'samplebibtex.pdf'
Latexmk: All targets (samplebibtex.pdf) are up-to-date

我提前感谢任何建议和帮助!

答案1

该类定义一个命令\label@firstpage并在 \maketitle 中使用它。该命令的定义是

\def\label@firstpage{%
   \@ifundefined{Hy@Warning}{% hyperref not loaded
     \immediate\write\@auxout{\string
    \newlabel{firstpage}{{}{\thepage}}}
  }{
    \immediate\write\@auxout{\string
    \newlabel{firstpage}{{}{\thepage}{}{%
     \ifHy@pageanchor page.\Hy@temp\fi}{}}}
  }
}

这个定义完全是错误的,该类不应该使用\Hy@temp。这是 hyperref 的内部命令,用于存储临时代码,该类无法控制其实际内容。

将此错误报告给课程作者。作为解决方法,请在序言中添加

\makeatletter
\def\label@firstpage{\label{firstpage}}
\makeatother

相关内容