How to share an image between two questions?

Added by Paco Riviere about 4 years ago

I do tests with questions needing an image. Several questions share the same image that takes up a lot of space, and sometimes that image comes out twice in the same copy, even on the same page.
How can I reference the same image from two questions that are randomly included with \copygroup and avoid repeating the same image on the same page or copy?


Replies (17)

RE: How to share an image between two questions? - Added by Frédéric Bréal about 4 years ago

Use \AMClabel, \AMCref and \AMCpageref (5.4.14 Using references inside the test sheets, documentation)

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

Thanks Gérard,
I think I can understand how to reference an inserted graphic, from another one with /AMClabel and /AMCref. Just need some tries.

But how to make image print only once when two questions share this image?
How to know how may times an image is appearing in a paper?
If the image is only once, then nothing changes,
In case it is more than once, then the image should be printed only once,
No idea how I could build such a question, or group of questions!

RE: How to share an image between two questions? - Added by Frédéric Bréal about 4 years ago

OK, I had not understood the "sub-text" ; I always need to use google traduction.

No idea how I could build such a question, or group of questions!

I have one with a counter or a newif.
I'll attempt tomorow

RE: How to share an image between two questions? - Added by Frédéric Bréal about 4 years ago

I failed to perform a test with a conditional test or a boolean.
I used a counter.
I am not sure the result is what you expected. The image is always connected with the first question.

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

It works fine!
Need to try with several figures.
Merci, Gérard.

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

How to use it with several shared images.

1. Should I use a different counter \newcounter{imageAffichee} for each different image, I guess?

I guess the code:

\ifthenelse{\value{imageAffichee}  = 1 }{Voir question 1}%
{\begin{figure}[!h]\includegraphics{example-image-1x1}\caption{example-image-1x1}\label{image-b}\end{figure}

2. Are the lines placing the image or the reference on the question, I guess?

3. What will be the text for the second image:

\ifthenelse{\value{imageAffichee}  = 1 }{Voir question 2}%

I guess?

4. Can I use the same image in different groups, or in groups not included in this run?

5. Is {% and %} a comment, a separator or a reference?

I guess

6. Is the code:

\restituegroupe{image}

The same as
\insertgroup{image}

?

Thanks again Gèrard.

This is a usefull tip deserving a place in the userguide/wiki

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

What does
\setdefaultgroupmode{withreplacement}
exactly means?

I cannot get in any way what the user guide means.

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

How to manage the image if it is wrapped? in a parbox

I guess the parbox including the image should be include in the ifthenelse?:

\ifthenelse{\value{imageAffichee}  = 1 }{Voir question 1}%
%% here should start the parbox including the image ... I guess
...
} %% end of the parbox
} %% end of the ifthenelse

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

To be more speficic, I include the actual code of the question with the image, so you may show the new neede code to shre images.
This is to wrap the image on the right side:

\element{group_name}{
\begin{question}{question_name}\\
  \parbox[c]{.44\linewidth}{
  Question text
  \begin{choices}
    \wrongchoice{answer text}
    \correctchoice{answer text}
    \wrongchoice{answer text}
    \wrongchoice{answer text}
  \end{choices}}
    \parbox[c]{.44\linewidth}{
    \includegraphics[width=0.48\textwidth]{./Figures/image_name.png}}
\end{question}}

Btw. What is the difference between?:

\setdefaultgroupmode{cyclic} % as I was using

and

\setdefaultgroupmode{withreplacement} % as you suggest

RE: How to share an image between two questions? - Added by Alexis Bienvenüe about 4 years ago

1. Should I use a different counter \newcounter{imageAffichee} for each different image, I guess?

Yes.

5. Is {% and %} a comment, a separator or a reference?

In LaTeX code, % starts a comment. You can often find a % just after an other character, such as {, to cancel the newline effect (inserting a space).

6. Is the code: \restituegroupe{image}
The same as \insertgroup{image}

Yes (French version).

RE: How to share an image between two questions? - Added by Alexis Bienvenüe about 4 years ago

Btw. What is the difference between?:
\setdefaultgroupmode{cyclic} % as I was using
and
\setdefaultgroupmode{withreplacement} % as you suggest

I hope the attached dcument makes it more clear.

shuffle.tex (1.6 kB)

shuffle.pdf (39.1 kB)

RE: How to share an image between two questions? - Added by Frédéric Bréal about 4 years ago

Pour Alexis : Peut-on avoir accès au nombre d'éléments dans chaque groupe ? Est-ce un compteur ?
To Paco : I'm waiting some precisions from Alexis before make an attempt.

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

Thanks Gèrard!
I get the idea for fixed and cyclic, but, what is the difference between the two last modes?

What I discover from your source is I can use different shuffle ways on the same test!

RE: How to share an image between two questions? - Added by Frédéric Bréal about 4 years ago

Suppose you have a group named mygroup and 4 questions a, b, c and d)
  • withreplacement :
    \insertgroup{mygroup} give (for example) : sheet 1 a c b d, shuffle, sheet 2 a b d c, shuffle, sheet 3 b d c a
    \insertgroup[ 3]{mygroup} give (for example) : sheet 1 a c b , shuffle, sheet 2 a b c, shuffle, sheet 3 b d c
  • withoutreplacement (if i have correctly understood)
    \insertgroup[ 3]{mygroup} give (for example) : sheet 1 a c b , sheet 2 d shuffle b c, sheet 3 a shuffle d b

RE: How to share an image between two questions? - Added by Paco Riviere about 4 years ago

This makes sense. I think `withoutreplacement` I've sometimes run out if questions.

RE: How to share an image between two questions? - Added by Alexis Bienvenüe about 4 years ago

Pour Alexis : Peut-on avoir accès au nombre d'éléments dans chaque groupe ? Est-ce un compteur ?

Oui c'est le compteur \nomdugroupe@k

RE: How to share an image between two questions? - Added by Frédéric Bréal almost 4 years ago

This is not what I had on my mind. I can't find a way to use the counter \elemens@k.

(1-17/17)