如何在 Latex 文档源中放置一个小图形?
我的文档中有一个小图形。它是 PDF 格式,有 193 行,附言中混有一些二进制数据。我目前正在使用 Graphicx 包并将 pdf 作为单独的文件包含在内。有没有办法可以将它直接内联到我的乳胶源中?
I have a small graphic that is part of my document. It's PDF, is 193 lines, and has some binary data mixed with its postscript. I'm currently using the graphicx package and including the pdf as a separate file. Is there a way I can inline it directly in my latex source?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是我设计的一个解决方案:
\special
宏嵌入 postscript。一个缺点是使用 \special 嵌入 postscript 需要我发出 dvi 而不是 pdf。改进这个解决方案以允许直接发出 pdf 会很好。
乳胶源看起来像这样。
我在 github 上做了一个 gist ,提供了一个完整的示例。
Here's a solution I devised:
pdftops
(part of the xpdf package),\special
macro.A drawback is that embedding postscript using \special requires me to emit dvi instead of pdf. It would be nice to improve this solution to allow pdf to be emitted directly.
The latex source will look something like this.
I made a gist at github that provides a complete example.
看看 Asymptote 和 Latex 集成指南
Take a look at Asymptote and Latex Integration Guide
我认为没有办法在 LaTeX 中内联二进制数据。您可以使用各种软件包(例如 lpthnc 推荐的 Asymptote)将图形重新创建为矢量类型图像。如果你真的很聪明,你可以编写一些 TeX 来以数组格式存储数据并重新创建它,但我不认为有一个包可以简单地做到这一点。
I don't think there is a way to inline binary data in LaTeX. You could recreate graphics as vector type images with various packages (such as Asymptote recommended by lpthnc). If you're really clever you could write some TeX to store the data in array format and recreate it, but I don't think there's a package to do it simply.
您还应该查看
pdfpages
包。在 PDF 文档中包含 PDF 的各种选项。pdfpages: http://www.ctan.org/ tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf
you should also take a look at the
pdfpages
package. all kinds of options for including PDFs in your PDF document.pdfpages: http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf
好的,我认为这符合您的要求,但除非您确实需要做这样的事情,否则其他解决方案会更好。
为了能够使用此解决方案,您需要:
-shell-escape
命令行选项)。出于安全原因,默认情况下禁用 Shell 转义。uuencode
和uudecode
程序。假设您的图形是
graphic.png
,您的主文档是doc.tex
。首先,对graphic.png
进行编码并将其附加到末尾(编码后的数据都是文本):然后,在将图形包含在
doc.tex
:例如,这是我创建的一个文档:
然后,这将起作用:
正如我所说,有更好更好的解决方案,除非您确实必须有一个源文件,否则不要做这个。
OK, I think this does what you want, but unless you really need to do something like this, other solutions are better.
To be able to use this solution, you need to:
-shell-escape
command line option). Shell escape is disabled by default because of security reasons.uuencode
anduudecode
programs where you're compiling the file.Let's say your graphic is
graphic.png
, and your main document isdoc.tex
. First, encodegraphic.png
and append it to the end (the encoded data is all text):Then, make sure you have this before you include the graphic in
doc.tex
:For example, here's a document I created:
Then, this will work:
As I said, there are much nicer and better solutions, and unless you really have to have one source file, don't do this.