Adding a small colored rounded box around inline text
Is it possible to write a command using TikZ to produce a small rounded and colored box around a piece of text, inside sentence? I know the framedbox
command gives a rectangle around a piece of text (but not a rounded rectangle as far as I know).
I guess one could also adjust the color of the background when using framebox (using tips from answers to this question), but I don't think it could help with other factors such as the box's edge-width, the amount of roundness, etc.
The following picture was produced with Inkscape for the purpose of the question.
tikz-pgf
add a comment |
Is it possible to write a command using TikZ to produce a small rounded and colored box around a piece of text, inside sentence? I know the framedbox
command gives a rectangle around a piece of text (but not a rounded rectangle as far as I know).
I guess one could also adjust the color of the background when using framebox (using tips from answers to this question), but I don't think it could help with other factors such as the box's edge-width, the amount of roundness, etc.
The following picture was produced with Inkscape for the purpose of the question.
tikz-pgf
2
How abouttcolorbox
? Ortikzmark
?
– marmot
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
3
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago
add a comment |
Is it possible to write a command using TikZ to produce a small rounded and colored box around a piece of text, inside sentence? I know the framedbox
command gives a rectangle around a piece of text (but not a rounded rectangle as far as I know).
I guess one could also adjust the color of the background when using framebox (using tips from answers to this question), but I don't think it could help with other factors such as the box's edge-width, the amount of roundness, etc.
The following picture was produced with Inkscape for the purpose of the question.
tikz-pgf
Is it possible to write a command using TikZ to produce a small rounded and colored box around a piece of text, inside sentence? I know the framedbox
command gives a rectangle around a piece of text (but not a rounded rectangle as far as I know).
I guess one could also adjust the color of the background when using framebox (using tips from answers to this question), but I don't think it could help with other factors such as the box's edge-width, the amount of roundness, etc.
The following picture was produced with Inkscape for the purpose of the question.
tikz-pgf
tikz-pgf
asked 1 hour ago
smilingbuddha
85641016
85641016
2
How abouttcolorbox
? Ortikzmark
?
– marmot
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
3
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago
add a comment |
2
How abouttcolorbox
? Ortikzmark
?
– marmot
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
3
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago
2
2
How about
tcolorbox
? Or tikzmark
?– marmot
1 hour ago
How about
tcolorbox
? Or tikzmark
?– marmot
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
3
3
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
Another option is tikzmark
, which less options than tcolorbox
, but allows you to connect different boxes and also detect the mode you are in (text vs. math etc.).
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
Here is some text and tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{test}{something about relativity}.
[tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{testeq}{E~=~m,c^2}
begin{tikzpicture}[overlay,remember picture]
draw[thick,cyan,latex-latex] (test.-5) to[out=-90,in=0] (testeq.east);
end{tikzpicture}]
end{document}
add a comment |
Either use TikZ
directly or tcolorbox
with tcbox
and a lot configurable settings.
If such boxes should appear more than once, a newtcbox
is appropiate, setting the options there and just saying inlinebox{foo}
etc.
As can be seen from the direct usage of tcbox
that the margins are too wide, but the inlinebox
has a nicer look, there the margins are set with left=...
and right=...
and boxsep=...
documentclass{article}
PassOptionsToPackage{svgnames,x11names,dvipsnames}{xcolor}
usepackage[most]{tcolorbox}
newtcbox{inlinebox}[1]{enhanced,
box align=base,
nobeforeafter,
colback=cyan,
colframe=Green4,
size=small,
left=0pt,
right=0pt,
boxsep=2pt,
#1}
begin{document}
Hello tcbox[enhanced,box align=base,nobeforeafter,colback=cyan,colframe=Green4,size=small]{World} -- what do you expect from the year inlinebox{2019}?
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f467833%2fadding-a-small-colored-rounded-box-around-inline-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Another option is tikzmark
, which less options than tcolorbox
, but allows you to connect different boxes and also detect the mode you are in (text vs. math etc.).
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
Here is some text and tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{test}{something about relativity}.
[tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{testeq}{E~=~m,c^2}
begin{tikzpicture}[overlay,remember picture]
draw[thick,cyan,latex-latex] (test.-5) to[out=-90,in=0] (testeq.east);
end{tikzpicture}]
end{document}
add a comment |
Another option is tikzmark
, which less options than tcolorbox
, but allows you to connect different boxes and also detect the mode you are in (text vs. math etc.).
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
Here is some text and tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{test}{something about relativity}.
[tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{testeq}{E~=~m,c^2}
begin{tikzpicture}[overlay,remember picture]
draw[thick,cyan,latex-latex] (test.-5) to[out=-90,in=0] (testeq.east);
end{tikzpicture}]
end{document}
add a comment |
Another option is tikzmark
, which less options than tcolorbox
, but allows you to connect different boxes and also detect the mode you are in (text vs. math etc.).
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
Here is some text and tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{test}{something about relativity}.
[tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{testeq}{E~=~m,c^2}
begin{tikzpicture}[overlay,remember picture]
draw[thick,cyan,latex-latex] (test.-5) to[out=-90,in=0] (testeq.east);
end{tikzpicture}]
end{document}
Another option is tikzmark
, which less options than tcolorbox
, but allows you to connect different boxes and also detect the mode you are in (text vs. math etc.).
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
Here is some text and tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{test}{something about relativity}.
[tikzmarknode[fill=cyan,fill
opacity=0.3,draw=green!60!black,thick,rounded corners,inner sep=2pt,text
opacity=1]{testeq}{E~=~m,c^2}
begin{tikzpicture}[overlay,remember picture]
draw[thick,cyan,latex-latex] (test.-5) to[out=-90,in=0] (testeq.east);
end{tikzpicture}]
end{document}
answered 1 hour ago
marmot
86.8k499185
86.8k499185
add a comment |
add a comment |
Either use TikZ
directly or tcolorbox
with tcbox
and a lot configurable settings.
If such boxes should appear more than once, a newtcbox
is appropiate, setting the options there and just saying inlinebox{foo}
etc.
As can be seen from the direct usage of tcbox
that the margins are too wide, but the inlinebox
has a nicer look, there the margins are set with left=...
and right=...
and boxsep=...
documentclass{article}
PassOptionsToPackage{svgnames,x11names,dvipsnames}{xcolor}
usepackage[most]{tcolorbox}
newtcbox{inlinebox}[1]{enhanced,
box align=base,
nobeforeafter,
colback=cyan,
colframe=Green4,
size=small,
left=0pt,
right=0pt,
boxsep=2pt,
#1}
begin{document}
Hello tcbox[enhanced,box align=base,nobeforeafter,colback=cyan,colframe=Green4,size=small]{World} -- what do you expect from the year inlinebox{2019}?
end{document}
add a comment |
Either use TikZ
directly or tcolorbox
with tcbox
and a lot configurable settings.
If such boxes should appear more than once, a newtcbox
is appropiate, setting the options there and just saying inlinebox{foo}
etc.
As can be seen from the direct usage of tcbox
that the margins are too wide, but the inlinebox
has a nicer look, there the margins are set with left=...
and right=...
and boxsep=...
documentclass{article}
PassOptionsToPackage{svgnames,x11names,dvipsnames}{xcolor}
usepackage[most]{tcolorbox}
newtcbox{inlinebox}[1]{enhanced,
box align=base,
nobeforeafter,
colback=cyan,
colframe=Green4,
size=small,
left=0pt,
right=0pt,
boxsep=2pt,
#1}
begin{document}
Hello tcbox[enhanced,box align=base,nobeforeafter,colback=cyan,colframe=Green4,size=small]{World} -- what do you expect from the year inlinebox{2019}?
end{document}
add a comment |
Either use TikZ
directly or tcolorbox
with tcbox
and a lot configurable settings.
If such boxes should appear more than once, a newtcbox
is appropiate, setting the options there and just saying inlinebox{foo}
etc.
As can be seen from the direct usage of tcbox
that the margins are too wide, but the inlinebox
has a nicer look, there the margins are set with left=...
and right=...
and boxsep=...
documentclass{article}
PassOptionsToPackage{svgnames,x11names,dvipsnames}{xcolor}
usepackage[most]{tcolorbox}
newtcbox{inlinebox}[1]{enhanced,
box align=base,
nobeforeafter,
colback=cyan,
colframe=Green4,
size=small,
left=0pt,
right=0pt,
boxsep=2pt,
#1}
begin{document}
Hello tcbox[enhanced,box align=base,nobeforeafter,colback=cyan,colframe=Green4,size=small]{World} -- what do you expect from the year inlinebox{2019}?
end{document}
Either use TikZ
directly or tcolorbox
with tcbox
and a lot configurable settings.
If such boxes should appear more than once, a newtcbox
is appropiate, setting the options there and just saying inlinebox{foo}
etc.
As can be seen from the direct usage of tcbox
that the margins are too wide, but the inlinebox
has a nicer look, there the margins are set with left=...
and right=...
and boxsep=...
documentclass{article}
PassOptionsToPackage{svgnames,x11names,dvipsnames}{xcolor}
usepackage[most]{tcolorbox}
newtcbox{inlinebox}[1]{enhanced,
box align=base,
nobeforeafter,
colback=cyan,
colframe=Green4,
size=small,
left=0pt,
right=0pt,
boxsep=2pt,
#1}
begin{document}
Hello tcbox[enhanced,box align=base,nobeforeafter,colback=cyan,colframe=Green4,size=small]{World} -- what do you expect from the year inlinebox{2019}?
end{document}
edited 1 hour ago
answered 1 hour ago
Christian Hupfer
147k14192386
147k14192386
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f467833%2fadding-a-small-colored-rounded-box-around-inline-text%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
2
How about
tcolorbox
? Ortikzmark
?– marmot
1 hour ago
possible duplicate : tex.stackexchange.com/q/458864/138900
– AndréC
1 hour ago
3
Possible duplicate of How to add a small rounded rectangle around a word inline
– AndréC
1 hour ago