How to wrap a figure in exam document?Wrapping itemize around figure using floatflt in multicol environment -...
When does a person lose diplomatic status?
Protagonist constantly has to have long words explained to her. Will this get tedious?
Is there any danger of my neighbor having my wife's signature?
Why can't I set the 'prototype' of a function created using 'bind'?
Isn't a semicolon (';') needed after a function declaration in C++?
How to regain lost focus?
Is it possible to have the same planeswalker from different editions in a Commander deck?
Why is Acetic acid (pKa = 4.76) stronger than carbonic acid (pKa = 6.36)?
Why do single electrical receptacles exist?
Plotting a bump function
Crack the bank account's password!
Can't figure out a htaccess rule
What does "south of due west" mean?
Coworker is trying to get me to sign his petition to run for office. How to decline politely?
Dealing with an internal ScriptKiddie
How to display the vertices while in object mode?
Is the UK legally prevented from having another referendum on Brexit?
How do I fight with Heavy Armor as a Wizard with Tenser's Transformation?
How to deal with an underperforming subordinate?
In a post apocalypse world, with no power and few survivors, would Satnav still work?
Is having explosions as a go-to solution considered bad table manners?
Taking an academic pseudonym?
Expression for "unconsciously using words (or accents) used by a person you often talk with or listen to"?
How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?
How to wrap a figure in exam document?
Wrapping itemize around figure using floatflt in multicol environment - figure doesn't showWrap Figure Pushes Text AroundHow to wrap one column text around a centered figure?Wrap figure moves all the following textTex padded left after figure wrapWrapfig and multicol — how to avoid wrapping text?Wrap text in figureWeird text wrapping problem (wrapfigure, wraptable) - trying to wrap text around an image and a tableAdjust intextsep for wrapfigure onlyMiktex/XeLaTeX - non-working wrapped images (wrapfigure)How to wrap text around part of a figure
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 2 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
4 mins 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-of
package, if the only application of thecaption
package would becaptionof
.
– Skillmon
43 mins 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 ofabovecaptionskip
andbelowcaptionskip
, whence captions much too close to tables, whereascaption
does.
– Bernard
34 mins ago
I know. The above is only the advise given by the documentation ofcaption
as well. And thanks again for sharing yourinsbox
+itemize
magic to me :)
– Skillmon
32 mins 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
7 mins 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
4 mins 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
4 mins 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 39 mins ago
answered 1 hour 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
4 mins 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
4 mins 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
4 mins 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
4 mins 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-of
package, if the only application of thecaption
package would becaptionof
.
– Skillmon
43 mins 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 ofabovecaptionskip
andbelowcaptionskip
, whence captions much too close to tables, whereascaption
does.
– Bernard
34 mins ago
I know. The above is only the advise given by the documentation ofcaption
as well. And thanks again for sharing yourinsbox
+itemize
magic to me :)
– Skillmon
32 mins 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
7 mins 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-of
package, if the only application of thecaption
package would becaptionof
.
– Skillmon
43 mins 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 ofabovecaptionskip
andbelowcaptionskip
, whence captions much too close to tables, whereascaption
does.
– Bernard
34 mins ago
I know. The above is only the advise given by the documentation ofcaption
as well. And thanks again for sharing yourinsbox
+itemize
magic to me :)
– Skillmon
32 mins 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
7 mins 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 1 hour ago
BernardBernard
171k775202
171k775202
As far as I know, it is advised to use thecapt-of
package, if the only application of thecaption
package would becaptionof
.
– Skillmon
43 mins 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 ofabovecaptionskip
andbelowcaptionskip
, whence captions much too close to tables, whereascaption
does.
– Bernard
34 mins ago
I know. The above is only the advise given by the documentation ofcaption
as well. And thanks again for sharing yourinsbox
+itemize
magic to me :)
– Skillmon
32 mins 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
7 mins ago
add a comment |
As far as I know, it is advised to use thecapt-of
package, if the only application of thecaption
package would becaptionof
.
– Skillmon
43 mins 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 ofabovecaptionskip
andbelowcaptionskip
, whence captions much too close to tables, whereascaption
does.
– Bernard
34 mins ago
I know. The above is only the advise given by the documentation ofcaption
as well. And thanks again for sharing yourinsbox
+itemize
magic to me :)
– Skillmon
32 mins 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
7 mins 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
43 mins 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
43 mins 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
34 mins 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
34 mins 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
32 mins 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
32 mins 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
7 mins 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
7 mins 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