\ doifundefined 内的 ConTeXt xtables 无法编译

\ doifundefined 内的 ConTeXt xtables 无法编译

下面的小示例无法编译:

\starttext
\doifundefined{undefined}{%
\startxtable
    \startxtablebody
        \startxrow
            \startxcell cell \stopxcell
        \stopxrow
    \stopxtablebody
\stopxtable}
\stoptext

这是我得到的:

lcc@home:tex> context --batchmode xtable2.tex

resolvers       | trees | analyzing '/Users/lcc/Library/texlive/texmf-config'
resolvers       | trees | analyzing '/Users/lcc/Library/texlive/texmf'
mtx-context     | run 1: luatex --fmt="/Users/lcc/Library/texlive/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en" --interaction="batchmode" --jobname="xtable2" --lua="/Users/lcc/Library/texlive/texmf-var/luatex-cache/context/a86c089b384a3076dc514ba966a1fac9/formats/luatex/cont-en.lui" --no-parse-first-line --c:batchmode --c:currentrun=1 --c:fulljobname="./xtable2.tex" --c:input="./xtable2.tex" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
This is LuaTeX, Version 0.95.0 (TeX Live 2016)
 system commands enabled.

resolvers       > trees > analyzing '/Users/lcc/Library/texlive/texmf-config'

resolvers       > trees > analyzing '/Users/lcc/Library/texlive/texmf'
open source     > 1 > 1 > /usr/local/texlive/current/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv
system          > 'cont-new.mkiv' loaded
open source     > 2 > 2 > /usr/local/texlive/current/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
close source    > 2 > 2 > /usr/local/texlive/current/texmf-dist/tex/context/base/mkiv/cont-new.mkiv
system          > files > jobname 'xtable2', input './xtable2', result 'xtable2'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
open source     > 2 > 3 > /Users/lcc/Projects/inactive/MVNECO/tex/xtable2.tex
close source    > 2 > 3 > /Users/lcc/Projects/inactive/MVNECO/tex/xtable2.tex
close source    > 1 > 3 > /usr/local/texlive/current/texmf-dist/tex/context/base/mkiv/cont-yes.mkiv

tex error       > tex error on line 0 in file : ! Emergency stop



<empty file>


mtx-context     | fatal error: return code: 1

相同的文档无需\doifundefined编译即可正常进行,并产生所需的输出。我可以做什么来有条件地排版 xtable?

我正在使用 texlive 2016 附带的最新 ConTeXt 发行版。

答案1

xtable 是缓冲区:如果要嵌入 xtables,请\startembeddedxtable使用\startxtable

\starttext
 \doifundefined{undefined}{%
 \startembeddedxtable
 \startxtablebody
    \startxrow
        \startxcell cell \stopxcell
    \stopxrow
\stopxtablebody
\stopembeddedxtable
}
\stoptext

另一个选项是,如果命令未定义,则设置一种模式,并根据该模式处理内容:

\starttext
\doifundefined{undefined}{\enablemode[alltables]}
\startmode[alltables]
\startxtable
    \startxtablebody
        \startxrow
            \startxcell cell \stopxcell
        \stopxrow
    \stopxtablebody
\stopxtable
\stopmode
\stoptext

或者首先将表的内容存储在缓冲区中,如果变量未定义则处理缓冲区:

\starttext
\startbuffer[content]
\startxtable
    \startxtablebody
        \startxrow
            \startxcell cell \stopxcell
        \stopxrow
    \stopxtablebody
\stopxtable
\stopbuffer
\doifundefined{undefined}{\getbuffer[content]}
\stoptext

(汉斯·哈根)

相关内容