How to add a small rounded rectangle around a word inline
up vote
7
down vote
favorite
I want to add a box with a very light pink background and red border around a word but inline and within a sentence.
i.e. something like this (drawn with inkscape)
I know the mdframed
package can be used for placing boxes around paragraphs, but it does not seem to work inline and also give colored boxes.
Possibly TikZ is a solution? From the little I know of TikZ, it can be used to draw pictures inline inside a sentence.
tikz-pgf boxes
add a comment |
up vote
7
down vote
favorite
I want to add a box with a very light pink background and red border around a word but inline and within a sentence.
i.e. something like this (drawn with inkscape)
I know the mdframed
package can be used for placing boxes around paragraphs, but it does not seem to work inline and also give colored boxes.
Possibly TikZ is a solution? From the little I know of TikZ, it can be used to draw pictures inline inside a sentence.
tikz-pgf boxes
Seetcolorbox
package documentation at the bottom of page 16.
– CarLaTeX
Nov 7 at 20:46
add a comment |
up vote
7
down vote
favorite
up vote
7
down vote
favorite
I want to add a box with a very light pink background and red border around a word but inline and within a sentence.
i.e. something like this (drawn with inkscape)
I know the mdframed
package can be used for placing boxes around paragraphs, but it does not seem to work inline and also give colored boxes.
Possibly TikZ is a solution? From the little I know of TikZ, it can be used to draw pictures inline inside a sentence.
tikz-pgf boxes
I want to add a box with a very light pink background and red border around a word but inline and within a sentence.
i.e. something like this (drawn with inkscape)
I know the mdframed
package can be used for placing boxes around paragraphs, but it does not seem to work inline and also give colored boxes.
Possibly TikZ is a solution? From the little I know of TikZ, it can be used to draw pictures inline inside a sentence.
tikz-pgf boxes
tikz-pgf boxes
edited Nov 7 at 22:12
asked Nov 7 at 20:42
smilingbuddha
6954915
6954915
Seetcolorbox
package documentation at the bottom of page 16.
– CarLaTeX
Nov 7 at 20:46
add a comment |
Seetcolorbox
package documentation at the bottom of page 16.
– CarLaTeX
Nov 7 at 20:46
See
tcolorbox
package documentation at the bottom of page 16.– CarLaTeX
Nov 7 at 20:46
See
tcolorbox
package documentation at the bottom of page 16.– CarLaTeX
Nov 7 at 20:46
add a comment |
2 Answers
2
active
oldest
votes
up vote
7
down vote
accepted
Update : Adding a solution using tcolorbox
Yes, it is possible with TikZ
. You can do this in two ways:
- by including the code directly in the text.
- by creating a LaTeX command named
autour
which contains theTikZ
code.
Here is an example of two possibilities that have different parameters in order to visually show their effects.
documentclass{article}
usepackage{tikz}
newcommand{autour}[1]{tikz[baseline=(X.base)]node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
begin{document}
Quick brown fox tikz[baseline=(X.base)]node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
bigskip
Quick brown fox autour{jumped} over the lazy dog.
end{document}
Update : with tcolorbox
A simple adaptation of the code on page 16 of the manual indicated by @CarlaTeX in its commentary.
documentclass{article}
usepackage{tcolorbox}
newtcbox{entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
begin{document}
Quick brown fox entoure{jumped} over the lazy dog.
Quick brown fox entoure[blue]{jumped} over the lazy dog.
end{document}
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
add a comment |
up vote
7
down vote
This is a bit similar to AndréC's answer but to point out that there so some extent tikzmarknode
, which comes with the really cool tikzmark
library, got reinvented. And tikzmark
allows you to do much more, of course.
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
section*{Some basic examples}
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
bigskip
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
section*{Some more elaborate examples}
As it is well known,
[ sumlimits_{tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^infty
k~=~-frac{1}{12};,]
where $tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
tikz[overlay,remember picture]{draw[latex-latex] (B) to[bend left] (A);
draw[latex-latex] (k1) to[bend right] (k2);
}
end{document}
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention thattikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.
– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities oftikzmark
that I still did not know. Unfortunately, having to write the completetikzmark
code every time you want to frame a word is not very practical to use here. You should add aLaTeX
command that would simplify its use for our friend @smilingbuddha.
– AndréC
Nov 8 at 5:48
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
Update : Adding a solution using tcolorbox
Yes, it is possible with TikZ
. You can do this in two ways:
- by including the code directly in the text.
- by creating a LaTeX command named
autour
which contains theTikZ
code.
Here is an example of two possibilities that have different parameters in order to visually show their effects.
documentclass{article}
usepackage{tikz}
newcommand{autour}[1]{tikz[baseline=(X.base)]node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
begin{document}
Quick brown fox tikz[baseline=(X.base)]node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
bigskip
Quick brown fox autour{jumped} over the lazy dog.
end{document}
Update : with tcolorbox
A simple adaptation of the code on page 16 of the manual indicated by @CarlaTeX in its commentary.
documentclass{article}
usepackage{tcolorbox}
newtcbox{entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
begin{document}
Quick brown fox entoure{jumped} over the lazy dog.
Quick brown fox entoure[blue]{jumped} over the lazy dog.
end{document}
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
add a comment |
up vote
7
down vote
accepted
Update : Adding a solution using tcolorbox
Yes, it is possible with TikZ
. You can do this in two ways:
- by including the code directly in the text.
- by creating a LaTeX command named
autour
which contains theTikZ
code.
Here is an example of two possibilities that have different parameters in order to visually show their effects.
documentclass{article}
usepackage{tikz}
newcommand{autour}[1]{tikz[baseline=(X.base)]node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
begin{document}
Quick brown fox tikz[baseline=(X.base)]node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
bigskip
Quick brown fox autour{jumped} over the lazy dog.
end{document}
Update : with tcolorbox
A simple adaptation of the code on page 16 of the manual indicated by @CarlaTeX in its commentary.
documentclass{article}
usepackage{tcolorbox}
newtcbox{entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
begin{document}
Quick brown fox entoure{jumped} over the lazy dog.
Quick brown fox entoure[blue]{jumped} over the lazy dog.
end{document}
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
add a comment |
up vote
7
down vote
accepted
up vote
7
down vote
accepted
Update : Adding a solution using tcolorbox
Yes, it is possible with TikZ
. You can do this in two ways:
- by including the code directly in the text.
- by creating a LaTeX command named
autour
which contains theTikZ
code.
Here is an example of two possibilities that have different parameters in order to visually show their effects.
documentclass{article}
usepackage{tikz}
newcommand{autour}[1]{tikz[baseline=(X.base)]node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
begin{document}
Quick brown fox tikz[baseline=(X.base)]node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
bigskip
Quick brown fox autour{jumped} over the lazy dog.
end{document}
Update : with tcolorbox
A simple adaptation of the code on page 16 of the manual indicated by @CarlaTeX in its commentary.
documentclass{article}
usepackage{tcolorbox}
newtcbox{entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
begin{document}
Quick brown fox entoure{jumped} over the lazy dog.
Quick brown fox entoure[blue]{jumped} over the lazy dog.
end{document}
Update : Adding a solution using tcolorbox
Yes, it is possible with TikZ
. You can do this in two ways:
- by including the code directly in the text.
- by creating a LaTeX command named
autour
which contains theTikZ
code.
Here is an example of two possibilities that have different parameters in order to visually show their effects.
documentclass{article}
usepackage{tikz}
newcommand{autour}[1]{tikz[baseline=(X.base)]node [draw=red,fill=gray!40,semithick,rectangle,inner sep=2pt, rounded corners=3pt] (X) {#1};}
begin{document}
Quick brown fox tikz[baseline=(X.base)]node [draw=black,fill=cyan!20,thick,rectangle,inner sep=3pt, rounded corners=4pt] (X) {jumped}; over the lazy dog.
bigskip
Quick brown fox autour{jumped} over the lazy dog.
end{document}
Update : with tcolorbox
A simple adaptation of the code on page 16 of the manual indicated by @CarlaTeX in its commentary.
documentclass{article}
usepackage{tcolorbox}
newtcbox{entoure}[1][red]{on line,
arc=3pt,colback=#1!10!white,colframe=#1!50!black,
before upper={rule[-3pt]{0pt}{10pt}},boxrule=1pt,
boxsep=0pt,left=2pt,right=2pt,top=1pt,bottom=.5pt}
begin{document}
Quick brown fox entoure{jumped} over the lazy dog.
Quick brown fox entoure[blue]{jumped} over the lazy dog.
end{document}
edited Nov 8 at 6:01
answered Nov 7 at 21:23
AndréC
5,5121937
5,5121937
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
add a comment |
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
Works great! Thanks!
– smilingbuddha
Nov 7 at 22:10
add a comment |
up vote
7
down vote
This is a bit similar to AndréC's answer but to point out that there so some extent tikzmarknode
, which comes with the really cool tikzmark
library, got reinvented. And tikzmark
allows you to do much more, of course.
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
section*{Some basic examples}
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
bigskip
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
section*{Some more elaborate examples}
As it is well known,
[ sumlimits_{tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^infty
k~=~-frac{1}{12};,]
where $tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
tikz[overlay,remember picture]{draw[latex-latex] (B) to[bend left] (A);
draw[latex-latex] (k1) to[bend right] (k2);
}
end{document}
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention thattikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.
– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities oftikzmark
that I still did not know. Unfortunately, having to write the completetikzmark
code every time you want to frame a word is not very practical to use here. You should add aLaTeX
command that would simplify its use for our friend @smilingbuddha.
– AndréC
Nov 8 at 5:48
add a comment |
up vote
7
down vote
This is a bit similar to AndréC's answer but to point out that there so some extent tikzmarknode
, which comes with the really cool tikzmark
library, got reinvented. And tikzmark
allows you to do much more, of course.
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
section*{Some basic examples}
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
bigskip
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
section*{Some more elaborate examples}
As it is well known,
[ sumlimits_{tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^infty
k~=~-frac{1}{12};,]
where $tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
tikz[overlay,remember picture]{draw[latex-latex] (B) to[bend left] (A);
draw[latex-latex] (k1) to[bend right] (k2);
}
end{document}
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention thattikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.
– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities oftikzmark
that I still did not know. Unfortunately, having to write the completetikzmark
code every time you want to frame a word is not very practical to use here. You should add aLaTeX
command that would simplify its use for our friend @smilingbuddha.
– AndréC
Nov 8 at 5:48
add a comment |
up vote
7
down vote
up vote
7
down vote
This is a bit similar to AndréC's answer but to point out that there so some extent tikzmarknode
, which comes with the really cool tikzmark
library, got reinvented. And tikzmark
allows you to do much more, of course.
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
section*{Some basic examples}
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
bigskip
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
section*{Some more elaborate examples}
As it is well known,
[ sumlimits_{tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^infty
k~=~-frac{1}{12};,]
where $tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
tikz[overlay,remember picture]{draw[latex-latex] (B) to[bend left] (A);
draw[latex-latex] (k1) to[bend right] (k2);
}
end{document}
This is a bit similar to AndréC's answer but to point out that there so some extent tikzmarknode
, which comes with the really cool tikzmark
library, got reinvented. And tikzmark
allows you to do much more, of course.
documentclass{article}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
section*{Some basic examples}
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=cyan!30]{A}{jumped} over the lazy dog.
bigskip
The quick brown fox tikzmarknode[draw,inner sep=2pt,rounded corners,fill=red!30]{B}{jumped} over the lazy dog.
section*{Some more elaborate examples}
As it is well known,
[ sumlimits_{tikzmarknode[rounded corners,fill=blue!30,inner sep=1pt]{k1}{k}=1}^infty
k~=~-frac{1}{12};,]
where $tikzmarknode[rounded corners,fill=blue!30,inner sep=2pt]{k2}{k}$ is a summation index.
tikz[overlay,remember picture]{draw[latex-latex] (B) to[bend left] (A);
draw[latex-latex] (k1) to[bend right] (k2);
}
end{document}
edited Nov 7 at 22:28
answered Nov 7 at 22:05
marmot
74.6k482157
74.6k482157
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention thattikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.
– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities oftikzmark
that I still did not know. Unfortunately, having to write the completetikzmark
code every time you want to frame a word is not very practical to use here. You should add aLaTeX
command that would simplify its use for our friend @smilingbuddha.
– AndréC
Nov 8 at 5:48
add a comment |
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention thattikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.
– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities oftikzmark
that I still did not know. Unfortunately, having to write the completetikzmark
code every time you want to frame a word is not very practical to use here. You should add aLaTeX
command that would simplify its use for our friend @smilingbuddha.
– AndréC
Nov 8 at 5:48
1
1
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
Wow cool! Thanks!
– smilingbuddha
Nov 7 at 22:11
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
So tikzmark allows you to connect one or more marked positions on the page, is that correct?
– smilingbuddha
Nov 7 at 22:24
@smilingbuddha You're welcome. Let me also mention that
tikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.– marmot
Nov 7 at 22:32
@smilingbuddha You're welcome. Let me also mention that
tikzmark
does actually much more than what I showed. I add some more info. One particularly nice feature is that it detects whether or not you are in math mode, and if you are in math mode, in which style. So it always gives you the right fonts and sizes, things that, sorry to say that so openly, AndrèC's proposal fails to achieve. And given how complicated it is to achieve this, I am deeply impressed by what LoopSpace has done.– marmot
Nov 7 at 22:32
I have just discovered thanks to your answer the great possibilities of
tikzmark
that I still did not know. Unfortunately, having to write the complete tikzmark
code every time you want to frame a word is not very practical to use here. You should add a LaTeX
command that would simplify its use for our friend @smilingbuddha.– AndréC
Nov 8 at 5:48
I have just discovered thanks to your answer the great possibilities of
tikzmark
that I still did not know. Unfortunately, having to write the complete tikzmark
code every time you want to frame a word is not very practical to use here. You should add a LaTeX
command that would simplify its use for our friend @smilingbuddha.– AndréC
Nov 8 at 5:48
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%2f458864%2fhow-to-add-a-small-rounded-rectangle-around-a-word-inline%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
See
tcolorbox
package documentation at the bottom of page 16.– CarLaTeX
Nov 7 at 20:46