dvipdfm 水平裁剪图像

dvipdfm 水平裁剪图像

在 Windows 7 64 位上,使用 Miktex 2.9latex正确编译我的文档,DVI 正确显示所有图像。然后dvipdfm生成正确的 PDF,除了一个水平裁剪的图像。要重现,请下载这个例子进而:

latex test.tex
yap test.dvi           # correct
dvipdfm test.dvi
AcroRd32.exe test.pdf  # cropped

问:如何预防这种行为?

答案1

从 PostScript 到 PDF 的转换配置如下dvipdfmx.cfg

%% Ghostscript (PS-to-PDF and PDF-to-PDF):
%%
%% ps2pdf is a front-end to gs. For a complete list of options, see
%% http://ghostscript.com/doc/current/Ps2pdf.htm#Options
%%
%% By default, gs encodes all images contained in a PS file using
%% the lossy DCT (i.e., JPEG) filter. This often leads to inferior
%% result (see the discussion at http://electron.mit.edu/~gsteele/pdf/).
%% The "-dAutoFilterXXXImages" and "-dXXXImageFilter" options used
%% below force all images to be encoded with the lossless Flate (zlib,
%% same as PNG) filter. Note that if the PS file already contains DCT
%% encoded images (which is possible in PS level 2), then these images
%% will also be re-encoded using Flate. To turn the conversion off,
%% simply remove the options mentioned above.
%%
%% Also note that PAPERSIZE=a0 is specified below. This converts PS
%% files (including EPS) to A0 papersize PDF. This is necessary to
%% prevent gs from clipping PS figure at some papersize. (A0 above
%% simply means large size paper.) If you have figures even larger
%% than A0, and their llx=lly=0, you can use "-dEPSCrop" instead of
%% "-sPAPERSIZE=a0"
%%
%% In TeX Live, we use the rungs wrapper instead of ps2pdf, becuse we
%% must omit the -dSAFER which ps2pdf specifies: in order for pstricks
%% to work with xetex,
%% /usr/local/texlive/*/texmf-dist/dvips/pstricks/pstricks.pro (for
%% example) needs to be accessed.  (Also, it is better to use our
%% supplied gs on Windows.)  You can also add -dNOSAFER to the ps2pdf
%% command line.
%%
%% Incidentally, especially in TL, more than one dvipdfmx.cfg may be
%% extant.  You can find the one that is active by running:
%% kpsewhich -progname=dvipdfmx -format='other text files' dvipdfmx.cfg
%%
D  "rungs -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=%v -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilter ColorImages=false -dColorImageFilter=/FlateEncode -sOutputFile='%o' '%i' -c quit"

figure02.eps尺寸为 3854bp x 1882bp,大于 A0 的 841mm x 1189mm。

因此,您可以使用重新配置-dEPSCrop或手动将文件转换为 PDF:

ps2pdf -dEPSCrop figure02.eps

并运行以获取LaTeX包ebb驱动程序的边界框数据文件:dvipdfmxgraphics

ebb -x figure02.pdf

然后可以将图像包含为 PDF 文件:

\documentclass{article}
\usepackage[dvipdfmx]{graphicx}
\begin{document}

\includegraphics[width=0.9\columnwidth,keepaspectratio=true]{figure02.pdf}

\end{document}

这也加快了编译速度,因为每次运行时不需要转换 EPS 图形dvipdfmx

答案2

我遇到了与 SiliconValley 相同的问题,但我无法使用任何额外的 latex 包和选项。因此我无法应用 Heiko 的解决方案 - 否则这会很棒。

如果 eps 图形的高度小于最大宽度,并且 eps 图形的宽度小于最大高度,则在创建时将 eps 图形旋转 90 度,并在 latex include 命令中将其旋转 -90 度。因此,旋转后的 eps 文件在 tex 文件中的包含方式如下:

\includegraphics[width=6.2cm,angle=-90]{demo_rotated.eps}

如果不旋转,它将被纳入

\includegraphics[width=6.2cm]{demo.eps}


编辑2015-11-21:
可能存在不允许您使用graphicx带有选项的包的情况dvipdfmx。就我的情况而言,我正在为《大气化学和物理学》撰写一篇期刊文章,必须使用哥白尼出版物 LaTeX 软件包,版本 3.8. 使用附加包的指导方针非常严格。

假设我们有一个 eps 文件,其宽度width_eps和高度分别height_eps为 。裁剪后图像的最大可能宽度和高度分别为width_maxheight_max。不幸的是,我们有width_eps > width_max。但是,如果width_eps < height_maxheight_eps < width_max我们

  • 在 latex 之外旋转我们的 eps 文件(创建旋转文件)并
  • 将其与选项angle=-90angle=90(上面发布的代码)一起包含在内。

是的,如果width_eps > height_maxheight_eps > width_max

相关内容