Why does the iterator in foreach not work?












2















I've split an animated GIF into the frames and saved them as a PNG sequence. I use the beamer class and want to load the images from the sequence, replacing each other without an autostart animation.



begin{frame}frametitle{FooBar}
foreach x in {0,...,5} {
includegraphics<x+1>[width=0.95textwidth]{dbgp-setup2-x.png}
}
end{frame}


The compiler output says that



Latexmk: Missing input file: 'dbgp-setup2-.png' from line



The filename should be dbgp-setup2-0.png, dbgp-setup2-1.png etc.. Why does x not work?










share|improve this question




















  • 2





    Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

    – marmot
    Feb 28 at 0:29













  • Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

    – Werner
    Feb 28 at 1:00











  • @Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

    – Christian
    Feb 28 at 21:31











  • @Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

    – Werner
    Feb 28 at 22:23
















2















I've split an animated GIF into the frames and saved them as a PNG sequence. I use the beamer class and want to load the images from the sequence, replacing each other without an autostart animation.



begin{frame}frametitle{FooBar}
foreach x in {0,...,5} {
includegraphics<x+1>[width=0.95textwidth]{dbgp-setup2-x.png}
}
end{frame}


The compiler output says that



Latexmk: Missing input file: 'dbgp-setup2-.png' from line



The filename should be dbgp-setup2-0.png, dbgp-setup2-1.png etc.. Why does x not work?










share|improve this question




















  • 2





    Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

    – marmot
    Feb 28 at 0:29













  • Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

    – Werner
    Feb 28 at 1:00











  • @Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

    – Christian
    Feb 28 at 21:31











  • @Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

    – Werner
    Feb 28 at 22:23














2












2








2








I've split an animated GIF into the frames and saved them as a PNG sequence. I use the beamer class and want to load the images from the sequence, replacing each other without an autostart animation.



begin{frame}frametitle{FooBar}
foreach x in {0,...,5} {
includegraphics<x+1>[width=0.95textwidth]{dbgp-setup2-x.png}
}
end{frame}


The compiler output says that



Latexmk: Missing input file: 'dbgp-setup2-.png' from line



The filename should be dbgp-setup2-0.png, dbgp-setup2-1.png etc.. Why does x not work?










share|improve this question
















I've split an animated GIF into the frames and saved them as a PNG sequence. I use the beamer class and want to load the images from the sequence, replacing each other without an autostart animation.



begin{frame}frametitle{FooBar}
foreach x in {0,...,5} {
includegraphics<x+1>[width=0.95textwidth]{dbgp-setup2-x.png}
}
end{frame}


The compiler output says that



Latexmk: Missing input file: 'dbgp-setup2-.png' from line



The filename should be dbgp-setup2-0.png, dbgp-setup2-1.png etc.. Why does x not work?







foreach






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 28 at 22:25









Werner

446k699871692




446k699871692










asked Feb 28 at 0:24









ChristianChristian

132




132








  • 2





    Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

    – marmot
    Feb 28 at 0:29













  • Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

    – Werner
    Feb 28 at 1:00











  • @Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

    – Christian
    Feb 28 at 21:31











  • @Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

    – Werner
    Feb 28 at 22:23














  • 2





    Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

    – marmot
    Feb 28 at 0:29













  • Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

    – Werner
    Feb 28 at 1:00











  • @Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

    – Christian
    Feb 28 at 21:31











  • @Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

    – Werner
    Feb 28 at 22:23








2




2





Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

– marmot
Feb 28 at 0:29







Welcome! Try foreach x [count=y] in {0,...,5} { includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x.png} } The parser does not know that it should compute the argument of <....>, so you have to do that.

– marmot
Feb 28 at 0:29















Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

– Werner
Feb 28 at 1:00





Are you sure dbgp-setup2-0.png, dbgp-setup2-1.png, ... are in the working folder?

– Werner
Feb 28 at 1:00













@Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

– Christian
Feb 28 at 21:31





@Werner yes they are. I've included graphicspath{ {./img/} } before. The package graphicx is also loaded.

– Christian
Feb 28 at 21:31













@Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

– Werner
Feb 28 at 22:23





@Christian: The solution to the question seem to be related to foreach that isn't defined. As such, the x isn't defined, leading to the missing number in the image reference. For future reference, include a complete, yet minimal example that allows us to replicate the behaviour. Such a minimal, working example (MWE) should start with documentclass and end with end{document} and allow the community to copy-and-paste-and-compile and see exactly what you're seeing. For that, use images from mwe and lipsum text, if needed.

– Werner
Feb 28 at 22:23










2 Answers
2






active

oldest

votes


















5














The parser does not parse x+1, so you need to do this yourself. In this case x+1 coincides with the count, so we can use this. (Of course I do not have your images so I renamed some standard images.)



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x [count=y] in {0,...,3} {
includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x}
}
end{frame}
end{document}


enter image description here






share|improve this answer



















  • 1





    I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

    – Christian
    Feb 28 at 21:46











  • @Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

    – marmot
    Feb 28 at 21:47



















