How to prevent a line break after insertion of a figure in to a body of text












3















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!



enter image description hereenter image description here










share|improve this question







New contributor




GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    3















    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!



    enter image description hereenter image description here










    share|improve this question







    New contributor




    GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      3












      3








      3


      1






      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!



      enter image description hereenter image description here










      share|improve this question







      New contributor




      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      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!



      enter image description hereenter image description here







      floats






      share|improve this question







      New contributor




      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      GraduatedDylinderGraduatedDylinder

      184




      184




      New contributor




      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      GraduatedDylinder is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          3 Answers
          3






          active

          oldest

          votes


















          6














          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.






          share|improve this answer
























          • 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



















          3














          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}


          enter image description here






          share|improve this answer































            2














            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}


            enter image description here






            share|improve this answer


























            • 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













            • 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













            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.










            draft saved

            draft discarded


















            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









            6














            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.






            share|improve this answer
























            • 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
















            6














            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.






            share|improve this answer
























            • 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














            6












            6








            6







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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











            3














            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}


            enter image description here






            share|improve this answer




























              3














              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}


              enter image description here






              share|improve this answer


























                3












                3








                3







                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}


                enter image description here






                share|improve this answer













                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}


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered yesterday









                DenisDenis

                2,303520




                2,303520























                    2














                    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}


                    enter image description here






                    share|improve this answer


























                    • 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













                    • 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


















                    2














                    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}


                    enter image description here






                    share|improve this answer


























                    • 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













                    • 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
















                    2












                    2








                    2







                    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}


                    enter image description here






                    share|improve this answer















                    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}


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    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 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













                    • 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 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













                    • 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 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












                    GraduatedDylinder is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    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.




                    draft saved


                    draft discarded














                    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





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    Origin of the phrase “under your belt”?