9
\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.

2 Answers 2

8

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.

enter image description here

Actually I'd define

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

so you can specify additional options to myquestion.

8

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} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .