Miktex/XeLaTeX - wrong aligned images to the top of text using wrapfigure

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2














I'm trying to display image wrapped by text, but I'm not able to align them exactly. Image is always rendered one line below the begin of text block. Additionally, it's displayed line below even when I want to align it with the subsection.



I've tried to shift the image by vspace-33pt, but it works only when wrapfigure has specified width. This setting is completely ignored in my case when I need to detect wrapfigure width using 0pt width settings.
(Please don't be confused by specified image (=rule) width in my example - real document contains hundreds of images of variable width, so width can't be specified as a parameter and wrapfigure width must be really detected.)



How shall be correctly aligned top of the image to



1) subsection header



2) first line of text



with additional requirement for wrapfigure width detection?



Full non-working code and screenshots describing observed and expected behaviour are below.



documentclass[a4paper]book

usepackagefontspec

usepackagepolyglossia
setmainlanguageczech

usepackageulem
usepackagespverbatim
usepackage[unicode]hyperref
usepackagegraphicx
usepackagegrffile
usepackagecolor

usepackagewrapfig
usepackagehologo

usepackagepdfpages

usepackageneedspace

begindocument

chapterChapter 1
sectionSection 1
needspace6cm
beginwrapfigureR0pt
%vspace-33pt % Doesn't work for width detection (0pt above)
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

chapterChapter 2
sectionSection 2
subsectionSubsection 2
needspace6cm
beginwrapfigureR0pt
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

enddocument


Screenshot 1Screenshot 2










share|improve this question



















  • 2




    off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
    – Zarko
    Dec 22 '18 at 22:46















2














I'm trying to display image wrapped by text, but I'm not able to align them exactly. Image is always rendered one line below the begin of text block. Additionally, it's displayed line below even when I want to align it with the subsection.



I've tried to shift the image by vspace-33pt, but it works only when wrapfigure has specified width. This setting is completely ignored in my case when I need to detect wrapfigure width using 0pt width settings.
(Please don't be confused by specified image (=rule) width in my example - real document contains hundreds of images of variable width, so width can't be specified as a parameter and wrapfigure width must be really detected.)



How shall be correctly aligned top of the image to



1) subsection header



2) first line of text



with additional requirement for wrapfigure width detection?



Full non-working code and screenshots describing observed and expected behaviour are below.



documentclass[a4paper]book

usepackagefontspec

usepackagepolyglossia
setmainlanguageczech

usepackageulem
usepackagespverbatim
usepackage[unicode]hyperref
usepackagegraphicx
usepackagegrffile
usepackagecolor

usepackagewrapfig
usepackagehologo

usepackagepdfpages

usepackageneedspace

begindocument

chapterChapter 1
sectionSection 1
needspace6cm
beginwrapfigureR0pt
%vspace-33pt % Doesn't work for width detection (0pt above)
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

chapterChapter 2
sectionSection 2
subsectionSubsection 2
needspace6cm
beginwrapfigureR0pt
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

enddocument


Screenshot 1Screenshot 2










share|improve this question



















  • 2




    off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
    – Zarko
    Dec 22 '18 at 22:46













2












2








2







I'm trying to display image wrapped by text, but I'm not able to align them exactly. Image is always rendered one line below the begin of text block. Additionally, it's displayed line below even when I want to align it with the subsection.



I've tried to shift the image by vspace-33pt, but it works only when wrapfigure has specified width. This setting is completely ignored in my case when I need to detect wrapfigure width using 0pt width settings.
(Please don't be confused by specified image (=rule) width in my example - real document contains hundreds of images of variable width, so width can't be specified as a parameter and wrapfigure width must be really detected.)



How shall be correctly aligned top of the image to



1) subsection header



2) first line of text



with additional requirement for wrapfigure width detection?



Full non-working code and screenshots describing observed and expected behaviour are below.



documentclass[a4paper]book

usepackagefontspec

usepackagepolyglossia
setmainlanguageczech

usepackageulem
usepackagespverbatim
usepackage[unicode]hyperref
usepackagegraphicx
usepackagegrffile
usepackagecolor

usepackagewrapfig
usepackagehologo

usepackagepdfpages

usepackageneedspace

begindocument

chapterChapter 1
sectionSection 1
needspace6cm
beginwrapfigureR0pt
%vspace-33pt % Doesn't work for width detection (0pt above)
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

