How to define an inner margin for a tcolorbox?
up vote
12
down vote
favorite
I created a poster with the baposter class. The basic structure is defined through posterbox objects. Within these, I did embed pictures, using tcolorbox as frame.
Actual Code:
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
includegraphics[width=5.8cm]{figure.eps}
end{tcolorbox}
Minimal working example:
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
end{tcolorbox}
end{document}
I did realize that the embedded image protrudes the rounded corners. How can I apply something like an inner margin? I did play with the boxsep argument, which did not seem to help.
Sorry for not providing the complete file. I would have to strip quite a lot, since the poster contains a lot of unpublished data.
Edit: Sorry for not providing an image! MWE also included now.
Also happens for empty tcolorboxes.
This portion added by Steven Segletes to better demonstrate the strange behavior. Changing the arc
units from em
to pt
changes the behavior completely.
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=.3em,boxsep=-1mm]
end{tcolorbox}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=3.4pt,boxsep=-1mm]
end{tcolorbox}
end{document}
tcolorbox
|
show 5 more comments
up vote
12
down vote
favorite
I created a poster with the baposter class. The basic structure is defined through posterbox objects. Within these, I did embed pictures, using tcolorbox as frame.
Actual Code:
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
includegraphics[width=5.8cm]{figure.eps}
end{tcolorbox}
Minimal working example:
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
end{tcolorbox}
end{document}
I did realize that the embedded image protrudes the rounded corners. How can I apply something like an inner margin? I did play with the boxsep argument, which did not seem to help.
Sorry for not providing the complete file. I would have to strip quite a lot, since the poster contains a lot of unpublished data.
Edit: Sorry for not providing an image! MWE also included now.
Also happens for empty tcolorboxes.
This portion added by Steven Segletes to better demonstrate the strange behavior. Changing the arc
units from em
to pt
changes the behavior completely.
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=.3em,boxsep=-1mm]
end{tcolorbox}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=3.4pt,boxsep=-1mm]
end{tcolorbox}
end{document}
tcolorbox
Welcome to TeX.SX! Try to use theleft=
,right=
etc. options, with some length arguments. Theboxsep
option acts in addition to them
– Christian Hupfer
Jan 7 '15 at 20:32
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
1
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting withdocumentclass{...}
and ending withend{document}
.
– Christian Hupfer
Jan 7 '15 at 20:51
1
Interestingly, if you specifyarc
inpt
instead ofem
, all seems well. Very strange.
– Steven B. Segletes
Jan 7 '15 at 21:16
|
show 5 more comments
up vote
12
down vote
favorite
up vote
12
down vote
favorite
I created a poster with the baposter class. The basic structure is defined through posterbox objects. Within these, I did embed pictures, using tcolorbox as frame.
Actual Code:
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
includegraphics[width=5.8cm]{figure.eps}
end{tcolorbox}
Minimal working example:
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
end{tcolorbox}
end{document}
I did realize that the embedded image protrudes the rounded corners. How can I apply something like an inner margin? I did play with the boxsep argument, which did not seem to help.
Sorry for not providing the complete file. I would have to strip quite a lot, since the poster contains a lot of unpublished data.
Edit: Sorry for not providing an image! MWE also included now.
Also happens for empty tcolorboxes.
This portion added by Steven Segletes to better demonstrate the strange behavior. Changing the arc
units from em
to pt
changes the behavior completely.
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=.3em,boxsep=-1mm]
end{tcolorbox}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=3.4pt,boxsep=-1mm]
end{tcolorbox}
end{document}
tcolorbox
I created a poster with the baposter class. The basic structure is defined through posterbox objects. Within these, I did embed pictures, using tcolorbox as frame.
Actual Code:
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
includegraphics[width=5.8cm]{figure.eps}
end{tcolorbox}
Minimal working example:
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=0.6em,boxsep=-1mm]
end{tcolorbox}
end{document}
I did realize that the embedded image protrudes the rounded corners. How can I apply something like an inner margin? I did play with the boxsep argument, which did not seem to help.
Sorry for not providing the complete file. I would have to strip quite a lot, since the poster contains a lot of unpublished data.
Edit: Sorry for not providing an image! MWE also included now.
Also happens for empty tcolorboxes.
This portion added by Steven Segletes to better demonstrate the strange behavior. Changing the arc
units from em
to pt
changes the behavior completely.
documentclass[a0paper,portrait]{article}
usepackage{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=.3em,boxsep=-1mm]
end{tcolorbox}
begin{tcolorbox}[colframe=gray,colback=white,boxrule=2pt,arc=3.4pt,boxsep=-1mm]
end{tcolorbox}
end{document}
tcolorbox
tcolorbox
edited Jan 7 '15 at 21:21


