这个问题可能之前已经有人问过了,但是我怎样才能让只有部分但没有章节hyperref
的文章(使用 KOMAscrartcl
类)顺利运行呢?它抱怨道:
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 90.
书签变得混乱,下一部分被“提升”到上一级。有趣的是,使用 stockarticle
类不会发生这种情况。
% vim: ft=tex tw=0
% arara: lualatex: { synctex: true, shell: true }
% arara: lualatex: { synctex: true, shell: true }
\documentclass{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage[math]{blindtext}
\title{A minimum working example}
\usepackage{hyperref}
\hypersetup{
pdfauthor={Robbie Smith},
pdftitle={A minimum working example},
pdfcreator={An infinite number of gremlins hitting random keys on typewriters...},
pdfpagemode=UseOutlines,
colorlinks=false,
hypertexnames=false,
hidelinks}
\usepackage[all]{hypcap}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\part{Design and Testing}
\section{Objective}
\blindtext
\section{Summary}
\label{sec:summary}
\blindtext
\section{Geometric design}
\label{sec:geometry}
\blindtext
\subsection{Final geometic design}
\label{ssec:geo:final}
The final geometric design is provided in the table below. Formulae references
are to the calculations in the above sections.
\blindtext
\section{Fabrication}
\label{sec:fabrication}
\blindtext
\section{Testing}
\label{sec:testing}
\blindtext
\section{Proposed improvements}
\label{sec:improvements}
\blindtext
\section{Conclusions}
\label{sec:conclusions}
\blindtext
\appendix
\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand*{\thetable}{\thesection.\arabic{table}}
\renewcommand*{\thefigure}{\thesection.\arabic{figure}}
\part{Preliminary Designs}
\label{part:preliminary-designs}
The preliminary designs were developed prior to building and testing.
\section{First Iteration}
\blindtext
\subsection{Something something}
\blindtext
\section{Second Iteration}
\blindtext
\section{Third Iteration}
\blindtext
\end{document}
lualatex
使用via进行编译的日志latexmk
如下:
$ latexmk mwe.tex
Latexmk: This is Latexmk, John Collins, 17 Jan. 2018, version: 4.55.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': Rules & subrules not known to be previously run:
pdflatex
Rule 'pdflatex': The following rules & subrules became out-of-date:
'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'lualatex --synctex=1 --shell-escape -recorder "mwe.tex"'
------------
This is LuaTeX, Version 1.07.0 (TeX Live 2018)
system commands enabled.
(./mwe.tex
LaTeX2e <2018-04-01> patch level 3
(using write cache: /opt/texlive/2018/texmf-var/luatex-cache/generic)(using rea
d cache: /opt/texlive/2018/texmf-var/luatex-cache/generic /home/faraday/.config
/texlive/2018/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.104 seconds
Babel <3.20> and hyphenation patterns for 1 language(s) loaded.
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2018/03/30 v3.25 KOMA-Script document class (article)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrsize11pt.clo(load luc: /
opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc
)) (/opt/texlive/2018/texmf-dist/tex/latex/koma-script/typearea.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer-scrpage.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/blindtext/blindtext.sty
(/opt/texlive/2018/texmf-dist/tex/latex/tools/xspace.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty
(/opt/texlive/2018/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/opt/texlive/2018/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/opt/texlive/2018/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/opt/texlive/2018/texmf-dist/tex/latex/url/url.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hluatex.def
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/hypcap.sty) (./mwe.aux)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/nameref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))(load lu
c: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmsans10-regular.
luc)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmsan
s10-bold.luc)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/
otl/lmroman12-regular.luc)
LaTeX Warning: No \author given.
(load luc: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmromansl
ant10-regular.luc) [1{/opt/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdfte
x.map}]
part I.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 33.
[2] [3]
part II.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 86.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 90.
[4] [5] (./mwe.aux)
Package rerunfilecheck Warning: File `mwe.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
)
380 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 3 attribute, 50 glue_spec, 3 attribute_lis
t, 1 write nodes
avail lists: 2:260,3:85,4:5,5:181,6:37,7:3890,8:37,9:154,10:4,11:314
</opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></
opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.otf></op
t/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmsans10-bold.otf>
Output written on mwe.pdf (5 pages, 21070 bytes).
SyncTeX written on mwe.synctex.gz.
Transcript written on mwe.log.
=== TeX engine is 'LuaTeX'
Latexmk: References changed.
Latexmk: References changed.
Latexmk: Log file says output to 'mwe.pdf'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'mwe.aux'
------------
Run number 2 of rule 'pdflatex'
------------
------------
Running 'lualatex --synctex=1 --shell-escape -recorder "mwe.tex"'
------------
This is LuaTeX, Version 1.07.0 (TeX Live 2018)
system commands enabled.
(./mwe.tex
LaTeX2e <2018-04-01> patch level 3
(using write cache: /opt/texlive/2018/texmf-var/luatex-cache/generic)(using rea
d cache: /opt/texlive/2018/texmf-var/luatex-cache/generic /home/faraday/.config
/texlive/2018/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.103 seconds
Babel <3.20> and hyphenation patterns for 1 language(s) loaded.
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2018/03/30 v3.25 KOMA-Script document class (article)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrsize11pt.clo(load luc: /
opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc
)) (/opt/texlive/2018/texmf-dist/tex/latex/koma-script/typearea.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer-scrpage.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/blindtext/blindtext.sty
(/opt/texlive/2018/texmf-dist/tex/latex/tools/xspace.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty
(/opt/texlive/2018/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/opt/texlive/2018/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/opt/texlive/2018/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/opt/texlive/2018/texmf-dist/tex/latex/url/url.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hluatex.def
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/hypcap.sty) (./mwe.aux)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/nameref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./mwe.out) (./mwe.out)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/gene
ric/fonts/otl/lmsans10-regular.luc)(load luc: /opt/texlive/2018/texmf-var/luate
x-cache/generic/fonts/otl/lmsans10-bold.luc)(load luc: /opt/texlive/2018/texmf-
var/luatex-cache/generic/fonts/otl/lmroman12-regular.luc)
LaTeX Warning: No \author given.
(./mwe.toc)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/ot
l/lmromanslant10-regular.luc) [1{/opt/texlive/2018/texmf-var/fonts/map/pdftex/u
pdmap/pdftex.map}]
part I.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 33.
[2] [3]
part II.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 86.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 90.
[4] [5] (./mwe.aux))
400 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 3 attribute, 54 glue_spec, 3 attribute_lis
t, 1 write nodes
avail lists: 2:563,3:140,4:5,5:181,6:58,7:3894,8:49,9:203,10:4,11:314
</opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></
opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.otf></op
t/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmsans10-bold.otf>
Output written on mwe.pdf (5 pages, 23032 bytes).
SyncTeX written on mwe.synctex.gz.
Transcript written on mwe.log.
=== TeX engine is 'LuaTeX'
Latexmk: Log file says output to 'mwe.pdf'
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'mwe.aux'
'mwe.out'
'mwe.toc'
------------
Run number 3 of rule 'pdflatex'
------------
------------
Running 'lualatex --synctex=1 --shell-escape -recorder "mwe.tex"'
------------
This is LuaTeX, Version 1.07.0 (TeX Live 2018)
system commands enabled.
(./mwe.tex
LaTeX2e <2018-04-01> patch level 3
(using write cache: /opt/texlive/2018/texmf-var/luatex-cache/generic)(using rea
d cache: /opt/texlive/2018/texmf-var/luatex-cache/generic /home/faraday/.config
/texlive/2018/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.096 seconds
Babel <3.20> and hyphenation patterns for 1 language(s) loaded.
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2018/03/30 v3.25 KOMA-Script document class (article)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrbase.sty
(/opt/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrsize11pt.clo(load luc: /
opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl/lmroman10-regular.luc
)) (/opt/texlive/2018/texmf-dist/tex/latex/koma-script/typearea.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer-scrpage.sty
(/opt/texlive/2018/texmf-dist/tex/latex/koma-script/scrlayer.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/blindtext/blindtext.sty
(/opt/texlive/2018/texmf-dist/tex/latex/tools/xspace.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty
(/opt/texlive/2018/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua)))
(/opt/texlive/2018/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/opt/texlive/2018/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/opt/texlive/2018/texmf-dist/tex/latex/url/url.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/hluatex.def
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/opt/texlive/2018/texmf-dist/tex/latex/oberdiek/hypcap.sty) (./mwe.aux)
(/opt/texlive/2018/texmf-dist/tex/latex/hyperref/nameref.sty
(/opt/texlive/2018/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./mwe.out) (./mwe.out)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/gene
ric/fonts/otl/lmsans10-regular.luc)(load luc: /opt/texlive/2018/texmf-var/luate
x-cache/generic/fonts/otl/lmsans10-bold.luc)(load luc: /opt/texlive/2018/texmf-
var/luatex-cache/generic/fonts/otl/lmroman12-regular.luc)
LaTeX Warning: No \author given.
(./mwe.toc)(load luc: /opt/texlive/2018/texmf-var/luatex-cache/generic/fonts/ot
l/lmromanslant10-regular.luc) [1{/opt/texlive/2018/texmf-var/fonts/map/pdftex/u
pdmap/pdftex.map}]
part I.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 33.
[2] [3]
part II.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 86.
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 90.
[4] [5] (./mwe.aux))
400 words of node memory still in use:
2 hlist, 1 vlist, 1 rule, 2 glue, 3 attribute, 54 glue_spec, 3 attribute_lis
t, 1 write nodes
avail lists: 2:563,3:140,4:5,5:181,6:58,7:3894,8:49,9:203,10:4,11:314
</opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></
opt/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman12-regular.otf></op
t/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmsans10-bold.otf>
Output written on mwe.pdf (5 pages, 23032 bytes).
SyncTeX written on mwe.synctex.gz.
Transcript written on mwe.log.
=== TeX engine is 'LuaTeX'
Latexmk: Log file says output to 'mwe.pdf'
Latexmk: All targets (mwe.pdf) are up-to-date
答案1
这些警告与 KOMA-Script 有关。“MWE”与 KOMA-Script 2015/10/03 v3.19a ( scrartcl.cls
) 配合良好。
最新版本2018/03/30 v3.25重新定义\toclevel@part
从0为-1,“部分”与“节”层级之间留有2的间隙。
前两个警告就是因为“part”和“section”之间存在间隙而导致的。软件包hyperref
通过将 part 之后的 section 设置为 0 级来解决这个问题。接下来的\subsection
级别为 2 的警告会引发第三个警告。
使固定:
\documentclass{scrartcl}
\usepackage{hyperref}
\makeatletter
\renewcommand*{\toclevel@part}{0}
\makeatother
推荐使用软件包bookmark
。它还修复了该问题,因为其改进的算法支持级别间隙(并且上面的修复是不需要的)。此外,它更新书签的速度更快(通常不需要第二次运行)。
答案2
KOMA-Script v3.26 不再发生此问题,因为scrartcl
现在bookmarks
如果hyperref
加载了 就会自动加载。它还提供了一种解决方法,可以防止加载bookmark
,因此即使:
% vim: ft=tex tw=0
% arara: lualatex: { synctex: true, shell: true }
% arara: lualatex: { synctex: true, shell: true }
\documentclass[bookmarkpackage=false]{scrartcl}
\usepackage{scrlayer-scrpage}
\usepackage[math]{blindtext}
\title{A minimum working example}
\usepackage{hyperref}
\hypersetup{
pdfauthor={Robbie Smith},
pdftitle={A minimum working example},
pdfcreator={An infinite number of gremlins hitting random keys on typewriters...},
pdfpagemode=UseOutlines,
colorlinks=false,
hypertexnames=false,
hidelinks}
\usepackage[all]{hypcap}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\part{Design and Testing}
\section{Objective}
\blindtext
\section{Summary}
\label{sec:summary}
\blindtext
\section{Geometric design}
\label{sec:geometry}
\blindtext
\subsection{Final geometic design}
\label{ssec:geo:final}
The final geometric design is provided in the table below. Formulae references
are to the calculations in the above sections.
\blindtext
\section{Fabrication}
\label{sec:fabrication}
\blindtext
\section{Testing}
\label{sec:testing}
\blindtext
\section{Proposed improvements}
\label{sec:improvements}
\blindtext
\section{Conclusions}
\label{sec:conclusions}
\blindtext
\appendix
\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand*{\thetable}{\thesection.\arabic{table}}
\renewcommand*{\thefigure}{\thesection.\arabic{figure}}
\part{Preliminary Designs}
\label{part:preliminary-designs}
The preliminary designs were developed prior to building and testing.
\section{First Iteration}
\blindtext
\subsection{Something something}
\blindtext
\section{Second Iteration}
\blindtext
\section{Third Iteration}
\blindtext
\end{document}
确实会产生正确的书签:
并且没有任何hyperref
警告。但在这种情况下,scrartcl
它本身会发出警告:
Class scrartcl Warning: Trying emergency fix for bookmark level gap, (scrartcl) because toclevel of `part' (-1) (scrartcl) is more than 1 lower than currently lowest (scrartcl) known level (1). (scrartcl) Note: This fix can fail and you should load (scrartcl) package `bookmark' to avoid usage of this (scrartcl) fix on input line 24.
删除选项后,bookmarkpackage=false
警告消失。但是现在,auxhook
向文件写入一条信息log
:
Package auxhook Info: \AddLineBeginMainAux comes a little late, (auxhook) because the main .aux file is already opened on input lin e 164.
\usepackage{bookmark}
所以推荐的解决方案仍然是在加载后添加hyperref
。