我正在根据 Springer Nature 提供的模板创建 LaTeX 模板关联.. 和直接下载链接
渲染时出现以下错误:
compilation failed- error
Undefined control sequence.
\__hook shipout/firstpage ...geHook \headerps@out
{/burl@stx null def /BU.S ...
l.91 \item D
ata availability
我的问题是:我该如何调试?我可以使用哪种系统流程来解开错误根源... 我很高兴得到“如何修复错误”的答案,但实际上我更愿意了解如何自己解决问题。
主要问题是回溯...钩子、运出等等从何而来?
...我是并非唯一哀叹 TeX 调试 :-)
我已经精简了 Springer 模板很多(它载有注释和占位符文本),但它仍然包含所有相关的包等:
%\documentclass[sn-vancouver,Numbered]{sn-jnl}% Vancouver Reference Style
\documentclass[]{sn-jnl}%
%% Added by S. O'Neill, as required by pandoc
\usepackage{hyperref}%
% \usepackage{iftex}
% \usepackage{unicode-math}%
% \usepackage{lmodern}
% \usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
% \usepackage{textcomp}
% \usepackage{upquote}
% \usepackage[]{microtype}
% \usepackage{parskip}
% \usepackage{xcolor}
% \usepackage{color}
% \usepackage{fancyvrb}
% \usepackage{framed}
% \usepackage{longtable,booktabs,array}
% \usepackage{calc}
% \usepackage{etoolbox}
% \usepackage{footnotehyper}
% \usepackage{footnote}
% \usepackage{graphicx}
% \usepackage{bookmark}
\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{mathrsfs}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{listings}%
\raggedbottom
\begin{document}
\title[Article Title]{Article Title}
\author*[1,2]{\fnm{First} \sur{Author}}\email{[email protected]}
\affil*[1]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{100190}, \state{State}, \country{Country}}}
\abstract{The abstract ..}
\keywords{keyword1, Keyword2, Keyword3, Keyword4}
\maketitle
$body$
\backmatter
\bmhead{Supplementary information}
If your article has accompanying supplementary file/s please state so here.
\bmhead{Acknowledgements}
Acknowledgements are not compulsory. Where included they should be brief. Grant or contribution numbers may be acknowledged.
Please refer to Journal-level guidance for any specific requirements.
\section*{Declarations}
Some journals require declarations to be submitted in a standardised format. Please check the Instructions for Authors of the journal to which you are submitting to see if you need to complete this section. If yes, your manuscript must contain the following sections under the heading `Declarations':
\begin{itemize}
\item Funding
\item Conflict of interest/Competing interests (check journal-specific guidelines for which heading to use)
\item Ethics approval and consent to participate
\item Consent for publication
\item Data availability
\item Materials availability
\item Code availability
\item Author contribution
\end{itemize}
\begin{appendices}
\section{Section title of first appendix}\label{secA1}
An appendix contains supplementary information that is not an essential part of the text itself but which may be helpful in providing a more comprehensive understanding of the research problem or it is information that is too cumbersome to be included in the body of the paper.
No bib...
\end{appendices}
% \bibliography{sn-bibliography}% common bib file
%% if required, the content of .bbl file can be included here once bbl is generated
%%\input sn-article.bbl
\end{document}
...据我所知,只有超链接是 Pandoc 的附加要求,因此我将其添加。
该模板由 minimal-working-example quarto markdown 文件使用:
---
title: "This is the title."
date: 2008-02-29
format:
pdf:
template: sn-article-short.tex
echo: false # This is required - the 'Shaded' environment (part of the pandoc template), is not part of the sn template
---
# A headline
Some text
作为参考,这里是 Latex 日志文件的尾部:
This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2022/dev/Debian) (preloaded format=xelatex 2024.3.18) 2 APR 2024 08:35
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
...
Document Class: sn-jnl 2019/11/18 v0.1: An authoring template for Springer Jour
nal articles
...
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info: Trying to load font information for U+msb on input line 58.
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
LaTeX Font Info: Trying to load font information for U+rsfs on input line 58
.
(/usr/share/texlive/texmf-dist/tex/latex/jknapltx/ursfs.fd
File: ursfs.fd 1998/03/24 rsfs font definition file (jk)
)
LaTeX Font Warning: Font shape `U/rsfs/m/n' in size <8.43146> not available
(Font) size <8> substituted on input line 58.
LaTeX Font Info: Calculating math sizes for size <11.04124> on input line 58
.
LaTeX Font Warning: Font shape `OT1/cmr/bx/n' in size <5.52061> not available
(Font) size <6> substituted on input line 58.
LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.52061> not available
(Font) size <6> substituted on input line 58.
LaTeX Font Warning: Font shape `OMS/cmsy/b/n' in size <5.52061> not available
(Font) size <6> substituted on input line 58.
LaTeX Font Warning: Font shape `U/rsfs/m/n' in size <5.52061> not available
(Font) size <6> substituted on input line 58.
LaTeX Font Info: Calculating math sizes for size <10.03749> on input line 58
.
Package hyperref Warning: Difference (4) between bookmark levels is greater
(hyperref) than one, level fixed on input line 74.
Package hyperref Warning: Difference (3) between bookmark levels is greater
(hyperref) than one, level fixed on input line 78.
Underfull \vbox (badness 10000) has occurred while \output is active []
! Undefined control sequence.
\__hook shipout/firstpage ...geHook \headerps@out
{/burl@stx null def /BU.S ...
l.91 \item D
ata availability
Here is how much of TeX's memory you used:
13572 strings out of 477600
212159 string characters out of 5839383
509268 words of memory out of 5000000
33981 multiletter control sequences out of 15000+600000
480326 words of font info for 89 fonts, out of 8000000 for 9000
360 hyphenation exceptions out of 8191
85i,7n,90p,329b,424s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
答案1
好吧,你问如何调试这个。
错误一开始就很明显,所以首先你要检查正文中的内容是否真的相关。如果不符合,我们用一些虚拟文本替换它。
然后,我们通过逐块注释和删除来检查是否有任何包相关。这导致了此文档(需要 amsmath,因为略有缺陷的类使用 amsmath 命令而不加载包本身):
\documentclass[]{sn-jnl}%
\usepackage{amsmath}
\usepackage{hyperref}%
\begin{document}
blub
\end{document}
然后你查看错误消息:使用了未定义的命令,幸运的是,错误直接为你提供了一些提示,因为它提到了 shipout/firstpage 钩子。usrguide.pdf 中提到了钩子,它将你指向 lthooks-doc.pdf(或者你搜索互联网),它会告诉你,你可以使用(在序言中)\ShowHook{shipout/firstpage}
来查看这个钩子。这给出
-> The hook 'shipout/firstpage':
> Code chunks:
> hyperref -> \Hy@FirstPageHook
> breakurl -> \headerps@out {/burl@stx null
...
并告诉您 breakurl 包是问题所在。
然后,您可以查看该类并搜索 breakurl 并会发现:
\gdef\breakurldefns{%
\if@pdflatex\else%
\RequirePackage[hyphenbreaks]{breakurl}%
% \let\href\burlalt%
\fi}%
\breakurldefns%
然后,如果您对 TeX 引擎的差异有一点了解,您也许可以猜出问题在于您使用的是 xelatex,而 breakurl 不适用于此引擎。或者您可以做现在做的事情:寻求帮助。
解决错误的选项是使用另一个引擎(lualatex 和 pdflatex breakurl 将不会被加载或静默退出),或者禁用加载:
\makeatletter
\disable@package@load{breakurl}{}
\makeatother
\documentclass[]{sn-jnl}%
我也会报告错误,该类可以在这里使用更好的测试。