Ejercicios con enlaces a respuestas (problema al usar el contador)

Ejercicios con enlaces a respuestas (problema al usar el contador)

Lo siento, el sitio web no me permite hacer preguntas detalladas como comentario (tampoco muestra la barra de herramientas de formato), por lo que agrego una nueva pregunta.

Problema: intentar crear una lista de ejercicios (con enlaces a las respuestas correspondientes). todas las respuestas al final del documento. Sin embargo, no quiero etiquetar manualmente cada pregunta. Entonces, pensé en usar el número de pregunta como etiqueta, pero aparentemente usa el número total de preguntas como etiqueta. Cualquier ayuda se agradece. Gracias a @CarLaTeX por responder la pregunta original.aquí.

\documentclass{article}
\usepackage{hyperref}% you must load it before the exercise package
\usepackage[answerdelayed]{exercise}

\begin{document}

    \begin{Exercise}[label={exerciseNumber}]
        What is the value of 2+5? (To see the answer click here: \refAnswer{\ExerciseLabel})
    \end{Exercise}
    \begin{Answer}[ref=\ExerciseLabel]
        7
    \end{Answer}

    \begin{Exercise}[label={exerciseNumber}]
        What is the value of 4-1? (To see the answer click here: \refAnswer{\ExerciseLabel})
    \end{Exercise}
    \begin{Answer}[ref=\ExerciseLabel]
        3
    \end{Answer}

     \begin{Exercise}[label={exerciseNumber}]
        What is the value of 2*4? (To see the answer click here: \refAnswer{\ExerciseLabel})
    \end{Exercise}
    \begin{Answer}[ref=\ExerciseLabel]
        8
    \end{Answer}
    \shipoutAnswer
\end{document}

Salida (incorrecta):

ingrese la descripción de la imagen aquí

Respuesta1

El 'número de pregunta' que está buscando se almacena como un contador, con el nombre apropiado Exercise(al menos, para el entorno de Ejercicio). Puede acceder al mostrador utilizando:

\the\value{Exercise}

Entonces, todo lo que necesitas hacer es usar esto como etiqueta cuando lo pases como una opción en \begin{Exercise}. Vea a continuación un ejemplo.

MWE:

\documentclass{article}
\usepackage{hyperref}% you must load it before the exercise package
\usepackage[answerdelayed]{exercise}

\begin{document}
  \begin{Exercise}[label={\the\value{Exercise}}]
    What is the value of $2+5$? (To see the answer click here:~\refAnswer{\ExerciseLabel})
  \end{Exercise}
  \begin{Answer}[ref=\ExerciseLabel]
    7
  \end{Answer}

  \begin{Exercise}[label={\the\value{Exercise}}]
    What is the value of $4-1$? (To see the answer click here:~\refAnswer{\ExerciseLabel})
  \end{Exercise}
  \begin{Answer}[ref=\ExerciseLabel]
    3
  \end{Answer}

  \begin{Exercise}[label={\the\value{Exercise}}]
    What is the value of $2\times 4$? (To see the answer click here:~\refAnswer{\ExerciseLabel})
  \end{Exercise}
  \begin{Answer}[ref=\ExerciseLabel]
    8
  \end{Answer}
  \shipoutAnswer
\end{document}

Ex v2


Información adicional

Quizás pueda hacer que sea menos engorroso escribir la etiqueta, si

(Opción 1)defines una macro como \blah:

% Preamble:    
\newcommand*{\blah}{\the\value{Exercise}}
% Main document:
\begin{Exercise}[label=\blah]

o

(Opcion 2)Si te sientes muy vago, simplemente define un nuevo entorno:

% In Preamble
\newcounter{Ex}
\newenvironment{Ex}{\begin{Exercise}[name={Exercise},
    counter={Ex},
    label=\the\value{Ex}]}
{\end{Exercise}}

y luego en el documento principal, llama a tus ejercicios así:

% In Main document
\begin{Ex}
    What is the value of $2+5$? (To see the answer click here:~\refAnswer{\ExerciseLabel})
\end{Ex}
\begin{Answer}[ref=\ExerciseLabel]
    7
\end{Answer}

información relacionada