代码之家  ›  专栏  ›  技术社区  ›  Stefano

如何在组织模式表中执行内联源块?

  •  3
  • Stefano  · 技术社区  · 9 年前

    我希望在组织模式表中获得src\u R块的输出:

    | Variable | Value    |
    |----------+----------|
    | x        | src_R{x} |
    

    然而,当我导出到PDF(通过LaTeX)时,我得到的是文字src\u R{x},而不是底层R会话中x变量的值。我可以在文本中使用相同的src\u R{x},它可以按预期工作。

    有没有办法支持表中的内联源代码?

    (我看到这个问题的标题类似: Code blocks inside tables for org-mode

    1 回复  |  直到 9 年前
        1
  •  4
  •   Stefano    9 年前

    多亏了Juancho的提示(见评论),我在这里找到了答案: http://orgmode.org/worg/org-contrib/babel/intro.html#spreadsheet

    #+NAME: my-code
    #+BEGIN_SRC R :results output
      message(10)
    #+END_SRC
    

    (假设输出只是数字10)。然后我将其插入表中,如下所示:

    | Variable | Value |
    |----------+-------|
    | Name     |       |
    #+TBLFM: @2$2='(org-sbe my-code)
    

    评论: