Coloring a sub-table

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I want modify the following example to obtain a colored sub-table (only the border) as in the present picture.

documentclassarticle
usepackagearray
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
hline
A & B& C& B& C \
hline
D & E & K& B& F \
hline
G & H & I& B& C\
hline
endtabular
enddocument
tables
add a comment |
up vote
3
down vote
favorite
I want modify the following example to obtain a colored sub-table (only the border) as in the present picture.

documentclassarticle
usepackagearray
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
hline
A & B& C& B& C \
hline
D & E & K& B& F \
hline
G & H & I& B& C\
hline
endtabular
enddocument
tables
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I want modify the following example to obtain a colored sub-table (only the border) as in the present picture.

documentclassarticle
usepackagearray
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
hline
A & B& C& B& C \
hline
D & E & K& B& F \
hline
G & H & I& B& C\
hline
endtabular
enddocument
tables
I want modify the following example to obtain a colored sub-table (only the border) as in the present picture.

documentclassarticle
usepackagearray
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
hline
A & B& C& B& C \
hline
D & E & K& B& F \
hline
G & H & I& B& C\
hline
endtabular
enddocument
tables
tables
edited Dec 1 at 22:08
asked Dec 1 at 21:55
user105476
645
645
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
8
down vote
Not that elegant, but you could use a combination of cline and multicolumn to achieve the desired red frame around the four cells:
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
A & multicolumn1c!colorredvruleB& C& multicolumn1c!colorredvruleB& C \
hline
D & multicolumn1c!colorredvruleE & K& multicolumn1c!colorredvruleB& F \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
G & H & I& B& C\
hline
endtabular
enddocument

Thank you ........
– user105476
Dec 1 at 22:58
add a comment |
up vote
7
down vote
That's just for fun: you can draw pretty much anything with tikz, so why not here? In particular, when using tikzmark you can conveniently annotate whatever you already have.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
draw[red,thick] ([yshift=-1pt]$(3)!0.5!(C1)$) rectangle ([yshift=-1pt]$(B)!0.5!(C2)$);
endtikzpicture
enddocument

