How can I use `uline` from the `ulem` package to underline text inside a `colorbox`?
Screenshot:
I have the following code:
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
Which looks like this:

How can I get a continuous line for the text inside colorbox, too?
MCVE:
documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
end{document}
Constraints:
I cannot use soul and I think plain underline doesn't look very good. (By the way, those who can use soul should have a look at Underline text with background (soul and ulem nesting) )
formatting highlighting ulem underline colorbox
add a comment |
Screenshot:
I have the following code:
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
Which looks like this:

How can I get a continuous line for the text inside colorbox, too?
MCVE:
documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
end{document}
Constraints:
I cannot use soul and I think plain underline doesn't look very good. (By the way, those who can use soul should have a look at Underline text with background (soul and ulem nesting) )
formatting highlighting ulem underline colorbox
add a comment |
Screenshot:
I have the following code:
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
Which looks like this:

How can I get a continuous line for the text inside colorbox, too?
MCVE:
documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
end{document}
Constraints:
I cannot use soul and I think plain underline doesn't look very good. (By the way, those who can use soul should have a look at Underline text with background (soul and ulem nesting) )
formatting highlighting ulem underline colorbox
Screenshot:
I have the following code:
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
Which looks like this:

How can I get a continuous line for the text inside colorbox, too?
MCVE:
documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
uline{No underlining for colorbox{lightgray}{everything} inside the colorbox.}
end{document}
Constraints:
I cannot use soul and I think plain underline doesn't look very good. (By the way, those who can use soul should have a look at Underline text with background (soul and ulem nesting) )
formatting highlighting ulem underline colorbox
formatting highlighting ulem underline colorbox
asked Dec 20 '18 at 19:36
finefootfinefoot
215110
215110
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
One way is to underline in a box first:

documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
sbox0{uline{hspace{fboxsep}everythinghspace{fboxsep}}}
uline{No underlining for colorbox{lightgray}{hspace{-fboxsep}usebox0hspace{-fboxsep}} inside the colorbox.}
end{document}
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I meancolorboxis inside ofuline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?
– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content insideulineI'm afraid. Do you think there is hope for a solution without nesting?
– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefineuline so that locallycolorbox` is defined as I show above, or (given theulineworks withfboxsomeone may suggest a different extension so that it works directly with colorbox..
– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefineulinesocolorboxis locally defined to have underlined text, too
– finefoot
Jan 2 at 19:27
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%2f466745%2fhow-can-i-use-uline-from-the-ulem-package-to-underline-text-inside-a-colo%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One way is to underline in a box first:

documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
sbox0{uline{hspace{fboxsep}everythinghspace{fboxsep}}}
uline{No underlining for colorbox{lightgray}{hspace{-fboxsep}usebox0hspace{-fboxsep}} inside the colorbox.}
end{document}
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I meancolorboxis inside ofuline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?
– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content insideulineI'm afraid. Do you think there is hope for a solution without nesting?
– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefineuline so that locallycolorbox` is defined as I show above, or (given theulineworks withfboxsomeone may suggest a different extension so that it works directly with colorbox..
– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefineulinesocolorboxis locally defined to have underlined text, too
– finefoot
Jan 2 at 19:27
add a comment |
One way is to underline in a box first:

documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
sbox0{uline{hspace{fboxsep}everythinghspace{fboxsep}}}
uline{No underlining for colorbox{lightgray}{hspace{-fboxsep}usebox0hspace{-fboxsep}} inside the colorbox.}
end{document}
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I meancolorboxis inside ofuline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?
– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content insideulineI'm afraid. Do you think there is hope for a solution without nesting?
– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefineuline so that locallycolorbox` is defined as I show above, or (given theulineworks withfboxsomeone may suggest a different extension so that it works directly with colorbox..
– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefineulinesocolorboxis locally defined to have underlined text, too
– finefoot
Jan 2 at 19:27
add a comment |
One way is to underline in a box first:

documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
sbox0{uline{hspace{fboxsep}everythinghspace{fboxsep}}}
uline{No underlining for colorbox{lightgray}{hspace{-fboxsep}usebox0hspace{-fboxsep}} inside the colorbox.}
end{document}
One way is to underline in a box first:

documentclass[12pt]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{lmodern}
usepackage{xcolor}
usepackage[normalem]{ulem}
begin{document}
sbox0{uline{hspace{fboxsep}everythinghspace{fboxsep}}}
uline{No underlining for colorbox{lightgray}{hspace{-fboxsep}usebox0hspace{-fboxsep}} inside the colorbox.}
end{document}
answered Jan 2 at 1:25
David CarlisleDavid Carlisle
484k4011171859
484k4011171859
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I meancolorboxis inside ofuline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?
– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content insideulineI'm afraid. Do you think there is hope for a solution without nesting?
– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefineuline so that locallycolorbox` is defined as I show above, or (given theulineworks withfboxsomeone may suggest a different extension so that it works directly with colorbox..
– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefineulinesocolorboxis locally defined to have underlined text, too
– finefoot
Jan 2 at 19:27
add a comment |
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I meancolorboxis inside ofuline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?
– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content insideulineI'm afraid. Do you think there is hope for a solution without nesting?
– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefineuline so that locallycolorbox` is defined as I show above, or (given theulineworks withfboxsomeone may suggest a different extension so that it works directly with colorbox..
– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefineulinesocolorboxis locally defined to have underlined text, too
– finefoot
Jan 2 at 19:27
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I mean
colorbox is inside of uline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?– finefoot
Jan 2 at 16:44
Wow, okay. Thanks! :-) That's more complicated than I thought it would be. I mean
colorbox is inside of uline, I thought there would be a simple way to raise the "z-index" of the line or something like that... Can you explain why the line doesn't show up in front of the colorbox?– finefoot
Jan 2 at 16:44
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
@Jayjayyy not exactly, I started to trace but didn't have much time yesterday so i just nested the uline (the hspace are so the line spans over the fboxsep padding in the colorbox)
– David Carlisle
Jan 2 at 19:06
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content inside
uline I'm afraid. Do you think there is hope for a solution without nesting?– finefoot
Jan 2 at 19:13
Yes, it's definitely a valid answer to the question. :-) Unfortunately, I cannot use it like this because I cannot change the content inside
uline I'm afraid. Do you think there is hope for a solution without nesting?– finefoot
Jan 2 at 19:13
@Jayjayyy you could redefine
uline so that locally colorbox` is defined as I show above, or (given the uline works with fbox someone may suggest a different extension so that it works directly with colorbox..– David Carlisle
Jan 2 at 19:15
@Jayjayyy you could redefine
uline so that locally colorbox` is defined as I show above, or (given the uline works with fbox someone may suggest a different extension so that it works directly with colorbox..– David Carlisle
Jan 2 at 19:15
Thank you, I wasn't aware that this is possible. Opened a new question Redefine
uline so colorbox is locally defined to have underlined text, too– finefoot
Jan 2 at 19:27
Thank you, I wasn't aware that this is possible. Opened a new question Redefine
uline so colorbox is locally defined to have underlined text, too– finefoot
Jan 2 at 19:27
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%2f466745%2fhow-can-i-use-uline-from-the-ulem-package-to-underline-text-inside-a-colo%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