How to prevent a line break after insertion of a figure in to a body of text
I am inserting a figure into a body of text using the 'h' float specifier. In the example below, the figure is placed at the beginning of the next page (2) since there isn't enough room left on the current page (1).
Current code:
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.
begin{figure}[h]
centering
includegraphics[scale=0.35]{./fig1}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure
end{document}
The text that follows immediately after the figure fills the remainder of page 1, but starts on a new line. Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?
Thanks for your help!
floats
New contributor
add a comment |
I am inserting a figure into a body of text using the 'h' float specifier. In the example below, the figure is placed at the beginning of the next page (2) since there isn't enough room left on the current page (1).
Current code:
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.
begin{figure}[h]
centering
includegraphics[scale=0.35]{./fig1}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure
end{document}
The text that follows immediately after the figure fills the remainder of page 1, but starts on a new line. Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?
Thanks for your help!
floats
New contributor
add a comment |
I am inserting a figure into a body of text using the 'h' float specifier. In the example below, the figure is placed at the beginning of the next page (2) since there isn't enough room left on the current page (1).
Current code:
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.
begin{figure}[h]
centering
includegraphics[scale=0.35]{./fig1}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure
end{document}
The text that follows immediately after the figure fills the remainder of page 1, but starts on a new line. Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?
Thanks for your help!
floats
New contributor
I am inserting a figure into a body of text using the 'h' float specifier. In the example below, the figure is placed at the beginning of the next page (2) since there isn't enough room left on the current page (1).
Current code:
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.
begin{figure}[h]
centering
includegraphics[scale=0.35]{./fig1}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure after figure
end{document}
The text that follows immediately after the figure fills the remainder of page 1, but starts on a new line. Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?
Thanks for your help!
floats
floats
New contributor
New contributor
New contributor
asked yesterday
GraduatedDylinderGraduatedDylinder
184
184
New contributor
New contributor
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
It is not the figure that inserted the newline (actually, paragraph break) you added it explicitly in the source file, the blank line forces a paragraph break, you would see the same if you deleted the figure.
Simply remove the blank lines.
It is almost always better to use [htp]
rather than [h]
normally LaTeX warns about [h]
and changes it to [ht]
to make it possible to set the figure.
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
add a comment |
To exemplify David Carlisle's answer
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
begin{figure}[h]
centering
includegraphics[scale=0.35]{example-image-a}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after
figure after figure after figure after figure
after figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after figure after
figure after figure after figure after figure after figure after
end{document}
add a comment |
If you need precision when placing images, may I suggest not using floats.
Floats allow images to swim around the text to provide the ideal placement according to TeX's programmed penalties. The whole purpose is to try and make them show up at the top, middle, or bottom of pages depending on how the text gets laid out while typesetting.
Here is an example of a custom figure environment that does not function as a float (despite the float caption type). I just hijacked the existing caption code, which is designed to work within float environments.
documentclass{article}
usepackage{xparse}% for LaTeX3's NewDocumentEnvironment
usepackage{graphicx}% for includegraphics
makeatletter
NewDocumentEnvironment{myfigure}{ O{} m }
{%
def@captype{figure}% see source2e for using caption outside of float
includegraphics[#1]{#2}%
}
{}
makeatother
begin{document}
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
%caption{Here is a caption.}
end{myfigure}
After after after
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
caption{Here is a caption.} % note that this adds a new line, but could be remedied by boxing the whole thing in the environment
end{myfigure}
After after after
end{document}
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with theAfter....
text.
– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the wordAfter
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.
– David Carlisle
yesterday
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',
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
});
}
});
GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.
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%2f472894%2fhow-to-prevent-a-line-break-after-insertion-of-a-figure-in-to-a-body-of-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
It is not the figure that inserted the newline (actually, paragraph break) you added it explicitly in the source file, the blank line forces a paragraph break, you would see the same if you deleted the figure.
Simply remove the blank lines.
It is almost always better to use [htp]
rather than [h]
normally LaTeX warns about [h]
and changes it to [ht]
to make it possible to set the figure.
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
add a comment |
It is not the figure that inserted the newline (actually, paragraph break) you added it explicitly in the source file, the blank line forces a paragraph break, you would see the same if you deleted the figure.
Simply remove the blank lines.
It is almost always better to use [htp]
rather than [h]
normally LaTeX warns about [h]
and changes it to [ht]
to make it possible to set the figure.
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
add a comment |
It is not the figure that inserted the newline (actually, paragraph break) you added it explicitly in the source file, the blank line forces a paragraph break, you would see the same if you deleted the figure.
Simply remove the blank lines.
It is almost always better to use [htp]
rather than [h]
normally LaTeX warns about [h]
and changes it to [ht]
to make it possible to set the figure.
It is not the figure that inserted the newline (actually, paragraph break) you added it explicitly in the source file, the blank line forces a paragraph break, you would see the same if you deleted the figure.
Simply remove the blank lines.
It is almost always better to use [htp]
rather than [h]
normally LaTeX warns about [h]
and changes it to [ht]
to make it possible to set the figure.
answered yesterday
David CarlisleDavid Carlisle
488k4111271874
488k4111271874
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
add a comment |
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
Building on this, for source-readability, I often preserve whitespace around a mid-paragraph figure (or equation) by putting in a set of empty-comment lines before and after the environment.
– RLH
yesterday
add a comment |
To exemplify David Carlisle's answer
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
begin{figure}[h]
centering
includegraphics[scale=0.35]{example-image-a}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after
figure after figure after figure after figure
after figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after figure after
figure after figure after figure after figure after figure after
end{document}
add a comment |
To exemplify David Carlisle's answer
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
begin{figure}[h]
centering
includegraphics[scale=0.35]{example-image-a}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after
figure after figure after figure after figure
after figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after figure after
figure after figure after figure after figure after figure after
end{document}
add a comment |
To exemplify David Carlisle's answer
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
begin{figure}[h]
centering
includegraphics[scale=0.35]{example-image-a}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after
figure after figure after figure after figure
after figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after figure after
figure after figure after figure after figure after figure after
end{document}
To exemplify David Carlisle's answer
documentclass[11pt, oneside, letterpaper]{book}
usepackage{graphicx}
begin{document}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum orem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum orem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum orem
begin{figure}[h]
centering
includegraphics[scale=0.35]{example-image-a}
caption{This is a figure caption.}
label{fig:figure1}
end{figure}
after figure after figure after
figure after figure after figure after figure
after figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after
figure after figure after figure after figure after figure after
figure after figure after figure after figure after figure after
end{document}
answered yesterday
DenisDenis
2,303520
2,303520
add a comment |
add a comment |
If you need precision when placing images, may I suggest not using floats.
Floats allow images to swim around the text to provide the ideal placement according to TeX's programmed penalties. The whole purpose is to try and make them show up at the top, middle, or bottom of pages depending on how the text gets laid out while typesetting.
Here is an example of a custom figure environment that does not function as a float (despite the float caption type). I just hijacked the existing caption code, which is designed to work within float environments.
documentclass{article}
usepackage{xparse}% for LaTeX3's NewDocumentEnvironment
usepackage{graphicx}% for includegraphics
makeatletter
NewDocumentEnvironment{myfigure}{ O{} m }
{%
def@captype{figure}% see source2e for using caption outside of float
includegraphics[#1]{#2}%
}
{}
makeatother
begin{document}
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
%caption{Here is a caption.}
end{myfigure}
After after after
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
caption{Here is a caption.} % note that this adds a new line, but could be remedied by boxing the whole thing in the environment
end{myfigure}
After after after
end{document}
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with theAfter....
text.
– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the wordAfter
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.
– David Carlisle
yesterday
add a comment |
If you need precision when placing images, may I suggest not using floats.
Floats allow images to swim around the text to provide the ideal placement according to TeX's programmed penalties. The whole purpose is to try and make them show up at the top, middle, or bottom of pages depending on how the text gets laid out while typesetting.
Here is an example of a custom figure environment that does not function as a float (despite the float caption type). I just hijacked the existing caption code, which is designed to work within float environments.
documentclass{article}
usepackage{xparse}% for LaTeX3's NewDocumentEnvironment
usepackage{graphicx}% for includegraphics
makeatletter
NewDocumentEnvironment{myfigure}{ O{} m }
{%
def@captype{figure}% see source2e for using caption outside of float
includegraphics[#1]{#2}%
}
{}
makeatother
begin{document}
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
%caption{Here is a caption.}
end{myfigure}
After after after
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
caption{Here is a caption.} % note that this adds a new line, but could be remedied by boxing the whole thing in the environment
end{myfigure}
After after after
end{document}
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with theAfter....
text.
– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the wordAfter
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.
– David Carlisle
yesterday
add a comment |
If you need precision when placing images, may I suggest not using floats.
Floats allow images to swim around the text to provide the ideal placement according to TeX's programmed penalties. The whole purpose is to try and make them show up at the top, middle, or bottom of pages depending on how the text gets laid out while typesetting.
Here is an example of a custom figure environment that does not function as a float (despite the float caption type). I just hijacked the existing caption code, which is designed to work within float environments.
documentclass{article}
usepackage{xparse}% for LaTeX3's NewDocumentEnvironment
usepackage{graphicx}% for includegraphics
makeatletter
NewDocumentEnvironment{myfigure}{ O{} m }
{%
def@captype{figure}% see source2e for using caption outside of float
includegraphics[#1]{#2}%
}
{}
makeatother
begin{document}
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
%caption{Here is a caption.}
end{myfigure}
After after after
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
caption{Here is a caption.} % note that this adds a new line, but could be remedied by boxing the whole thing in the environment
end{myfigure}
After after after
end{document}
If you need precision when placing images, may I suggest not using floats.
Floats allow images to swim around the text to provide the ideal placement according to TeX's programmed penalties. The whole purpose is to try and make them show up at the top, middle, or bottom of pages depending on how the text gets laid out while typesetting.
Here is an example of a custom figure environment that does not function as a float (despite the float caption type). I just hijacked the existing caption code, which is designed to work within float environments.
documentclass{article}
usepackage{xparse}% for LaTeX3's NewDocumentEnvironment
usepackage{graphicx}% for includegraphics
makeatletter
NewDocumentEnvironment{myfigure}{ O{} m }
{%
def@captype{figure}% see source2e for using caption outside of float
includegraphics[#1]{#2}%
}
{}
makeatother
begin{document}
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
%caption{Here is a caption.}
end{myfigure}
After after after
Before before before
begin{myfigure}[width=.3textwidth]{Router_Diagram.pdf}
caption{Here is a caption.} % note that this adds a new line, but could be remedied by boxing the whole thing in the environment
end{myfigure}
After after after
end{document}
edited yesterday
answered yesterday
Jonathan KomarJonathan Komar
6,57633077
6,57633077
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with theAfter....
text.
– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the wordAfter
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.
– David Carlisle
yesterday
add a comment |
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with theAfter....
text.
– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the wordAfter
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.
– David Carlisle
yesterday
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with the
After....
text.– David Carlisle
yesterday
the one line capt-of package could be used to define the caption (using the same code) but this does not answer the OPs question, the question is how to avoid starting a paragraph with the
After....
text.– David Carlisle
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
@DavidCarlisle I did my best to make sense of: "Is it possible to make the text after the figure follow immediately after the text from before the figure, on the same line?" That seems like the crux of the question, but it is phrased awkwardly. Also, my environment does not add a line break (start a paragraph). Where are you seeing that?
– Jonathan Komar
yesterday
the word
After
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.– David Carlisle
yesterday
the word
After
in your example starts a paragraph for the same reason it does in the question, there is a blank line in the source before it.– David Carlisle
yesterday
add a comment |
GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.
GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.
GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.
GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.
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%2f472894%2fhow-to-prevent-a-line-break-after-insertion-of-a-figure-in-to-a-body-of-text%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