\newcommand 中的 \end{禁忌}

\newcommand 中的 \end{禁忌}

我想放入\end{tabu}一個\newcommand

\documentclass{article}

\usepackage{tabu}

\newcommand
{\tableBegin}[1]
{
    \begin{tabu}[#1]
    % some other stuff
}

\newcommand
{\tableEnd}
{\end{tabu}}

\begin{document}

\tableBegin{ccc}
1 & 2 & 3 \\
a & b & c
\tableEnd
%\end{tabu}

\end{document}

但是當我使用\tableEnd而不是\end{tabu}我得到以下錯誤: ! Missing $ inserted.

答案1

tabu(如 AMS 環境等),將其主體作為參數,以便在來源中tabularx明確找到。\end{tabu}可以解決這個問題,但不這樣做更簡單,只需使用記錄的環境名稱即可。

\tableBegin/End與 LaTeX 約定非常不同,為什麼不定義一個新的環境呢?

相關內容