我刚开始接触Markdown。我喜欢它,但有一件事困扰着我:如何使用Markdown更改图像的大小?
文档仅为图像提供以下建议:

如果可能的话,我希望图片也居中。我问的是Markdown将军,而不仅仅是GitHub是如何做到的。
我刚开始接触Markdown。我喜欢它,但有一件事困扰着我:如何使用Markdown更改图像的大小?
文档仅为图像提供以下建议:

如果可能的话,我希望图片也居中。我问的是Markdown将军,而不仅仅是GitHub是如何做到的。
当前回答
Tieme的答案在大多数情况下都是最好的。
在我的例子中,我使用pandoc将markdown转换为乳胶。HTML标记在这里不起作用。
我的解决方案是重新实现includegraphics
\let\maxincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\maxincludegraphics[max width=\textwidth]{#1}}
类似于在转换为HTML后使用CSS。
其他回答
您可以在Markdown中使用一些HTML:
<img src="drawing.jpg" alt="drawing" width="200"/>
或通过样式属性(GitHub不支持)
<img src="drawing.jpg" alt="drawing" style="width:200px;"/>
或者您可以使用自定义CSS文件,如以下关于Markdown和图像对齐的回答所述

另一个文件中的CSS:
img[alt=drawing] { width: 200px; }
如果您正在为PanDoc编写MarkDown,可以执行以下操作:
{ width=50% }
这会将style=“width:50%;”添加到HTML<img>标记中,或将[width=0.5\textwidth]添加到LaTeX中的\includegraphics中。
资料来源:http://pandoc.org/MANUAL.html#extension-链接属性
这会奏效的
<style>
img{width: 50%;}
#foo {color: red;}
</style>
<p id="foo">foo</p>
<p style="color: blue">bar</p>
如果您在Gihub Flavored Markdown中使用参考样式图像:
Here is an image of tree:
![alt text][tree]{height=400px width=500px}
[//]: # (Image References)
[tree]: ./images/tree.png "This is a tree"
对于那些热衷于手工和针织解决方案的人。有一些方法可以在不使用html的情况下调整.rmd文件中的图像大小:
您可以简单地通过添加{width=123px}来指定图像的宽度。不要在括号之间引入空格:
{width=250px}
另一种选择是使用knifer::include_graphics:
```{r, fig.cap="image description", out.width = '50%'}
knitr::include_graphics('your-image.png')
```