
私の質問は、表形式の環境と\DeclareDocumentEnvironment
コマンド(xparseパッケージ)。
コード内にいくつかの演算子を含む環境を設定するにはどうすればいいですか?表形式の&
またはなどの環境\\
?
これは私ができると思っていたものの、エラーが発生する最小限の(機能しない)例です。
\documentclass{article}
\usepackage{xparse,booktabs}
\DeclareDocumentEnvironment{env}{mm}{\toprule #1 & #2 &}{\\ \bottomrule}
\begin{document}
\begin{tabular}{lll}
\begin{env}{one}{two}
three
\end{env}
\end{tabular}
\end{document}
この環境を内部で動作させるために何ができるか表形式の環境?
よろしくお願いします、
ピエリック
答え1
以前に展開できないものに遭遇した場合、エラー\toprule
が発生します。この問題は、単純な古いコマンドを使用して回避できます。
\documentclass{article}
%\usepackage{xparse,booktabs}
%\DeclareDocumentEnvironment{env}{mm}{\toprule #1 & #2 &}{\\ \bottomrule}
\usepackage{booktabs}
\newcommand{\env}[2]{\toprule #1 & #2 &}
\newcommand{\envend}{\\ \bottomrule}
\begin{document}\thispagestyle{empty}
\begin{tabular}{lll}
\env{one}{two}
three
\envend
\env{four}{five}
six
\envend
\end{tabular}
\end{document}