如果使用 crop 包,反向搜索会跳转到 tex 文件中的错误位置

如果使用 crop 包,反向搜索会跳转到 tex 文件中的错误位置

使用时,pdflatex我生成一个synctex文件进行反向搜索。到目前为止,在 PDF 查看器 (SumatraPDF) 中指向并单击会将我带到 TeX 编辑器 (TeXnicCenter) 中的正确行。

但是,如果我使用crop包,反向搜索给出的几乎所有行号都是错误的(有些行偏移了)。单击 PDF 会将我带到tex源代码中太远的地方。这很烦人,绝对不应该这样。

例子 (更新):

\documentclass[a4paper]{article}
\usepackage[a3,frame,center]{crop} %without this package inverse search works fine!
% (We let "crop" print on a3 paper to be able to see the produced frame.)
\usepackage{lipsum}

\begin{document}
\section{The first lipsum}
\lipsum
% the cursor should be placed around this line by the inverse search of
% the  ***last lines***  of above lipsum text in the PDF
\section{The second lipsum}
\lipsum
% but the cursor appears at the next line!
\section{The third lipsum}
\lipsum
\end{document}

有什么解决方法吗?顺便问一下,在哪里synctex维护?

仅供参考,对于此示例,\listfiles输出(更新

*File List*
article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    crop.sty    2003/05/20 v1.9 crop marks (mf)
  color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
  color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  lipsum.sty    2011/04/14 v1.2 150 paragraphs of Lorem Ipsum dummy text
supp-pdf.mkii
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
  ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live

需要注意的是,以下文件不被使用更新例子: geometry.styifvtex.styifxetex.stycrop.cfgatbegshi.sty

且 部分文件 版本发生变更 ,旧 版本 为:ifpdf.sty(v2.1),,,,,,,,,。pdftex.def(v0.05d)lipsum(v1.1)ltxcmds(v1.7)pdftexcmds.sty(v0.9)grfext.sty(v1.0)kvoptions.sty(v3.7)kvsetkeys.sty(v1.9)etexcmds.sty(v1.3)

答案1

(更多评论)

这似乎是“对我有用”的\listfiles输出

*File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
geometry.sty    2010/09/12 v5.6 Page Geometry
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
    crop.sty    2003/05/20 v1.9 crop marks (mf)
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
 ltxcmds.sty    2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
    crop.cfg
  lipsum.sty    2011/04/14 v1.2 150 paragraphs of Lorem Ipsum dummy text
atbegshi.sty    2011/01/30 v1.15 At begin shipout hook (HO)
supp-pdf.mkii
pdftexcmds.sty    2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Managing graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Defining keys (HO)
kvoptions.sty    2010/12/23 v3.10 Keyval support for LaTeX options (HO)
kvsetkeys.sty    2011/04/07 v1.13 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Prefix for e-TeX command names (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 ***********

并使用 TeX Live 2010 和 2011 进行了测试。您能否提供更多版本信息,否则对我来说这看起来“过于本地化”。

答案2

第一次尝试。添加以下行装载crop包裹。(请注意,这会导致箱子过满!)

%\usepackage[........]{crop}  must comes before the patch!
%------ our patch
\usepackage{pict2e}
\usepackage{etoolbox}
\makeatletter
\patchcmd\CROP@kernel{\hb@xt@\z@}{}{}{}
\makeatother
%------

讲到细节。

  1. crop包使用-environments 绘制框架等。逆向搜索与-environmentpicture的原始定义不兼容,但picturepict2e包以逆向搜索可以工作的方式重新定义了它。

  2. 为了绘制框架等,picture环境嵌套在类型\vbox和的框中。使用包的对包\hbox进行小幅修改将使反向搜索正常工作,但crop\patchcmdetoolbox代价是箱子太满!!

以下是完整的 MWE:

\documentclass[a4paper]{article}
\usepackage[a3,frame,center]{crop}
\usepackage{pict2e}
\usepackage{etoolbox}
\makeatletter
\patchcmd\CROP@kernel{\hb@xt@\z@}{}{}{}
\makeatother
\usepackage{lipsum}

\begin{document}
\section{The first lipsum}
\lipsum

\section{The second lipsum}
\lipsum

\section{The third lipsum}
\lipsum
\end{document}

相关内容