如何使用pandoc在markdown中引用数字?

时间:2012-02-24 16:38:14

标签: latex markdown figure cross-reference pandoc

我目前正在写一个markdown的文档,我想从我的文本中引用一个图像。

this is my text, I want a reference to my image1 [here]. blablabla

![image1](img/image1.png)

我想做那个参考,因为在将我的降价转换为pdf后,图像会放在一页或两页之后,文档没有任何意义。

更新:

我在Ryan's answer中尝试了that post,但我无法让它发挥作用。 显然代码:

[image]: image.png "Image Title" 
![Alt text][image] 
A reference to the [image](#image).

应该产生:

\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}).

相反,我获得了:

\begin{figure}[htbp]
\centering
\includegraphics{image.png}
\caption{Alt text}
\end{figure}

A reference to the \href{\#image}{image}.

我注意到两个问题:

  • \label{image}未出现:未创建参考。
  • (\autoref{image})变为\href{\#image}{image}:未检测到交叉引用。

然后,当我将其转换为pdf时,它显然没有链接到图像。有一个链接,但它没有链接到任何东西。

任何帮助都将非常感谢!!

6 个答案:

答案 0 :(得分:83)

在pandoc中你甚至可以这样做:

![This is the caption\label{mylabel}](/url/of/image.png)
See figure \ref{mylabel}.

答案 1 :(得分:18)

在类似的帖子中阅读his answer之后,我和Ryan Gray聊了聊。实际上他使用的解决方案:

[image]: image.png "Image Title" 
![Alt text][image] 
A reference to the [image](#image).
仅在使用多标记时才会调整

说到pandoc,进行交叉引用的唯一解决方案是直接使用latex关键字:

[image]: image.png "Image Title"
![Alt text \label{mylabel}][image]
See figure \ref{mylabel}.

答案 2 :(得分:18)

您可以使用pandoc-fignos过滤器进行图号编码和参考。它适用于任何输出格式 - 不仅仅是LaTeX。

为图像的属性添加标签,如下所示:

 ![Caption.](image.png) {#fig:description}

...然后像这样引用这个数字:

 @fig:description

有关如何安装和应用pandoc-fignos过滤器的信息,请参见其网页。还有pandoc-eqnos过滤器可以用方程做同样的事情。

答案 3 :(得分:4)

Pandoc支持引用部分(通过前缀为#的{​​{3}})。

对此section identifiers的评论描述了以下解决方法如何利用部分标识符在LaTeX和HTML中生成图像引用:

<div id="fig:lalune">
![A voyage to the moon\label{fig:lalune}](lalune.jpg)

</div>

[The voyage to the moon](#fig:lalune).

需要</div>之前的空行。

答案 4 :(得分:1)

使用pandoc-crossref,您可以使用以下语法交叉引用图形:

![Caption](file.ext){#fig:label}

然后引用类似于引用语法[@fig:label]的文本中的图形,并使用--filter pandoc-crossref进行编译(如果您还使用--filter pandoc-citeproc,则必须在其之前)。

您可以通过以下方式控制样式: \usepackage[font=small,labelfont=bf]{caption}中的header-includes


如果您在乳胶中使用\listoffigures,那么一个与整洁相关的技巧就是this lua-filter,它使您可以设置一个简短的标题,而不必在图形列表中显示整个图形图例:

![Caption](file.ext){#fig:label short-caption='my short caption'}

然后使用--lua-filter short-captions.lua进行编译。

答案 5 :(得分:0)

这里有很多很棒的 awnsers。 我只想让您注意一个细节:

必须有标题! 如:

sorryButton.setOnClickListener {

        val name = nameInput.editableText.toString()

        if (name.contains(" ") || name.length < 4 || name.isEmpty()) {
            nameInput.setError("Username required")
        } else {
            val intent = Intent(this, MainActivity2::class.java)
            intent.putExtra("name", name)
            startActivity(intent)

        }


    }

以下将不起作用工作

Lore ipsum @fig:label

![Caption](file.ext){#fig:label}
相关问题