Algorithm keeps appearing on the last page of my latex document
I am writing an algorithm with the algorithmic environment and Latex keeps pushing it on the last page, no matter what I do, this is just a short example.
documentclass[a4paper,10pt, twoside]{book}
usepackage{algorithm}
usepackage{algorithmic}
usepackage[utf8]{inputenc}
begin{document}
begin{algorithm}[h]
caption{my algorithm}
label{alg:example}
begin{algorithmic}
STATE REQUIRE (F, G, j)
STATE (B_{1} = {b_{1}[1],dots,b_{1}[|g_r|]})
STATE (B_{1})
FOR{(i=1) TO (n)}
STATE DO smoething...
STATE
ENDFOR
ENDFOR
end{algorithmic}
end{algorithm}
end{document}
The problem is that the algorithm is one page long, so I tried to put the h argument, and then after the algorithm a newpage, so that everything else comes after it. But still it just ignores all my command and puts in on the last page, no matter what I try :S
algorithms algorithmic
|
show 1 more comment
I am writing an algorithm with the algorithmic environment and Latex keeps pushing it on the last page, no matter what I do, this is just a short example.
documentclass[a4paper,10pt, twoside]{book}
usepackage{algorithm}
usepackage{algorithmic}
usepackage[utf8]{inputenc}
begin{document}
begin{algorithm}[h]
caption{my algorithm}
label{alg:example}
begin{algorithmic}
STATE REQUIRE (F, G, j)
STATE (B_{1} = {b_{1}[1],dots,b_{1}[|g_r|]})
STATE (B_{1})
FOR{(i=1) TO (n)}
STATE DO smoething...
STATE
ENDFOR
ENDFOR
end{algorithmic}
end{algorithm}
end{document}
The problem is that the algorithm is one page long, so I tried to put the h argument, and then after the algorithm a newpage, so that everything else comes after it. But still it just ignores all my command and puts in on the last page, no matter what I try :S
algorithms algorithmic
1
Welcome to TeX.SX! Obviouslyalgorithm
is an environment with floating enabled.
– user31729
Oct 5 '14 at 11:39
What Christian means is that you shouldn't specifyh
in the optional argument of thealgorithm
environment. Let that environment "float".
– jubobs
Oct 5 '14 at 11:42
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
[h]
tells latex the float isn't allowed at the top of a page (as not
) or bottom (nob
) or on a page of floats (nop
) which gives latex very few places to place it so holding it to the end is quite likely
– David Carlisle
Oct 5 '14 at 11:49
|
show 1 more comment
I am writing an algorithm with the algorithmic environment and Latex keeps pushing it on the last page, no matter what I do, this is just a short example.
documentclass[a4paper,10pt, twoside]{book}
usepackage{algorithm}
usepackage{algorithmic}
usepackage[utf8]{inputenc}
begin{document}
begin{algorithm}[h]
caption{my algorithm}
label{alg:example}
begin{algorithmic}
STATE REQUIRE (F, G, j)
STATE (B_{1} = {b_{1}[1],dots,b_{1}[|g_r|]})
STATE (B_{1})
FOR{(i=1) TO (n)}
STATE DO smoething...
STATE
ENDFOR
ENDFOR
end{algorithmic}
end{algorithm}
end{document}
The problem is that the algorithm is one page long, so I tried to put the h argument, and then after the algorithm a newpage, so that everything else comes after it. But still it just ignores all my command and puts in on the last page, no matter what I try :S
algorithms algorithmic
I am writing an algorithm with the algorithmic environment and Latex keeps pushing it on the last page, no matter what I do, this is just a short example.
documentclass[a4paper,10pt, twoside]{book}
usepackage{algorithm}
usepackage{algorithmic}
usepackage[utf8]{inputenc}
begin{document}
begin{algorithm}[h]
caption{my algorithm}
label{alg:example}
begin{algorithmic}
STATE REQUIRE (F, G, j)
STATE (B_{1} = {b_{1}[1],dots,b_{1}[|g_r|]})
STATE (B_{1})
FOR{(i=1) TO (n)}
STATE DO smoething...
STATE
ENDFOR
ENDFOR
end{algorithmic}
end{algorithm}
end{document}
The problem is that the algorithm is one page long, so I tried to put the h argument, and then after the algorithm a newpage, so that everything else comes after it. But still it just ignores all my command and puts in on the last page, no matter what I try :S
algorithms algorithmic
algorithms algorithmic
asked Oct 5 '14 at 11:36
user63716user63716
6113
6113
1
Welcome to TeX.SX! Obviouslyalgorithm
is an environment with floating enabled.
– user31729
Oct 5 '14 at 11:39
What Christian means is that you shouldn't specifyh
in the optional argument of thealgorithm
environment. Let that environment "float".
– jubobs
Oct 5 '14 at 11:42
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
[h]
tells latex the float isn't allowed at the top of a page (as not
) or bottom (nob
) or on a page of floats (nop
) which gives latex very few places to place it so holding it to the end is quite likely
– David Carlisle
Oct 5 '14 at 11:49
|
show 1 more comment
1
Welcome to TeX.SX! Obviouslyalgorithm
is an environment with floating enabled.
– user31729
Oct 5 '14 at 11:39
What Christian means is that you shouldn't specifyh
in the optional argument of thealgorithm
environment. Let that environment "float".
– jubobs
Oct 5 '14 at 11:42
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
[h]
tells latex the float isn't allowed at the top of a page (as not
) or bottom (nob
) or on a page of floats (nop
) which gives latex very few places to place it so holding it to the end is quite likely
– David Carlisle
Oct 5 '14 at 11:49
1
1
Welcome to TeX.SX! Obviously
algorithm
is an environment with floating enabled.– user31729
Oct 5 '14 at 11:39
Welcome to TeX.SX! Obviously
algorithm
is an environment with floating enabled.– user31729
Oct 5 '14 at 11:39
What Christian means is that you shouldn't specify
h
in the optional argument of the algorithm
environment. Let that environment "float".– jubobs
Oct 5 '14 at 11:42
What Christian means is that you shouldn't specify
h
in the optional argument of the algorithm
environment. Let that environment "float".– jubobs
Oct 5 '14 at 11:42
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
[h]
tells latex the float isn't allowed at the top of a page (as no t
) or bottom (no b
) or on a page of floats (no p
) which gives latex very few places to place it so holding it to the end is quite likely– David Carlisle
Oct 5 '14 at 11:49
[h]
tells latex the float isn't allowed at the top of a page (as no t
) or bottom (no b
) or on a page of floats (no p
) which gives latex very few places to place it so holding it to the end is quite likely– David Carlisle
Oct 5 '14 at 11:49
|
show 1 more comment
1 Answer
1
active
oldest
votes
Replace begin{algorithm}[h]
by begin{algorithm}[H]
in your code.
It would place the float precisely (instead of approximately) at the location in the LATEX code. See float specifiers.
Note that there are some drawbacks may appear when use [H] specifier Drawbacks of the [H] specifier. However, it works without any problems in my code (which is too long to attach here, according to the nature of the problem).
Alternatively, the specifier [!htbp] works also and without wasting any page area before the algorithm position.
Both specifiers works in my code without any errors.
1
[!]
will only work by coincident because!
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option!htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning withLaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use[!]
in your answer, it might be better to suggest[!htbp]
because this is the configuration which is actually used.
– user36296
Mar 30 at 13:28
|
show 2 more comments
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%2f204649%2falgorithm-keeps-appearing-on-the-last-page-of-my-latex-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Replace begin{algorithm}[h]
by begin{algorithm}[H]
in your code.
It would place the float precisely (instead of approximately) at the location in the LATEX code. See float specifiers.
Note that there are some drawbacks may appear when use [H] specifier Drawbacks of the [H] specifier. However, it works without any problems in my code (which is too long to attach here, according to the nature of the problem).
Alternatively, the specifier [!htbp] works also and without wasting any page area before the algorithm position.
Both specifiers works in my code without any errors.
1
[!]
will only work by coincident because!
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option!htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning withLaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use[!]
in your answer, it might be better to suggest[!htbp]
because this is the configuration which is actually used.
– user36296
Mar 30 at 13:28
|
show 2 more comments
Replace begin{algorithm}[h]
by begin{algorithm}[H]
in your code.
It would place the float precisely (instead of approximately) at the location in the LATEX code. See float specifiers.
Note that there are some drawbacks may appear when use [H] specifier Drawbacks of the [H] specifier. However, it works without any problems in my code (which is too long to attach here, according to the nature of the problem).
Alternatively, the specifier [!htbp] works also and without wasting any page area before the algorithm position.
Both specifiers works in my code without any errors.
1
[!]
will only work by coincident because!
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option!htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning withLaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use[!]
in your answer, it might be better to suggest[!htbp]
because this is the configuration which is actually used.
– user36296
Mar 30 at 13:28
|
show 2 more comments
Replace begin{algorithm}[h]
by begin{algorithm}[H]
in your code.
It would place the float precisely (instead of approximately) at the location in the LATEX code. See float specifiers.
Note that there are some drawbacks may appear when use [H] specifier Drawbacks of the [H] specifier. However, it works without any problems in my code (which is too long to attach here, according to the nature of the problem).
Alternatively, the specifier [!htbp] works also and without wasting any page area before the algorithm position.
Both specifiers works in my code without any errors.
Replace begin{algorithm}[h]
by begin{algorithm}[H]
in your code.
It would place the float precisely (instead of approximately) at the location in the LATEX code. See float specifiers.
Note that there are some drawbacks may appear when use [H] specifier Drawbacks of the [H] specifier. However, it works without any problems in my code (which is too long to attach here, according to the nature of the problem).
Alternatively, the specifier [!htbp] works also and without wasting any page area before the algorithm position.
Both specifiers works in my code without any errors.
edited Mar 30 at 18:27
answered Mar 29 at 18:57
Mohamed SalamaMohamed Salama
112
112
1
[!]
will only work by coincident because!
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option!htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning withLaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use[!]
in your answer, it might be better to suggest[!htbp]
because this is the configuration which is actually used.
– user36296
Mar 30 at 13:28
|
show 2 more comments
1
[!]
will only work by coincident because!
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option!htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning withLaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use[!]
in your answer, it might be better to suggest[!htbp]
because this is the configuration which is actually used.
– user36296
Mar 30 at 13:28
1
1
[!]
will only work by coincident because !
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option !htbp
– user36296
Mar 29 at 19:03
[!]
will only work by coincident because !
is on it's own no valid option for the floating specifier and will issue a warning and be replaced with the default option !htbp
– user36296
Mar 29 at 19:03
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
According to this blog, it works on determining "good" float positions. It did not issue a warning in my code, and I searched for what is possible problems associated with [!] and did not find there would be any warning issues.
– Mohamed Salama
Mar 29 at 19:30
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning with LaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
!
can only be used in combination with other floating specifier, such as h, t, b or p, not on its own. You'll get a warning with LaTeX Warning: No positions in optional float specifier. Default added (so using !htbp) on input line 8.
– user36296
Mar 29 at 21:12
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
Yes, you are right. I just found this warning. However, the pdf is generated as required.
– Mohamed Salama
Mar 30 at 2:40
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use
[!]
in your answer, it might be better to suggest [!htbp]
because this is the configuration which is actually used.– user36296
Mar 30 at 13:28
As the warning tells you, the missing arguments are replaced with the default ones, that's why the pdf is generated as it should. So instead of suggesting to use
[!]
in your answer, it might be better to suggest [!htbp]
because this is the configuration which is actually used.– user36296
Mar 30 at 13:28
|
show 2 more comments
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%2f204649%2falgorithm-keeps-appearing-on-the-last-page-of-my-latex-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
1
Welcome to TeX.SX! Obviously
algorithm
is an environment with floating enabled.– user31729
Oct 5 '14 at 11:39
What Christian means is that you shouldn't specify
h
in the optional argument of thealgorithm
environment. Let that environment "float".– jubobs
Oct 5 '14 at 11:42
@Jubobs: Yes, I was too quick ;-) More over, the code does not compile at all
– user31729
Oct 5 '14 at 11:43
Ok sorry for putting an uncompilable code there, I just tried to copy as fast as possible a short example. my fault. Oh wow it worked... But isn't figure also an floating environment, because I-ve seen a lot of examples using the htb arguments for figures?
– user63716
Oct 5 '14 at 11:48
[h]
tells latex the float isn't allowed at the top of a page (as not
) or bottom (nob
) or on a page of floats (nop
) which gives latex very few places to place it so holding it to the end is quite likely– David Carlisle
Oct 5 '14 at 11:49