LaTeX - invalid page break for first includegraphics in chapter
I've created chapter containing only images with caption. All images shall have fixed width (textwidth), height is always unknown (image shall be correctly scaled).
From second image everything works fine, but first image has damaged page break, see the screenshot:

Current behaviour: chapter title is broken to next page, image itself is displayed to the same page although it doesn't fit.
Expected behaviour: chapter title stays on the first page, image is displayed to next page if it doesn't fit the previous.
Interesting is that for further images it works - if image doesn't fit, it's rendered correctly to following page.
I've tried to fix it using additional ~newline before first image, but it still provides wrong result:

Full code:
documentclass[a4paper]{book}
usepackage{fontspec}
usepackage{polyglossia}
setmainlanguage{czech}
usepackage{ulem}
usepackage{spverbatim}
usepackage[unicode]{hyperref}
defdo#1{apptoUrlSpecials{do#1{mathchar`#1 mskip 0mu plus 1mupenalty100relax}}}
do-do/dodo1do2do3do4do5do6do7do8do9doadobdocdoddoedofdogdohdoidojdokdoldomdondoodopdoqdordosdotdoudovdowdoxdoydozdoAdoBdoCdoDdoEdoFdoGdoHdoIdoJdoKdoLdoMdoNdoOdoPdoQdoRdoSdoTdoUdoVdoWdoXdoYdoZ
usepackage{graphicx}
usepackage{grffile}
usepackage{color}
usepackage{wrapfig}
usepackage{float}
usepackage{hologo}
usepackage{pdfpages}
usepackage{needspace}
intextsep=0pt
makeatletter
renewcommand{l@section}{@dottedtocline{1}{1.5em}{2.6em}}
renewcommand{l@subsection}{@dottedtocline{2}{4.0em}{3.6em}}
renewcommand{l@subsubsection}{@dottedtocline{3}{7.4em}{4.8em}}
makeatother
begin{document}
chapter{Chapter}
section{Section}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_0}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_0]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_1}
rule{textwidth}{0.61textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_1]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_2}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_2]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_3}
rule{textwidth}{1.3textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_3]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_4}
rule{textwidth}{1.5textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_4]{Dokument~9999}}
end{figure}
end{document}
Question is simple: how to display first image in chapter correctly? Solution shall be universal - for tall images which don't fit to page together with chapter title and for wide images which fit to the same page (so forcing page break doesn't help, height of images is unknown).
page-breaking chapters includegraphics
add a comment |
I've created chapter containing only images with caption. All images shall have fixed width (textwidth), height is always unknown (image shall be correctly scaled).
From second image everything works fine, but first image has damaged page break, see the screenshot:

Current behaviour: chapter title is broken to next page, image itself is displayed to the same page although it doesn't fit.
Expected behaviour: chapter title stays on the first page, image is displayed to next page if it doesn't fit the previous.
Interesting is that for further images it works - if image doesn't fit, it's rendered correctly to following page.
I've tried to fix it using additional ~newline before first image, but it still provides wrong result:

Full code:
documentclass[a4paper]{book}
usepackage{fontspec}
usepackage{polyglossia}
setmainlanguage{czech}
usepackage{ulem}
usepackage{spverbatim}
usepackage[unicode]{hyperref}
defdo#1{apptoUrlSpecials{do#1{mathchar`#1 mskip 0mu plus 1mupenalty100relax}}}
do-do/dodo1do2do3do4do5do6do7do8do9doadobdocdoddoedofdogdohdoidojdokdoldomdondoodopdoqdordosdotdoudovdowdoxdoydozdoAdoBdoCdoDdoEdoFdoGdoHdoIdoJdoKdoLdoMdoNdoOdoPdoQdoRdoSdoTdoUdoVdoWdoXdoYdoZ
usepackage{graphicx}
usepackage{grffile}
usepackage{color}
usepackage{wrapfig}
usepackage{float}
usepackage{hologo}
usepackage{pdfpages}
usepackage{needspace}
intextsep=0pt
makeatletter
renewcommand{l@section}{@dottedtocline{1}{1.5em}{2.6em}}
renewcommand{l@subsection}{@dottedtocline{2}{4.0em}{3.6em}}
renewcommand{l@subsubsection}{@dottedtocline{3}{7.4em}{4.8em}}
makeatother
begin{document}
chapter{Chapter}
section{Section}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_0}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_0]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_1}
rule{textwidth}{0.61textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_1]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_2}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_2]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_3}
rule{textwidth}{1.3textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_3]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_4}
rule{textwidth}{1.5textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_4]{Dokument~9999}}
end{figure}
end{document}
Question is simple: how to display first image in chapter correctly? Solution shall be universal - for tall images which don't fit to page together with chapter title and for wide images which fit to the same page (so forcing page break doesn't help, height of images is unknown).
page-breaking chapters includegraphics
1
the whole reason that figures are normally floating environments is to help with page breaking, but you have use[H]so disabled that mechanism and not allowed latex to adjust the figure positions.
– David Carlisle
Jan 1 at 21:26
1
all warnings about bad page breaks go if you change every[H]to[htp]
– David Carlisle
Jan 1 at 21:27
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
1
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
Solution works fine, thank you
– Joseph
Jan 2 at 21:09
add a comment |
I've created chapter containing only images with caption. All images shall have fixed width (textwidth), height is always unknown (image shall be correctly scaled).
From second image everything works fine, but first image has damaged page break, see the screenshot:

