【问题标题】:How can I use [@ref] in a figure context in latex?如何在乳胶的图形上下文中使用 [@ref]?
【发布时间】:2019-07-24 20:11:18
【问题描述】:

我想像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 

【问题讨论】:

标签: latex pandoc


【解决方案1】:

主要问题是 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}
```

【讨论】:

  • 它现在可以工作了,非常感谢,但格式化很痛苦。也许有一种方法可以为此编写宏或函数。再次感谢,这对现在有帮助
  • 可以使用Lua filter。最好为此提出一个新问题。
【解决方案2】:

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

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

【讨论】:

  • 这就是我通常这样做的方式,但在这种情况下,我需要在一行中显示两个或多个数字,这不能以我想要的方式与 pandoc 一起使用。所以我猜我必须使用 raw tex
  • 那么您应该更新问题以反映这一点。可能您可以在header-includes 中包含一些 LaTeX,或者将降价图形包装在降价 div 中并使用 pandoc 过滤器...
  • 我已经更改了问题并将帖子链接到我想要做什么
猜你喜欢
  • 2015-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多