我想知道是否有一种简单的方法可以在 PDF 预览中找到孤行和寡行(就像使用黑框在边距外搜索单词的草稿选项一样)。
答案1
根据这个问题的答案问题,这是一次尝试。同样的警告也适用,即您可能会得到一些误报。
\documentclass[draft]{article}
\usepackage{ifdraft}
\usepackage{xcolor}
\usepackage{marginnote}
\clubpenalty=153
\widowpenalty=152
% check if the output penalty was due to orphan or widow or both
\ifdraft{
\def\testforwidowsandorphans{%
\ifnum\outputpenalty=152
\marginnote{\color{green}\rule[10pt]{5pt}{5pt}}%
% Widow
\else
\ifnum\outputpenalty=153
\marginnote{\color{blue}\rule[10pt]{5pt}{5pt}}%
% Orphan
\else
\ifnum\outputpenalty=305
\marginnote{\color{red}\rule[10pt]{5pt}{5pt}}%
% Family (orphan + widow)
\fi
\fi
\fi
}}{\def\testforwidowsandorphans{}}
% execute this code at the very beginning of the OR
\toks0=\output
\output\expandafter{\expandafter\testforwidowsandorphans
\the\toks0}
\newcommand\stupidpara{First line\\second line\\and final line\par}
\newcommand\verystupidpara{First line\\and final one\par}
\setlength\textheight{5\baselineskip}
\begin{document}
\stupidpara\stupidpara\stupidpara\stupidpara
\verystupidpara\verystupidpara\verystupidpara\verystupidpara
\end{document}
孤儿:
寡妇(是的,它出现在下一页...我不知道是否可以轻松修复它):
孤儿+寡妇:
(该代码的原始版本:寻找所有寡妇和孤儿)