To be clear, I am not suggesting to use this if you only want to draw some red lines. In this case, I think that Leandris' very nice answer is the way to go. However, at the very moment you are interested in more fancy things, then this here might be the way to go.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
newlengthBorder
Border=0.8pt
fill[left color=red,right color=blue,shading angle=45,even odd rule]
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1-0.5Border,xshift=+0.5Border]$(B)!0.5!(C2)$)
[rounded corners]
([yshift=-1pt-0.5Border,xshift=0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(B)!0.5!(C2)$)
;
endtikzpicture
enddocument

add a comment |
up vote
3
down vote
You can use cellcolor.. to color single cells. You need the xcolor package or just the colortbl package, the former loads the latter. Note that some PDF viewers hide table lines behind the color.
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \hline
A & B& cellcolorblue!25C& cellcolorblue!25B& C \hline
D & E & cellcolorblue!25K& cellcolorblue!25B& F \hline
G & H & I& B& C \hline
endtabular
enddocument

1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
Not that elegant, but you could use a combination of cline and multicolumn to achieve the desired red frame around the four cells:
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
A & multicolumn1c!colorredvruleB& C& multicolumn1c!colorredvruleB& C \
hline
D & multicolumn1c!colorredvruleE & K& multicolumn1c!colorredvruleB& F \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
G & H & I& B& C\
hline
endtabular
enddocument

Thank you ........
– user105476
Dec 1 at 22:58
add a comment |
up vote
8
down vote
Not that elegant, but you could use a combination of cline and multicolumn to achieve the desired red frame around the four cells:
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
A & multicolumn1c!colorredvruleB& C& multicolumn1c!colorredvruleB& C \
hline
D & multicolumn1c!colorredvruleE & K& multicolumn1c!colorredvruleB& F \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
G & H & I& B& C\
hline
endtabular
enddocument

Thank you ........
– user105476
Dec 1 at 22:58
add a comment |
up vote
8
down vote
up vote
8
down vote
Not that elegant, but you could use a combination of cline and multicolumn to achieve the desired red frame around the four cells:
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
A & multicolumn1c!colorredvruleB& C& multicolumn1c!colorredvruleB& C \
hline
D & multicolumn1c!colorredvruleE & K& multicolumn1c!colorredvruleB& F \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
G & H & I& B& C\
hline
endtabular
enddocument

Not that elegant, but you could use a combination of cline and multicolumn to achieve the desired red frame around the four cells:
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
A & multicolumn1c!colorredvruleB& C& multicolumn1c!colorredvruleB& C \
hline
D & multicolumn1c!colorredvruleE & K& multicolumn1c!colorredvruleB& F \
cline1-2 arrayrulecolorredcline3-4 arrayrulecolorblackcline5-5
G & H & I& B& C\
hline
endtabular
enddocument

edited Dec 2 at 9:20
answered Dec 1 at 22:55
leandriis
7,8771528
7,8771528
Thank you ........
– user105476
Dec 1 at 22:58
add a comment |
Thank you ........
– user105476
Dec 1 at 22:58
Thank you ........
– user105476
Dec 1 at 22:58
Thank you ........
– user105476
Dec 1 at 22:58
add a comment |
up vote
7
down vote
That's just for fun: you can draw pretty much anything with tikz, so why not here? In particular, when using tikzmark you can conveniently annotate whatever you already have.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
draw[red,thick] ([yshift=-1pt]$(3)!0.5!(C1)$) rectangle ([yshift=-1pt]$(B)!0.5!(C2)$);
endtikzpicture
enddocument

To be clear, I am not suggesting to use this if you only want to draw some red lines. In this case, I think that Leandris' very nice answer is the way to go. However, at the very moment you are interested in more fancy things, then this here might be the way to go.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
newlengthBorder
Border=0.8pt
fill[left color=red,right color=blue,shading angle=45,even odd rule]
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1-0.5Border,xshift=+0.5Border]$(B)!0.5!(C2)$)
[rounded corners]
([yshift=-1pt-0.5Border,xshift=0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(B)!0.5!(C2)$)
;
endtikzpicture
enddocument

add a comment |
up vote
7
down vote
That's just for fun: you can draw pretty much anything with tikz, so why not here? In particular, when using tikzmark you can conveniently annotate whatever you already have.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
draw[red,thick] ([yshift=-1pt]$(3)!0.5!(C1)$) rectangle ([yshift=-1pt]$(B)!0.5!(C2)$);
endtikzpicture
enddocument

To be clear, I am not suggesting to use this if you only want to draw some red lines. In this case, I think that Leandris' very nice answer is the way to go. However, at the very moment you are interested in more fancy things, then this here might be the way to go.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
newlengthBorder
Border=0.8pt
fill[left color=red,right color=blue,shading angle=45,even odd rule]
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1-0.5Border,xshift=+0.5Border]$(B)!0.5!(C2)$)
[rounded corners]
([yshift=-1pt-0.5Border,xshift=0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(B)!0.5!(C2)$)
;
endtikzpicture
enddocument

add a comment |
up vote
7
down vote
up vote
7
down vote
That's just for fun: you can draw pretty much anything with tikz, so why not here? In particular, when using tikzmark you can conveniently annotate whatever you already have.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
draw[red,thick] ([yshift=-1pt]$(3)!0.5!(C1)$) rectangle ([yshift=-1pt]$(B)!0.5!(C2)$);
endtikzpicture
enddocument

To be clear, I am not suggesting to use this if you only want to draw some red lines. In this case, I think that Leandris' very nice answer is the way to go. However, at the very moment you are interested in more fancy things, then this here might be the way to go.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
newlengthBorder
Border=0.8pt
fill[left color=red,right color=blue,shading angle=45,even odd rule]
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1-0.5Border,xshift=+0.5Border]$(B)!0.5!(C2)$)
[rounded corners]
([yshift=-1pt-0.5Border,xshift=0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(B)!0.5!(C2)$)
;
endtikzpicture
enddocument

That's just for fun: you can draw pretty much anything with tikz, so why not here? In particular, when using tikzmark you can conveniently annotate whatever you already have.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
draw[red,thick] ([yshift=-1pt]$(3)!0.5!(C1)$) rectangle ([yshift=-1pt]$(B)!0.5!(C2)$);
endtikzpicture
enddocument

To be clear, I am not suggesting to use this if you only want to draw some red lines. In this case, I think that Leandris' very nice answer is the way to go. However, at the very moment you are interested in more fancy things, then this here might be the way to go.
documentclassarticle
usepackagearray
usepackagetikz
usetikzlibrarytikzmark,calc
begindocument
begintabularc
hline
1 & tikzmarknode33 & 2& B& C \
hline
A & B& tikzmarknodeC1C& B& C \
hline
D & E & K& tikzmarknodeBB& F \
hline
G & H & I& B& tikzmarknodeC2C\
hline
endtabular
begintikzpicture[overlay,remember picture]
newlengthBorder
Border=0.8pt
fill[left color=red,right color=blue,shading angle=45,even odd rule]
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1-0.5Border,xshift=+0.5Border]$(B)!0.5!(C2)$)
[rounded corners]
([yshift=-1pt-0.5Border,xshift=0.5Border]$(3)!0.5!(C1)$) rectangle
([yshift=-1pt+0.5Border,xshift=-0.5Border]$(B)!0.5!(C2)$)
;
endtikzpicture
enddocument

