# How to define a new environment with old environment by setting the optional parameter?

\documentclass{ctexbook}
\title{Introduction to Latex}
\author{Me}
\date{}

\usepackage{exsheets}
\SetupExSheets{counter-within={chapter}}
\newenvironment{myquestion}{\begin{question}[name={myExercise}]}{\end{question}}

\begin{document}
\chapter{first}
\section{start}
\subsection{install}
\begin{myquestion}
Review the documentation for your compiler and determine what file naming convention it uses. Compile and Run the main program from page 2.
\end{myquestion}
\end{document}


The exsheets package has defined an environment with optional parameter, eg. name. I want to define a new environment named myquestion with environment question by setting the optional parameter name={myExercise}.

But LaTeX gives me an error.

Use \question and \endquestion:

\documentclass{book}
\title{Introduction to Latex}
\author{Me}
\date{}

\usepackage{exsheets}
\SetupExSheets{counter-within={chapter}}
\newenvironment{myquestion}
{\question[name={myExercise}]}
{\endquestion}

\begin{document}

\chapter{first}

\section{start}
\subsection{install}

\begin{myquestion}
Review the documentation for your compiler and determine what
file naming convention it uses. Compile and Run the main
program from page 2.
\end{myquestion}

\end{document}


That's a known “problem” with exsheets.

Actually I'd define

\newenvironment{myquestion}[1][]
{\question[name={myExercise},#1]}
{\endquestion}


so you can specify additional options to myquestion.

I suggest to use \NewQuSolPair instead of fiddling with \question and \endquestion, because that's the way how other than the predefined environments question and solution can be used.

Since I neither have Chinese fonts on my hard disk nor do I understand Chinese language or can read Chinese at all, I switched from ctexbook to book class.

\documentclass{book}
\title{Introduction to Latex}
\author{Me}
\date{}

\usepackage{exsheets}
\SetupExSheets{counter-within={chapter}}
\NewQuSolPair{myquestion}[name={MyExercise}]{mysolution}[name=MySolution]

\begin{document}
\chapter{first}
\section{start}
\subsection{install}
\begin{myquestion}
Review the documentation for your compiler and determine what file naming convention it uses. Compile and Run the main program from page 2.
\end{myquestion}

\begin{mysolution}[print]
$E = mc^{2}$
\end{mysolution}
\end{document}