[Tex/LaTex] How to define a starred version of an environment in LaTeX

environmentsstarred-version

I am interested in defining a new environment in LaTeX that has a starred version. How is this done?

Best Answer

Since the \newenvironment command uses a \csname, you can define it directly.

\documentclass{article}
\newenvironment{test*}
{start}{end}
\begin{document}
\begin{test*}
hello
\end{test*}
\end{document}

You can have any combination of characters (with catcode 11 and 12) as you would in a \csname...\endcsname construct,

\documentclass{article}
\newenvironment{test123*}
{start}{end}
\begin{document}
\begin{test123*}
hello
\end{test123*}
\end{document}

What you do with the starred command is up to you.

Related Question