Vertical align (top) graphic and top of text-line

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











up vote
4
down vote

favorite












I want to align the top of an image, and the top of a line of text. Below is a MWE with the current setup (using a placeholder "graphic" but the effect seems the same) and the desired behavior.



documentclassarticle

usepackagegraphicx

begindocument

beginminipage[t]0.5textwidth
%includegraphics[height=0.4in]theimage.png
rule0.95textwidth0.5in
endminipage%
beginminipage[t]0.5textwidth
sometext to fill the line
endminipage

enddocument


MWE behavior:



MWE behavior



Desired behavior:



enter image description here







share|improve this question




















  • Welcome to TeX.SE! Please have a look at this post.
    – marmot
    Aug 22 at 4:00










  • Isn't this what you want? tex.stackexchange.com/questions/29143/…
    – Oleg Lobachev
    Aug 22 at 12:45










  • thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
    – amoodie
    Aug 22 at 13:56














up vote
4
down vote

favorite












I want to align the top of an image, and the top of a line of text. Below is a MWE with the current setup (using a placeholder "graphic" but the effect seems the same) and the desired behavior.



documentclassarticle

usepackagegraphicx

begindocument

beginminipage[t]0.5textwidth
%includegraphics[height=0.4in]theimage.png
rule0.95textwidth0.5in
endminipage%
beginminipage[t]0.5textwidth
sometext to fill the line
endminipage

enddocument


MWE behavior:



MWE behavior



Desired behavior:



enter image description here







share|improve this question




















  • Welcome to TeX.SE! Please have a look at this post.
    – marmot
    Aug 22 at 4:00










  • Isn't this what you want? tex.stackexchange.com/questions/29143/…
    – Oleg Lobachev
    Aug 22 at 12:45










  • thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
    – amoodie
    Aug 22 at 13:56












up vote
4
down vote

favorite









up vote
4
down vote

favorite











I want to align the top of an image, and the top of a line of text. Below is a MWE with the current setup (using a placeholder "graphic" but the effect seems the same) and the desired behavior.



documentclassarticle

usepackagegraphicx

begindocument

beginminipage[t]0.5textwidth
%includegraphics[height=0.4in]theimage.png
rule0.95textwidth0.5in
endminipage%
beginminipage[t]0.5textwidth
sometext to fill the line
endminipage

enddocument


MWE behavior:



MWE behavior



Desired behavior:



enter image description here







share|improve this question












I want to align the top of an image, and the top of a line of text. Below is a MWE with the current setup (using a placeholder "graphic" but the effect seems the same) and the desired behavior.



documentclassarticle

usepackagegraphicx

begindocument

beginminipage[t]0.5textwidth
%includegraphics[height=0.4in]theimage.png
rule0.95textwidth0.5in
endminipage%
beginminipage[t]0.5textwidth
sometext to fill the line
endminipage

enddocument


MWE behavior:



MWE behavior



Desired behavior:



enter image description here









share|improve this question











share|improve this question




share|improve this question










asked Aug 22 at 3:54









amoodie

233




233











  • Welcome to TeX.SE! Please have a look at this post.
    – marmot
    Aug 22 at 4:00










  • Isn't this what you want? tex.stackexchange.com/questions/29143/…
    – Oleg Lobachev
    Aug 22 at 12:45










  • thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
    – amoodie
    Aug 22 at 13:56
















  • Welcome to TeX.SE! Please have a look at this post.
    – marmot
    Aug 22 at 4:00










  • Isn't this what you want? tex.stackexchange.com/questions/29143/…
    – Oleg Lobachev
    Aug 22 at 12:45










  • thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
    – amoodie
    Aug 22 at 13:56















Welcome to TeX.SE! Please have a look at this post.
– marmot
Aug 22 at 4:00




Welcome to TeX.SE! Please have a look at this post.
– marmot
Aug 22 at 4:00












Isn't this what you want? tex.stackexchange.com/questions/29143/…
– Oleg Lobachev
Aug 22 at 12:45




Isn't this what you want? tex.stackexchange.com/questions/29143/…
– Oleg Lobachev
Aug 22 at 12:45












thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
– amoodie
Aug 22 at 13:56




thanks to both of you, I was having trouble locating these resources by searches. Should have searched harder I guess.
– amoodie
Aug 22 at 13:56










3 Answers
3






active

oldest

votes

















up vote
4
down vote



accepted










A simple way to fix your problem is by adding vspace0pt as soon as a minipage is created:



Output



documentclassarticle

usepackagegraphicx

begindocument
beginminipage[t]0.5textwidth
vspace0pt
%includegraphics[height=0.4in]theimage.png
rule0.95textwidth0.5in
endminipage%
beginminipage[t]0.5textwidth
vspace0pt
sometext to fill the line
endminipage
enddocument





share|improve this answer




















  • This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
    – amoodie
    Aug 22 at 13:57

















up vote
5
down vote













You could use adjustbox, as marmot suggested in his comment.



Moreover, instead of using minipages, you could use a tabularx.



documentclassarticle
usepackagetabularx
usepackagegraphicx
usepackage[export]adjustbox
begindocument
noindentbegintabularxlinewidth@X@hspace2ptX@
includegraphics[height=0.4in, width=0.475textwidth,valign=t]example-image
&
sometext to fill the line \
endtabularx
enddocument


enter image description here






share|improve this answer



























    up vote
    0
    down vote













    A potential workaround I found is that if I know the height of the image, I can add a negative vspace. This seems kind of hacky though and I'm wondering if there is a cleaner solution



    documentclassarticle

    usepackagegraphicx

    begindocument

    beginminipage[t]0.5textwidth
    % includegraphics[height=0.4in]theimage.png%
    rule0.95textwidth4baselineskip
    endminipage%
    beginminipage[t]0.5textwidth
    vspace*-4baselineskip
    sometext to fill the line
    endminipage

    enddocument





    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',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      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%2f447104%2fvertical-align-top-graphic-and-top-of-text-line%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote



      accepted










      A simple way to fix your problem is by adding vspace0pt as soon as a minipage is created:



      Output



      documentclassarticle

      usepackagegraphicx

      begindocument
      beginminipage[t]0.5textwidth
      vspace0pt
      %includegraphics[height=0.4in]theimage.png
      rule0.95textwidth0.5in
      endminipage%
      beginminipage[t]0.5textwidth
      vspace0pt
      sometext to fill the line
      endminipage
      enddocument





      share|improve this answer




















      • This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
        – amoodie
        Aug 22 at 13:57














      up vote
      4
      down vote



      accepted










      A simple way to fix your problem is by adding vspace0pt as soon as a minipage is created:



      Output



      documentclassarticle

      usepackagegraphicx

      begindocument
      beginminipage[t]0.5textwidth
      vspace0pt
      %includegraphics[height=0.4in]theimage.png
      rule0.95textwidth0.5in
      endminipage%
      beginminipage[t]0.5textwidth
      vspace0pt
      sometext to fill the line
      endminipage
      enddocument





      share|improve this answer




















      • This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
        – amoodie
        Aug 22 at 13:57












      up vote
      4
      down vote



      accepted







      up vote
      4
      down vote



      accepted






      A simple way to fix your problem is by adding vspace0pt as soon as a minipage is created:



      Output



      documentclassarticle

      usepackagegraphicx

      begindocument
      beginminipage[t]0.5textwidth
      vspace0pt
      %includegraphics[height=0.4in]theimage.png
      rule0.95textwidth0.5in
      endminipage%
      beginminipage[t]0.5textwidth
      vspace0pt
      sometext to fill the line
      endminipage
      enddocument





      share|improve this answer












      A simple way to fix your problem is by adding vspace0pt as soon as a minipage is created:



      Output



      documentclassarticle

      usepackagegraphicx

      begindocument
      beginminipage[t]0.5textwidth
      vspace0pt
      %includegraphics[height=0.4in]theimage.png
      rule0.95textwidth0.5in
      endminipage%
      beginminipage[t]0.5textwidth
      vspace0pt
      sometext to fill the line
      endminipage
      enddocument






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Aug 22 at 6:12









      M. Al Jumaily

      3636




      3636











      • This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
        – amoodie
        Aug 22 at 13:57
















      • This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
        – amoodie
        Aug 22 at 13:57















      This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
      – amoodie
      Aug 22 at 13:57




      This also feels a little hacky (similar to my answer below) but it works. Can you explain why adding the zero-height vspace works in this case?
      – amoodie
      Aug 22 at 13:57










      up vote
      5
      down vote













      You could use adjustbox, as marmot suggested in his comment.



      Moreover, instead of using minipages, you could use a tabularx.



      documentclassarticle
      usepackagetabularx
      usepackagegraphicx
      usepackage[export]adjustbox
      begindocument
      noindentbegintabularxlinewidth@X@hspace2ptX@
      includegraphics[height=0.4in, width=0.475textwidth,valign=t]example-image
      &
      sometext to fill the line \
      endtabularx
      enddocument


      enter image description here






      share|improve this answer
























        up vote
        5
        down vote













        You could use adjustbox, as marmot suggested in his comment.



        Moreover, instead of using minipages, you could use a tabularx.



        documentclassarticle
        usepackagetabularx
        usepackagegraphicx
        usepackage[export]adjustbox
        begindocument
        noindentbegintabularxlinewidth@X@hspace2ptX@
        includegraphics[height=0.4in, width=0.475textwidth,valign=t]example-image
        &
        sometext to fill the line \
        endtabularx
        enddocument


        enter image description here






        share|improve this answer






















          up vote
          5
          down vote










          up vote
          5
          down vote









          You could use adjustbox, as marmot suggested in his comment.



          Moreover, instead of using minipages, you could use a tabularx.



          documentclassarticle
          usepackagetabularx
          usepackagegraphicx
          usepackage[export]adjustbox
          begindocument
          noindentbegintabularxlinewidth@X@hspace2ptX@
          includegraphics[height=0.4in, width=0.475textwidth,valign=t]example-image
          &
          sometext to fill the line \
          endtabularx
          enddocument


          enter image description here






          share|improve this answer












          You could use adjustbox, as marmot suggested in his comment.



          Moreover, instead of using minipages, you could use a tabularx.



          documentclassarticle
          usepackagetabularx
          usepackagegraphicx
          usepackage[export]adjustbox
          begindocument
          noindentbegintabularxlinewidth@X@hspace2ptX@
          includegraphics[height=0.4in, width=0.475textwidth,valign=t]example-image
          &
          sometext to fill the line \
          endtabularx
          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 22 at 5:06









          CarLaTeX

          25.4k442110




          25.4k442110




















              up vote
              0
              down vote













              A potential workaround I found is that if I know the height of the image, I can add a negative vspace. This seems kind of hacky though and I'm wondering if there is a cleaner solution



              documentclassarticle

              usepackagegraphicx

              begindocument

              beginminipage[t]0.5textwidth
              % includegraphics[height=0.4in]theimage.png%
              rule0.95textwidth4baselineskip
              endminipage%
              beginminipage[t]0.5textwidth
              vspace*-4baselineskip
              sometext to fill the line
              endminipage

              enddocument





              share|improve this answer
























                up vote
                0
                down vote













                A potential workaround I found is that if I know the height of the image, I can add a negative vspace. This seems kind of hacky though and I'm wondering if there is a cleaner solution



                documentclassarticle

                usepackagegraphicx

                begindocument

                beginminipage[t]0.5textwidth
                % includegraphics[height=0.4in]theimage.png%
                rule0.95textwidth4baselineskip
                endminipage%
                beginminipage[t]0.5textwidth
                vspace*-4baselineskip
                sometext to fill the line
                endminipage

                enddocument





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  A potential workaround I found is that if I know the height of the image, I can add a negative vspace. This seems kind of hacky though and I'm wondering if there is a cleaner solution



                  documentclassarticle

                  usepackagegraphicx

                  begindocument

                  beginminipage[t]0.5textwidth
                  % includegraphics[height=0.4in]theimage.png%
                  rule0.95textwidth4baselineskip
                  endminipage%
                  beginminipage[t]0.5textwidth
                  vspace*-4baselineskip
                  sometext to fill the line
                  endminipage

                  enddocument





                  share|improve this answer












                  A potential workaround I found is that if I know the height of the image, I can add a negative vspace. This seems kind of hacky though and I'm wondering if there is a cleaner solution



                  documentclassarticle

                  usepackagegraphicx

                  begindocument

                  beginminipage[t]0.5textwidth
                  % includegraphics[height=0.4in]theimage.png%
                  rule0.95textwidth4baselineskip
                  endminipage%
                  beginminipage[t]0.5textwidth
                  vspace*-4baselineskip
                  sometext to fill the line
                  endminipage

                  enddocument






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 22 at 3:56









                  amoodie

                  233




                  233






















                       

                      draft saved


                      draft discarded


























                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f447104%2fvertical-align-top-graphic-and-top-of-text-line%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      這個網誌中的熱門文章

                      How to combine Bézier curves to a surface?

                      Mutual Information Always Non-negative

                      Why am i infinitely getting the same tweet with the Twitter Search API?