Current behaviour: chapter title is broken to next page, image itself is displayed to the same page although it doesn't fit.
Expected behaviour: chapter title stays on the first page, image is displayed to next page if it doesn't fit the previous.
Interesting is that for further images it works - if image doesn't fit, it's rendered correctly to following page.
I've tried to fix it using additional ~newline before first image, but it still provides wrong result:

Full code:
documentclass[a4paper]{book}
usepackage{fontspec}
usepackage{polyglossia}
setmainlanguage{czech}
usepackage{ulem}
usepackage{spverbatim}
usepackage[unicode]{hyperref}
defdo#1{apptoUrlSpecials{do#1{mathchar`#1 mskip 0mu plus 1mupenalty100relax}}}
do-do/dodo1do2do3do4do5do6do7do8do9doadobdocdoddoedofdogdohdoidojdokdoldomdondoodopdoqdordosdotdoudovdowdoxdoydozdoAdoBdoCdoDdoEdoFdoGdoHdoIdoJdoKdoLdoMdoNdoOdoPdoQdoRdoSdoTdoUdoVdoWdoXdoYdoZ
usepackage{graphicx}
usepackage{grffile}
usepackage{color}
usepackage{wrapfig}
usepackage{float}
usepackage{hologo}
usepackage{pdfpages}
usepackage{needspace}
intextsep=0pt
makeatletter
renewcommand{l@section}{@dottedtocline{1}{1.5em}{2.6em}}
renewcommand{l@subsection}{@dottedtocline{2}{4.0em}{3.6em}}
renewcommand{l@subsubsection}{@dottedtocline{3}{7.4em}{4.8em}}
makeatother
begin{document}
chapter{Chapter}
section{Section}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_0}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_0]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_1}
rule{textwidth}{0.61textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_1]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_2}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_2]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_3}
rule{textwidth}{1.3textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_3]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_4}
rule{textwidth}{1.5textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_4]{Dokument~9999}}
end{figure}
end{document}
Question is simple: how to display first image in chapter correctly? Solution shall be universal - for tall images which don't fit to page together with chapter title and for wide images which fit to the same page (so forcing page break doesn't help, height of images is unknown).
page-breaking chapters includegraphics
I've created chapter containing only images with caption. All images shall have fixed width (textwidth), height is always unknown (image shall be correctly scaled).
From second image everything works fine, but first image has damaged page break, see the screenshot:

Current behaviour: chapter title is broken to next page, image itself is displayed to the same page although it doesn't fit.
Expected behaviour: chapter title stays on the first page, image is displayed to next page if it doesn't fit the previous.
Interesting is that for further images it works - if image doesn't fit, it's rendered correctly to following page.
I've tried to fix it using additional ~newline before first image, but it still provides wrong result:

