Inserting image in example

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












Here is my tex-code:



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:
endExample

beginfigure[ht!]
centering
includegraphics[width=4cm]billede.png
labelfig:boat1
endfigure

enddocument


I would like my image to be inside the example-box but latex keeps showing an error. How do I fix this?



billede



Thanks.










share|improve this question









New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Welcome to TeX.Stackexchange!
    – samcarter
    2 hours ago






  • 1




    Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
    – samcarter
    2 hours ago















up vote
2
down vote

favorite












Here is my tex-code:



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:
endExample

beginfigure[ht!]
centering
includegraphics[width=4cm]billede.png
labelfig:boat1
endfigure

enddocument


I would like my image to be inside the example-box but latex keeps showing an error. How do I fix this?



billede



Thanks.










share|improve this question









New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Welcome to TeX.Stackexchange!
    – samcarter
    2 hours ago






  • 1




    Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
    – samcarter
    2 hours ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











Here is my tex-code:



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:
endExample

beginfigure[ht!]
centering
includegraphics[width=4cm]billede.png
labelfig:boat1
endfigure

enddocument


I would like my image to be inside the example-box but latex keeps showing an error. How do I fix this?



billede



Thanks.










share|improve this question









New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Here is my tex-code:



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:
endExample

beginfigure[ht!]
centering
includegraphics[width=4cm]billede.png
labelfig:boat1
endfigure

enddocument


I would like my image to be inside the example-box but latex keeps showing an error. How do I fix this?



billede



Thanks.







graphics






share|improve this question









New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 hours ago









Bobyandbob

3,86851263




3,86851263






New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









saleem

111




111




New contributor




saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






saleem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Welcome to TeX.Stackexchange!
    – samcarter
    2 hours ago






  • 1




    Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
    – samcarter
    2 hours ago

















  • Welcome to TeX.Stackexchange!
    – samcarter
    2 hours ago






  • 1




    Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
    – samcarter
    2 hours ago
















Welcome to TeX.Stackexchange!
– samcarter
2 hours ago




Welcome to TeX.Stackexchange!
– samcarter
2 hours ago




1




1




Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
– samcarter
2 hours ago





Unrelated to your problem, but labelfig:boat1 won't work because the figure does not have a caption.
– samcarter
2 hours ago











2 Answers
2






active

oldest

votes

















up vote
3
down vote













If you want your image inside the example box, you should not use a figure environment, because a figure environment allows your image to "float" through your document, which is contra productive if you want it at a specific place.



In case you might want a caption for your image, you could use the captionof macro from the caption package.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:

centering
includegraphics[width=4cm]example-image
endExample

enddocument


enter image description here






share|improve this answer




















  • Thanks. It worked.
    – saleem
    26 mins ago

















up vote
2
down vote













Welcome in TeX.SE.



The error comes from the float environment figure. Floats may not to be inside any fixed environment as example in your example. You can simply remove the figure environment and add:



begincenter
includegraphics[width=4cm]billede.png
endcenter


at the end of your example environment.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:


begincenter
includegraphics[width=4cm]billede.png
endcenter

endExample

enddocument





share|improve this answer






















  • a figure is float environment as well a table is. both should not be included in any box...
    – Zarko
    2 hours ago










  • @Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
    – Piroooh
    2 hours ago










  • i took liberty and extend your explanation in you answer with my comment (instead of you).
    – Zarko
    24 mins ago










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',
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
);



);






saleem is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457989%2finserting-image-in-example%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













If you want your image inside the example box, you should not use a figure environment, because a figure environment allows your image to "float" through your document, which is contra productive if you want it at a specific place.



In case you might want a caption for your image, you could use the captionof macro from the caption package.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:

centering
includegraphics[width=4cm]example-image
endExample

enddocument


enter image description here






share|improve this answer




















  • Thanks. It worked.
    – saleem
    26 mins ago














up vote
3
down vote













If you want your image inside the example box, you should not use a figure environment, because a figure environment allows your image to "float" through your document, which is contra productive if you want it at a specific place.



In case you might want a caption for your image, you could use the captionof macro from the caption package.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:

centering
includegraphics[width=4cm]example-image
endExample

enddocument


enter image description here






share|improve this answer




















  • Thanks. It worked.
    – saleem
    26 mins ago












up vote
3
down vote










up vote
3
down vote









If you want your image inside the example box, you should not use a figure environment, because a figure environment allows your image to "float" through your document, which is contra productive if you want it at a specific place.



In case you might want a caption for your image, you could use the captionof macro from the caption package.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:

centering
includegraphics[width=4cm]example-image
endExample

enddocument


enter image description here






share|improve this answer












If you want your image inside the example box, you should not use a figure environment, because a figure environment allows your image to "float" through your document, which is contra productive if you want it at a specific place.



In case you might want a caption for your image, you could use the captionof macro from the caption package.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:

centering
includegraphics[width=4cm]example-image
endExample

enddocument


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 hours ago









samcarter

79.7k787253




79.7k787253











  • Thanks. It worked.
    – saleem
    26 mins ago
















  • Thanks. It worked.
    – saleem
    26 mins ago















Thanks. It worked.
– saleem
26 mins ago




Thanks. It worked.
– saleem
26 mins ago










up vote
2
down vote













Welcome in TeX.SE.



The error comes from the float environment figure. Floats may not to be inside any fixed environment as example in your example. You can simply remove the figure environment and add:



begincenter
includegraphics[width=4cm]billede.png
endcenter


at the end of your example environment.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:


begincenter
includegraphics[width=4cm]billede.png
endcenter

endExample

enddocument





share|improve this answer






















  • a figure is float environment as well a table is. both should not be included in any box...
    – Zarko
    2 hours ago










  • @Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
    – Piroooh
    2 hours ago










  • i took liberty and extend your explanation in you answer with my comment (instead of you).
    – Zarko
    24 mins ago














up vote
2
down vote













Welcome in TeX.SE.



The error comes from the float environment figure. Floats may not to be inside any fixed environment as example in your example. You can simply remove the figure environment and add:



begincenter
includegraphics[width=4cm]billede.png
endcenter


at the end of your example environment.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:


begincenter
includegraphics[width=4cm]billede.png
endcenter

endExample

enddocument





share|improve this answer






















  • a figure is float environment as well a table is. both should not be included in any box...
    – Zarko
    2 hours ago










  • @Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
    – Piroooh
    2 hours ago










  • i took liberty and extend your explanation in you answer with my comment (instead of you).
    – Zarko
    24 mins ago












up vote
2
down vote










up vote
2
down vote









Welcome in TeX.SE.



The error comes from the float environment figure. Floats may not to be inside any fixed environment as example in your example. You can simply remove the figure environment and add:



begincenter
includegraphics[width=4cm]billede.png
endcenter


at the end of your example environment.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:


begincenter
includegraphics[width=4cm]billede.png
endcenter

endExample

enddocument





share|improve this answer














Welcome in TeX.SE.



The error comes from the float environment figure. Floats may not to be inside any fixed environment as example in your example. You can simply remove the figure environment and add:



begincenter
includegraphics[width=4cm]billede.png
endcenter


at the end of your example environment.



documentclass[12pt]article

usepackagetikz
usepackageamsmath
usetikzlibraryarrows
usepackagexcolor
usepackagesectsty
usepackageamsfonts
usepackage[utf8]inputenc
usepackage[yyyymmdd]datetime
usepackage[margin=1in]geometry
usepackagegraphicx

usepackagecleveref
usepackage[most]tcolorbox

newtcbtheoremTheoremTheorem
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!75!black,
fonttitle=bfseries,
boxed title style=
sharp corners,
size=small,
colback=blue!75!black,
colframe=blue!75!black,

thm
newtcbtheorem[no counter]ExampleEksempel
enhanced,
sharp corners,
attach boxed title to top left=
yshifttext=-1mm
,
colback=white,
colframe=blue!25,
fonttitle=bfseries,
coltitle=black,
boxed title style=
sharp corners,
size=small,
colback=blue!25,
colframe=blue!25,

prf


begindocument

section*Funktioner

subsection*Hvad er en graf?

noindent En textbfgraf er billedet af en funktion, som man tegner ind i et koordinatsystem. \

beginExample
noindent Vi ønsker, at tegne grafen for funktionen $y=4cdot x$. Denne funktion beskriver sammenhængen mellem $x$ og $y$. Vi vælger først forskellige $x$-værdier og finder deres $y$-værdier: \
begincenter
begintabular hline
$x$ & $y$ \ hline
0 & 0 \
1 & 4 \
2 & 8 \
3 & 12 \
4 & 16 \ hline
endtabular
endcenter

noindent Ved at bruge $x$ og $y$-værdierne kan vi nu tegne grafen (billedet) af funktionen $y=4cdot x$:


begincenter
includegraphics[width=4cm]billede.png
endcenter

endExample

enddocument






share|improve this answer














share|improve this answer



share|improve this answer








edited 24 secs ago









samcarter

79.7k787253




79.7k787253










answered 2 hours ago









Piroooh

858




858











  • a figure is float environment as well a table is. both should not be included in any box...
    – Zarko
    2 hours ago










  • @Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
    – Piroooh
    2 hours ago










  • i took liberty and extend your explanation in you answer with my comment (instead of you).
    – Zarko
    24 mins ago
















  • a figure is float environment as well a table is. both should not be included in any box...
    – Zarko
    2 hours ago










  • @Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
    – Piroooh
    2 hours ago










  • i took liberty and extend your explanation in you answer with my comment (instead of you).
    – Zarko
    24 mins ago















a figure is float environment as well a table is. both should not be included in any box...
– Zarko
2 hours ago




a figure is float environment as well a table is. both should not be included in any box...
– Zarko
2 hours ago












@Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
– Piroooh
2 hours ago




@Zarko yes, you are right. My answer mentions otherwise ? I can edit to avoid misunderstanding.
– Piroooh
2 hours ago












i took liberty and extend your explanation in you answer with my comment (instead of you).
– Zarko
24 mins ago




i took liberty and extend your explanation in you answer with my comment (instead of you).
– Zarko
24 mins ago










saleem is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















saleem is a new contributor. Be nice, and check out our Code of Conduct.












saleem is a new contributor. Be nice, and check out our Code of Conduct.











saleem is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457989%2finserting-image-in-example%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery