浮动图形内的 natbib、hyperref 和引用

浮动图形内的 natbib、hyperref 和引用

我使用 Lyx 和 MikTeX 2.9 根据书中的 KOMA-script 撰写论文。在最后,我在 pdflatex 运行时遇到错误:

Extra }, or forgotten \ endgroup.

<argument> ... \IeC {\c s}i dreapta D=2.9\relax }}
                                              \hyper@linkend 
l.25 ...apta D=2.9\relax }}{32}{figure.caption.25}

I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

这是我的代码:

\documentclass[romanian]{article}
\usepackage[]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{float}
\usepackage[unicode=true,pdfusetitle,
  bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
  breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
 {hyperref}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{type1ec}
\usepackage[T1]{fontenc}
\usepackage{ucs}
\usepackage{hyperref}
\makeatletter
\newcommand\bibstyle@comma{\bibpunct(),a,,}
\newcommand\bibstyle@semicolon{\bibpunct();a,,}
\makeatother
\pretocmd\citet{\citestyle{comma}}\relax\relax
\pretocmd\Citet{\citestyle{comma}}\relax\relax
\pretocmd\citep{\citestyle{semicolon}}\relax\relax
\pretocmd\Citep{\citestyle{semicolon}}\relax\relax

\makeatother

\begin{document}
\begin{figure}[H]
\begin{centering}
aaaa
\par\end{centering}

\caption{Suprafete fractale Brown-iene obinute cu funcia \emph{r.surf.fractal}
\cite{Wood1996} din GRASS GIS: stanga - D=2.1, centru D=2.5 si dreapta
D=2.9}
\end{figure}


\bibliographystyle{chicago}
\phantomsection\addcontentsline{toc}{section}{\refname}\bibliography{D:/JURNALE/a}

\end{document}

参赛号码为:

@phdthesis{Wood1996,
author = {Wood, Jo},
booktitle = {Advances in cancer research},
file = {:D$\backslash$:/JURNALE/Bettuzzi\_2009.pdf:pdf},
issn = {0065-230X},
month = jan,
pmid = {19878769},
school = {University of Leicester},
title = {{The geomorphological characterisation of digital elevation models}},
volume = {104},
year = {1996}
}

比布文件。

我使用了芝加哥 bibtex 风格的修改版。

虽然代码包含了很多优化,但错误是在我添加代码时出现的

\newcommand\bibstyle@comma{\bibpunct(),a,,}
\newcommand\bibstyle@semicolon{\bibpunct();a,,}
\makeatother
\pretocmd\citet{\citestyle{comma}}\relax\relax
\pretocmd\Citet{\citestyle{comma}}\relax\relax
\pretocmd\citep{\citestyle{semicolon}}\relax\relax
\pretocmd\Citep{\citestyle{semicolon}}\relax\relax

这是我获得逗号和冒号分隔的引用所必需的。

该错误与浮动图标题中包含的一些引用有关。我在网上看到,有时 natbib 和 hyperref 彼此不兼容,而且当我注释文档上方的代码时,确实可以编译。

有关此问题的任何线索都会有所帮助!提前致谢!

米哈伊

答案1

你的例子缺少两部分:

\usepackage{natbib}
\usepackage{etoolbox}

第一个是获取命令\citet和类似命令;第二个提供\pretocmd。但是,以这种方式修补这些命令是错误的,因为它们是“强命令”。

这样做:

\usepackage{xpatch}
\xpretocmd\citet{\citestyle{comma}}{}{}
\xpretocmd\Citet{\citestyle{comma}}{}{}
\xpretocmd\citep{\citestyle{semicolon}}{}{}
\xpretocmd\Citep{\citestyle{semicolon}}{}{}

这样补丁才会正确对应内部宏。natbib当然,你仍然需要。加载etoolbox不是必需的。

如果xpatch你的 TeX 发行版中没有,你仍然可以执行正确的修补:

\usepackage{etoolbox}
\expandafter\pretocmd\csname citet \endcsname{\citestyle{comma}}{}{}

(其他三个命令类似)。

相关内容