Full code:
documentclass[a4paper]{book}
usepackage{fontspec}
usepackage{polyglossia}
setmainlanguage{czech}
usepackage{ulem}
usepackage{spverbatim}
usepackage[unicode]{hyperref}
defdo#1{apptoUrlSpecials{do#1{mathchar`#1 mskip 0mu plus 1mupenalty100relax}}}
do-do/dodo1do2do3do4do5do6do7do8do9doadobdocdoddoedofdogdohdoidojdokdoldomdondoodopdoqdordosdotdoudovdowdoxdoydozdoAdoBdoCdoDdoEdoFdoGdoHdoIdoJdoKdoLdoMdoNdoOdoPdoQdoRdoSdoTdoUdoVdoWdoXdoYdoZ
usepackage{graphicx}
usepackage{grffile}
usepackage{color}
usepackage{wrapfig}
usepackage{float}
usepackage{hologo}
usepackage{pdfpages}
usepackage{needspace}
intextsep=0pt
makeatletter
renewcommand{l@section}{@dottedtocline{1}{1.5em}{2.6em}}
renewcommand{l@subsection}{@dottedtocline{2}{4.0em}{3.6em}}
renewcommand{l@subsubsection}{@dottedtocline{3}{7.4em}{4.8em}}
makeatother
begin{document}
chapter{Chapter}
section{Section}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_0}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_0]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_1}
rule{textwidth}{0.61textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_1]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_2}
rule{textwidth}{1.41textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_2]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_3}
rule{textwidth}{1.3textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_3]{Dokument~9999}}
end{figure}
begin{figure}[H]
centering
phantomsectionlabel{ID_FIL_DISPLAY_DOC_4}
rule{textwidth}{1.5textwidth}
caption{hyperref[ID_FIL_DISPLAY_DOC_4]{Dokument~9999}}
end{figure}
end{document}
Question is simple: how to display first image in chapter correctly? Solution shall be universal - for tall images which don't fit to page together with chapter title and for wide images which fit to the same page (so forcing page break doesn't help, height of images is unknown).
page-breaking chapters includegraphics
page-breaking chapters includegraphics
asked Jan 1 at 21:19
JosephJoseph
374
374
1
the whole reason that figures are normally floating environments is to help with page breaking, but you have use[H]so disabled that mechanism and not allowed latex to adjust the figure positions.
– David Carlisle
Jan 1 at 21:26
1
all warnings about bad page breaks go if you change every[H]to[htp]
– David Carlisle
Jan 1 at 21:27
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
1
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
Solution works fine, thank you
– Joseph
Jan 2 at 21:09
add a comment |
1
the whole reason that figures are normally floating environments is to help with page breaking, but you have use[H]so disabled that mechanism and not allowed latex to adjust the figure positions.
– David Carlisle
Jan 1 at 21:26
1
all warnings about bad page breaks go if you change every[H]to[htp]
– David Carlisle
Jan 1 at 21:27
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
1
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
Solution works fine, thank you
– Joseph
Jan 2 at 21:09
1
1
the whole reason that figures are normally floating environments is to help with page breaking, but you have use
[H] so disabled that mechanism and not allowed latex to adjust the figure positions.– David Carlisle
Jan 1 at 21:26
the whole reason that figures are normally floating environments is to help with page breaking, but you have use
[H] so disabled that mechanism and not allowed latex to adjust the figure positions.– David Carlisle
Jan 1 at 21:26
1
1
all warnings about bad page breaks go if you change every
[H] to [htp]– David Carlisle
Jan 1 at 21:27
all warnings about bad page breaks go if you change every
[H] to [htp]– David Carlisle
Jan 1 at 21:27
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
1
1
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
Solution works fine, thank you
– Joseph
Jan 2 at 21:09
Solution works fine, thank you
– Joseph
Jan 2 at 21:09
add a comment |
0
active
oldest
votes
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%2f468178%2flatex-invalid-page-break-for-first-includegraphics-in-chapter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f468178%2flatex-invalid-page-break-for-first-includegraphics-in-chapter%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
the whole reason that figures are normally floating environments is to help with page breaking, but you have use
[H]so disabled that mechanism and not allowed latex to adjust the figure positions.– David Carlisle
Jan 1 at 21:26
1
all warnings about bad page breaks go if you change every
[H]to[htp]– David Carlisle
Jan 1 at 21:27
@David Carlisle: it looks better with [htp], but new issue has arised: images are vertically centered. How to draw them from the top of page?
– Joseph
Jan 1 at 21:40
1
tex.stackexchange.com/questions/28556/…
– David Carlisle
Jan 1 at 21:41
Solution works fine, thank you
– Joseph
Jan 2 at 21:09