2

I want to type some exercises at the end of a certain chapter in a book. Furthermore, I'm using the xepersian package to type the book in Persian. I have got some problems in using the exercises package for the typesetting of the exercises. They are:

  1. The title of exercises is not typeset in Persian which is (تمرین‌ها)
  2. I want to have the number of exercises according to the chapter such as 1.1, 1.2, 1.3 ...
  3. I want to change the : symbol into a dot for each exercise.

In the following I attach the minimal code:

\documentclass{book} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{exercises}

\usepackage{xepersian}
\settextfont{Yas}

\begin{document}

\chapter{فصل 1}

\begin{exercise}
    محاسبه کند 
    $ 1 + 2 $
\end{exercise}

\end{document}
7
  • 1
    You can use the option exercisename=... to set the name of the exercises and you can do \renewcommand\exercises@formatnumbers[1]{\thechapter.\arabic{#1}} but the colon is hard-coded into exercises I'm afraid. You may try xsim as an alternative package… it allows you complete control over the layout.
    – cgnieder
    Jan 2, 2021 at 10:50
  • Dear @cgnieder, thank you so much for your suggestion. But it did not work out.
    – AYBRXQD
    Jan 2, 2021 at 16:32
  • Which suggestion? The option exercisename? The redefinition of \exercises@formatnumbers? xsim? I tested all three before I suggested them to you and all three did what they were supposed to… “did not work out” is not very specific.
    – cgnieder
    Jan 2, 2021 at 17:35
  • I meant the \exercises@formatnumbers
    – AYBRXQD
    Jan 2, 2021 at 17:42
  • OK. In which way didn't it work out?
    – cgnieder
    Jan 2, 2021 at 17:51

2 Answers 2

1

You can use the option exercisename=... to set the name of the exercises and you can do \renewcommand\exercises@formatnumbers[1]{\thechapter.\arabic{#1}} (surrounded by \makeatletter and \makeatother) but the colon is hard-coded into exercises I'm afraid:

\documentclass{book} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[exercisename=تمرین‌ها]{exercises}

\usepackage{xepersian}
\settextfont{Yas}

\makeatletter
\renewcommand\exercises@formatnumbers[1]{\thechapter.\arabic{#1}}
\makeatother

\begin{document}

\chapter{فصل 1}

\begin{exercise}
    محاسبه کند 
    $ 1 + 2 $
\end{exercise}

\end{document}

enter image description here

You may try xsim as an alternative package… it allows you complete control over the layout:

\documentclass{book} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{xsim}

\usepackage{xepersian}
\settextfont{Yas}

\xsimsetup{
  exercise/name = تمرین‌ها ,
  exercise/the-counter = \thechapter.\arabic{exercise}
}

\begin{document}

\chapter{فصل 1}

\begin{exercise}
    محاسبه کند 
    $ 1 + 2 $
\end{exercise}

\end{document}

enter image description here

0

I could not find what wanted but I find an appropriate solution. Indeed, I should neglect using of exercises package. I used \newtheorem{exercise}{تمرین}[chapter] as a new environment for the exercise section. In the following, you may see the results:

\documentclass{book} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}


\usepackage{xepersian}
\settextfont{Yas}
\setdigitfont{Yas}

\newtheorem{exercise}{تمرین}[chapter]

\begin{document}

\chapter{فصل 1}

\begin{exercise}
    \label{ex-1}
    محاسبه کند 
    $ 1 + 2 $
\end{exercise}

\begin{exercise}
\label{ex-2}
    محاسبه کند 
    $ 2 + 3 $
\end{exercise}

\begin{latin}

I can even refer to them those exercises such 
Ex. \ref{ex-1} and \ref{ex-2}.

\end{latin}

\end{document}

The result is

enter image description here

In this form, I even can cite a specific exercise.

You must log in to answer this question.

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