0














I'm not sure why doing the thing so complicated:



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x in {0,...,3} {%
includegraphics<+>[width=0.95textwidth]{dbgp-setup2-x}%
}
end{frame}
end{document}


enter image description here






share|improve this answer
























  • Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

    – Christian
    Mar 1 at 0:47











  • @Christian It just tells beamer to use the object in another overlay

    – egreg
    Mar 1 at 10:44











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477058%2fwhy-does-the-iterator-in-foreach-not-work%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









5














The parser does not parse x+1, so you need to do this yourself. In this case x+1 coincides with the count, so we can use this. (Of course I do not have your images so I renamed some standard images.)



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x [count=y] in {0,...,3} {
includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x}
}
end{frame}
end{document}


enter image description here






share|improve this answer



















  • 1





    I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

    – Christian
    Feb 28 at 21:46











  • @Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

    – marmot
    Feb 28 at 21:47
















5














The parser does not parse x+1, so you need to do this yourself. In this case x+1 coincides with the count, so we can use this. (Of course I do not have your images so I renamed some standard images.)



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x [count=y] in {0,...,3} {
includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x}
}
end{frame}
end{document}


enter image description here






share|improve this answer



















  • 1





    I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

    – Christian
    Feb 28 at 21:46











  • @Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

    – marmot
    Feb 28 at 21:47














5












5








5







The parser does not parse x+1, so you need to do this yourself. In this case x+1 coincides with the count, so we can use this. (Of course I do not have your images so I renamed some standard images.)



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x [count=y] in {0,...,3} {
includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x}
}
end{frame}
end{document}


enter image description here






share|improve this answer













The parser does not parse x+1, so you need to do this yourself. In this case x+1 coincides with the count, so we can use this. (Of course I do not have your images so I renamed some standard images.)



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x [count=y] in {0,...,3} {
includegraphics<y>[width=0.95textwidth]{dbgp-setup2-x}
}
end{frame}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 28 at 0:42









marmotmarmot

106k5129243




106k5129243








  • 1





    I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

    – Christian
    Feb 28 at 21:46











  • @Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

    – marmot
    Feb 28 at 21:47














  • 1





    I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

    – Christian
    Feb 28 at 21:46











  • @Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

    – marmot
    Feb 28 at 21:47








1




1





I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

– Christian
Feb 28 at 21:46





I made two mistakes. The first one was not including usepackage{pgffor} and the second one was the one with x+1. Thank you, everything's working fine now!

– Christian
Feb 28 at 21:46













@Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

– marmot
Feb 28 at 21:47





@Christian Glad to hear! (The first one is hard to detect since you did not show your preamble.)

– marmot
Feb 28 at 21:47











0














I'm not sure why doing the thing so complicated:



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x in {0,...,3} {%
includegraphics<+>[width=0.95textwidth]{dbgp-setup2-x}%
}
end{frame}
end{document}


enter image description here






share|improve this answer
























  • Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

    – Christian
    Mar 1 at 0:47











  • @Christian It just tells beamer to use the object in another overlay

    – egreg
    Mar 1 at 10:44
















0














I'm not sure why doing the thing so complicated:



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x in {0,...,3} {%
includegraphics<+>[width=0.95textwidth]{dbgp-setup2-x}%
}
end{frame}
end{document}


enter image description here






share|improve this answer
























  • Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

    – Christian
    Mar 1 at 0:47











  • @Christian It just tells beamer to use the object in another overlay

    – egreg
    Mar 1 at 10:44














0












0








0







I'm not sure why doing the thing so complicated:



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x in {0,...,3} {%
includegraphics<+>[width=0.95textwidth]{dbgp-setup2-x}%
}
end{frame}
end{document}


enter image description here






share|improve this answer













I'm not sure why doing the thing so complicated:



documentclass{beamer}
usepackage{pgffor}
begin{document}
begin{frame}frametitle{FooBar}
foreach x in {0,...,3} {%
includegraphics<+>[width=0.95textwidth]{dbgp-setup2-x}%
}
end{frame}
end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 28 at 23:29









egregegreg

724k8819183223




724k8819183223













  • Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

    – Christian
    Mar 1 at 0:47











  • @Christian It just tells beamer to use the object in another overlay

    – egreg
    Mar 1 at 10:44



















  • Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

    – Christian
    Mar 1 at 0:47











  • @Christian It just tells beamer to use the object in another overlay

    – egreg
    Mar 1 at 10:44

















Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

– Christian
Mar 1 at 0:47





Excellent! What does the <+> exactly do? There is another detail that keeps the following images in position: %

– Christian
Mar 1 at 0:47













@Christian It just tells beamer to use the object in another overlay

– egreg
Mar 1 at 10:44





@Christian It just tells beamer to use the object in another overlay

– egreg
Mar 1 at 10:44


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f477058%2fwhy-does-the-iterator-in-foreach-not-work%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?