edited Dec 2 at 1:02
answered Dec 2 at 0:29
marmot
82k492175
82k492175
add a comment |
add a comment |
up vote
3
down vote
You can use cellcolor.. to color single cells. You need the xcolor package or just the colortbl package, the former loads the latter. Note that some PDF viewers hide table lines behind the color.
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \hline
A & B& cellcolorblue!25C& cellcolorblue!25B& C \hline
D & E & cellcolorblue!25K& cellcolorblue!25B& F \hline
G & H & I& B& C \hline
endtabular
enddocument

1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
add a comment |
up vote
3
down vote
You can use cellcolor.. to color single cells. You need the xcolor package or just the colortbl package, the former loads the latter. Note that some PDF viewers hide table lines behind the color.
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \hline
A & B& cellcolorblue!25C& cellcolorblue!25B& C \hline
D & E & cellcolorblue!25K& cellcolorblue!25B& F \hline
G & H & I& B& C \hline
endtabular
enddocument

1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
add a comment |
up vote
3
down vote
up vote
3
down vote
You can use cellcolor.. to color single cells. You need the xcolor package or just the colortbl package, the former loads the latter. Note that some PDF viewers hide table lines behind the color.
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \hline
A & B& cellcolorblue!25C& cellcolorblue!25B& C \hline
D & E & cellcolorblue!25K& cellcolorblue!25B& F \hline
G & H & I& B& C \hline
endtabular
enddocument

You can use cellcolor.. to color single cells. You need the xcolor package or just the colortbl package, the former loads the latter. Note that some PDF viewers hide table lines behind the color.
documentclassarticle
usepackagearray
usepackage[table]xcolor
begindocument
begintabularc
hline
1 & 3 & 2& B& C \hline
A & B& cellcolorblue!25C& cellcolorblue!25B& C \hline
D & E & cellcolorblue!25K& cellcolorblue!25B& F \hline
G & H & I& B& C \hline
endtabular
enddocument

answered Dec 1 at 22:02
AboAmmar
31.8k22781
31.8k22781
1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
add a comment |
1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
1
1
I want please coloring only the border.
– user105476
Dec 1 at 22:07
I want please coloring only the border.
– user105476
Dec 1 at 22:07
2
2
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
@user105476, than you need to make your question more clear. please edit it and explain what you like to have. above answer gives exactly what you ask.
– Zarko
Dec 1 at 22:28
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%2f462753%2fcoloring-a-sub-table%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