latex - Markdown : cross-reference image included with markdown syntax

标签 latex r-markdown bookdown cross-reference

我想交叉引用我包含在 Markdown 中的图像 ![caption with spaces](path/to/image.png)句法。
我希望能够将此图像交叉引用为 \@ref(fig:caption-with-spaces) .
我正在使用 bookdown::pdf_document2 .
这可能吗?

最佳答案

可以使用语法 ![caption](path/to/image){#fig:anchor_name} 将标签附加到 Markdown 中包含的图像。 .
也就是说,还有两个进一步的选择

  • 使用 LaTeX \includegraphics命令。
  • 使用knitr的include_graphics功能。

  • LaTeX 解决方案如下所示:
    \begin{figure}
       \includegraphics{path/to/picture.png}
       \caption{Caption with spaces}
       \label{fig:example}
    \end{figure}
    
    knitr 解决方案看起来像
    ```{r, fig.cap = "Caption with spaces", label="example"}
    knitr::include_graphics("path/to/picture.png")
    ```
    
    使用这两种解决方案,您可以使用 \ref{fig:example} 交叉引用生成的图像。 .

    关于latex - Markdown : cross-reference image included with markdown syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64363508/

    相关文章:

    r - 如何在RMarkdown中嵌入ggvis交互式图表?

    latex - Texstudio词库已损坏

    r - 在 Shiny 模式下在 R Markdown 中插入 latex 方程

    latex - VScode : Stop autocompilation Latex toolchain

    knitr - 在 bookdown :html_document2 中没有使用 pander 的表格编号

    r-markdown - 如何在 R bookdown 中逐字折叠文本(不是代码)?

    R Markdown、Knitr、Pandoc 和 Bookdown 之间的关系

    latex - 如何摆脱 Sphinx Latex 输出页眉中的 "Release 1"?

    r - RMarkdown 和 Beamer 中的增量子项目符号

    r - 如何在 rmarkdown html_document 中对齐表格和绘图