How to wrap a figure in exam document?
I can wrap in ARTICLE, but not in EXAM. How to wrap in EXAM?
(Question Plus-if you´re a LaTeX master-.- What´s the mosr suitable and easy package to do this kind of things?)
I can wrap a figure in an ARTICLE document
with this code
documentclass[12pt]{article}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
%begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
%end{questions}
end{document}

BUT I´d like wrap images in EXAM documents, and this code doesn´t give the wrapped figure:
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
question Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

wrapfigure flo
add a comment |
I can wrap in ARTICLE, but not in EXAM. How to wrap in EXAM?
(Question Plus-if you´re a LaTeX master-.- What´s the mosr suitable and easy package to do this kind of things?)
I can wrap a figure in an ARTICLE document
with this code
documentclass[12pt]{article}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
%begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
%end{questions}
end{document}

BUT I´d like wrap images in EXAM documents, and this code doesn´t give the wrapped figure:
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
question Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

wrapfigure flo
add a comment |
I can wrap in ARTICLE, but not in EXAM. How to wrap in EXAM?
(Question Plus-if you´re a LaTeX master-.- What´s the mosr suitable and easy package to do this kind of things?)
I can wrap a figure in an ARTICLE document
with this code
documentclass[12pt]{article}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
%begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
%end{questions}
end{document}

BUT I´d like wrap images in EXAM documents, and this code doesn´t give the wrapped figure:
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
question Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

wrapfigure flo
I can wrap in ARTICLE, but not in EXAM. How to wrap in EXAM?
(Question Plus-if you´re a LaTeX master-.- What´s the mosr suitable and easy package to do this kind of things?)
I can wrap a figure in an ARTICLE document
with this code
documentclass[12pt]{article}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
%begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
%end{questions}
end{document}

BUT I´d like wrap images in EXAM documents, and this code doesn´t give the wrapped figure:
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
begin{document}
begin{questions}
begin{wrapfigure}{r}{.3linewidth}
centering
includegraphics[width=linewidth]{example-image-a.png}
caption{This is A}
end{wrapfigure}
question Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

