在这儿如何让环境成为明星锻炼?,我发布了制作明星练习。
如何制作星号练习及其环境答案?例如,对于练习 1.1,我们有答案 1.1,对于练习 1.5*,我们有答案 1.5*。
答案1
下面通过定义sol*
环境来提供您请求的功能非常类似ex*
环境:
\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}
基本代码取自egreg 的回答。