Html 如何在组织模式下调整图像大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11670654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:50:24  来源:igfitidea点击:

How to resize images in org-mode

htmlimageresizeexportorg-mode

提问by user1323995

Is there a general way to define the size, in percent or pixels, for an image that is linked in org-mode?

是否有一种通用的方法来定义链接的图像的大小(以百分比或像素为单位)org-mode

Say I have the following link in my .orgfile:

假设我的.org文件中有以下链接:

[[~/images/example.jpg]]

This JPG is way too large, so if I export it to HTML or LaTeX or open it in org-modewith C-c C-o iwill only see a fraction of the image.

这JPG是太大,所以如果我把它导出为HTML或LaTeX或打开它org-modeC-c C-o i将只能看到图像的一部分。

回答by yPhil

As of Org 8.0, "Attribute lines now take plists" :

Org 8.0 开始,“属性行现在采用plists”:

#+attr_html: :width 100px
#+attr_latex: :width 100px
[[~/images/example.jpg]]

回答by Adam

As per Jacobo's comment, add the following to your init.el file:

根据 Jacobo 的评论,将以下内容添加到您的 init.el 文件中:

(setq org-image-actual-width nil)

Then in org-mode, you can use this for inline previews of JPGs and PNGs. Doesn't appear to work for SVGs (no idea why)

然后在组织模式下,您可以将其用于 JPG 和 PNG 的内联预览。似乎不适用于 SVG(不知道为什么)

#+ATTR_ORG: :width 100
[[~/images/example.jpg]]

and if you want to size this for both inline previews and html output:

如果您想为内联预览和 html 输出调整大小:

#+ATTR_HTML: width="100px"
#+ATTR_ORG: :width 100
[[~/images/example.jpg]]

回答by bzg

#+ATTR_HTML: width="100px"
[[~/images/example.jpg]]

回答by Alioth

This is a sample on how to resize an image using percentages (Org mode version 9.0.5):

这是关于如何使用百分比调整图像大小的示例(组织模式版本 9.0.5)

#+CAPTION: Weight space                                                                                                                                     
#+ATTR_HTML: :alt neural network :title Neural network representation :align right                                                                          
#+ATTR_HTML: :width 50% :height 50%                                                                                                                         
https://i.stack.imgur.com/nzHSl.jpg

回答by 6pi

For LaTeX, to remove the default width=.9\linewidth, set the org-latex-image-default-widthto empty string. By this way, the image will have its natural size.

对于 LaTeX,要删除默认值width=.9\linewidth,请将 设置org-latex-image-default-width为空字符串。通过这种方式,图像将具有其自然大小。

To do that on the fly use the set-variableemacs command. Or to set this variable permanently, add the following line in your init.el : (setq org-latex-image-default-width "")

要即时执行此操作,请使用set-variableemacs 命令。或者要永久设置此变量,请在 init.el 中添加以下行: (setq org-latex-image-default-width "")