wrapfigure flo
wrapfigure flo
asked 5 hours ago
Mika IkeMika Ike
1,72321436
1,72321436
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
wrapfig doesn't work in lists, and questions is just another version of a list. The following is a quick and dirty reimplementation of https://tex.stackexchange.com/a/453624/117050 to work with enumerate like lists instead of with itemize. It uses insbox just like @Bernard's answer, but shouldn't require a manual paragraph. It does only implement the code to wrap inside one question, not inside the next one, too.
EDIT: It now should support exam's points system, but I didn't test it thoroughly. You might come back and complain if it doesn't work out.
EDIT2: Streamlined the interface to be more like the one of InsertBoxR, the new macro's name is questionInsbox and it takes an optional argument, two mandatory ones, and a second optional one. The first optional argument is like the one of question, the two mandatory arguments and the following optional one are like those of InsertBoxR.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
input{insbox}
usepackage{capt-of}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{etoolbox}
makeatletter
%% Stealing some code from exam:
defmypointshandling
{%>>>
if@bonus
defpadded@point@block{%
begingroup
@placepointstrue
bonuspoint@block
endgroup
}%
else
defpadded@point@block{%
begingroup
@placepointstrue
point@block
endgroup
}%
fi
if@pointsdropped
else
if@bonus
if@bonusqformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
else
if@qformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
fi
fi
global MyIfPointsfalse
}%<<<
newififMyIfPoints
protecteddefquestionInsbox
{%
@ifnextchar[questionInsbox@a{questionInsbox@a}%
}
protectedlongdefquestionInsbox@a[#1]#2#3%
{%
@ifnextchar[{questionInsbox@b{#1}{#2}{#3}}
{questionInsbox@b{#1}{#2}{#3}[0]}
}
longdefquestionInsbox@b#1#2#3[#4]%
{%
apptocmd@itemlabel{hskipleftmargin}{}{}%
defmakelabel##1{hssllap{##1}}%
ifrelaxdetokenize{#1}relax
question
else
globalMyIfPointstrue
patchcmd@readpoints{global@placepointstrue}{relax}{}{}%
question[#1]%
patchcmd@readpoints{relax}{global@placepointstrue}{}{}%
fi
patchcmd@itemlabel{hskipleftmargin}{}{}{}%
letmakelabel@mklab
mbox{}%
vspace*{-baselineskip}%
setlength{leftskip}{leftmargin}%
InsertBoxR{#2}{hskip-leftmargin#3hskipleftmargin}[#4]%
ifMyIfPoints
mypointshandling
fi
thepoint@toks
ignorespaces
}
makeatother
begin{document}
begin{questions}
questionInsbox[5]{0}
{%
parbox[t]{.3linewidth}
{%
centering
includegraphics[width=linewidth]{example-image-a.png}
captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
question[5] Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
add a comment |
Here is a solution with caption and the plain TeX insbox macro package. It defines a InsertBoxR command, to be inserted at the very beginning of a paragraph, which takes two mandatory arguments: the number of untouched lines before a box id inserted, and the inserted box itself. In addition, in case TeX has a wrong computation of number of the necessary shorter lines, it accepts as an optional argument the number of supplementary shorter lines that you want.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{caption}
input{insbox}
begin{document}
begin{questions}
question
Hello, I want to wrap this figure in exam. par
InsertBoxR {0}{parbox{0.3linewidth}{includegraphics[width=linewidth]{example-image-a.png}captionof{figure}{This is A}}}[3]
lipsum[2]lipsum[1]
end{questions}
end{document}

As far as I know, it is advised to use thecapt-ofpackage, if the only application of thecaptionpackage would becaptionof.
– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values ofabovecaptionskipandbelowcaptionskip, whence captions much too close to tables, whereascaptiondoes.
– Bernard
3 hours ago
I know. The above is only the advise given by the documentation ofcaptionas well. And thanks again for sharing yourinsbox+itemizemagic to me :)
– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into theexamcode — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.
– Bernard
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476381%2fhow-to-wrap-a-figure-in-exam-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
wrapfig doesn't work in lists, and questions is just another version of a list. The following is a quick and dirty reimplementation of https://tex.stackexchange.com/a/453624/117050 to work with enumerate like lists instead of with itemize. It uses insbox just like @Bernard's answer, but shouldn't require a manual paragraph. It does only implement the code to wrap inside one question, not inside the next one, too.
EDIT: It now should support exam's points system, but I didn't test it thoroughly. You might come back and complain if it doesn't work out.
EDIT2: Streamlined the interface to be more like the one of InsertBoxR, the new macro's name is questionInsbox and it takes an optional argument, two mandatory ones, and a second optional one. The first optional argument is like the one of question, the two mandatory arguments and the following optional one are like those of InsertBoxR.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
input{insbox}
usepackage{capt-of}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{etoolbox}
makeatletter
%% Stealing some code from exam:
defmypointshandling
{%>>>
if@bonus
defpadded@point@block{%
begingroup
@placepointstrue
bonuspoint@block
endgroup
}%
else
defpadded@point@block{%
begingroup
@placepointstrue
point@block
endgroup
}%
fi
if@pointsdropped
else
if@bonus
if@bonusqformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
else
if@qformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
fi
fi
global MyIfPointsfalse
}%<<<
newififMyIfPoints
protecteddefquestionInsbox
{%
@ifnextchar[questionInsbox@a{questionInsbox@a}%
}
protectedlongdefquestionInsbox@a[#1]#2#3%
{%
@ifnextchar[{questionInsbox@b{#1}{#2}{#3}}
{questionInsbox@b{#1}{#2}{#3}[0]}
}
longdefquestionInsbox@b#1#2#3[#4]%
{%
apptocmd@itemlabel{hskipleftmargin}{}{}%
defmakelabel##1{hssllap{##1}}%
ifrelaxdetokenize{#1}relax
question
else
globalMyIfPointstrue
patchcmd@readpoints{global@placepointstrue}{relax}{}{}%
question[#1]%
patchcmd@readpoints{relax}{global@placepointstrue}{}{}%
fi
patchcmd@itemlabel{hskipleftmargin}{}{}{}%
letmakelabel@mklab
mbox{}%
vspace*{-baselineskip}%
setlength{leftskip}{leftmargin}%
InsertBoxR{#2}{hskip-leftmargin#3hskipleftmargin}[#4]%
ifMyIfPoints
mypointshandling
fi
thepoint@toks
ignorespaces
}
makeatother
begin{document}
begin{questions}
questionInsbox[5]{0}
{%
parbox[t]{.3linewidth}
{%
centering
includegraphics[width=linewidth]{example-image-a.png}
captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
question[5] Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
add a comment |
wrapfig doesn't work in lists, and questions is just another version of a list. The following is a quick and dirty reimplementation of https://tex.stackexchange.com/a/453624/117050 to work with enumerate like lists instead of with itemize. It uses insbox just like @Bernard's answer, but shouldn't require a manual paragraph. It does only implement the code to wrap inside one question, not inside the next one, too.
EDIT: It now should support exam's points system, but I didn't test it thoroughly. You might come back and complain if it doesn't work out.
EDIT2: Streamlined the interface to be more like the one of InsertBoxR, the new macro's name is questionInsbox and it takes an optional argument, two mandatory ones, and a second optional one. The first optional argument is like the one of question, the two mandatory arguments and the following optional one are like those of InsertBoxR.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
input{insbox}
usepackage{capt-of}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{etoolbox}
makeatletter
%% Stealing some code from exam:
defmypointshandling
{%>>>
if@bonus
defpadded@point@block{%
begingroup
@placepointstrue
bonuspoint@block
endgroup
}%
else
defpadded@point@block{%
begingroup
@placepointstrue
point@block
endgroup
}%
fi
if@pointsdropped
else
if@bonus
if@bonusqformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
else
if@qformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
fi
fi
global MyIfPointsfalse
}%<<<
newififMyIfPoints
protecteddefquestionInsbox
{%
@ifnextchar[questionInsbox@a{questionInsbox@a}%
}
protectedlongdefquestionInsbox@a[#1]#2#3%
{%
@ifnextchar[{questionInsbox@b{#1}{#2}{#3}}
{questionInsbox@b{#1}{#2}{#3}[0]}
}
longdefquestionInsbox@b#1#2#3[#4]%
{%
apptocmd@itemlabel{hskipleftmargin}{}{}%
defmakelabel##1{hssllap{##1}}%
ifrelaxdetokenize{#1}relax
question
else
globalMyIfPointstrue
patchcmd@readpoints{global@placepointstrue}{relax}{}{}%
question[#1]%
patchcmd@readpoints{relax}{global@placepointstrue}{}{}%
fi
patchcmd@itemlabel{hskipleftmargin}{}{}{}%
letmakelabel@mklab
mbox{}%
vspace*{-baselineskip}%
setlength{leftskip}{leftmargin}%
InsertBoxR{#2}{hskip-leftmargin#3hskipleftmargin}[#4]%
ifMyIfPoints
mypointshandling
fi
thepoint@toks
ignorespaces
}
makeatother
begin{document}
begin{questions}
questionInsbox[5]{0}
{%
parbox[t]{.3linewidth}
{%
centering
includegraphics[width=linewidth]{example-image-a.png}
captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
question[5] Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
add a comment |
wrapfig doesn't work in lists, and questions is just another version of a list. The following is a quick and dirty reimplementation of https://tex.stackexchange.com/a/453624/117050 to work with enumerate like lists instead of with itemize. It uses insbox just like @Bernard's answer, but shouldn't require a manual paragraph. It does only implement the code to wrap inside one question, not inside the next one, too.
EDIT: It now should support exam's points system, but I didn't test it thoroughly. You might come back and complain if it doesn't work out.
EDIT2: Streamlined the interface to be more like the one of InsertBoxR, the new macro's name is questionInsbox and it takes an optional argument, two mandatory ones, and a second optional one. The first optional argument is like the one of question, the two mandatory arguments and the following optional one are like those of InsertBoxR.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
input{insbox}
usepackage{capt-of}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{etoolbox}
makeatletter
%% Stealing some code from exam:
defmypointshandling
{%>>>
if@bonus
defpadded@point@block{%
begingroup
@placepointstrue
bonuspoint@block
endgroup
}%
else
defpadded@point@block{%
begingroup
@placepointstrue
point@block
endgroup
}%
fi
if@pointsdropped
else
if@bonus
if@bonusqformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
else
if@qformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
fi
fi
global MyIfPointsfalse
}%<<<
newififMyIfPoints
protecteddefquestionInsbox
{%
@ifnextchar[questionInsbox@a{questionInsbox@a}%
}
protectedlongdefquestionInsbox@a[#1]#2#3%
{%
@ifnextchar[{questionInsbox@b{#1}{#2}{#3}}
{questionInsbox@b{#1}{#2}{#3}[0]}
}
longdefquestionInsbox@b#1#2#3[#4]%
{%
apptocmd@itemlabel{hskipleftmargin}{}{}%
defmakelabel##1{hssllap{##1}}%
ifrelaxdetokenize{#1}relax
question
else
globalMyIfPointstrue
patchcmd@readpoints{global@placepointstrue}{relax}{}{}%
question[#1]%
patchcmd@readpoints{relax}{global@placepointstrue}{}{}%
fi
patchcmd@itemlabel{hskipleftmargin}{}{}{}%
letmakelabel@mklab
mbox{}%
vspace*{-baselineskip}%
setlength{leftskip}{leftmargin}%
InsertBoxR{#2}{hskip-leftmargin#3hskipleftmargin}[#4]%
ifMyIfPoints
mypointshandling
fi
thepoint@toks
ignorespaces
}
makeatother
begin{document}
begin{questions}
questionInsbox[5]{0}
{%
parbox[t]{.3linewidth}
{%
centering
includegraphics[width=linewidth]{example-image-a.png}
captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
question[5] Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

wrapfig doesn't work in lists, and questions is just another version of a list. The following is a quick and dirty reimplementation of https://tex.stackexchange.com/a/453624/117050 to work with enumerate like lists instead of with itemize. It uses insbox just like @Bernard's answer, but shouldn't require a manual paragraph. It does only implement the code to wrap inside one question, not inside the next one, too.
EDIT: It now should support exam's points system, but I didn't test it thoroughly. You might come back and complain if it doesn't work out.
EDIT2: Streamlined the interface to be more like the one of InsertBoxR, the new macro's name is questionInsbox and it takes an optional argument, two mandatory ones, and a second optional one. The first optional argument is like the one of question, the two mandatory arguments and the following optional one are like those of InsertBoxR.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
input{insbox}
usepackage{capt-of}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{etoolbox}
makeatletter
%% Stealing some code from exam:
defmypointshandling
{%>>>
if@bonus
defpadded@point@block{%
begingroup
@placepointstrue
bonuspoint@block
endgroup
}%
else
defpadded@point@block{%
begingroup
@placepointstrue
point@block
endgroup
}%
fi
if@pointsdropped
else
if@bonus
if@bonusqformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
else
if@qformat
ifxques@ref@queslevel
else
setup@point@toks
fi
else
setup@point@toks
fi
fi
fi
global MyIfPointsfalse
}%<<<
newififMyIfPoints
protecteddefquestionInsbox
{%
@ifnextchar[questionInsbox@a{questionInsbox@a}%
}
protectedlongdefquestionInsbox@a[#1]#2#3%
{%
@ifnextchar[{questionInsbox@b{#1}{#2}{#3}}
{questionInsbox@b{#1}{#2}{#3}[0]}
}
longdefquestionInsbox@b#1#2#3[#4]%
{%
apptocmd@itemlabel{hskipleftmargin}{}{}%
defmakelabel##1{hssllap{##1}}%
ifrelaxdetokenize{#1}relax
question
else
globalMyIfPointstrue
patchcmd@readpoints{global@placepointstrue}{relax}{}{}%
question[#1]%
patchcmd@readpoints{relax}{global@placepointstrue}{}{}%
fi
patchcmd@itemlabel{hskipleftmargin}{}{}{}%
letmakelabel@mklab
mbox{}%
vspace*{-baselineskip}%
setlength{leftskip}{leftmargin}%
InsertBoxR{#2}{hskip-leftmargin#3hskipleftmargin}[#4]%
ifMyIfPoints
mypointshandling
fi
thepoint@toks
ignorespaces
}
makeatother
begin{document}
begin{questions}
questionInsbox[5]{0}
{%
parbox[t]{.3linewidth}
{%
centering
includegraphics[width=linewidth]{example-image-a.png}
captionof{figure}{This is A}%
}%
}[1]
Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
question[5] Hello, I want to wrap this figure in exam
lipsum[2]lipsum[1]
end{questions}
end{document}

edited 3 hours ago
answered 4 hours ago
SkillmonSkillmon
22.7k11943
22.7k11943
@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
add a comment |
@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
@Skillmom the solutions it´s exactly how I liked. We need to add many code lines, but the result it´s exactly how I liked. With the tabulars/indents as question of exam docs.
– Mika Ike
3 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
Is possible another questionInsbox with option for Left figure instead of Right figure?
– Mika Ike
2 hours ago
add a comment |
Here is a solution with caption and the plain TeX insbox macro package. It defines a InsertBoxR command, to be inserted at the very beginning of a paragraph, which takes two mandatory arguments: the number of untouched lines before a box id inserted, and the inserted box itself. In addition, in case TeX has a wrong computation of number of the necessary shorter lines, it accepts as an optional argument the number of supplementary shorter lines that you want.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{caption}
input{insbox}
begin{document}
begin{questions}
question
Hello, I want to wrap this figure in exam. par
InsertBoxR {0}{parbox{0.3linewidth}{includegraphics[width=linewidth]{example-image-a.png}captionof{figure}{This is A}}}[3]
lipsum[2]lipsum[1]
end{questions}
end{document}

As far as I know, it is advised to use thecapt-ofpackage, if the only application of thecaptionpackage would becaptionof.
– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values ofabovecaptionskipandbelowcaptionskip, whence captions much too close to tables, whereascaptiondoes.
– Bernard
3 hours ago
I know. The above is only the advise given by the documentation ofcaptionas well. And thanks again for sharing yourinsbox+itemizemagic to me :)
– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into theexamcode — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.
– Bernard
2 hours ago
add a comment |
Here is a solution with caption and the plain TeX insbox macro package. It defines a InsertBoxR command, to be inserted at the very beginning of a paragraph, which takes two mandatory arguments: the number of untouched lines before a box id inserted, and the inserted box itself. In addition, in case TeX has a wrong computation of number of the necessary shorter lines, it accepts as an optional argument the number of supplementary shorter lines that you want.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{caption}
input{insbox}
begin{document}
begin{questions}
question
Hello, I want to wrap this figure in exam. par
InsertBoxR {0}{parbox{0.3linewidth}{includegraphics[width=linewidth]{example-image-a.png}captionof{figure}{This is A}}}[3]
lipsum[2]lipsum[1]
end{questions}
end{document}

As far as I know, it is advised to use thecapt-ofpackage, if the only application of thecaptionpackage would becaptionof.
– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values ofabovecaptionskipandbelowcaptionskip, whence captions much too close to tables, whereascaptiondoes.
– Bernard
3 hours ago
I know. The above is only the advise given by the documentation ofcaptionas well. And thanks again for sharing yourinsbox+itemizemagic to me :)
– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into theexamcode — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.
– Bernard
2 hours ago
add a comment |
Here is a solution with caption and the plain TeX insbox macro package. It defines a InsertBoxR command, to be inserted at the very beginning of a paragraph, which takes two mandatory arguments: the number of untouched lines before a box id inserted, and the inserted box itself. In addition, in case TeX has a wrong computation of number of the necessary shorter lines, it accepts as an optional argument the number of supplementary shorter lines that you want.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{caption}
input{insbox}
begin{document}
begin{questions}
question
Hello, I want to wrap this figure in exam. par
InsertBoxR {0}{parbox{0.3linewidth}{includegraphics[width=linewidth]{example-image-a.png}captionof{figure}{This is A}}}[3]
lipsum[2]lipsum[1]
end{questions}
end{document}

Here is a solution with caption and the plain TeX insbox macro package. It defines a InsertBoxR command, to be inserted at the very beginning of a paragraph, which takes two mandatory arguments: the number of untouched lines before a box id inserted, and the inserted box itself. In addition, in case TeX has a wrong computation of number of the necessary shorter lines, it accepts as an optional argument the number of supplementary shorter lines that you want.
documentclass[12pt]{exam}
usepackage{graphicx,wrapfig,lipsum}
usepackage[onehalfspacing]{setspace}
usepackage{mwe}
usepackage{caption}
input{insbox}
begin{document}
begin{questions}
question
Hello, I want to wrap this figure in exam. par
InsertBoxR {0}{parbox{0.3linewidth}{includegraphics[width=linewidth]{example-image-a.png}captionof{figure}{This is A}}}[3]
lipsum[2]lipsum[1]
end{questions}
end{document}

answered 4 hours ago
BernardBernard
171k775202
171k775202
As far as I know, it is advised to use thecapt-ofpackage, if the only application of thecaptionpackage would becaptionof.
– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values ofabovecaptionskipandbelowcaptionskip, whence captions much too close to tables, whereascaptiondoes.
– Bernard
3 hours ago
I know. The above is only the advise given by the documentation ofcaptionas well. And thanks again for sharing yourinsbox+itemizemagic to me :)
– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into theexamcode — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.
– Bernard
2 hours ago
add a comment |
As far as I know, it is advised to use thecapt-ofpackage, if the only application of thecaptionpackage would becaptionof.
– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values ofabovecaptionskipandbelowcaptionskip, whence captions much too close to tables, whereascaptiondoes.
– Bernard
3 hours ago
I know. The above is only the advise given by the documentation ofcaptionas well. And thanks again for sharing yourinsbox+itemizemagic to me :)
– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into theexamcode — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.
– Bernard
2 hours ago
As far as I know, it is advised to use the
capt-of package, if the only application of the caption package would be captionof.– Skillmon
3 hours ago
As far as I know, it is advised to use the
capt-of package, if the only application of the caption package would be captionof.– Skillmon
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values of
abovecaptionskip and belowcaptionskip, whence captions much too close to tables, whereas caption does.– Bernard
3 hours ago
You're probably right. However, I systematically load it for another reason: when you put captions above tables (as is the typographical tradition, for obvious reasons), LaTeX does not swap the values of
abovecaptionskip and belowcaptionskip, whence captions much too close to tables, whereas caption does.– Bernard
3 hours ago
I know. The above is only the advise given by the documentation of
caption as well. And thanks again for sharing your insbox+itemize magic to me :)– Skillmon
3 hours ago
I know. The above is only the advise given by the documentation of
caption as well. And thanks again for sharing your insbox+itemize magic to me :)– Skillmon
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
@Bernard I like the solution. It´s not complicated (little code) but the tabulars/indent are not ok in all the questions i.imgur.com/BUH1Brt.jpg
– Mika Ike
3 hours ago
I didn't try to delve into the
exam code — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.– Bernard
2 hours ago
I didn't try to delve into the
exam code — I don't use this package, and don't have the expertise for that. Skillmon did a really fine job.– Bernard
2 hours ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476381%2fhow-to-wrap-a-figure-in-exam-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown