TikZ rectangle split horizontal extra space

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











up vote
4
down vote

favorite
1












The following code gives extra space both on the left under the graphic and on the right under the text. Is there a way to make the split rectangles tight against the larger text or graphic?



% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = XeLaTeX

documentclassarticle

usepackagegraphicx
usepackagetikz
usepackagemulticol

usetikzlibraryshapes.multipart,positioning

newsaveboxtestbox

begindocument

beginlrboxtestbox
beginminipage3in
beginmulticols2
This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
endmulticols
And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
endminipage
endlrbox

tikz%
node[%
rectangle split,
rectangle split parts=2,
rectangle split horizontal,
rectangle split part align=top,
draw,
line width=3pt
](test)%
includegraphics[width=2in]example-image-a
nodeparttwo useboxtestbox.
;
node[above=12pt of test.south,fill=white]%
bfseriesLARGEcolorred $Longleftarrow$ EXTRA SPACE? $Longrightarrow$;
%

enddocument


Example of extra space.










share|improve this question

























    up vote
    4
    down vote

    favorite
    1












    The following code gives extra space both on the left under the graphic and on the right under the text. Is there a way to make the split rectangles tight against the larger text or graphic?



    % !TEX encoding = UTF-8 Unicode
    % !TEX TS-program = XeLaTeX

    documentclassarticle

    usepackagegraphicx
    usepackagetikz
    usepackagemulticol

    usetikzlibraryshapes.multipart,positioning

    newsaveboxtestbox

    begindocument

    beginlrboxtestbox
    beginminipage3in
    beginmulticols2
    This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
    endmulticols
    And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
    endminipage
    endlrbox

    tikz%
    node[%
    rectangle split,
    rectangle split parts=2,
    rectangle split horizontal,
    rectangle split part align=top,
    draw,
    line width=3pt
    ](test)%
    includegraphics[width=2in]example-image-a
    nodeparttwo useboxtestbox.
    ;
    node[above=12pt of test.south,fill=white]%
    bfseriesLARGEcolorred $Longleftarrow$ EXTRA SPACE? $Longrightarrow$;
    %

    enddocument


    Example of extra space.










    share|improve this question























      up vote
      4
      down vote

      favorite
      1









      up vote
      4
      down vote

      favorite
      1






      1





      The following code gives extra space both on the left under the graphic and on the right under the text. Is there a way to make the split rectangles tight against the larger text or graphic?



      % !TEX encoding = UTF-8 Unicode
      % !TEX TS-program = XeLaTeX

      documentclassarticle

      usepackagegraphicx
      usepackagetikz
      usepackagemulticol

      usetikzlibraryshapes.multipart,positioning

      newsaveboxtestbox

      begindocument

      beginlrboxtestbox
      beginminipage3in
      beginmulticols2
      This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
      endmulticols
      And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
      endminipage
      endlrbox

      tikz%
      node[%
      rectangle split,
      rectangle split parts=2,
      rectangle split horizontal,
      rectangle split part align=top,
      draw,
      line width=3pt
      ](test)%
      includegraphics[width=2in]example-image-a
      nodeparttwo useboxtestbox.
      ;
      node[above=12pt of test.south,fill=white]%
      bfseriesLARGEcolorred $Longleftarrow$ EXTRA SPACE? $Longrightarrow$;
      %

      enddocument


      Example of extra space.










      share|improve this question













      The following code gives extra space both on the left under the graphic and on the right under the text. Is there a way to make the split rectangles tight against the larger text or graphic?



      % !TEX encoding = UTF-8 Unicode
      % !TEX TS-program = XeLaTeX

      documentclassarticle

      usepackagegraphicx
      usepackagetikz
      usepackagemulticol

      usetikzlibraryshapes.multipart,positioning

      newsaveboxtestbox

      begindocument

      beginlrboxtestbox
      beginminipage3in
      beginmulticols2
      This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
      endmulticols
      And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
      endminipage
      endlrbox

      tikz%
      node[%
      rectangle split,
      rectangle split parts=2,
      rectangle split horizontal,
      rectangle split part align=top,
      draw,
      line width=3pt
      ](test)%
      includegraphics[width=2in]example-image-a
      nodeparttwo useboxtestbox.
      ;
      node[above=12pt of test.south,fill=white]%
      bfseriesLARGEcolorred $Longleftarrow$ EXTRA SPACE? $Longrightarrow$;
      %

      enddocument


      Example of extra space.







      tikz-pgf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 25 at 17:30









      sgmoye

      3,64711225




      3,64711225




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          This has to do with the way you include the graphics. Here is one out of many ways to fix it: put it in $vcenterhbox...$, which is a standard trick to vertically center objects (in equations). My choice is not special, nor sophisticated, but seems to work. As for the question: why is this necessary here? I do not have a compelling answer except maybe that I am not surprised to have to care about the vertical alignment.



          documentclassarticle

          usepackagegraphicx
          usepackagetikz
          usepackagemulticol

          usetikzlibraryshapes.multipart,positioning

          newsaveboxtestbox

          begindocument

          beginlrboxtestbox
          beginminipage3in
          beginmulticols2
          This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
          endmulticols
          And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
          endminipage
          endlrbox

          tikz%
          node[%
          rectangle split,
          rectangle split parts=2,
          rectangle split horizontal,
          rectangle split part align=top,
          draw,
          line width=3pt
          ](test)%
          $vcenterhboxincludegraphics[width=2in]example-image-a$
          nodeparttwo useboxtestbox.
          ;
          %

          enddocument


          enter image description here






          share|improve this answer






















          • Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
            – sgmoye
            Sep 25 at 18:37







          • 1




            @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
            – marmot
            Sep 25 at 19:32











          • I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
            – sgmoye
            Sep 26 at 11:27






          • 1




            @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
            – marmot
            Sep 26 at 11:56






          • 1




            Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
            – sgmoye
            Sep 26 at 13:29


















          up vote
          3
          down vote













          an alternative solution is use of the adjustbox package:



          documentclassarticle
          usepackage[export]adjustbox
          usepackagetikz
          usetikzlibrarypositioning,
          shapes.multipart
          usepackagemulticol
          usepackageragged2e

          newsaveboxtestbox

          begindocument

          beginlrboxtestbox
          beginminipage3inRaggedRight
          beginmulticols2
          This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
          endmulticols
          And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
          endminipage
          endlrbox

          tikz%
          node[%
          rectangle split,
          rectangle split parts=2,
          rectangle split horizontal,
          rectangle split part align=top,
          draw,
          line width=3pt
          ] (test)
          includegraphics[width=2in,valign=c]example-image-a % with "valign=c" is image baseline moved to its vertical center
          nodeparttwo useboxtestbox
          ;


          enddocument


          enter image description here






          share|improve this answer




















          • Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
            – sgmoye
            Sep 25 at 19:04










          • all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
            – Zarko
            Sep 25 at 19:14











          • Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
            – sgmoye
            Sep 26 at 13:06










          • @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
            – Zarko
            Sep 26 at 13:14

















          up vote
          3
          down vote













          In case you could accept text box and not a TikZ node, tcolorbox offers a tcbsidebyside box where you can decide which part will adapt to its size while the other uses the available space (textwidth or box width).



          documentclassarticle
          usepackage[most]tcolorbox
          usepackagemulticol
          usepackagelmodern

          begindocument
          tcbsidebyside[notitle,
          sidebyside adapt=left,
          colback=white,
          enhanced,
          segmentation style=solid,
          sharp corners]
          %
          includegraphics[width=3cm]example-image-a
          %
          beginmulticols2
          This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
          endmulticols
          And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more


          tcbsidebyside[notitle,
          sidebyside adapt=left,
          colback=white,
          enhanced,
          segmentation style=solid,
          sharp corners]
          %
          includegraphics[width=5cm]example-image-a
          %
          And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more

          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',
            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%2f452488%2ftikz-rectangle-split-horizontal-extra-space%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
            3
            down vote



            accepted










            This has to do with the way you include the graphics. Here is one out of many ways to fix it: put it in $vcenterhbox...$, which is a standard trick to vertically center objects (in equations). My choice is not special, nor sophisticated, but seems to work. As for the question: why is this necessary here? I do not have a compelling answer except maybe that I am not surprised to have to care about the vertical alignment.



            documentclassarticle

            usepackagegraphicx
            usepackagetikz
            usepackagemulticol

            usetikzlibraryshapes.multipart,positioning

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3in
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ](test)%
            $vcenterhboxincludegraphics[width=2in]example-image-a$
            nodeparttwo useboxtestbox.
            ;
            %

            enddocument


            enter image description here






            share|improve this answer






















            • Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
              – sgmoye
              Sep 25 at 18:37







            • 1




              @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
              – marmot
              Sep 25 at 19:32











            • I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
              – sgmoye
              Sep 26 at 11:27






            • 1




              @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
              – marmot
              Sep 26 at 11:56






            • 1




              Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
              – sgmoye
              Sep 26 at 13:29















            up vote
            3
            down vote



            accepted










            This has to do with the way you include the graphics. Here is one out of many ways to fix it: put it in $vcenterhbox...$, which is a standard trick to vertically center objects (in equations). My choice is not special, nor sophisticated, but seems to work. As for the question: why is this necessary here? I do not have a compelling answer except maybe that I am not surprised to have to care about the vertical alignment.



            documentclassarticle

            usepackagegraphicx
            usepackagetikz
            usepackagemulticol

            usetikzlibraryshapes.multipart,positioning

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3in
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ](test)%
            $vcenterhboxincludegraphics[width=2in]example-image-a$
            nodeparttwo useboxtestbox.
            ;
            %

            enddocument


            enter image description here






            share|improve this answer






















            • Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
              – sgmoye
              Sep 25 at 18:37







            • 1




              @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
              – marmot
              Sep 25 at 19:32











            • I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
              – sgmoye
              Sep 26 at 11:27






            • 1




              @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
              – marmot
              Sep 26 at 11:56






            • 1




              Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
              – sgmoye
              Sep 26 at 13:29













            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            This has to do with the way you include the graphics. Here is one out of many ways to fix it: put it in $vcenterhbox...$, which is a standard trick to vertically center objects (in equations). My choice is not special, nor sophisticated, but seems to work. As for the question: why is this necessary here? I do not have a compelling answer except maybe that I am not surprised to have to care about the vertical alignment.



            documentclassarticle

            usepackagegraphicx
            usepackagetikz
            usepackagemulticol

            usetikzlibraryshapes.multipart,positioning

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3in
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ](test)%
            $vcenterhboxincludegraphics[width=2in]example-image-a$
            nodeparttwo useboxtestbox.
            ;
            %

            enddocument


            enter image description here






            share|improve this answer














            This has to do with the way you include the graphics. Here is one out of many ways to fix it: put it in $vcenterhbox...$, which is a standard trick to vertically center objects (in equations). My choice is not special, nor sophisticated, but seems to work. As for the question: why is this necessary here? I do not have a compelling answer except maybe that I am not surprised to have to care about the vertical alignment.



            documentclassarticle

            usepackagegraphicx
            usepackagetikz
            usepackagemulticol

            usetikzlibraryshapes.multipart,positioning

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3in
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ](test)%
            $vcenterhboxincludegraphics[width=2in]example-image-a$
            nodeparttwo useboxtestbox.
            ;
            %

            enddocument


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 26 at 1:35

























            answered Sep 25 at 17:36









            marmot

            62.8k468135




            62.8k468135











            • Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
              – sgmoye
              Sep 25 at 18:37







            • 1




              @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
              – marmot
              Sep 25 at 19:32











            • I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
              – sgmoye
              Sep 26 at 11:27






            • 1




              @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
              – marmot
              Sep 26 at 11:56






            • 1




              Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
              – sgmoye
              Sep 26 at 13:29

















            • Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
              – sgmoye
              Sep 25 at 18:37







            • 1




              @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
              – marmot
              Sep 25 at 19:32











            • I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
              – sgmoye
              Sep 26 at 11:27






            • 1




              @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
              – marmot
              Sep 26 at 11:56






            • 1




              Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
              – sgmoye
              Sep 26 at 13:29
















            Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
            – sgmoye
            Sep 25 at 18:37





            Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I tried hbox and mbox but would wouldn't have thought of vcenter in a gajillion years. Some interaction between includegraphics and rectangle split horizontal? I don't think I've ever seen includegraphics behave this way on its own. Thanks for the help!
            – sgmoye
            Sep 25 at 18:37





            1




            1




            @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
            – marmot
            Sep 25 at 19:32





            @sgmoye Sorry, I am in meeting after meeting. vcenter was what I immediately thought of using here, just compare $xincludegraphics[width=2in]example-image-a$ to $xvcenterhboxincludegraphics[width=2in]example-image-a$. The latter is the standard trick of vertically centering things in an equation. So my thought was to try it and it worked. Need to rush to the next meeting, will explain more later.
            – marmot
            Sep 25 at 19:32













            I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
            – sgmoye
            Sep 26 at 11:27




            I would really appreciate knowing why a math mode TeX primitive is necessary to make this work. To all appearances, this indicates some non-obvious (to me, anyway) manipulation of boxes by TikZ.
            – sgmoye
            Sep 26 at 11:27




            1




            1




            @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
            – marmot
            Sep 26 at 11:56




            @sgmoye I do not know the details what TikZ dos precisely in these multipart nodes. I guess both of us looked at the code but at least I gave up due to the complexity. Nonetheless, the vcenterhbox... thingy is something I do rather often, e.g. to center a Feynman diagram or some other graphics in an equation. Out of the top of my head, I wouldn't know an alternative (other than using some baseline option if the diagram is drawn with TikZ), so for me using the threshold using this primitive is very low since it was always fine.
            – marmot
            Sep 26 at 11:56




            1




            1




            Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
            – sgmoye
            Sep 26 at 13:29





            Interesting. I just discovered that this works: parbox2inincludegraphics[width=2in]example-image-a..
            – sgmoye
            Sep 26 at 13:29











            up vote
            3
            down vote













            an alternative solution is use of the adjustbox package:



            documentclassarticle
            usepackage[export]adjustbox
            usepackagetikz
            usetikzlibrarypositioning,
            shapes.multipart
            usepackagemulticol
            usepackageragged2e

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3inRaggedRight
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ] (test)
            includegraphics[width=2in,valign=c]example-image-a % with "valign=c" is image baseline moved to its vertical center
            nodeparttwo useboxtestbox
            ;


            enddocument


            enter image description here






            share|improve this answer




















            • Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
              – sgmoye
              Sep 25 at 19:04










            • all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
              – Zarko
              Sep 25 at 19:14











            • Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
              – sgmoye
              Sep 26 at 13:06










            • @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
              – Zarko
              Sep 26 at 13:14














            up vote
            3
            down vote













            an alternative solution is use of the adjustbox package:



            documentclassarticle
            usepackage[export]adjustbox
            usepackagetikz
            usetikzlibrarypositioning,
            shapes.multipart
            usepackagemulticol
            usepackageragged2e

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3inRaggedRight
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ] (test)
            includegraphics[width=2in,valign=c]example-image-a % with "valign=c" is image baseline moved to its vertical center
            nodeparttwo useboxtestbox
            ;


            enddocument


            enter image description here






            share|improve this answer




















            • Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
              – sgmoye
              Sep 25 at 19:04










            • all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
              – Zarko
              Sep 25 at 19:14











            • Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
              – sgmoye
              Sep 26 at 13:06










            • @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
              – Zarko
              Sep 26 at 13:14












            up vote
            3
            down vote










            up vote
            3
            down vote









            an alternative solution is use of the adjustbox package:



            documentclassarticle
            usepackage[export]adjustbox
            usepackagetikz
            usetikzlibrarypositioning,
            shapes.multipart
            usepackagemulticol
            usepackageragged2e

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3inRaggedRight
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ] (test)
            includegraphics[width=2in,valign=c]example-image-a % with "valign=c" is image baseline moved to its vertical center
            nodeparttwo useboxtestbox
            ;


            enddocument


            enter image description here






            share|improve this answer












            an alternative solution is use of the adjustbox package:



            documentclassarticle
            usepackage[export]adjustbox
            usepackagetikz
            usetikzlibrarypositioning,
            shapes.multipart
            usepackagemulticol
            usepackageragged2e

            newsaveboxtestbox

            begindocument

            beginlrboxtestbox
            beginminipage3inRaggedRight
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more
            endminipage
            endlrbox

            tikz%
            node[%
            rectangle split,
            rectangle split parts=2,
            rectangle split horizontal,
            rectangle split part align=top,
            draw,
            line width=3pt
            ] (test)
            includegraphics[width=2in,valign=c]example-image-a % with "valign=c" is image baseline moved to its vertical center
            nodeparttwo useboxtestbox
            ;


            enddocument


            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 25 at 18:56









            Zarko

            114k863152




            114k863152











            • Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
              – sgmoye
              Sep 25 at 19:04










            • all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
              – Zarko
              Sep 25 at 19:14











            • Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
              – sgmoye
              Sep 26 at 13:06










            • @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
              – Zarko
              Sep 26 at 13:14
















            • Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
              – sgmoye
              Sep 25 at 19:04










            • all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
              – Zarko
              Sep 25 at 19:14











            • Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
              – sgmoye
              Sep 26 at 13:06










            • @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
              – Zarko
              Sep 26 at 13:14















            Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
            – sgmoye
            Sep 25 at 19:04




            Thank you -- that also didn't occur to me at all. But why is all this necessary? What is the underlying mechanism that causes the extra space? I'd like to be aware of the mechanics so that I can avoid a similar conundrum in the future. Thanks again. I've learned something and that's always nice...
            – sgmoye
            Sep 25 at 19:04












            all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
            – Zarko
            Sep 25 at 19:14





            all is about boxes. and how they are aligned to each other. but i might be wrong. you should read TeXbook ... (instead thanks, you can up-vote both answers)
            – Zarko
            Sep 25 at 19:14













            Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
            – sgmoye
            Sep 26 at 13:06




            Yes, I suppose that we could all, no doubt, benefit from a re-(re-re-re-re-)reading of the TeXbook, but the problem, it seems to me, lies with TikZ and what it is doing with boxes -- I looked at the code but came away none the wiser. Marmot's interesting solution requires the use of a math mode TeX primitive. Altogether non-obvious, at least to me. Some explanation of that would also be useful.
            – sgmoye
            Sep 26 at 13:06












            @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
            – Zarko
            Sep 26 at 13:14




            @sgmoye, both solution do the same: move image baseline to the center. for this they are only used different tools. for better (or more correct) explanation you should ask some latex guru (what i'm not).
            – Zarko
            Sep 26 at 13:14










            up vote
            3
            down vote













            In case you could accept text box and not a TikZ node, tcolorbox offers a tcbsidebyside box where you can decide which part will adapt to its size while the other uses the available space (textwidth or box width).



            documentclassarticle
            usepackage[most]tcolorbox
            usepackagemulticol
            usepackagelmodern

            begindocument
            tcbsidebyside[notitle,
            sidebyside adapt=left,
            colback=white,
            enhanced,
            segmentation style=solid,
            sharp corners]
            %
            includegraphics[width=3cm]example-image-a
            %
            beginmulticols2
            This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
            endmulticols
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more


            tcbsidebyside[notitle,
            sidebyside adapt=left,
            colback=white,
            enhanced,
            segmentation style=solid,
            sharp corners]
            %
            includegraphics[width=5cm]example-image-a
            %
            And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more

            enddocument


            enter image description here






            share|improve this answer
























              up vote
              3
              down vote













              In case you could accept text box and not a TikZ node, tcolorbox offers a tcbsidebyside box where you can decide which part will adapt to its size while the other uses the available space (textwidth or box width).



              documentclassarticle
              usepackage[most]tcolorbox
              usepackagemulticol
              usepackagelmodern

              begindocument
              tcbsidebyside[notitle,
              sidebyside adapt=left,
              colback=white,
              enhanced,
              segmentation style=solid,
              sharp corners]
              %
              includegraphics[width=3cm]example-image-a
              %
              beginmulticols2
              This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
              endmulticols
              And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more


              tcbsidebyside[notitle,
              sidebyside adapt=left,
              colback=white,
              enhanced,
              segmentation style=solid,
              sharp corners]
              %
              includegraphics[width=5cm]example-image-a
              %
              And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more

              enddocument


              enter image description here






              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                In case you could accept text box and not a TikZ node, tcolorbox offers a tcbsidebyside box where you can decide which part will adapt to its size while the other uses the available space (textwidth or box width).



                documentclassarticle
                usepackage[most]tcolorbox
                usepackagemulticol
                usepackagelmodern

                begindocument
                tcbsidebyside[notitle,
                sidebyside adapt=left,
                colback=white,
                enhanced,
                segmentation style=solid,
                sharp corners]
                %
                includegraphics[width=3cm]example-image-a
                %
                beginmulticols2
                This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
                endmulticols
                And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more


                tcbsidebyside[notitle,
                sidebyside adapt=left,
                colback=white,
                enhanced,
                segmentation style=solid,
                sharp corners]
                %
                includegraphics[width=5cm]example-image-a
                %
                And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more

                enddocument


                enter image description here






                share|improve this answer












                In case you could accept text box and not a TikZ node, tcolorbox offers a tcbsidebyside box where you can decide which part will adapt to its size while the other uses the available space (textwidth or box width).



                documentclassarticle
                usepackage[most]tcolorbox
                usepackagemulticol
                usepackagelmodern

                begindocument
                tcbsidebyside[notitle,
                sidebyside adapt=left,
                colback=white,
                enhanced,
                segmentation style=solid,
                sharp corners]
                %
                includegraphics[width=3cm]example-image-a
                %
                beginmulticols2
                This is a lot of bla bla bla to see what is happening. And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more.
                endmulticols
                And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more


                tcbsidebyside[notitle,
                sidebyside adapt=left,
                colback=white,
                enhanced,
                segmentation style=solid,
                sharp corners]
                %
                includegraphics[width=5cm]example-image-a
                %
                And this is more text. and a lot more. And this is more text. and a lot more. And this is more text. and a lot more

                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 25 at 19:31









                Ignasi

                87.7k4157292




                87.7k4157292



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452488%2ftikz-rectangle-split-horizontal-extra-space%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

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

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?