我刚开始接触Markdown。我喜欢它,但有一件事困扰着我:如何使用Markdown更改图像的大小?

文档仅为图像提供以下建议:

![drawing](drawing.jpg)

如果可能的话,我希望图片也居中。我问的是Markdown将军,而不仅仅是GitHub是如何做到的。


当前回答

对于R-Markdown,以上两种解决方案都不适用于我,所以我转向了常规的LaTeX语法,这很好。

\begin{figure}
 \includegraphics[width=300pt, height = 125 pt]{drawing.jpg}
\end{figure}

然后,可以使用例如\ begin{center}语句将图像居中。

其他回答

如果您在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"

有添加类和css样式的方法

!〔pic〕〔logo〕{.classname}

然后在下面写下链接和css

[logo]: (picurl)

<style type="text/css">
    .classname{
        width: 200px;
    }
</style>

此处引用

如果您正在为PanDoc编写MarkDown,可以执行以下操作:

![drawing](drawing.jpg){ width=50% }

这会将style=“width:50%;”添加到HTML<img>标记中,或将[width=0.5\textwidth]添加到LaTeX中的\includegraphics中。

资料来源:http://pandoc.org/MANUAL.html#extension-链接属性

您可以像这样设置图像末尾的大小:

![image.png](source **=600x400**)

对于那些热衷于手工和针织解决方案的人。有一些方法可以在不使用html的情况下调整.rmd文件中的图像大小:

您可以简单地通过添加{width=123px}来指定图像的宽度。不要在括号之间引入空格:

![image description]('your-image.png'){width=250px}

另一种选择是使用knifer::include_graphics:

```{r, fig.cap="image description", out.width = '50%'}
knitr::include_graphics('your-image.png')
```