\begin{block}{Command} \newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\begin{tabularx}{\textwidth}{*{2}{@{}l}@{}R}
1 & 2 & 3
\end{tabularx}
\end{block}
Since this is a bit cumbersome, I want to use \newenvironment to make things easier.
\documentclass[10pt]{beamer}
\usepackage{tabularx}
\newenvironment{Command}[1]
{\begin{block}{Command}%
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\begin{tabularx}{\textwidth}{*{#1}{@{}l}@{}R}%
}{ \end{tabularx}%
\end{block}}
\begin{document}
% THIS IS CORRECT
% \begin{block}{Command} \newcolumntype{R}{>{\raggedleft\arraybackslash}X}
% \begin{tabularx}{\textwidth}{*{2}{@{}l}@{}R}
% 1 & 2 & 3
% \end{tabularx}
% \end{block}
% THIS IS INCORRECT
\begin{Command}{2}
1 & 2 & 3
\end{Command}
\end{document}
This is what I've tried, but it doesn't work, and the error message is
! Missing } inserted.
<inserted text>
}
l.nn \end{tabularx}
EDITED
According to the thread @TeXnician mentioned, I tried
\newenvironment{Command}[1]
{ \newcolumntype{R}{>{\raggedleft\arraybackslash}X}%
\tabularx{\textwidth}{#1}%
}{ \endtabularx}
and it does work. However, if \begin{block}\end{block} are added, the warning pops up:
! Undefined control sequence.
\endbeamercolorbox ->\ifdim \beamer@colbox@sep
=0pt\else \vskip \beamer@colb...
l.nn ^^I\end{block}

\tabularx{XX}and\endtabularxinstead of\begin{tabularx}{XX}and\end{tabularx}. – Kevin Dong Aug 21 '17 at 16:17