2

I try to convert from exsheets to xsim but I fail to implement runin. I just copied the runin-template from the manual (http://ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/xsim/doc/xsim_manual.pdf) but I cannot compile it (error: runaway argument? {par \vspace {\baselineskip} \Needspace*{...). Does anybody know why or how I could implement runin?

Here I my source-code

\documentclass[11pt, a4paper, parskip=full]{scrartcl}

\renewcommand\thesection{\Alph{section}}
\usepackage{xsim}


\xsimsetup{%     
    exercise/within = subsection ,      
    exercise/the-counter = \thesubsection.\arabic{exercise} 
}

\usepackage{needspace}
\DeclareExerciseEnvironmentTemplate{runin}
  {%
    \par\vspace{\baselineskip}
    \Needspace*{2\baselineskip}
    \noindent
    \textbf{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}}%
    \GetExercisePropertyT{subtitle}{ \textit{#1}} % <<< notice the space
    \IfInsideSolutionF{%
      \GetExercisePropertyT{points}{%
        \marginpar{%
          \printgoal{\PropertyValue}%
          \GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}%
\,\IfExerciseGoalSingularTF{points}
    {\XSIMtranslate{point}}
    {\XSIMtranslate{points}}%
}% }%
}% }
{}

\DeclareExerciseType{problem}{
 exercise-env = exercise ,
 solution-env = solution ,
 exercise-name = Aufgabe ,
 solution-name = Aufgabe ,
 exercise-template = runin ,
 solution-template = runin
 }




\begin{document}

\selectlanguage{ngerman}

\section{Aufgaben} 

\subsection{subsection}

\begin{exercise}[subtitle=test]
Was ist 1 mal 1? 
\end{exercise}  
\begin{solution} 
1 mal 1 ist 1.  siehe \ref{abba}
\end{solution} 

\begin{exercise} 
Was ist 2 mal 2? 
\end{exercise}  
\begin{solution} 
2 mal 2 ist 4. 
\end{solution} 

\section{Schwere Aufgaben} 
\subsection{subsection}
\begin{exercise}  
Was ist 3 mal 3? 
\end{exercise}  
\subsection{subsection}
\begin{solution} 
3 mal 3 ist 9. 
\end{solution} 

\begin{exercise}  
Was ist 4 mal 4? 
\end{exercise}  
\begin{solution} 
4 mal 4 ist 16. 
\end{solution} 

Lösungen
\printsolutions


\end{document}

1 Answer 1

4

As stated in the xsim manual (page 29), the runin style is available through the style file layouts. Loading this style file using the command \loadxsimstyle{layouts} is sufficient to use the style in your document.

MWE:

\documentclass[11pt, a4paper, parskip=full]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xsim}
\loadxsimstyle{layouts}

\xsimsetup{%     
    exercise/within = subsection ,      
    exercise/the-counter = \thesubsection.\arabic{exercise} 
}
\SetExerciseParameters{exercise}{
 exercise-name = Aufgabe ,
 solution-name = Aufgabe ,
 exercise-template = runin ,
 solution-template = runin
}

\renewcommand\thesection{\Alph{section}}

\begin{document}

\section{Aufgaben} 

\subsection{subsection}

\begin{exercise}[subtitle=test]
Was ist 1 mal 1? 
\end{exercise}  
\begin{solution} 
1 mal 1 ist 1.
\end{solution} 

\begin{exercise} 
Was ist 2 mal 2? 
\end{exercise}  
\begin{solution} 
2 mal 2 ist 4. 
\end{solution} 

\section{Schwere Aufgaben} 
\subsection{subsection}
\begin{exercise}  
Was ist 3 mal 3? 
\end{exercise}  
\subsection{subsection}
\begin{solution} 
3 mal 3 ist 9. 
\end{solution} 

\begin{exercise}  
Was ist 4 mal 4? 
\end{exercise}  
\begin{solution} 
4 mal 4 ist 16. 
\end{solution} 

Lösungen
\printsolutions

\end{document}

Result:

enter image description here

Note that the errors that resulted from your original code were caused by a copy-paste mistake: all closing brackets in the last three lines of \DeclareExerciseEnvironmentTemplate are supposed to be on separate lines, now two of them are accidentally commented out by the end of line % characters of the other bracket lines.

1
  • Thanks, I have some further questions which I will post in a new question.
    – garondal
    Jul 7, 2019 at 17:56

You must log in to answer this question.

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