Steven B. Segletes
151k9190398
151k9190398
asked Jan 7 '15 at 20:28
engineer
5361413
5361413
Welcome to TeX.SX! Try to use theleft=
,right=
etc. options, with some length arguments. Theboxsep
option acts in addition to them
– Christian Hupfer
Jan 7 '15 at 20:32
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
1
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting withdocumentclass{...}
and ending withend{document}
.
– Christian Hupfer
Jan 7 '15 at 20:51
1
Interestingly, if you specifyarc
inpt
instead ofem
, all seems well. Very strange.
– Steven B. Segletes
Jan 7 '15 at 21:16
|
show 5 more comments
Welcome to TeX.SX! Try to use theleft=
,right=
etc. options, with some length arguments. Theboxsep
option acts in addition to them
– Christian Hupfer
Jan 7 '15 at 20:32
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
1
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting withdocumentclass{...}
and ending withend{document}
.
– Christian Hupfer
Jan 7 '15 at 20:51
1
Interestingly, if you specifyarc
inpt
instead ofem
, all seems well. Very strange.
– Steven B. Segletes
Jan 7 '15 at 21:16
Welcome to TeX.SX! Try to use the
left=
, right=
etc. options, with some length arguments. The boxsep
option acts in addition to them– Christian Hupfer
Jan 7 '15 at 20:32
Welcome to TeX.SX! Try to use the
left=
, right=
etc. options, with some length arguments. The boxsep
option acts in addition to them– Christian Hupfer
Jan 7 '15 at 20:32
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
1
1
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with
documentclass{...}
and ending with end{document}
.– Christian Hupfer
Jan 7 '15 at 20:51
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with
documentclass{...}
and ending with end{document}
.– Christian Hupfer
Jan 7 '15 at 20:51
1
1
Interestingly, if you specify
arc
in pt
instead of em
, all seems well. Very strange.– Steven B. Segletes
Jan 7 '15 at 21:16
Interestingly, if you specify
arc
in pt
instead of em
, all seems well. Very strange.– Steven B. Segletes
Jan 7 '15 at 21:16
|
show 5 more comments
1 Answer
1
active
oldest
votes
up vote
17
down vote
accepted
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
documentclass[a0paper,portrait]{article}
usepackage[skins]{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
includegraphics[width=linewidth]{example-image}
end{tcolorbox}
end{document}
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
begin{tcolorbox}[arc=0.3em]
end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version3.40
.
– Thomas F. Sturm
Jan 17 '15 at 18:56
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
17
down vote
accepted
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
documentclass[a0paper,portrait]{article}
usepackage[skins]{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
includegraphics[width=linewidth]{example-image}
end{tcolorbox}
end{document}
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
begin{tcolorbox}[arc=0.3em]
end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version3.40
.
– Thomas F. Sturm
Jan 17 '15 at 18:56
add a comment |
up vote
17
down vote
accepted
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
documentclass[a0paper,portrait]{article}
usepackage[skins]{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
includegraphics[width=linewidth]{example-image}
end{tcolorbox}
end{document}
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
begin{tcolorbox}[arc=0.3em]
end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version3.40
.
– Thomas F. Sturm
Jan 17 '15 at 18:56
add a comment |
up vote
17
down vote
accepted
up vote
17
down vote
accepted
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
documentclass[a0paper,portrait]{article}
usepackage[skins]{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
includegraphics[width=linewidth]{example-image}
end{tcolorbox}
end{document}
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
begin{tcolorbox}[arc=0.3em]
end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
There is more than one question to answer here. I try to answer them step by step.
1. How to define an inner margin for a tcolorbox?
The margins are set by left
, right
, top
, bottom
. Additionally, boxsep
is added to all these values for the resulting margin.
E.g.
begin{tcolorbox}[boxsep=1pt,left=2pt,right=2pt,top=0pt,bottom=0pt]...
gives a total of 3pt
for the left and right margin, and a total of 1pt
for the top and bottom margin.
2. Content clipping
If rounded corners are used, but there is no margin or a very small margin, the text content (e.g. a picture) can protrude over the rounded corners. This can be avoided by using the enhanced
and clip upper
options of the skins
library which clip the interior:
documentclass[a0paper,portrait]{article}
usepackage[skins]{tcolorbox}
begin{document}
title{Test}
begin{tcolorbox}[
enhanced,clip upper,%<------------
colframe=gray,colback=white,boxrule=2pt,arc=10pt,
boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt]
includegraphics[width=linewidth]{example-image}
end{tcolorbox}
end{document}
3. Font dependend units
A tcolorbox
is drawn inside a pgfpicture
or a tikzpicture
environment. Inside such an environment, a nullfont is used. If font dependend units like arc=.3em
are given, the actual sizing depends on where this setting is used exactly inside the internal implementation. If it is used (and expanded) before the actual tikzpicture
, it will have the intended size, but if it is used very lately in the drawing process, it may become zero.
Using
begin{tcolorbox}[arc=0.3em]
end{tcolorbox}
gives an unlucky combination of this effect. The outer arc
is computed automatically before the graphical environment is started. It gets the intended (expanded) size. The inner arc (i.e. arc
) stays at 0.3em
and becomes 0pt
inside the graphical environment.
So, currently, one should use fixed units like 3pt
or 3mm
to avoid such effects. But, for the next tcolorbox
version (3.36
or higher), I will implement a sanitize procedure which freezes font depended units before entering the graphical environment.
edited Jan 8 '15 at 16:27
answered Jan 8 '15 at 7:08


Thomas F. Sturm
19.2k13171
19.2k13171
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version3.40
.
– Thomas F. Sturm
Jan 17 '15 at 18:56
add a comment |
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version3.40
.
– Thomas F. Sturm
Jan 17 '15 at 18:56
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version
3.40
.– Thomas F. Sturm
Jan 17 '15 at 18:56
@AboAmmar Thank you :-) Meanwhile, the sanitize procedure for font dependend units is implemented in the current version
3.40
.– Thomas F. Sturm
Jan 17 '15 at 18:56
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f222152%2fhow-to-define-an-inner-margin-for-a-tcolorbox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to TeX.SX! Try to use the
left=
,right=
etc. options, with some length arguments. Theboxsep
option acts in addition to them– Christian Hupfer
Jan 7 '15 at 20:32
Thank you for the fast response. left/right= seems to shift e.g. text within the tcolorbox, but the embedded image remains in its place.
– engineer
Jan 7 '15 at 20:44
Perhaps your image is too large? ;-)
– Christian Hupfer
Jan 7 '15 at 20:45
1
Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with
documentclass{...}
and ending withend{document}
.– Christian Hupfer
Jan 7 '15 at 20:51
1
Interestingly, if you specify
arc
inpt
instead ofem
, all seems well. Very strange.– Steven B. Segletes
Jan 7 '15 at 21:16