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

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

如果可能的话,我希望图片也居中。我问的是Markdown将军,而不仅仅是GitHub是如何做到的。
当前回答
如果您正在为PanDoc编写MarkDown,可以执行以下操作:
{ width=50% }
这会将style=“width:50%;”添加到HTML<img>标记中,或将[width=0.5\textwidth]添加到LaTeX中的\includegraphics中。
资料来源:http://pandoc.org/MANUAL.html#extension-链接属性
其他回答
如果您在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"
我知道这个答案有点具体,但它可能会帮助其他需要帮助的人。
由于许多照片是使用Imgur服务上传的,因此您可以使用此处详述的API来更改照片的大小。
当在GitHub问题评论中上传照片时,它将通过Imgur添加,因此如果照片非常大,这将非常有用。
基本上http://i.imgur.com/12345.jpg,你会把http://i.imgur.com/12345m.jpg对于中等大小的图像。
如果每个md文件中有一个图像,控制图像大小的一种简便方法是:
添加css样式如下:
## Who Invented JSON?
`Douglas Crockford`
Douglas Crockford originally specified the JSON format in the early 2000s.

<style type="text/css">
img {
width: 250px;
}
</style>
输出如下:
如果每个md页面中有更多的图像,那么控制每个图像或每个自定义标记的简便方法是在css中定义每个元素。对于img标记,我们可以有:
//在css或样式标签中:img[alt=“结果1”]{宽度:100px;}img[alt=“结果2”]{宽度:200px;}img[alt=“结果3”]{宽度:400px;}//尝试使用以下方法之一在文档中插入图像:<br/><img src=“https://i.stack.imgur.com/xUb54.png“alt=”结果1“><br/><img src=“https://i.stack.imgur.com/xUb54.png“alt=”结果2“><br/><img src=“https://i.stack.imgur.com/xUb54.png“alt=”结果3“><br/><br/>在md中:<br/><br/><br/>
对于所有在R markdown/bookdown中工作的解决方案,上述解决方案不工作或需要略微调整:
工作
追加{width=50%}或{width=50%height=50%}{width=50%}{宽度=50%高度=50%}重要提示:宽度和高度之间没有逗号,即{width=50%,height=30%}不起作用!追加{height=“36px”width=“36px”}{height=“36px”width=“36px”}注意:带冒号的{:height=“36px”width=“36px”}(来自@sayth)似乎不适用于R markdown
不工作:
附加=宽度x高度在图形文件的URL之后调整图像大小(从@prosseek)两者都不=宽度x高度nor=仅宽度工作
对于R-Markdown,以上两种解决方案都不适用于我,所以我转向了常规的LaTeX语法,这很好。
\begin{figure}
\includegraphics[width=300pt, height = 125 pt]{drawing.jpg}
\end{figure}
然后,可以使用例如\ begin{center}语句将图像居中。