3

At here How to make an environment star Exercise?, I posted make star Exercise.

How to make star Exercise and its environmet answer? Example, with Exercise 1.1, we have Answer 1.1, with Exercise 1.5*, we have Answer 1.5*.

1 Answer 1

4

The following provides the functionality you requested by defining the sol* environment to be very similar to the ex* environment:

enter image description here

\documentclass{book}
\usepackage{amsfonts,amssymb,amsmath}% http://ctan.org/pkg/{amsfonts,amssymb,amsmath}
\newtheorem{ex}{Exercise}[chapter]
\newenvironment{ex*}
  {\renewcommand\theex{\thechapter.\arabic{ex}\rlap{$^*$}}%
   \ex\edef\@currentlabel{\thechapter.\arabic{ex}}}
  {\endex}
\newtheorem{sol}{Answer}[chapter]
\newenvironment{sol*}
  {\renewcommand\thesol{\theex\rlap{$^*$}}%
   \sol\edef\@currentlabel{\theex}}
  {\endsol}
\renewcommand\thesol{\theex}

\begin{document}
\chapter{First Chapter}
\section{First section}
\begin{ex}
This is an Exercise.
\end{ex}
\begin{sol}
This is a Solution.
\end{sol}

\begin{ex}
This is an Exercise.
\end{ex}

\begin{ex*}
This is a difficult Exercise.
\end{ex*}
\begin{sol*}
This is an easy solution.
\end{sol*}

\end{document}

The base code was taken from egreg's answer.

2
  • If there are some Problems doesn't need answer, \begin{ex} This is an Exercise. \end{ex} \begin{ex} This is an Exercise. \end{ex} \begin{ex} This is an Exercise. \end{ex} \begin{sol} This is a Solution. \end{sol} \begin{ex*} This is a difficult Exercise. \end{ex*} \begin{sol*} This is an easy solution. \end{sol*} How to fix? Jun 27, 2013 at 6:59
  • @minthao_2011: See my updated solution.
    – Werner
    Jun 27, 2013 at 7:07

You must log in to answer this question.

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