chapterChapter 2
sectionSection 2
subsectionSubsection 2
needspace6cm
beginwrapfigureR0pt
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

enddocument


Screenshot 1Screenshot 2










share|improve this question















I'm trying to display image wrapped by text, but I'm not able to align them exactly. Image is always rendered one line below the begin of text block. Additionally, it's displayed line below even when I want to align it with the subsection.



I've tried to shift the image by vspace-33pt, but it works only when wrapfigure has specified width. This setting is completely ignored in my case when I need to detect wrapfigure width using 0pt width settings.
(Please don't be confused by specified image (=rule) width in my example - real document contains hundreds of images of variable width, so width can't be specified as a parameter and wrapfigure width must be really detected.)



How shall be correctly aligned top of the image to



1) subsection header



2) first line of text



with additional requirement for wrapfigure width detection?



Full non-working code and screenshots describing observed and expected behaviour are below.



documentclass[a4paper]book

usepackagefontspec

usepackagepolyglossia
setmainlanguageczech

usepackageulem
usepackagespverbatim
usepackage[unicode]hyperref
usepackagegraphicx
usepackagegrffile
usepackagecolor

usepackagewrapfig
usepackagehologo

usepackagepdfpages

usepackageneedspace

begindocument

chapterChapter 1
sectionSection 1
needspace6cm
beginwrapfigureR0pt
%vspace-33pt % Doesn't work for width detection (0pt above)
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

chapterChapter 2
sectionSection 2
subsectionSubsection 2
needspace6cm
beginwrapfigureR0pt
centering
rule3cm4cm
%includegraphics[height=4cm,width=3cm]img.jpg
endwrapfigure
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

enddocument


Screenshot 1Screenshot 2







xetex wrapfigure alignment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 22 '18 at 22:57









David Carlisle

483k4011151856




483k4011151856










asked Dec 22 '18 at 22:33









Joseph

596




596







  • 2




    off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
    – Zarko
    Dec 22 '18 at 22:46












  • 2




    off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
    – Zarko
    Dec 22 '18 at 22:46







2




2




off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
– Zarko
Dec 22 '18 at 22:46




off-topic: your problem is not related to miktex , the very same problem you will meet at any latex distribution... wrapfigure work correctly (only) at standard paragraph.
– Zarko
Dec 22 '18 at 22:46










2 Answers
2






active

oldest

votes


















3














You can set intextsep to 0 to align with the first line of the paragraph. To move it more up in e.g. a heading use raisebox and hide the real height with the option argument. Be aware that a long heading will be overwritten by such an image.



documentclass[a4paper]book
usepackagewrapfig
usepackageneedspace
intextsep=0pt
begindocument

chapterChapter 1
sectionSection 1
needspace6cm
beginwrapfigureR0pt
centering
raiseboxbaselineskip[dimexprheight-baselineskip][0pt]rule3cm4cm
endwrapfigure
subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

chapterChapter 2
sectionSection 2
subsectionSubsection 2
needspace6cm
beginwrapfigureR0pt
centering
rule3cm4cm
endwrapfigure
Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

enddocument





