在之前的一个问题中按小节进行修订跟踪“我询问了按部分跟踪修订的情况。
对我而言最有效的答案是用户 Mike 编写的宏。
\documentclass[a4paper]{scrbook}
\usepackage{xcolor}
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\makeatletter
\newcommand*{\curr@revision}{}
\newcommand*{\curr@date}{}
\newcommand*{\curr@author}{}
% #1: revison
% #2: date
% #3: author (last modified by)
\newcommand*{\setrevision}[3]{%
\def\curr@revision{#1}%
\def\curr@date{#2}%
\def\curr@author{#3}%
}
\newcommand*{\printrevision}{%
\begingroup
\ifnum\c@section=0\relax
\let\the@sec@number\thechapter
\else
\ifnum\c@subsection=0\relax
\let\the@sec@number\thesection
\else
\let\the@sec@number\thesubsection
\fi
\fi
\addtocontents{lor}{\protect\revisionline{\the@sec@number}{\curr@revision}{\curr@date}{\curr@author}{\@currentHref}}%
\parfillskip0pt\color{gray}
last modified by: \textit{\curr@author}\dotfill
date: \textsf{\curr@date}\quad
revision: \textsf{\hbox to 2em{\hfill \curr@revision}}%
\par\endgroup\noindent
}
\newcommand*{\listofrevisions}{%
\chapter*{Revisions\@mkboth{Revisions}{Revisions}}%
\@starttoc{lor}%
}
\newcommand*{\revisionline}[5]{%
\ifx\\#5\\%
\@revisionline{#1}{#2}{#3}{#4}%
\else
\ifcase\Hy@linktoc % none
\@revisionline{#1}{#2}{#3}{#4}%
\or % (section) section number
\@revisionline{%
\hyper@linkstart{link}{#5}{#1}\hyper@linkend
}{#2}{#3}{#4}%
\or % (page) revision number
\@revisionline{#1}{%
\hyper@linkstart{link}{#5}{#2}\hyper@linkend
}{#3}{#4}%
\else % all
\@revisionline{%
\hyper@linkstart{link}{#5}{#1}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#2}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#3}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#4}\hyper@linkend
}%
\fi
\fi
}
\newcommand*{\@revisionline}[4]{%
\noindent\parskip\z@\hbox to 3em{#1}\dotfill
\textit{#4}\quad\textsf{#3}\quad\hbox to 2em{\hfill#2}\par
}
\makeatother
\begin{document}
\frontmatter
\begin{titlepage}
\centering
{\Huge The big Company Manual}
\vspace{1cm}
{\Large The inner workings of some big company}
\vspace{2cm}
\begin{tabular}{ll}
Authors & Harry Bigboss\\
& Ruth Cando\\
& Amelia Nicecode
\end{tabular}
\end{titlepage}
\tableofcontents
\listofrevisions
\mainmatter
\chapter{Overview}
\section{Status of this Manual}
\subsection{Usage}
\label{sec:usage}
\setrevision{123}{2018-06-10}{Harry Bigboss}
\printrevision
This manual is for internal use only. It must never leave the company.
Those who take it out, will be fired.
\subsection{Completeness}
\setrevision{55}{2018-06-11}{Ruth Cando}
\printrevision
This manual is in a pre-release state. We are still negotiating with Harry about
the contents of \autoref{sec:usage}.
\section{Goals of the Manual}
\subsection{Introduction}
\setrevision{783}{2018-06-10}{Amelia Nicecode}
\printrevision
The manual can be used as an introduction to the procedures used in this company.
\subsection{Reference}
\setrevision{2233}{2018-06-12}{Amelia Nicecode}
\printrevision
The manual is intended to be a reference of the companies internal procedures.
\end{document}
我的问题是,当我在某个节标题之后执行“\printrevision”时,\widowpenalty \clubpenalty 似乎没有任何反应,并且我的文档中出现了孤儿标题和孤立段落。
我试过 \nowidow 包,但没什么效果。我花了一些时间试图解决这个问题,但没有成功。
答案1
尝试这样做,其中更改位于 的末尾\printrevision
。主要避免这样做\par
。
\documentclass[a4paper]{scrbook}
\usepackage{xcolor}
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\makeatletter
\newcommand*{\curr@revision}{}
\newcommand*{\curr@date}{}
\newcommand*{\curr@author}{}
% #1: revison
% #2: date
% #3: author (last modified by)
\newcommand*{\setrevision}[3]{%
\def\curr@revision{#1}%
\def\curr@date{#2}%
\def\curr@author{#3}%
}
\newcommand*{\printrevision}{%
\begingroup
\ifnum\c@section=0\relax
\let\the@sec@number\thechapter
\else
\ifnum\c@subsection=0\relax
\let\the@sec@number\thesection
\else
\let\the@sec@number\thesubsection
\fi
\addtocontents{lor}{\protect\revisionline{\the@sec@number}{\curr@revision}{\curr@date}{\curr@author}{\@currentHref}}%
\endgroup
\noindent\textcolor{gray}{%
last modified by: \textit{\curr@author}\dotfill
date: \textsf{\curr@date}\quad
revision: \textsf{\hbox to 2em{\hfill \curr@revision}}}%
\linebreak[4]%
}
\newcommand*{\listofrevisions}{%
\chapter*{Revisions\@mkboth{Revisions}{Revisions}}%
\@starttoc{lor}%
}
\newcommand*{\revisionline}[5]{%
\ifx\\#5\\%
\@revisionline{#1}{#2}{#3}{#4}%
\else
\ifcase\Hy@linktoc % none
\@revisionline{#1}{#2}{#3}{#4}%
\or % (section) section number
\@revisionline{%
\hyper@linkstart{link}{#5}{#1}\hyper@linkend
}{#2}{#3}{#4}%
\or % (page) revision number
\@revisionline{#1}{%
\hyper@linkstart{link}{#5}{#2}\hyper@linkend
}{#3}{#4}%
\else % all
\@revisionline{%
\hyper@linkstart{link}{#5}{#1}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#2}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#3}\hyper@linkend
}{%
\hyper@linkstart{link}{#5}{#4}\hyper@linkend
}%
\fi
\fi
}
\newcommand*{\@revisionline}[4]{%
\noindent\parskip\z@\hbox to 3em{#1}\dotfill
\textit{#4}\quad\textsf{#3}\quad\hbox to 2em{\hfill#2}\par
}
\makeatother
\begin{document}
\frontmatter
\begin{titlepage}
\centering
{\Huge The big Company Manual}
\vspace{1cm}
{\Large The inner workings of some big company}
\vspace{2cm}
\begin{tabular}{ll}
Authors & Harry Bigboss\\
& Ruth Cando\\
& Amelia Nicecode
\end{tabular}
\end{titlepage}
\tableofcontents
\listofrevisions
\mainmatter
\chapter{Overview}
\section{Status of this Manual}
\subsection{Usage}
\label{sec:usage}
\setrevision{123}{2018-06-10}{Harry Bigboss}
\printrevision
This manual is for internal use only. It must never leave the company.
Those who take it out, will be fired.
\subsection{Completeness}
\setrevision{55}{2018-06-11}{Ruth Cando}
\printrevision
This manual is in a pre-release state. We are still negotiating with Harry about
the contents of \autoref{sec:usage}.
\section{Goals of the Manual}
\subsection{Introduction}
\setrevision{783}{2018-06-10}{Amelia Nicecode}
\printrevision
The manual can be used as an introduction to the procedures used in this company.
\vspace{6.51cm}% compare with 6.52cm
\subsection{Reference}
\setrevision{2233}{2018-06-12}{Amelia Nicecode}
\printrevision
The manual is intended to be a reference of the companies internal procedures.
\end{document}
随着整个内容的增加垂直空间0.01cm
转移到下一页。