ASL 類別檔案與 Cleveref 和 cite 套件之間的衝突

ASL 類別檔案與 Cleveref 和 cite 套件之間的衝突

我想提交一篇論文給符號邏輯雜誌,這意味著我需要使用Association of Symbolic Logic的類別文件asl.cls和參考書目樣式文件asl.bst,這兩個文件都可用這裡

過去,我已經成功地將hyperref,cleverefcite包與articlebook文檔類一起使用。然而,類文件asl.cls引起了麻煩。這是一個 MWE:

\documentclass{asl}

\usepackage{color}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor={blue},citecolor={orange}}
%\usepackage[nameinlink]{cleveref} % If this is switched on, then the .tex file fails to compile.
\usepackage{cite} % This package doesn't lead to a catastrophic failure, but the citation appears as [?].

\newtheorem{thm}{Theorem}

\title{A minimal working example}
\author{M.W.\ Example}

\begin{document}
\maketitle

\begin{thm}\label{theorem}
There exists a solution to this \LaTeX{} problem.
\end{thm}

\begin{proof}
See the \TeX{} Stack Exchange.
\end{proof}

A reference to the theorem: \ref{theorem} This is working! :)

A citation: \cite{test} This is not working. :(

\bibliography{MWE}
\bibliographystyle{asl}

\end{document}

這是檔案 MWE.bib:

 @article{test,
 author           = {Why, Y.O.},
 title            = {Clashes between packages and class files},
 journal          = {Journal of tricky \LaTeX{} problems},
 year             = {2017},
 volume           = {1},
 pages            = {1-101}
 }

到目前為止的一些觀察和嘗試:

  1. 該文件asl.cls來自 2002 年,我認為它早於某些軟體包,但我找不到更新的版本。
  2. 我已經查看了該文件asl.cls,但我對 LaTeX 類文件的內部工作原理的了解是非常有限並且有太多的依賴項我不知道從哪裡開始。
  3. 如果我關閉cite程式包,則引文將正確顯示為 [1](而不是 [?]),但它不可單擊。
  4. 一些標準包,例如amsthm,內置於文件中asl.cls(我並不完全理解如何構建)。

所以,我的問題是:有沒有辦法將hyperref,cleverefcite包與(可能的修改版本)一起使用asl.cls

答案1

我瀏覽了這些文件asl.clsasl.bst嘗試理解文件類的使用者指南(在 參考資料中asldoc.ps)。

  • 製作該文件的副本asl.cls並將副本命名為als-mod.cls.

  • 在文字編輯器中開啟該檔案als-mod.cls並轉到第 3332 行,其中\bibliographystyle開始(重新)定義。註解掉該巨集的整個(重新)定義,即第 3332 行到第 3349 行。

  • 在您的主 tex 檔案中,指定asl-mod為 的必要參數\documentclass,並指定選項bibotherotherbib-- 是的,這兩個!

  • \bibliographystyle在主 tex 檔案中,將from的參數變更aslplain。文件中的編碼asl.bst簡直超出了我們的想像。嘗試修復它沒有意義。文件類別的使用者指南asl建議(儘管是間接的)使用該樣式編譯參考書目是可以接受的plain;大膽試試吧! (使用者指南指出「沒有理由使用 之外的其他樣式asl。」雖然這聽起來確實像是對使用參考書目樣式的認可asl,但沒有跡象表明必須使用asl。)

透過這些更改,\cite說明實際上將為您提供數位引文標註。嗚呼!

  • 要開始cleveref工作,請務必 (a) 運行\newtheorem{thm}{Theorem} 載入並 (b)載入後cleveref提供說明。\crefname{thm}{Theorem}{Theorems}cleveref

在此輸入影像描述

\RequirePackage{filecontents}
\begin{filecontents}{MWE.bib}
@article{test,
 author       = {Why, Y. O.},
 title        = {Clashes between packages and class files},
 journal      = {Journal of tricky \LaTeX{} problems},
 year         = {2017},
 volume       = {1},
 pages        = {1-101}
 }
\end{filecontents}

\documentclass[otherbib,bibother]{asl-mod} % not 'asl'
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks=true,
            linkcolor={blue},
            citecolor={red}}

\newtheorem{thm}{Theorem}

\usepackage[nameinlink]{cleveref} % 'nameinlink' option is optional
\crefname{thm}{Theorem}{Theorems}

\bibliographystyle{plain} % not 'asl'

\begin{document}
%\title{A minimal working example}
%\author{M.W.\ Example}
%\maketitle

\begin{thm}\label{theorem}
There exists a solution to this \LaTeX{} problem.
\end{thm}

\begin{proof}
See the \TeX{} Stack Exchange.
\end{proof}

A \verb+\cref+ cross-reference: \cref{theorem}. This is now working.

A citation call-out: \cite{test}. This now works too.

\bibliography{MWE}
\end{document}

相關內容