share|improve this answer




























    3














    You can play with raisebox, fooling LaTeX with the real height of the image via the 1st optional argument of the command:



    documentclass[a4paper]book

    usepackagefontspec

    usepackagepolyglossia
    setmainlanguageczech

    usepackageulem
    usepackagespverbatim
    usepackage[unicode]hyperref
    usepackage[demo]graphicx
    usepackagegrffile
    usepackagecolor

    usepackagewrapfig
    usepackagehologo

    usepackagepdfpages

    usepackageneedspace
    usepackagelipsum

    begindocument

    chapterChapter 1
    sectionSection 1
    needspace6cm
    beginwrapfigureR0pt
    %vspace-33pt % Doesn't work for width detection (0pt above)
    centering
    rule3cm4cm
    %includegraphics[height=4cm,width=3cm]img.jpg
    endwrapfigure
    subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
    Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

    chapterChapter 2
    sectionSection 2
    subsectionSubsection 2
    needspace6cm
    beginwrapfigure[8]R0pt
    centering
    raisebox4ex[0.8height] includegraphics[height=4cm,width=3cm]img.jpg
    endwrapfigure
    leavevmode lipsum[1]

    enddocument


    enter image description here






    share|improve this answer




















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



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467036%2fmiktex-xelatex-wrong-aligned-images-to-the-top-of-text-using-wrapfigure%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      You can set intextsep to 0 to align with the first line of the paragraph. To move it more up in e.g. a heading use raisebox and hide the real height with the option argument. Be aware that a long heading will be overwritten by such an image.



      documentclass[a4paper]book
      usepackagewrapfig
      usepackageneedspace
      intextsep=0pt
      begindocument

      chapterChapter 1
      sectionSection 1
      needspace6cm
      beginwrapfigureR0pt
      centering
      raiseboxbaselineskip[dimexprheight-baselineskip][0pt]rule3cm4cm
      endwrapfigure
      subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
      Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

      chapterChapter 2
      sectionSection 2
      subsectionSubsection 2
      needspace6cm
      beginwrapfigureR0pt
      centering
      rule3cm4cm
      endwrapfigure
      Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

      enddocument





      share|improve this answer

























        3














        You can set intextsep to 0 to align with the first line of the paragraph. To move it more up in e.g. a heading use raisebox and hide the real height with the option argument. Be aware that a long heading will be overwritten by such an image.



        documentclass[a4paper]book
        usepackagewrapfig
        usepackageneedspace
        intextsep=0pt
        begindocument

        chapterChapter 1
        sectionSection 1
        needspace6cm
        beginwrapfigureR0pt
        centering
        raiseboxbaselineskip[dimexprheight-baselineskip][0pt]rule3cm4cm
        endwrapfigure
        subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
        Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

        chapterChapter 2
        sectionSection 2
        subsectionSubsection 2
        needspace6cm
        beginwrapfigureR0pt
        centering
        rule3cm4cm
        endwrapfigure
        Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

        enddocument





        share|improve this answer























          3












          3








          3






          You can set intextsep to 0 to align with the first line of the paragraph. To move it more up in e.g. a heading use raisebox and hide the real height with the option argument. Be aware that a long heading will be overwritten by such an image.



          documentclass[a4paper]book
          usepackagewrapfig
          usepackageneedspace
          intextsep=0pt
          begindocument

          chapterChapter 1
          sectionSection 1
          needspace6cm
          beginwrapfigureR0pt
          centering
          raiseboxbaselineskip[dimexprheight-baselineskip][0pt]rule3cm4cm
          endwrapfigure
          subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
          Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

          chapterChapter 2
          sectionSection 2
          subsectionSubsection 2
          needspace6cm
          beginwrapfigureR0pt
          centering
          rule3cm4cm
          endwrapfigure
          Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

          enddocument





          share|improve this answer












          You can set intextsep to 0 to align with the first line of the paragraph. To move it more up in e.g. a heading use raisebox and hide the real height with the option argument. Be aware that a long heading will be overwritten by such an image.



          documentclass[a4paper]book
          usepackagewrapfig
          usepackageneedspace
          intextsep=0pt
          begindocument

          chapterChapter 1
          sectionSection 1
          needspace6cm
          beginwrapfigureR0pt
          centering
          raiseboxbaselineskip[dimexprheight-baselineskip][0pt]rule3cm4cm
          endwrapfigure
          subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
          Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

          chapterChapter 2
          sectionSection 2
          subsectionSubsection 2
          needspace6cm
          beginwrapfigureR0pt
          centering
          rule3cm4cm
          endwrapfigure
          Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

          enddocument






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 22 '18 at 22:48









          Ulrike Fischer

          187k7290670




          187k7290670





















              3














              You can play with raisebox, fooling LaTeX with the real height of the image via the 1st optional argument of the command:



              documentclass[a4paper]book

              usepackagefontspec

              usepackagepolyglossia
              setmainlanguageczech

              usepackageulem
              usepackagespverbatim
              usepackage[unicode]hyperref
              usepackage[demo]graphicx
              usepackagegrffile
              usepackagecolor

              usepackagewrapfig
              usepackagehologo

              usepackagepdfpages

              usepackageneedspace
              usepackagelipsum

              begindocument

              chapterChapter 1
              sectionSection 1
              needspace6cm
              beginwrapfigureR0pt
              %vspace-33pt % Doesn't work for width detection (0pt above)
              centering
              rule3cm4cm
              %includegraphics[height=4cm,width=3cm]img.jpg
              endwrapfigure
              subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
              Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

              chapterChapter 2
              sectionSection 2
              subsectionSubsection 2
              needspace6cm
              beginwrapfigure[8]R0pt
              centering
              raisebox4ex[0.8height] includegraphics[height=4cm,width=3cm]img.jpg
              endwrapfigure
              leavevmode lipsum[1]

              enddocument


              enter image description here






              share|improve this answer

























                3














                You can play with raisebox, fooling LaTeX with the real height of the image via the 1st optional argument of the command:



                documentclass[a4paper]book

                usepackagefontspec

                usepackagepolyglossia
                setmainlanguageczech

                usepackageulem
                usepackagespverbatim
                usepackage[unicode]hyperref
                usepackage[demo]graphicx
                usepackagegrffile
                usepackagecolor

                usepackagewrapfig
                usepackagehologo

                usepackagepdfpages

                usepackageneedspace
                usepackagelipsum

                begindocument

                chapterChapter 1
                sectionSection 1
                needspace6cm
                beginwrapfigureR0pt
                %vspace-33pt % Doesn't work for width detection (0pt above)
                centering
                rule3cm4cm
                %includegraphics[height=4cm,width=3cm]img.jpg
                endwrapfigure
                subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
                Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

                chapterChapter 2
                sectionSection 2
                subsectionSubsection 2
                needspace6cm
                beginwrapfigure[8]R0pt
                centering
                raisebox4ex[0.8height] includegraphics[height=4cm,width=3cm]img.jpg
                endwrapfigure
                leavevmode lipsum[1]

                enddocument


                enter image description here






                share|improve this answer























                  3












                  3








                  3






                  You can play with raisebox, fooling LaTeX with the real height of the image via the 1st optional argument of the command:



                  documentclass[a4paper]book

                  usepackagefontspec

                  usepackagepolyglossia
                  setmainlanguageczech

                  usepackageulem
                  usepackagespverbatim
                  usepackage[unicode]hyperref
                  usepackage[demo]graphicx
                  usepackagegrffile
                  usepackagecolor

                  usepackagewrapfig
                  usepackagehologo

                  usepackagepdfpages

                  usepackageneedspace
                  usepackagelipsum

                  begindocument

                  chapterChapter 1
                  sectionSection 1
                  needspace6cm
                  beginwrapfigureR0pt
                  %vspace-33pt % Doesn't work for width detection (0pt above)
                  centering
                  rule3cm4cm
                  %includegraphics[height=4cm,width=3cm]img.jpg
                  endwrapfigure
                  subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
                  Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

                  chapterChapter 2
                  sectionSection 2
                  subsectionSubsection 2
                  needspace6cm
                  beginwrapfigure[8]R0pt
                  centering
                  raisebox4ex[0.8height] includegraphics[height=4cm,width=3cm]img.jpg
                  endwrapfigure
                  leavevmode lipsum[1]

                  enddocument


                  enter image description here






                  share|improve this answer












                  You can play with raisebox, fooling LaTeX with the real height of the image via the 1st optional argument of the command:



                  documentclass[a4paper]book

                  usepackagefontspec

                  usepackagepolyglossia
                  setmainlanguageczech

                  usepackageulem
                  usepackagespverbatim
                  usepackage[unicode]hyperref
                  usepackage[demo]graphicx
                  usepackagegrffile
                  usepackagecolor

                  usepackagewrapfig
                  usepackagehologo

                  usepackagepdfpages

                  usepackageneedspace
                  usepackagelipsum

                  begindocument

                  chapterChapter 1
                  sectionSection 1
                  needspace6cm
                  beginwrapfigureR0pt
                  %vspace-33pt % Doesn't work for width detection (0pt above)
                  centering
                  rule3cm4cm
                  %includegraphics[height=4cm,width=3cm]img.jpg
                  endwrapfigure
                  subsectionSubsection 1 % <----- Image shall be here, but is one line below Some text
                  Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below. Some text below.

                  chapterChapter 2
                  sectionSection 2
                  subsectionSubsection 2
                  needspace6cm
                  beginwrapfigure[8]R0pt
                  centering
                  raisebox4ex[0.8height] includegraphics[height=4cm,width=3cm]img.jpg
                  endwrapfigure
                  leavevmode lipsum[1]

                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 22 '18 at 23:08









                  Bernard

                  166k769194




                  166k769194



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467036%2fmiktex-xelatex-wrong-aligned-images-to-the-top-of-text-using-wrapfigure%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

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay