Is it wrong to use clearpage instead of newpage?
up vote
167
down vote
favorite
The commands newpage
and clearpage
both force a page break. In addition, the latter command also "flushes" all pending floats from the stack, i.e., forces them to be typeset starting on the page that follows the page break.
My question is: Is it ever a mistake to use clearpage
rather than newpage
, other than in cases where one might not want any pending floats to be flushed? From a casual inspection of the definitions of the two commands (see below), I can't tell if there's any trouble lurking in always using clearpage
.
For ease of reference, here's the definition of newpage
(from latex.ltx
):
def newpage {%
if@noskipsec
ifx @nodocumentrelax
leavevmode
global @noskipsecfalse
fi
fi
if@inlabel
leavevmode
global @inlabelfalse
fi
if@nobreak @nobreakfalse everypar{}fi
par
vfil
penalty -@M}
and here's the definition of clearpage
-- note that it invokes newpage
:
defclearpage{%
ifvmode
ifnum @dbltopnum =m@ne
ifdim pagetotal <topskip
hbox{}%
fi
fi
fi
newpage
writem@ne{}%
vbox{}%
penalty -@Mi
}
page-breaking
add a comment |
up vote
167
down vote
favorite
The commands newpage
and clearpage
both force a page break. In addition, the latter command also "flushes" all pending floats from the stack, i.e., forces them to be typeset starting on the page that follows the page break.
My question is: Is it ever a mistake to use clearpage
rather than newpage
, other than in cases where one might not want any pending floats to be flushed? From a casual inspection of the definitions of the two commands (see below), I can't tell if there's any trouble lurking in always using clearpage
.
For ease of reference, here's the definition of newpage
(from latex.ltx
):
def newpage {%
if@noskipsec
ifx @nodocumentrelax
leavevmode
global @noskipsecfalse
fi
fi
if@inlabel
leavevmode
global @inlabelfalse
fi
if@nobreak @nobreakfalse everypar{}fi
par
vfil
penalty -@M}
and here's the definition of clearpage
-- note that it invokes newpage
:
defclearpage{%
ifvmode
ifnum @dbltopnum =m@ne
ifdim pagetotal <topskip
hbox{}%
fi
fi
fi
newpage
writem@ne{}%
vbox{}%
penalty -@Mi
}
page-breaking
add a comment |
up vote
167
down vote
favorite
up vote
167
down vote
favorite
The commands newpage
and clearpage
both force a page break. In addition, the latter command also "flushes" all pending floats from the stack, i.e., forces them to be typeset starting on the page that follows the page break.
My question is: Is it ever a mistake to use clearpage
rather than newpage
, other than in cases where one might not want any pending floats to be flushed? From a casual inspection of the definitions of the two commands (see below), I can't tell if there's any trouble lurking in always using clearpage
.
For ease of reference, here's the definition of newpage
(from latex.ltx
):
def newpage {%
if@noskipsec
ifx @nodocumentrelax
leavevmode
global @noskipsecfalse
fi
fi
if@inlabel
leavevmode
global @inlabelfalse
fi
if@nobreak @nobreakfalse everypar{}fi
par
vfil
penalty -@M}
and here's the definition of clearpage
-- note that it invokes newpage
:
defclearpage{%
ifvmode
ifnum @dbltopnum =m@ne
ifdim pagetotal <topskip
hbox{}%
fi
fi
fi
newpage
writem@ne{}%
vbox{}%
penalty -@Mi
}
page-breaking
The commands newpage
and clearpage
both force a page break. In addition, the latter command also "flushes" all pending floats from the stack, i.e., forces them to be typeset starting on the page that follows the page break.
My question is: Is it ever a mistake to use clearpage
rather than newpage
, other than in cases where one might not want any pending floats to be flushed? From a casual inspection of the definitions of the two commands (see below), I can't tell if there's any trouble lurking in always using clearpage
.
For ease of reference, here's the definition of newpage
(from latex.ltx
):
def newpage {%
if@noskipsec
ifx @nodocumentrelax
leavevmode
global @noskipsecfalse
fi
fi
if@inlabel
leavevmode
global @inlabelfalse
fi
if@nobreak @nobreakfalse everypar{}fi
par
vfil
penalty -@M}
and here's the definition of clearpage
-- note that it invokes newpage
:
defclearpage{%
ifvmode
ifnum @dbltopnum =m@ne
ifdim pagetotal <topskip
hbox{}%
fi
fi
fi
newpage
writem@ne{}%
vbox{}%
penalty -@Mi
}
page-breaking
page-breaking
edited 3 mins ago
asked Feb 24 '12 at 10:41
Mico
272k30369756
272k30369756
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
171
down vote
accepted
Technically there is nothing wrong with using clearpage
instead of newpage
. However, the two commands have different semantics and the question is which of the semantics you are interested in.
First of all, as you already mentioned clearpage
not only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with newpage
you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast clearpage
would also output this float but on a page of its own.
So in situations like a chapter start it is advisable to end the previous chapter with a clearpage
(or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.
A second difference is clearpage
actually always starts a new "page" while newpage
really only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:
documentclass[twocolumn]{article}
begin{document}
A test
newpage % ends first column but not page
A second test
newpage
A clearpage test
clearpage % ends page (which has one column)
A second clearpage test
end{document}
Ok, I must claim I didn't think oftwocolumn
in my answer. But honestly: usingnewpage
orclearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.
– boycott.se - yo'
Feb 24 '12 at 13:27
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,newpage
is more appropriate in that case probably.
– boycott.se - yo'
Feb 24 '12 at 14:00
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,newpage
forces a new column whereasclearpage
forces a new page.
– Mico
Feb 24 '12 at 14:01
add a comment |
up vote
33
down vote
In my opinion, you can use clearpage
anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:
- a really empty page, then you call for instance
newpageleavevmodethispagestyle{empty}newpage
- something placed on a specific page or whatever (
clearpage
may add more than one pagebreak if there's a lot of queued floats, whereasnewpage
adds only one) - when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use
newpage
after typesetting the chapter title).
Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my chapter
mentioned above) or in preamble/...
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',
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%2f45609%2fis-it-wrong-to-use-clearpage-instead-of-newpage%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
up vote
171
down vote
accepted
Technically there is nothing wrong with using clearpage
instead of newpage
. However, the two commands have different semantics and the question is which of the semantics you are interested in.
First of all, as you already mentioned clearpage
not only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with newpage
you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast clearpage
would also output this float but on a page of its own.
So in situations like a chapter start it is advisable to end the previous chapter with a clearpage
(or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.
A second difference is clearpage
actually always starts a new "page" while newpage
really only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:
documentclass[twocolumn]{article}
begin{document}
A test
newpage % ends first column but not page
A second test
newpage
A clearpage test
clearpage % ends page (which has one column)
A second clearpage test
end{document}
Ok, I must claim I didn't think oftwocolumn
in my answer. But honestly: usingnewpage
orclearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.
– boycott.se - yo'
Feb 24 '12 at 13:27
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,newpage
is more appropriate in that case probably.
– boycott.se - yo'
Feb 24 '12 at 14:00
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,newpage
forces a new column whereasclearpage
forces a new page.
– Mico
Feb 24 '12 at 14:01
add a comment |
up vote
171
down vote
accepted
Technically there is nothing wrong with using clearpage
instead of newpage
. However, the two commands have different semantics and the question is which of the semantics you are interested in.
First of all, as you already mentioned clearpage
not only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with newpage
you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast clearpage
would also output this float but on a page of its own.
So in situations like a chapter start it is advisable to end the previous chapter with a clearpage
(or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.
A second difference is clearpage
actually always starts a new "page" while newpage
really only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:
documentclass[twocolumn]{article}
begin{document}
A test
newpage % ends first column but not page
A second test
newpage
A clearpage test
clearpage % ends page (which has one column)
A second clearpage test
end{document}
Ok, I must claim I didn't think oftwocolumn
in my answer. But honestly: usingnewpage
orclearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.
– boycott.se - yo'
Feb 24 '12 at 13:27
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,newpage
is more appropriate in that case probably.
– boycott.se - yo'
Feb 24 '12 at 14:00
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,newpage
forces a new column whereasclearpage
forces a new page.
– Mico
Feb 24 '12 at 14:01
add a comment |
up vote
171
down vote
accepted
up vote
171
down vote
accepted
Technically there is nothing wrong with using clearpage
instead of newpage
. However, the two commands have different semantics and the question is which of the semantics you are interested in.
First of all, as you already mentioned clearpage
not only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with newpage
you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast clearpage
would also output this float but on a page of its own.
So in situations like a chapter start it is advisable to end the previous chapter with a clearpage
(or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.
A second difference is clearpage
actually always starts a new "page" while newpage
really only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:
documentclass[twocolumn]{article}
begin{document}
A test
newpage % ends first column but not page
A second test
newpage
A clearpage test
clearpage % ends page (which has one column)
A second clearpage test
end{document}
Technically there is nothing wrong with using clearpage
instead of newpage
. However, the two commands have different semantics and the question is which of the semantics you are interested in.
First of all, as you already mentioned clearpage
not only ends the page (or column in two column mode) but additionally it flushes out all floats that have been deferred. On the face of it that might be a good idea but consider the following situation: you have one float waiting which is just 1/3 of the page size. Now with newpage
you start a new page and then the float algorithm (see description of this algorithm for details) would kick in and try to place waiting floats onto the next page (and most likely would assign the waiting float to the top area of the next page. In contrast clearpage
would also output this float but on a page of its own.
So in situations like a chapter start it is advisable to end the previous chapter with a clearpage
(or rather start the new one with it) to flush out all floats, but in other situations this might result fairly empty pages with only floats on them which may or may not be desired.
A second difference is clearpage
actually always starts a new "page" while newpage
really only ends the current column --- and that is a big difference in twocolumn mode. Just try the following to see the difference:
documentclass[twocolumn]{article}
begin{document}
A test
newpage % ends first column but not page
A second test
newpage
A clearpage test
clearpage % ends page (which has one column)
A second clearpage test
end{document}
edited Apr 13 '17 at 12:35
Community♦
1
1
answered Feb 24 '12 at 11:43
Frank Mittelbach
60k5175247
60k5175247
Ok, I must claim I didn't think oftwocolumn
in my answer. But honestly: usingnewpage
orclearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.
– boycott.se - yo'
Feb 24 '12 at 13:27
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,newpage
is more appropriate in that case probably.
– boycott.se - yo'
Feb 24 '12 at 14:00
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,newpage
forces a new column whereasclearpage
forces a new page.
– Mico
Feb 24 '12 at 14:01
add a comment |
Ok, I must claim I didn't think oftwocolumn
in my answer. But honestly: usingnewpage
orclearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.
– boycott.se - yo'
Feb 24 '12 at 13:27
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,newpage
is more appropriate in that case probably.
– boycott.se - yo'
Feb 24 '12 at 14:00
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,newpage
forces a new column whereasclearpage
forces a new page.
– Mico
Feb 24 '12 at 14:01
Ok, I must claim I didn't think of
twocolumn
in my answer. But honestly: using newpage
or clearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.– boycott.se - yo'
Feb 24 '12 at 13:27
Ok, I must claim I didn't think of
twocolumn
in my answer. But honestly: using newpage
or clearpage
inside a text block like chapter is really frowned upon in my opinion and should be done very carefully.– boycott.se - yo'
Feb 24 '12 at 13:27
4
4
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
@tohecz sure, but the question wasn't "should I use those commands at all (or when)" --- from a structural point of view they should most certainly only be used directly in a final editing stage and even then only if really necessary.
– Frank Mittelbach
Feb 24 '12 at 13:39
Yes, I know and somehow agree. And the truth is,
newpage
is more appropriate in that case probably.– boycott.se - yo'
Feb 24 '12 at 14:00
Yes, I know and somehow agree. And the truth is,
newpage
is more appropriate in that case probably.– boycott.se - yo'
Feb 24 '12 at 14:00
1
1
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,
newpage
forces a new column whereas clearpage
forces a new page.– Mico
Feb 24 '12 at 14:01
Thanks so much, Frank, for this detailed answer. I was completely unaware of the difference in the behavior of the two commands when LaTeX is in multicolumn mode, viz,
newpage
forces a new column whereas clearpage
forces a new page.– Mico
Feb 24 '12 at 14:01
add a comment |
up vote
33
down vote
In my opinion, you can use clearpage
anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:
- a really empty page, then you call for instance
newpageleavevmodethispagestyle{empty}newpage
- something placed on a specific page or whatever (
clearpage
may add more than one pagebreak if there's a lot of queued floats, whereasnewpage
adds only one) - when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use
newpage
after typesetting the chapter title).
Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my chapter
mentioned above) or in preamble/...
add a comment |
up vote
33
down vote
In my opinion, you can use clearpage
anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:
- a really empty page, then you call for instance
newpageleavevmodethispagestyle{empty}newpage
- something placed on a specific page or whatever (
clearpage
may add more than one pagebreak if there's a lot of queued floats, whereasnewpage
adds only one) - when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use
newpage
after typesetting the chapter title).
Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my chapter
mentioned above) or in preamble/...
add a comment |
up vote
33
down vote
up vote
33
down vote
In my opinion, you can use clearpage
anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:
- a really empty page, then you call for instance
newpageleavevmodethispagestyle{empty}newpage
- something placed on a specific page or whatever (
clearpage
may add more than one pagebreak if there's a lot of queued floats, whereasnewpage
adds only one) - when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use
newpage
after typesetting the chapter title).
Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my chapter
mentioned above) or in preamble/...
In my opinion, you can use clearpage
anywhere unless "there's a special reason for not doing so". This special reason for me is when you (for aestethic or whatever reason) really want to have:
- a really empty page, then you call for instance
newpageleavevmodethispagestyle{empty}newpage
- something placed on a specific page or whatever (
clearpage
may add more than one pagebreak if there's a lot of queued floats, whereasnewpage
adds only one) - when you want to have two pages just next to each other (I like it when chapter title in on the left page with no text, and text starts on the right page -- then I use
newpage
after typesetting the chapter title).
Surely all usage of any of these two commands should be conceptional, I mean, you shouldn't need to use them in a main text of your work, you use them in macro definitions (like my chapter
mentioned above) or in preamble/...
answered Feb 24 '12 at 11:42
boycott.se - yo'
39k8122231
39k8122231
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f45609%2fis-it-wrong-to-use-clearpage-instead-of-newpage%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