我想创建一个环境星练习,但我做不到。请帮帮我。
\documentclass{book}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\newtheorem{ex}{Exercise}[chapter]
\begin{document}
\chapter{First Chapter}
\section{First section}
\begin{ex}
This is an Exercise
\end{ex}
\begin{ex}
This is an Exercise
\end{ex}
\end{document}
如果接下来是一项困难的练习,例如如何定义新的环境练习之星\textbf{Exercise} $1.3^\text{*}$
。
答案1
只需修改困难练习的计数器的表示形式:
\documentclass{book}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\newtheorem{ex}{Exercise}[chapter]
\newenvironment{ex*}
{\renewcommand\theex{\thechapter.\arabic{ex}\rlap{$^*$}}\ex}
{\endex}
\begin{document}
\chapter{First Chapter}
\section{First section}
\begin{ex}
This is an Exercise
\end{ex}
\begin{ex}
This is an Exercise
\end{ex}
\begin{ex*}
This is a difficult Exercise
\end{ex*}
\end{document}
如果本练习的引用中不需要星号,则ex*
可以将的定义改为
\makeatletter
\newenvironment{ex*}
{\renewcommand\theex{\thechapter.\arabic{ex}\rlap{$^*$}}%
\ex\edef\@currentlabel{\thechapter.\arabic{ex}}}
{\endex}
\makeatother
这样就可以创建不带 * 的引用。
答案2
该软件包Exercise
可以提供帮助:
\documentclass{article}
\usepackage{exercise}
\begin{document}
\begin{Exercise}
This is an exercise.
\end{Exercise}
\begin{Exercise}[difficulty=1]
This is a difficult exercise.
\end{Exercise}
\end{document}
结果:
答案3
我刚刚找到答案
\documentclass[12pt,openany,twoside]{book}
\usepackage{fouriernc}
\usepackage[thmmarks,standard,thref]{ntheorem}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\theoremseparator{.}
\theorembodyfont{\upshape}
\newtheorem{ex}{Exercise}[chapter]
\theoremseparator{$^\text{*}$.}
\newtheorem{dex}[ex]{Exercise}
\usepackage{answers}
\Newassociation{sol}{Answer}{loigiaichung}
\Newassociation{sols}{ansF}{loigiaichung}
\newcommand{\preansF}{}
\renewcommand{\ansFlabel}[1]{{\bfseries #1*.}}
\renewcommand{\Answerlabel}[1]{\bfseries #1.}
\begin{document}
\chapter{First Chapter}
\Opensolutionfile{loigiaichung}[ex]
\section{First section}
\begin{ex}
This is an exercise
\begin{sol}
This is a solution
\end{sol}
\end{ex}
\begin{dex}
This is an exercise
\begin{sols}
This is a solution
\end{sols}
\end{dex}
\chapter{Second Chapter}
\Opensolutionfile{loigiaichung}[ex]
\section{Second section}
\begin{ex}
This is an exercise
\begin{sol}
This is a solution
\end{sol}
\end{ex}
\begin{dex}
This is an exercise
\begin{sols}
This is a solution
\end{sols}
\end{dex}
\Closesolutionfile{loigiaichung}
\section{Hint, anserw}
\input{ex}
\end{document}