TikZ rectangle split horizontal extra space
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
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
tikz-pgf
add a comment |Â
up vote
4
down vote
favorite
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
tikz-pgf
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
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
tikz-pgf
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
tikz-pgf
tikz-pgf
asked Sep 25 at 17:30
sgmoye
3,64711225
3,64711225
add a comment |Â
add a comment |Â
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
Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I triedhbox
andmbox
but would wouldn't have thought ofvcenter
in a gajillion years. Some interaction betweenincludegraphics
andrectangle split horizontal
? I don't think I've ever seenincludegraphics
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, thevcenterhbox...
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 somebaseline
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
add a comment |Â
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
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 readTeXbook
... (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 somelatex
guru (what i'm not).
â Zarko
Sep 26 at 13:14
add a comment |Â
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
add a comment |Â
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
Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I triedhbox
andmbox
but would wouldn't have thought ofvcenter
in a gajillion years. Some interaction betweenincludegraphics
andrectangle split horizontal
? I don't think I've ever seenincludegraphics
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, thevcenterhbox...
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 somebaseline
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
add a comment |Â
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
Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I triedhbox
andmbox
but would wouldn't have thought ofvcenter
in a gajillion years. Some interaction betweenincludegraphics
andrectangle split horizontal
? I don't think I've ever seenincludegraphics
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, thevcenterhbox...
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 somebaseline
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
add a comment |Â
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
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
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 triedhbox
andmbox
but would wouldn't have thought ofvcenter
in a gajillion years. Some interaction betweenincludegraphics
andrectangle split horizontal
? I don't think I've ever seenincludegraphics
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, thevcenterhbox...
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 somebaseline
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
add a comment |Â
Hmmm. Thanks, but this begs the question: Why are two levels of extra boxing necessary to make this happen? I triedhbox
andmbox
but would wouldn't have thought ofvcenter
in a gajillion years. Some interaction betweenincludegraphics
andrectangle split horizontal
? I don't think I've ever seenincludegraphics
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, thevcenterhbox...
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 somebaseline
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
add a comment |Â
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
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 readTeXbook
... (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 somelatex
guru (what i'm not).
â Zarko
Sep 26 at 13:14
add a comment |Â
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
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 readTeXbook
... (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 somelatex
guru (what i'm not).
â Zarko
Sep 26 at 13:14
add a comment |Â
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
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
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 readTeXbook
... (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 somelatex
guru (what i'm not).
â Zarko
Sep 26 at 13:14
add a comment |Â
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 readTeXbook
... (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 somelatex
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
answered Sep 25 at 19:31
Ignasi
87.7k4157292
87.7k4157292
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password