Rom*_*iel 95 markdown latex cross-reference figure pandoc
我目前正在写下markdown的文档,我想从我的文本中引用一个图像.
this is my text, I want a reference to my image1 [here]. blablabla

Run Code Online (Sandbox Code Playgroud)
我想做那个参考,因为在将我的降价转换为pdf之后,图像会放在一页或两页之后,文档没有任何意义.
更新:
[image]: image.png "Image Title"
![Alt text][image]
A reference to the [image](#image).
Run Code Online (Sandbox Code Playgroud)
应该产生:
\begin{figure}[htbp]
\centering
\includegraphics[keepaspectratio,width=\textwidth,height=0.75\textheight]{i mage.png}
\caption{Alt text}
\label{image}
\end{figure}
A reference to the image (\autoref{image}).
Run Code Online (Sandbox Code Playgroud)
相反,我获得:
\begin{figure}[htbp]
\centering
\includegraphics{image.png}
\caption{Alt text}
\end{figure}
A reference to the \href{\#image}{image}.
Run Code Online (Sandbox Code Playgroud)
我注意到两个问题:
\label{image} 没有出现:没有创建引用.(\autoref{image})变为\href{\#image}{image}:未检测到交叉引用.然后,当我将其转换为pdf时,它显然没有链接到图像.有一个链接,但它没有链接到任何东西.
任何帮助将非常感激!!
小智 89
在pandoc中你甚至可以这样做:

See figure \ref{mylabel}.
Run Code Online (Sandbox Code Playgroud)
tjd*_*tjd 20
您可以使用pandoc-fignos过滤器进行图形编号和参考.它适用于任何输出格式 - 不仅仅是LaTeX.
为图像的属性添加标签,如下所示:
 {#fig:description}
Run Code Online (Sandbox Code Playgroud)
...然后像这样引用这个数字:
@fig:description
Run Code Online (Sandbox Code Playgroud)
有关如何安装和应用pandoc-fignos过滤器的信息,请参见其网页.还有pandoc-eqnos过滤器用于使用方程做同样的事情.
Rom*_*iel 18
在一篇类似的帖子中读完答案之后,我和Ryan Gray聊了聊.实际上他使用的解决方案:
[image]: image.png "Image Title"
![Alt text][image]
A reference to the [image](#image).
Run Code Online (Sandbox Code Playgroud)
仅在使用多标记时进行调整.
说到pandoc,进行交叉引用的唯一解决方案是直接使用latex关键字:
[image]: image.png "Image Title"
![Alt text \label{mylabel}][image]
See figure \ref{mylabel}.
Run Code Online (Sandbox Code Playgroud)
Pandoc 支持引用节(通过前缀为 的节标识符#)。
关于此开放问题的评论描述了以下解决方法如何利用部分标识符在 LaTeX 和 HTML 中生成图像引用:
<div id="fig:lalune">

</div>
[The voyage to the moon](#fig:lalune).
Run Code Online (Sandbox Code Playgroud)
前面的空行</div>是必需的。
使用pandoc-crossref,您可以使用以下语法交叉引用图:
{#fig:label}
Run Code Online (Sandbox Code Playgroud)
然后引用文本中类似于引用语法的图[@fig:label]并使用它进行编译--filter pandoc-crossref(如果您也使用它,则需要在前面--filter pandoc-citeproc)。
\usepackage[font=small,labelfont=bf]{caption}您可以使用例如in控制样式header-includes。
\listoffigures如果您在 Latex 中使用,一个巧妙的相关技巧是lua-filter,它允许您设置一个短标题,而不是让整个图形图例显示在图形列表中:
{#fig:label short-caption='my short caption'}
Run Code Online (Sandbox Code Playgroud)
然后用 进行编译--lua-filter short-captions.lua。