cgnieder / xsim

eXercise Sheets IMproved
67 stars 23 forks source link

solution #117

Closed Jerrymouse999 closed 1 year ago

Jerrymouse999 commented 1 year ago

Why doesn't xsim output the answers in the order of the questions?

\documentclass[hyperref,a4paper,openany,UTF8]{ctexbook} \usepackage{amsmath,amssymb} \usepackage{amsthm} \usepackage{geometry} \usepackage{hyperref} \usepackage{indentfirst} \usepackage{latexsym} \usepackage{titlesec} \usepackage{xeCJK} \usepackage[no-files]{xsim} \usepackage{lastpage}

\xsimsetup{ load-style = layouts } \DeclareExerciseType{eg} {exercise-env = eg, solution-env = egans, exercise-name ={eg}, solution-name ={eg}, %exercise-template = item , %solution-template = item exercise-template =margin, solution-template =margin, %ex-heading = \subsection , %sol-heading = \subsection } \renewcommand*\theeg{\arabic{eg}}

\DeclareExerciseType{ex} {exercise-env = ex, solution-env = exans, exercise-name ={ex}, solution-name ={ex}, %exercise-template = item , %solution-template = item exercise-template =margin, solution-template =margin, %ex-heading = \subsection , %sol-heading = \subsection } \renewcommand*\theex{(\arabic{ex})}

\title{test} \author{test}

\date{\today}

\begin{document} \maketitle \tableofcontents

\part{problem} \chapter{test} \section{test1} \subsection{eg1} \begin{eg} $x^2=1,x=$ \end{eg} \begin{egans} $\pm1$ \end{egans}

\begin{ex} $x^2=0,x=$ \end{ex} \begin{exans} $0$ \end{exans}

\subsection{eg2} \begin{eg} $x^2=4,x=$ \end{eg} \begin{egans} $\pm2$ \end{egans}

\begin{ex} $x^2=9,x=$ \end{ex} \begin{exans} $\pm3$ \end{exans}

\section{test2} \subsection{eg3} \begin{eg} $x^2=16,x=$ \end{eg} \begin{egans} $\pm4$ \end{egans}

\begin{ex} $x^2=25,x=$ \end{ex} \begin{exans} $\pm5$ \end{exans}

\part{solution} \printsolutions[chapter=1,section=1,headings-template=none] \printsolutions[chapter=1,section=2,headings-template=none] \end{document}

test.pdf

muzimuzhi commented 1 year ago

Please always wrap multi-line code, here the latex example in (github flavored) markdown code block.

Also, please put some more effort in minimizing your example, for example drop unused packages and see if the problem reproduces with one of the stand document classes.

muzimuzhi commented 1 year ago

Why doesn't xsim output the answers in the order of the questions?

You need \printallsolutions, rather than \printsolutions. See package manual, sec. 11. "Printing Solutions" for more info.

\part{solution}
\verb|\printsolutions| prints the solutions of all used exercises of all types \emph{ordered by type}.
\printsolutions[chapter=1,section=1,headings-template=none]
\printsolutions[chapter=1,section=2,headings-template=none]

\verb|\printallsolutions| prints the solutions of all used exercises of all types \emph{ordered by appearance} in the document.
\printallsolutions[chapter=1,section=1,headings-template=none]
\printallsolutions[chapter=1,section=2,headings-template=none]

image

Jerrymouse999 commented 1 year ago

thank you

Jerrymouse999 commented 1 year ago

thank you