使用 hyperref 的圖參考問題

使用 hyperref 的圖參考問題

我的問題似乎很簡單,儘管我還沒有找到任何解決方案。我正在用 LaTeX 寫論文,但我對這種類型的語言完全陌生。

我試著引用一個數字:

(see Figure~\ref{fig:transistor1})

而該圖在引用後定義為:

\begin{figure}[htb]
\centering
\includegraphics[width=0.4\linewidth]{./_pic/transistor1}
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}

在編譯過程中,我收到錯誤“段落在 \Hy@setref@link 完成之前結束”,當然在編譯後的pdf中,“Figure”一詞後面沒有任何數字,而且也缺少 ) 符號。

我嘗試更改圖形及其引用的順序,留下 () 標記,但沒有任何幫助。

我正在等待你們的幫助,提前謝謝你們:)

更新: 微量元素:

\documentclass[a4paper,12pt,twoside,openright]{report}

\usepackage[pdfusetitle, colorlinks, filecolor={[rgb]{0,0,1}},urlcolor={[rgb]{0,0,1}}, citecolor={[rgb]{0,0,0.4}}, linkcolor={[rgb]{0,0,0.4}}, bookmarks]{hyperref}

\begin{document}
\chapter{MEMS technology}

\ref{fig:transistor1}

\begin{figure}[htb]
\centering
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}

\end{document}

現在,如果您在沒有 hyperref 套件的情況下編譯它,那麼與使用它相比,您可能會得到相同的錯誤。如果再次編譯,錯誤在 MWE 中消失(但在整個文件中錯誤仍然存在)。

更新#2: 現在我已經找到了正確的 MWE,當使用 \selectlanguage 命令時出現問題:

\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage[british,german,hungarian]{babel}
\usepackage[pdfusetitle, colorlinks, filecolor={[rgb]{0,0,1}},urlcolor={[rgb]{0,0,1}}, citecolor={[rgb]{0,0,0.4}}, linkcolor={[rgb]{0,0,0.4}}, bookmarks]{hyperref}

\begin{document}
\selectlanguage{british}
\chapter{MEMS technology}

\ref{fig:transistor1}

\begin{figure}[htb]
\centering
\caption[The first transistor]{The first point-contact transistor developed by Bell Laboratories}
\label{fig:transistor1}
\end{figure}

\end{document}

提前謝謝你亞當

答案1

hyperref與包nameref改變了資料的內部資料格式\label,因為它們需要額外的資料。因此,如果檔案中的資料.aux是由不同的套件組合寫入的,特別是帶有或不帶有hyperref/ nameref,則可能會觸發錯誤。

解決方法:

  • 在這種情況下,可以忽略該錯誤,.aux寫入一個新文件,並且下一次運行 LaTeX 應該沒問題。

  • 或刪除輔助文件,如果hyperref/ nameref(或其他一些包)被添加或刪除。

答案2

我找到了答案:如果您使用“匈牙利語”作為 babel 包選項中的最後一種語言,則會出現錯誤。如果您使用任何其他排列,程式碼將毫無問題地編譯...

相關內容