如何在乳胶的图形上下文中使用 [@ref]?

How can I use [@ref] in a figure context in latex?

我想像 this 那样并排显示多个图形。每张图片都有自己的来源,所以我想在标题中提及这一点。

为此,我想在带有 [@testQuelle] 的标题中添加图片来源,但它只显示图片下方的文字 [@testQuelle]。我做错了什么?

当我尝试在图形上下文之外引用我的来源时,它工作正常,所以我的围兜很好(参见代码)

---
header-includes: |
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption}
---
nach [@testQuelle] ist es..
\begin{figure} 
    \centering
    \caption{myCaption [@ref] }
    \label{fig:myLabel} 
\end{figure}
@online{testQuelle,
  langid = {german},
  title = {eine Test Quelle aus dem Internet},
  url = {https://testQuelle.de},
  abstract = {diese Quelle enthält viele tolle Daten},
  journaltitle = {Quelle},
  urldate = {2019-06-05},
}
#!/bin/sh
PATH=$PATH:/home/moritz/.cabal/bin/ pandoc --filter pandoc-citeproc --bibliography quellen.bib --csl=styles/din1505.csl --filter pandoc-include-code -V hyphens=URL -V breakurl -V papersize=a4paper --from=markdown --output=text.pdf  text.md \
--template template 

您应该使用 pandoc markdown to create the figure 而不是原始 TeX,因为 pandoc-citeproc 过滤器 AFAIK 不处理原始 TeX 的内容。

![myCaption [@ref]](image.png){#fig:myLabel}

主要问题是 pandoc 将图形语句识别为原始 LaTeX。这意味着所有包含的 Markdown 表达式,如 myCaption [@ref],都无法被识别,将被视为 LaTeX。

解决这个问题的方法是更明确地说明什么是原始 LaTeX,什么是 Markdown。这可以通过使用 generic raw attributes(需要 pandoc 版本 2 或更新版本)来实现:

```{=latex}
\begin{figure} 
    \centering
```

`\caption{`{=latex}myCaption [@ref]`}`{=latex}

```{=latex}
    \label{fig:myLabel} 
\end{figure}
```