Emacs 组织模式表:从导出中排除列

Emacs 组织模式表:从导出中排除列,emacs,latex,org-mode,Emacs,Latex,Org Mode,我有一组以组织模式导出的表,但我希望用于计算和代码块消耗的某些列从LaTeX导出中排除 我确信我看到了一种方法,通过在表下指定要导出的列的范围来实现这一点,但我在web上的任何地方都找不到对它的引用,所以我很有可能梦到了它 3.5.6公式的编辑和调试 使用“/”用于:不要导出此行。对于包含缩小“”标记或列组标记的行非常有用 注意:要做到这一点,您必须使用第一列获取额外信息。如果您使用的是“Radio Tables”,您可以执行以下操作 #+ORGTBL: SEND some-name orgt

我有一组以组织模式导出的表,但我希望用于计算和代码块消耗的某些列从LaTeX导出中排除

我确信我看到了一种方法,通过在表下指定要导出的列的范围来实现这一点,但我在web上的任何地方都找不到对它的引用,所以我很有可能梦到了它

3.5.6公式的编辑和调试 使用
“/”
用于:不要导出此行。对于包含缩小“”标记或列组标记的行非常有用

注意:要做到这一点,您必须使用第一列获取额外信息。

如果您使用的是“Radio Tables”,您可以执行以下操作

#+ORGTBL: SEND some-name orgtbl-to-latex :skipcols (3)
|-----+-------+------|
|   2 | 1/2   | junk |
|   4 | 1/4   | junk |
|   8 | 1/2   | junk |
有关所有详细信息,请参阅


我认为通过
C-C-e
直接导出可能不太可能,因为从2010年11月开始,他们在提供相同的答案。

实现这一点的另一种方法是定义“隐藏”在组织文件的LaTeX标题选项中输入列类型
H
,然后使用
#+ATTR\u LaTeX::align llH
指示在导出时隐藏第三列():

#+LATEX_头:\usepackage{array}

#+LATEX_头:\newcolumntype{H}{>{\setbox0=\hbox\bgroupc}c我使用Derek Feichtinger提出并编目的Michael Brand解决方案(确保以原始模式查看文件,否则源代码被GitHub隐藏)

为了方便起见,我复制了下面的代码:

* Exporting tables with some columns hidden

  It is desirable to be able and hide columns in exported output. This is often the
  case in tables where a lot of computations are done, and where intermediate
  results end up in columns that one does not want to end up in the exported document.

  This functionality is currently not available by standard org, but since this is Emacs, a simple function
  implementing this functionality was published by [[https://github.com/brandm][Michael Brand]] within this [[http://lists.gnu.org/archive/html/emacs-orgmode/2016-05/msg00027.html][emacs-orgmode thread]].

  #+BEGIN_SRC emacs-lisp :results silent :exports source
    (defun dfeich/org-export-delete-commented-cols (back-end)
      "Delete columns $2 to $> marked as `<#>' on a row with `/' in $1.
    If you want a non-empty column $1 to be deleted make it $2 by
    inserting an empty column before and adding `/' in $1."
      (while (re-search-forward "^[ \t]*| +/ +|\\(.*|\\)? +\\(<#>\\) *|" nil t)
    (goto-char (match-beginning 2))
    (org-table-delete-column)
    (beginning-of-line)))
    (add-hook 'org-export-before-processing-hook #'dfeich/org-export-delete-commented-cols)
    ;; (remove-hook 'org-export-before-processing-hook #'dfeich/org-export-delete-commented-cols)
  #+END_SRC  

  The exported table will have col2 removed.

  |   | col1 | col2 | col3 |
  | / |  <r> | <#>  |      |
  |   |   a1 | a2   | a3   |
  |   |   b1 | b2   | b3   |
*导出某些列隐藏的表
希望能够在导出的输出中隐藏列
在进行大量计算的表格中,如果
结果以不希望在导出文档中结束的列结束。
标准组织目前不提供此功能,但由于这是Emacs,因此它是一个简单的功能
实现此功能是由发布的[[https://github.com/brandm][迈克尔·布兰德]]在这个[[http://lists.gnu.org/archive/html/emacs-orgmode/2016-05/msg00027.html][emacs orgmode线程]]。
#+BEGIN_SRC emacs lisp:results silent:exports source
(defun dfeich/org导出删除已注释的COL(后端)
删除$1中带有“/”的行上标记为“%”的$2到$>列。
如果要删除非空列$1,请按将其删除为$2
在$1之前插入空列,并在$1中添加“/”
(而(向前搜索“^[\t]*.+/+\\\(...\\\)?+\(\\)*.\\”无)
(转到字符(匹配开始2))
(组织表删除列)
(行首)
(在处理hook#'dfeich/org导出之前添加hook'org export删除注释的cols)
(在处理钩子之前删除钩子“组织导出”#“dfeich/org导出删除已注释的COL)
#+结束(SRC)
导出的表将删除col2。
|| col1 | col2 | col3|
| / |   |   |      |
|| a1 | a2 | a3|
|| b1 | b2 | b3|

我发现最方便的方法是:

  • 使表不可与:noexport:tag一起导出
  • 使用elisp选择要用源块导出的列,并使结果可导出
  • 下面是一个使用elisp的示例

    * Hidden :noexport:
    #+NAME: google
    | file      | total | other | p  |
    |-----------+-------+-------+----|
    | de-01.pdf |   312 |    76 | 76 |
    | de-02.pdf |   428 |   101 | 77 |
    | de-03.pdf |  1069 |   217 | 80 |
    
    * Exported
    Here it comes.
    
    #+begin_src elisp :var data=google :colnames yes
    ;; select 0th and 3rd column from a table accessible with 'google' name
    ;; and do some math on it
      (mapcar (lambda (e) (list (nth 0 e) (nth 3 e))) data)
    #+end_src
    
    #+RESULTS:
    | file      | p  |
    |-----------+----|
    | de-01.pdf | 76 |
    | de-02.pdf | 77 |
    | de-03.pdf | 80 |
    

    您也可以使用源代码块支持的任何其他语言来循环结果并生成所需的输出。

    这允许您删除一行,但我需要删除一些列。谢谢。很难!我不确定这一点,因为我还在制作组织模式的电子表格。尽管如此,这似乎是目前唯一的方法正如链接所暗示的,它对出口不起作用。干杯。
    * Hidden :noexport:
    #+NAME: google
    | file      | total | other | p  |
    |-----------+-------+-------+----|
    | de-01.pdf |   312 |    76 | 76 |
    | de-02.pdf |   428 |   101 | 77 |
    | de-03.pdf |  1069 |   217 | 80 |
    
    * Exported
    Here it comes.
    
    #+begin_src elisp :var data=google :colnames yes
    ;; select 0th and 3rd column from a table accessible with 'google' name
    ;; and do some math on it
      (mapcar (lambda (e) (list (nth 0 e) (nth 3 e))) data)
    #+end_src
    
    #+RESULTS:
    | file      | p  |
    |-----------+----|
    | de-01.pdf | 76 |
    | de-02.pdf | 77 |
    | de-03.pdf | 80 |