我不想\end{tabularx}
在每个表的末尾写,所以我想定义以下宏:
\newcommand\et{\endtabularx}
这有效:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{100pt}{|X|X|X|}
\hline
$n$ & $0$ & $1$\\
\hline
$u_n$ & $2$ & $5$\\
\hline
\end{tabularx}
\end{document}
但这不行:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\newcommand\et{\end{tabularx}}
\begin{tabularx}{100pt}{|X|X|X|}
\hline
$n$ & $0$ & $1$\\
\hline
$u_n$ & $2$ & $5$\\
\hline
\et
\end{document}
答案1
如果您想要最小化/混淆代码,请完全执行此操作:
\documentclass{article}
\usepackage{tabularx}
\newcommand\tx[3]{\begin{tabularx}{#1}{#2}#3\end{tabularx}}
\begin{document}
\tx{100pt}{|X|X|X|}{\hline
$n$ & $0$ & $1$\\\hline
$u_n$ & $2$ & $5$\\\hline}
\end{document}