\ doifundefine 內的 ConTeXt xtables 無法編譯

\ doifundefine 內的 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 是緩衝區:如果您想要嵌入 xtable,請使用\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

(漢斯·哈根)

相關內容