使用 pdflatex 编译时边界框的等效性

使用 pdflatex 编译时边界框的等效性

我在将 .pdf 图像插入 .tex 文件时遇到问题(.eps 可以正常使用)。以下是问题描述。

当我通过执行以下操作插入.eps 图形时:

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\includegraphics[angle=90,bbllx=113bp,bblly=67bp,bburx=506bp,bbury=741bp,width=0.8\textwidth]{lipari-plot.eps}
\caption[]{}
\label{fig:liparieps}
\end{figure}
\end{document}

并使用 latex 编译我的 latex test.tex 文件(即在命令行上执行“latex test.tex; dvipdf test.dvi test.pdf;”),图形看起来如预期的那样。

但是,我需要使用 pdflatex 编译我的 test.tex 文件(因为我的图像需要是 .pdf 而不是 .eps)。

不幸的是,我找不到与 pdflatex 兼容的边界框。我尝试使用视口(网站和编译器建议的),但图像显示不正确。(我通过在命令行上执行“pdflatex test.tex;”来编译它。)

例如,我尝试过的代码是

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
\includegraphics[angle=90,viewport=113bp 67bp 506bp 741bp, clip, width=0.8\textwidth]{lipari-plot.pdf}
\caption[]{Caption}
\label{fig:liparipdf}
\end{figure}
\end{document}

(文件 lipari-plot.eps 和 lipari-plot.pdf 已上传至此网站:http://latex-community.org/forum/viewtopic.php?f=45&t=23286。抱歉,我不知道如何在这里上传它们)

有人知道如何使我的 .pdf 图像的编译版本看起来像 .eps 版本吗?

答案1

正如@egreg在评论中所说,原始eps文件存在缺陷,在转换为时会被裁剪pdf。边界框是错误的,但您可能不会在查看器中看到这一点,因为第一行也是错误的,导致文件显示为普通(非封装)后记(因此边界框将被忽略,您将看到边缘周围有很多空白)。幸运的是,这些问题相当容易解决。

方法 1

将“lipari-plot.eps”重命名为“lipari-plot.ps”,然后在终端中执行

ps2eps --ignoreBB lipari-plot.ps

方法 2

在您最喜欢的文本编辑器中打开 eps 文件。删除前六行(以 开头的行%),并将其替换为以下内容。

%!PS-Adobe-2.0 EPSF-2.0
%%BoundingBox: 124 78 479 735
%%HiResBoundingBox: 124.000000 78.500000 479.000000 735.000000
%%EndComments

这两种方式都可以生成一个可以无问题eps转换的文件。pdf

答案2

您的 EPS 文件没有说明其边界框的真实情况。它说

%!PS-Adobe
%%Creator: The Mighty Setlink.
%%BoundingBox: 58 35 612 525
%%EndComments

当你计算出一个相当于

%%BoundingBox: 113 67 506 741

而罪魁祸首正是顶部缺失的216bp。

如果我编辑 EPS 文件,使其显示为

%!PS-Adobe
%%Creator: The Mighty Setlink.
%%BoundingBox: 113 67 506 741
%%EndComments

一开始,转换就正确完成了,您不需要在 LaTeX 文件(带有 EPS)中添加边界框语句,也不需要 pdfLaTeX 文件中的视口中添加边界框语句。

相关内容