1

I am using xsim to type exercise-solution environments in my document.

I want to change the string used for the header in \printsolutions[headings=true].

The document language is Hebrew, so I want it to be written in that language. Moreover, the solutions should appear at the end of the chapter, and so I want it to read "Solutions to the exercises in chapter \thechapter":

\thechapter פתרונות לתרגילים בפרק

I am new to the xsim package (and its manual), and I couldn't find an answer for that in the manual.

A MWE:

%!TEX TS-program = xelatex
\documentclass{book}
\usepackage{xsim}
\xsimsetup{solution/print = false,}
\xsimsetup{
  exercise/name={תרגיל},
  exercises/name={תרגילים},
  solution/name={פתרון},
  solutions/name={פתרונות},
  exercise/within = chapter,
}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]
\begin{document}
\chapter{גיאומטריה}
\section{הקדמה}
\begin{exercise}[subtitle={משפט פיתגורס}]
הוכח שסכום שטחי הריבועים, הבנויים על הניצבים במשולש ישר זווית, שווה לשטח הריבוע הבנוי על היתר.
\end{exercise}
\begin{solution}
מוכיחים בקלות.
\end{solution}
\printsolutions[headings=true]
\end{document}

Output: enter image description here

1
  • @muzimuzhi Z Could you help me out with the other question I have which is related to this one?
    – tush
    Commented Jun 15, 2022 at 13:45

2 Answers 2

4

You can define a translation for the default-heading in Hebrew:

\DeclareExerciseTranslations{default-heading}{
  Hebrew = פתרונות לתרגילים בפרק \thechapter 
}

enter image description here

Complete code:

% arara: xelatex: { interaction: nonstopmode }
\documentclass{book}

\usepackage{xsim}
\xsimsetup{solution/print = false,}
\xsimsetup{
  exercise/name={תרגיל},
  exercises/name={תרגילים},
  solution/name={פתרון},
  solutions/name={פתרונות},
  exercise/within = chapter,
}
\DeclareExerciseTranslations{default-heading}{
  Hebrew = פתרונות לתרגילים בפרק \thechapter
}

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]

\begin{document}

\chapter{גיאומטריה}

\section{הקדמה}

\begin{exercise}[subtitle={משפט פיתגורס}]
הוכח שסכום שטחי הריבועים, הבנויים על הניצבים במשולש ישר זווית, שווה לשטח הריבוע הבנוי על היתר.
\end{exercise}
\begin{solution}
מוכיחים בקלות.
\end{solution}

\printsolutions[headings=true]

\end{document}
3
  • Thank you very much indeed! As the developer and creator of this package, I would like to have a chat talk with you about the syntax of the package. Is that possible?
    – tush
    Commented May 29, 2022 at 9:58
  • +1: One more answer and you have 1,000 answers! Commented Jun 1, 2022 at 1:55
  • @cgnieder I have another question about xsim that I need help me with. Could you have a look at it?
    – tush
    Commented Jun 15, 2022 at 13:48
4
+50

Changes I made:

% in preamble: declare a new heading template
\DeclareExerciseHeadingTemplate{solution}{%
    \section*{פתרונות לתרגילים בפרק \thechapter}%
}

% apply that template for \printsolutions
\printsolutions[headings=true,headings-template=solution]

Full example:

%!TEX TS-program = xelatex
\documentclass{book}
\usepackage{xsim}
\xsimsetup{solution/print = false,}
\xsimsetup{
  exercise/name={תרגיל},
  exercises/name={תרגילים},
  solution/name={פתרון},
  solutions/name={פתרונות},
  exercise/within = chapter,
}
\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]

\DeclareExerciseHeadingTemplate{solution}{%
    \section*{פתרונות לתרגילים בפרק \thechapter}%
}

\begin{document}
\chapter{גיאומטריה}
\section{הקדמה}
\begin{exercise}[subtitle={משפט פיתגורס}]
הוכח שסכום שטחי הריבועים, הבנויים על הניצבים במשולש ישר זווית, שווה לשטח הריבוע הבנוי על היתר.
\end{exercise}
\begin{solution}
מוכיחים בקלות.
\end{solution}

\printsolutions[headings=true,headings-template=solution]
\end{document}

enter image description here

5
  • Thank you. I have some other xsim related questions. Do you mind if we talk about it in the chat?
    – tush
    Commented May 29, 2022 at 9:45
  • @tush Or you can post them as separate questions then not only me on this site can see and help. Commented May 29, 2022 at 9:47
  • It is just that the waiting time for a comment or an answer could be days.. I particularly need help with the syntax of this package.
    – tush
    Commented May 29, 2022 at 9:49
  • For example, I want to introduce hints to the exercise (hints will be printed at the end of the chapter too), and print a page reference on the margins, adjacent to the exercise, as can be seen here
    – tush
    Commented May 29, 2022 at 9:56
  • @tush For hints printed at the end of each chapter, check Example 11: Give hints in xsim's package manual. For references on the margins, one option is to new exercise templates by \DeclareExerciseEnvironmentTemplate, and use \margin to add margins. Commented May 29, 2022 at 10:24

You must log in to answer this question.

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