在 LaTeX 中自动将图片调整为 A4 大小
我有很多图片,每张图片的尺寸差异很大。
我的目标是开发一种算法,允许您删除多余的空格。 此类算法用于信号处理中,以消除冗余噪声,例如在移动电话中。
该算法应按如下方式使用
\includegraphics[crop-redundant-whitespace]{picture.png}
函数 crop-redundant-whitespace
应更改 include 命令,例如,
\includegraphics[width=2.5cm, height=5.0cm]{picture.png}
该算法应
- 检测长度至少为 2cm 且彼此分离的部分
- ,如果存在许多大部件,那么应该选择最大的部件。
如何自动调整图片大小并使其固定为 A4?
I have many pictures which size differ much from picture to picture.
I aim to develop an algorithm which allows you to remove the extra whitespace. Such algorithms are used in Signal Processing in removing the redundant noise, for instance in mobile phones.
The algorithm should be used as follows
\includegraphics[crop-redundant-whitespace]{picture.png}
The function crop-redundant-whitespace
should change the include -command, for instance to
\includegraphics[width=2.5cm, height=5.0cm]{picture.png}
The algorithm should
- detect parts of size at least 2cm in length which are separate from each other
- if many large parts exist, then the biggest part should be selected.
How can you automatically resize pictures and make them fix to A4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这并不是一个真正的 LaTeX 问题;而是一个 LaTeX 问题。 可以对文档中包含的图像执行任意转换,但检测图像中的空白与 LaTeX 的有用功能范围相去甚远。
弄清楚如何使用 ImageMagick 或其他工具来完成此操作,然后询问如何与 LaTeX 进行交互。
This isn't really a LaTeX question; it is possible to execute arbitrary conversions on images you include in the document but detecting whitespace in an image, say, is very very far away from LaTeX's useful range of abilities.
Work out how to do it with ImageMagick or whatever, and then ask how to interface that with LaTeX.
您可以使用 epstopdf 的 shell 转义功能对图像执行任意转换。 以下是对包含的每个 PDF 文件执行 pdfcrop 的示例:
然而,我在 TeX Live 2009 的预发行版本中遇到了问题; 现在不能花任何时间进行调试,但可以看看在旧系统上的运行情况。
即使这对您来说效果很好,但效率相当低,因为它必须在每次编译文档时运行。 我建议只预处理你的图像。
You can perform arbitrary conversions on images with the shell-escape feature of epstopdf. Here's an example of pdfcrop being executed on each PDF file that is included:
However, I'm having trouble getting this in a pre-release version of TeX Live 2009; can't spend any time debugging now but see how you go on any older system.
Even if this works fine for you, this is pretty inefficient since it has to run every time the document is compiled. I'd suggest just preprocessing your images.
粗糙且准备就绪:
但您会失去纵横比。 将其中一个长度替换为“
!
”以保留比例。 您还可以在整个图形周围粘贴\rotatebox
来修复纵向/横向不兼容问题。使用
\includegraphics
的方括号样式参数,看起来像:这可能比我已经拖了 15 年的嘎吱作响的古老戏法更最新。 必须更新我的个人 bog-o-tricks 文件...
如果您发现默认的空白空间太大,则可以使用通常的边距欺骗。 您可能会考虑使用
slides
类。 我认为默认边距更接近页面边缘。Rough and ready:
but you'll lose the aspect ratio. Replace one or the other length with "
!
" to preserve the ratio. You could also stick a\rotatebox
around the whole graphics include to fix a portrait/landscape incompatibility.Using the square-bracket style arguments to
\includegraphics
, would look like:which is probably more up-to-date than the creaking ancient cantrip that I've been lugging around for 15 years. Must update my personal bog-o-tricks file...
The usual margin diddling is applicable if you find the default whitespace to be too expansive. And you might consider using the
slides
class. I think the default margins are closer to the edge of the page.不要重新发明轮子,从此处重新混合。
现在有一个问题:页面上有一些奇怪的白色上面板,不知道为什么,但我认为这比其他答案更接近(至少对我来说并没有真正起作用)——请参阅参考资料。
信息
Do not reinvent the wheel, remixed from here.
Now one problem: it has some odd white upper panel of white on the page, no idea why but I think this is closer than other answers (not really working at least for me) -- please see the reference.
Info