【问题标题】:Show footnote only after a pause in beamer with R Markdown仅在使用 R Markdown 的投影仪暂停后显示脚注
【发布时间】:2020-10-02 07:38:05
【问题描述】:

我正在制作 Beamer 演示文稿,并在单张幻灯片的内容之间使用暂停。我不知道如何在暂停后才显示脚注。

这是一个例子:

---
title: ""
author: ""
date: ""
output:
  beamer_presentation
bibliography: test.bib
---

* one argument

\pause

* another argument^[This citation should appear only with point 2: @fargues2006]

# references

test.bib:

@article{fargues2006,
  title = {The {{Demographic Benefit}} of {{International Migration}}: {{Hypothesis}} and {{Application}} to {{Middle Eastern}} and {{North African Contexts}}},
  author = {Fargues, Philippe},
  date = {2006},
  journaltitle = {World Bank Policy Research Paper},
  url = {http://documents.worldbank.org/curated/en/508301468280735279/pdf/wps4050.pdf},
  number = {4050}
}

在此示例中,脚注不应仅在显示第一个点时出现,而是在显示第二个点时出现。

我尝试申请this answer from TeX StackExchange,但没有成功。

我该怎么做?

编辑:在@samcarter_is_at_topanswers.xyz 的回答之后,我更喜欢一种不需要在文档中从markdown 切换到LaTeX 的解决方案,具体取决于幻灯片是否同时具有暂停和脚注.但是,我可以使用 .tex 文件或在 YAML 中添加 pandoc 参数(因为我认为解决方案必须是这种方式,但我可能错了)。

编辑#2:我想在这些脚注中加上@citationkey

还问on RStudio Community

【问题讨论】:

    标签: r latex r-markdown beamer


    【解决方案1】:

    编辑:更新-包括@citationkey

    问题在于 pandoc 如何在输出 tex 文件中将 ^[] 转换为 \footnote

    这在降价中:

    another argument ^[This citation should appear only with point 2: @fargues2006]
    

    在latex中编译成这个:

    another argument\footnote<.->{This citation should appear only
        with point 2: Fargues (2006)}
    

    为了让脚注只显示你的观点出现的幻灯片,你真的需要这个乳胶翻译:

    another argument\footnote\only<+->{This citation should appear only with point 2: Fargues (2006)}
    

    only&lt;+-&gt; 中,+ 是一个特殊符号,表示当前覆盖。

    要使其工作,您可以重新定义 \footnote 命令,以便当 pandoc 翻译它时它实际上调用:\only&lt;+-&gt;\footnote

    注意:

    完整的命令是\only&lt;+-&gt;\footnote&lt;.-&gt;,这可能会导致逐项幻灯片重复,因为有两个指针指向脚注应该出现的位置(\only&lt;+-&gt;&lt;.-&gt;),并且由于 pandoc 是自动插入的,所以我是不知道有什么办法可以摆脱它。

    这种重复也可能是使用 *\pause 和 pandoc 将其转换为出现在其自己的 itemize 环境中的每个项目的结果 - 它还具有脚注需要出现的位置的设置选项,并且再次是也是 pandoc 的东西。

    我还没有做足够的挖掘来知道其中哪些是重复项的真正罪魁祸首。但无论哪种方式,乳胶都应该为\footnotes命令应用第一个指针格式和一个“最本地”的设置环境(即,它会将脚注放在逐项列出).. 所以每张重复的幻灯片,所以你至少可以使用这种方法获得正确的格式,但你必须删除重复项。如果有人知道防止这种情况发生的方法——我很想听听。

    使用方法: 在降价的开头包含此内容:

    \let\oldfootnote\footnote
    \renewcommand{\footnote}{\only<+->\oldfootnote}
    

    您的完整降价:

    ---
    title: ""
    author: ""
    date: ""
    output:
      beamer_presentation:
        keep_tex: true
    bibliography: test.bib
    header-includes:
      - \let\oldfootnote\footnote
      - \renewcommand{\footnote}{\only<+->\oldfootnote}
    
    
    ---
    
    
    * one argument
    
    \pause
    
    * another argument ^[This citation should appear only with point 2: @fargues2006]
    
    \pause 
    
    * and another argument ^[This citation should appear only with point 3]
    
    

    输出:

    【讨论】:

    • 这与第一个答案类似,但问题是一样的:如果我在脚注中加上@citationkey的引用,它就不起作用
    • @bretauv 哦,以为您只是在寻找一种不在文档中在乳胶和降价之间跳转的方法。你能用引文关键问题的可重现示例更新问题吗?
    • 不错的答案!但一个缺点是,当同时出现两个脚注时,第二个脚注不起作用,但会在正文中显示&lt;.-&gt; The content of the footnote。要看到这一点,请在示例中的项目符号 2 和 3 之间删除 \pause。我可以忍受,因为我只需要在两个项目符号之间添加一个暂停,但我认为值得一提。
    【解决方案2】:

    您可以使用正确的 Latex 语法来解决此问题:

    ---
    title: ""
    author: ""
    date: ""
    output:
      beamer_presentation
    ---
    
    * one argument
    
    \pause
    
    * ```{=latex}
    another argument\footnote<.(1)->{This should appear only with point 2}
    ```
    

    或者带有隐藏的脚注:

    ---
    title: ""
    author: ""
    date: ""
    output:
      beamer_presentation:
        keep_tex: true
    ---
    
    ##  {.t}
    
    
    * one argument
    
    \pause
    
    * ```{=latex}
    another argument\only<.(1)->{\footnote{This should appear only with point 2}}
    ```
    

    (顶部对齐是为了避免跳跃n)

    【讨论】:

    • 那太好了,你知道在脚注不显示的情况下如何去掉脚注上方的行吗?
    • @bretauv 你有多个脚注的幻灯片吗?
    • 是的,有的有三四个
    • 好吧,但这意味着我们必须在文档中的latex和markdown之间跳转,这取决于框架中是否有带停顿的脚注,这不是很方便。当引用在脚注中时,这也会引起麻烦,因为我们不能像在文档的其余部分中那样使用@citationkey。你认为有办法通过使用.tex 文件中的代码作为序言来做到这一点吗?
    • @bretauv 最简单的方法是放弃markdown,只使用latex :) 这样你就不必在不同的语法之间跳转
    猜你喜欢
    • 1970-01-01
    • 2019-08-03
    • 2016-04-21
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多