很明显,即使、和都不存在,黑客也会破坏 的有关信息chapterbib.sty
的输出(在下面的例子中为)文件;这些写入 的操作是由的改变的命令触发的。toc, lof, and lot
main.aux
main=mwekeys
\tableofcontents
\listofigures
\listoftables
main.aux
chapterbib.sty
include
我正在协调一份多编辑报告,并使用该chapterbib
包输出章节级书目。用户 jfbu 非常热心地帮助我输出keys
到 TOC、lof 和 lot,这对跨章节编辑工作非常有帮助。(显示目录、图片列表、表格列表等中的标签的“键”)。chapterbib
使用时,编译会在最后挂起(如下所述)。
有人知道如何治愈这个病吗?
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 101.
Package atveryend Info: Empty hook `AfterLastShipout' on input line 101.
(./mwekeys.aux (./ONE.aux) (./TWO.aux))
Runaway argument?
! File ended while scanning use of \@writefile.
<inserted text>
\par
l.101 \end{document}
q
OK, entering \batchmode...
这是主文件/mwe:
% basic page setup
\documentclass[oneside,headsepline,footsepline]{scrbook}
\KOMAoptions{twocolumn=false}
\KOMAoptions{paper=letter}
\KOMAoptions{titlepage=true}
\usepackage{scrlayer-scrpage}
\clearplainofpairofpagestyles
\ihead{Testing Keys}
\cfoot[]{\rule{0pt}{2ex}\pagemark}
\ifoot[]{}
\ofoot[]{}
% packages... sorry so many
\usepackage{import}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{varioref}
\usepackage{graphicx}
\usepackage{array}
\usepackage[numbers,square,comma,sort&compress,merge]{natbib} % For endnotes
\usepackage{chapterbib}
% get Chapter labels and bibliography label automatically
\newcommand{\ChapLabel}{chap:empty}
\newcommand{\BibLabel}{emptyS:bib}
\newcommand{\tdrinclude}[1]
{
%\befchap
\renewcommand{\ChapLabel}{chap:#1} % define the label for the chapter
\renewcommand{\BibLabel}{#1S:bib} % define the label for the chapter
\subincludefrom{#1/}{#1}
%\aftchap
}
\newcommand{\tdrchap}[1]
{
\chapter{#1}\label{\ChapLabel}
}
\renewcommand{\bibsection}{\section{Bibliography}\label{\BibLabel}}
%\numberwithin{figure}{section}
%\numberwithin{table}{section}
%\numberwithin{equation}{section}
% The key display code
\newif\ifHNNdraft
\HNNdrafttrue
\makeatletter
\let\original@writefile\@writefile
\def\@writefile #1#2#3{\def\HNN@fileext{#1}%
\let\HNN@next\original@writefile
\in@{#1}{toc,lof,lot}%
\ifin@
\ifx\newlabel#3%
\def\HNN@next ##1##2\newlabel
{\futurelet\HNN@tmp\HNN@writefile #2\empty\HNN@writefile}%
\fi
\fi
\HNN@next {#1}{#2}#3% fingers extra crossed
}%
\def\HNN@writefile
{%
\ifx\HNN@tmp\contentsline\expandafter\HNN@writefile@a\else
\expandafter\HNN@writefile@abort
\fi
}%
\def\HNN@writefile@a \contentsline #1#2#3\HNN@writefile #4%
{%
\original@writefile{\HNN@fileext}{\contentsline{#1}{#2\HNN@showkey {#4}}#3}%
\newlabel {#4}%
}%
\def\HNN@writefile@abort #1\HNN@writefile
{%
\original@writefile{\HNN@fileext}{#1}\newlabel
}%
\protected\def\HNN@showkey #1%
{\ifHNNdraft\space\space \textit{key:} \texttt{#1}\fi}
\ifHNNdraft
\AtEndDocument{\write\@auxout {\relax}}% important
\KOMAoptions{listof=nochaptergap}
\fi
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\tdrinclude{ONE}
\tdrinclude{TWO}
\end{document}
答案1
要“在 aux 文件的最末尾放置一些内容”,可以尝试以下方法:
\usepackage{atveryend}% also loaded by hyperref
\makeatletter
\AfterLastShipout{\immediate\write\@mainaux{\relax}}%
\makeatother
例子:
\documentclass{article}
\usepackage{atveryend}% also loaded by hyperref
\let\WHATEVER\relax
\makeatletter
\AfterLastShipout{\immediate\write\@mainaux{\relax\WHATEVER}}%
\makeatother
\begin{document}
\section{Foo}\label{sec:1}
\subsection{Bar}\label{sec:2}
\end{document}
文件内容aux
:
\relax
\@writefile{toc}{\contentsline {section}{\numberline {1}Foo}{1}}
\newlabel{sec:1}{{1}{1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1}Bar}{1}}
\newlabel{sec:2}{{1.1}{1}}
\relax \WHATEVER