lineno 和 subfloat 之间有冲突吗?

lineno 和 subfloat 之间有冲突吗?

subfig我同时使用了两者lineno

\documentclass[aapm,graphicx]{revtex4-1}
\usepackage{graphicx}  
\usepackage[caption=false, font=footnotesize]{subfig}
\usepackage{floatrow}

\usepackage[mathlines]{lineno}
\modulolinenumbers[5]
\linenumbers\relax 

\begin{document}

但是,当我绘制图形时:

\floatsetup[figure]{style=plain,subcapbesideposition=top}
\begin{figure}[htbp]
\sidesubfloat[]{\includegraphics[height=2.0in]{figure5a.eps}}
\sidesubfloat[]{\includegraphics[height=2.0in]{figure5b.eps}}
\caption{  }
\label{fig5}
\end{figure}

\end{document}

出现错误:

! Improper \prevdepth.<recently read> \prevdepth ...ludegraphics[height=2.0in]{figure5a.eps}}
! You can't use `\prevdepth' in restricted horizontal mode.

但如果我注释掉\linenumbers\relax,错误就会消失,尽管无法显示行号。有人知道如何解决这个问题吗?

答案1

首先,当使用article而不是 时,您的示例文档可以很好地编译revtex4-1,因此看起来是revtex4-1和之间不兼容linenofigure使用floatrowsubfig只会引发问题。

现在回到问题本身:该lineno软件包会尽力防止在不需要的位置出现分页符,并且此代码会随着时间的推移而发生变化。摘自 lineno.sty:

% (New v4.00) 
%                                                  \begin{old}\begin{verbatim}
% %          \kern\z@ 
% \end{verbatim}
%                                                                    \end{old}
% was here previously. What for? 
% According to \TeX book p._125, Stephan's 
% interline penalty is changed into 10000. At the end of a 
% paragraph, the ~\parskip~ would follow that penalty of 10000, 
% so there could be a page break neither at the 
% ~\parskip~ nor at the ~\baselineskip~ (\TeX book p._110)---so 
% there could never be a page break between two paragraphs. 
% So something must screen off the 10000 penalty. 
% Indeed, the ~\kern~ is a place to break. 
% (Stephan once knew this: see `allow pagebreaks' above.)
% 
% Formerly, I tried to replace ~\kern\z@~ by 
%                                                  \begin{old}\begin{verbatim}
% %         \penalty\@LN@parpgpen\relax 
% \end{verbatim}
%                                                                    \end{old}
% ---but this allows a page break after heading. So: 
%% 
      \@LN@parpgbrk 
%% 
%% After heading, ~\kern\z@~ resulting from previous line 
%% (see below) is followed by ~\write~ or ~\penalty10000~, 
%% so causes no page break. 
% 
% These and similar changes were formerly done by ~linenox1.sty~. 
% (/New v4.00) 

\@LN@parpgbrk定义为:

% (New v4.00, v4.4) Initialize ~\@LN@parpgbrk~, accounting 
% for earlier space and for appropriate columndepth. 
% We use former ~\MakeLineNo~'s depth-preverving trick 
% ~\@LN@depthbox~ again: 

\def\@LN@screenoff@pen{% 
  \ifdim\lastskip=\z@ 
    \@tempdima\prevdepth \setbox\@tempboxa\null 
    \@LN@depthbox                           \fi}

\global\let\@LN@parpgbrk\@LN@screenoff@pen 

% (/New v4.4, v4.00) 

这段代码有问题。它假设它始终处于垂直模式,没有进行\prevdepth额外检查。

由于我对代码的了解不足以lineno提供万无一失的修复(添加\ifvmode..\fi就足够了吗?),我建议简单地恢复\@LN@parpgbrk\penalty\@LN@parpgpen\relax,这样我们至少有一个针对您的问题的解决方案:

\documentclass[aapm,graphicx]{revtex4-1}
\usepackage[demo]{graphicx}  
\usepackage[caption=false, font=footnotesize]{subfig}
\usepackage{floatrow}

\usepackage[mathlines]{lineno}
\modulolinenumbers[5]
\linenumbers\relax 

% Workaround for problem in lineno.sty
\usepackage{etoolbox}
\makeatletter
\patchcmd\linenumberpar{\@LN@parpgbrk}{\penalty\@LN@parpgpen\relax}{}{}
\makeatother

\begin{document}

\floatsetup[figure]{style=plain,subcapbesideposition=top}
\begin{figure}[htbp]
\sidesubfloat[]{\includegraphics[height=2.0in]{figure5a.eps}}%
\sidesubfloat[]{\includegraphics[height=2.0in]{figure5b.eps}}%
\caption{  }
\label{fig5}
\end{figure}

\end{document}

我建议向软件包的维护者发送lineno一个错误报告并尝试使用上述解决方法直到问题得到解决。

答案2

\linenumbers\relax使用时{revtex4-1},我得到了类似的错误

! Improper \prevdepth.<recently read> \prevdepth \begin{document}. 

通过移动\linenumbers\relax内部\begin{document}...\end{document},这个错误就解决了!

相关内容