Draw a palette box in LaTeX

Clash Royale CLAN TAG#URR8PPP
Is there a way to build a structure like the following in Latex?

They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.
color boxes
add a comment |
Is there a way to build a structure like the following in Latex?

They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.
color boxes
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56
add a comment |
Is there a way to build a structure like the following in Latex?

They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.
color boxes
Is there a way to build a structure like the following in Latex?

They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.
color boxes
color boxes
asked Feb 15 at 11:33
criwcriw
1384
1384
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56
add a comment |
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56
add a comment |
2 Answers
2
active
oldest
votes
documentclassarticle
usepackagexcolor,stackengine
newcommandpalbox[2]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12pt##2saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
begindocument
palbox1 103 14301678fquad
palbox221 109 16dd6d10quad
palbox18 54 69123645quad
palbox120 121 12478797c
enddocument

I hadn't at first realized that the top line of text is actually the RGB converted to hex. Thus, one can calculate that from the RGB and can reduce the number of arguments from two to one. I use the binhex.tex package for the conversion into hex.
documentclassarticle
usepackagexcolor,stackengine
input binhex.tex
newcommandpalbox[1]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12ptintohex#1saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
newcommandintohex[1]#intohexaux#1relax
defintohexaux#1 #2 #3relaxtwodigithex#1twodigithex#2twodigithex#3
newcommandtwodigithex[1]ifnum#1<16relax0fiMakeLowercasehex#1
begindocument
palbox1 103 143quad
palbox221 109 16quad
palbox18 54 69quad
palbox120 121 124
enddocument
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure thedefarguments (in this case, ofsaycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on thelistofitemspackage, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..
– Steven B. Segletes
Feb 15 at 12:50
What about usingMakeLowercase?
– Sigur
Feb 15 at 15:36
|
show 2 more comments
Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.
documentclassarticle
usepackage[margin=2cm]geometry
usepackagexparse
usepackagetikz
usetikzlibrarypositioning, backgrounds, shadows
ExplSyntaxOn
cs_new:Nn __criw_rgbtohex:n
clist_set:Nx l_tmpa_clist #1
clist_map_inline:Nn l_tmpa_clist
int_compare:nNnT ##1 < 16 0
int_to_hex:n ##1
cs_new:Nn __criw_palette_box:n
clist_set:Nx l_tmpa_clist #1
definecolor palettecolour RGB #1
begin tikzpicture
[
node~distance = 4mm,
inner~sep = 0mm,
every~node/.style = font = sffamilyfootnotesize
]
node (colour)
[
fill = palettecolour,
minimum~width = 3cm,
minimum~height = 3cm
]
;
node (hex)
[
below = of~colour.south~west,
anchor = north~west
]
#__criw_rgbtohex:n #1 ;
node (rgb)
[
below = of~hex.south~west,
anchor = north~west
]
R: clist_item:Nn l_tmpa_clist 1 ~
G: clist_item:Nn l_tmpa_clist 2 ~
B: clist_item:Nn l_tmpa_clist 3 ;
begin scope [ on~background~layer ]
shadedraw
[
left~color = white,
right~color = black!10,
draw = black!15,
drop~shadow =
shadow~xshift = 0.5mm,
shadow~yshift = -0.5mm,
fill = black!40,
opacity = 1
]
(current~bounding~box.south~west) + (-2mm, -2mm)
rectangle
( [ shift = (2mm, 2mm) ] current~bounding~box.north~east) ;
end scope
end tikzpicture
NewDocumentCommand PaletteBox m
__criw_palette_box:n #1
ExplSyntaxOff
begindocument
PaletteBox1, 103, 143quad
PaletteBox221, 109, 16quad
PaletteBox18, 54, 69quad
PaletteBox120, 121, 124
enddocument

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%2f475007%2fdraw-a-palette-box-in-latex%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
documentclassarticle
usepackagexcolor,stackengine
newcommandpalbox[2]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12pt##2saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
begindocument
palbox1 103 14301678fquad
palbox221 109 16dd6d10quad
palbox18 54 69123645quad
palbox120 121 12478797c
enddocument

I hadn't at first realized that the top line of text is actually the RGB converted to hex. Thus, one can calculate that from the RGB and can reduce the number of arguments from two to one. I use the binhex.tex package for the conversion into hex.
documentclassarticle
usepackagexcolor,stackengine
input binhex.tex
newcommandpalbox[1]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12ptintohex#1saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
newcommandintohex[1]#intohexaux#1relax
defintohexaux#1 #2 #3relaxtwodigithex#1twodigithex#2twodigithex#3
newcommandtwodigithex[1]ifnum#1<16relax0fiMakeLowercasehex#1
begindocument
palbox1 103 143quad
palbox221 109 16quad
palbox18 54 69quad
palbox120 121 124
enddocument
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure thedefarguments (in this case, ofsaycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on thelistofitemspackage, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..
– Steven B. Segletes
Feb 15 at 12:50
What about usingMakeLowercase?
– Sigur
Feb 15 at 15:36
|
show 2 more comments
documentclassarticle
usepackagexcolor,stackengine
newcommandpalbox[2]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12pt##2saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
begindocument
palbox1 103 14301678fquad
palbox221 109 16dd6d10quad
palbox18 54 69123645quad
palbox120 121 12478797c
enddocument

I hadn't at first realized that the top line of text is actually the RGB converted to hex. Thus, one can calculate that from the RGB and can reduce the number of arguments from two to one. I use the binhex.tex package for the conversion into hex.
documentclassarticle
usepackagexcolor,stackengine
input binhex.tex
newcommandpalbox[1]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12ptintohex#1saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
newcommandintohex[1]#intohexaux#1relax
defintohexaux#1 #2 #3relaxtwodigithex#1twodigithex#2twodigithex#3
newcommandtwodigithex[1]ifnum#1<16relax0fiMakeLowercasehex#1
begindocument
palbox1 103 143quad
palbox221 109 16quad
palbox18 54 69quad
palbox120 121 124
enddocument
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure thedefarguments (in this case, ofsaycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on thelistofitemspackage, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..
– Steven B. Segletes
Feb 15 at 12:50
What about usingMakeLowercase?
– Sigur
Feb 15 at 15:36
|
show 2 more comments
documentclassarticle
usepackagexcolor,stackengine
newcommandpalbox[2]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12pt##2saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
begindocument
palbox1 103 14301678fquad
palbox221 109 16dd6d10quad
palbox18 54 69123645quad
palbox120 121 12478797c
enddocument

I hadn't at first realized that the top line of text is actually the RGB converted to hex. Thus, one can calculate that from the RGB and can reduce the number of arguments from two to one. I use the binhex.tex package for the conversion into hex.
documentclassarticle
usepackagexcolor,stackengine
input binhex.tex
newcommandpalbox[1]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12ptintohex#1saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
newcommandintohex[1]#intohexaux#1relax
defintohexaux#1 #2 #3relaxtwodigithex#1twodigithex#2twodigithex#3
newcommandtwodigithex[1]ifnum#1<16relax0fiMakeLowercasehex#1
begindocument
palbox1 103 143quad
palbox221 109 16quad
palbox18 54 69quad
palbox120 121 124
enddocument
documentclassarticle
usepackagexcolor,stackengine
newcommandpalbox[2]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12pt##2saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
begindocument
palbox1 103 14301678fquad
palbox221 109 16dd6d10quad
palbox18 54 69123645quad
palbox120 121 12478797c
enddocument

I hadn't at first realized that the top line of text is actually the RGB converted to hex. Thus, one can calculate that from the RGB and can reduce the number of arguments from two to one. I use the binhex.tex package for the conversion into hex.
documentclassarticle
usepackagexcolor,stackengine
input binhex.tex
newcommandpalbox[1]sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorboxgray!50gray!10%
stackengine8pt%
colorbox[RGB]#1rule60pt0ptrule0pt60pt%
%
colorblack!60stackengine12ptintohex#1saycolors#1UlFFS%
UlFFS%
%
newcommandsaycolors[1]saycolorsaux#1relax
defsaycolorsaux#1 #2 #3relaxR:#1 G:#2 B:#3
newcommandintohex[1]#intohexaux#1relax
defintohexaux#1 #2 #3relaxtwodigithex#1twodigithex#2twodigithex#3
newcommandtwodigithex[1]ifnum#1<16relax0fiMakeLowercasehex#1
begindocument
palbox1 103 143quad
palbox221 109 16quad
palbox18 54 69quad
palbox120 121 124
enddocument
edited Feb 15 at 15:38
answered Feb 15 at 12:38
Steven B. SegletesSteven B. Segletes
158k9204411
158k9204411
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure thedefarguments (in this case, ofsaycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on thelistofitemspackage, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..
– Steven B. Segletes
Feb 15 at 12:50
What about usingMakeLowercase?
– Sigur
Feb 15 at 15:36
|
show 2 more comments
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure thedefarguments (in this case, ofsaycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on thelistofitemspackage, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..
– Steven B. Segletes
Feb 15 at 12:50
What about usingMakeLowercase?
– Sigur
Feb 15 at 15:36
Amazing (twice).
– Sigur
Feb 15 at 12:41
Amazing (twice).
– Sigur
Feb 15 at 12:41
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
@Sigur Thanks. (thanks). Macros make the world go round.
– Steven B. Segletes
Feb 15 at 12:44
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
What I liked is that the 1st argument is a list of numbers separated by spaces, not comma. Very useful.
– Sigur
Feb 15 at 12:46
@Sigur Often, one can structure the
def arguments (in this case, of saycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on the listofitems package, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..– Steven B. Segletes
Feb 15 at 12:50
@Sigur Often, one can structure the
def arguments (in this case, of saycolorsaux) to achieve the desired parsing. When that proves too difficult, I always fall back on the listofitems package, which is unsurpassed in its ability to parse a difficult construct into an expandable array structure..– Steven B. Segletes
Feb 15 at 12:50
What about using
MakeLowercase?– Sigur
Feb 15 at 15:36
What about using
MakeLowercase?– Sigur
Feb 15 at 15:36
|
show 2 more comments
Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.
documentclassarticle
usepackage[margin=2cm]geometry
usepackagexparse
usepackagetikz
usetikzlibrarypositioning, backgrounds, shadows
ExplSyntaxOn
cs_new:Nn __criw_rgbtohex:n
clist_set:Nx l_tmpa_clist #1
clist_map_inline:Nn l_tmpa_clist
int_compare:nNnT ##1 < 16 0
int_to_hex:n ##1
cs_new:Nn __criw_palette_box:n
clist_set:Nx l_tmpa_clist #1
definecolor palettecolour RGB #1
begin tikzpicture
[
node~distance = 4mm,
inner~sep = 0mm,
every~node/.style = font = sffamilyfootnotesize
]
node (colour)
[
fill = palettecolour,
minimum~width = 3cm,
minimum~height = 3cm
]
;
node (hex)
[
below = of~colour.south~west,
anchor = north~west
]
#__criw_rgbtohex:n #1 ;
node (rgb)
[
below = of~hex.south~west,
anchor = north~west
]
R: clist_item:Nn l_tmpa_clist 1 ~
G: clist_item:Nn l_tmpa_clist 2 ~
B: clist_item:Nn l_tmpa_clist 3 ;
begin scope [ on~background~layer ]
shadedraw
[
left~color = white,
right~color = black!10,
draw = black!15,
drop~shadow =
shadow~xshift = 0.5mm,
shadow~yshift = -0.5mm,
fill = black!40,
opacity = 1
]
(current~bounding~box.south~west) + (-2mm, -2mm)
rectangle
( [ shift = (2mm, 2mm) ] current~bounding~box.north~east) ;
end scope
end tikzpicture
NewDocumentCommand PaletteBox m
__criw_palette_box:n #1
ExplSyntaxOff
begindocument
PaletteBox1, 103, 143quad
PaletteBox221, 109, 16quad
PaletteBox18, 54, 69quad
PaletteBox120, 121, 124
enddocument

add a comment |
Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.
documentclassarticle
usepackage[margin=2cm]geometry
usepackagexparse
usepackagetikz
usetikzlibrarypositioning, backgrounds, shadows
ExplSyntaxOn
cs_new:Nn __criw_rgbtohex:n
clist_set:Nx l_tmpa_clist #1
clist_map_inline:Nn l_tmpa_clist
int_compare:nNnT ##1 < 16 0
int_to_hex:n ##1
cs_new:Nn __criw_palette_box:n
clist_set:Nx l_tmpa_clist #1
definecolor palettecolour RGB #1
begin tikzpicture
[
node~distance = 4mm,
inner~sep = 0mm,
every~node/.style = font = sffamilyfootnotesize
]
node (colour)
[
fill = palettecolour,
minimum~width = 3cm,
minimum~height = 3cm
]
;
node (hex)
[
below = of~colour.south~west,
anchor = north~west
]
#__criw_rgbtohex:n #1 ;
node (rgb)
[
below = of~hex.south~west,
anchor = north~west
]
R: clist_item:Nn l_tmpa_clist 1 ~
G: clist_item:Nn l_tmpa_clist 2 ~
B: clist_item:Nn l_tmpa_clist 3 ;
begin scope [ on~background~layer ]
shadedraw
[
left~color = white,
right~color = black!10,
draw = black!15,
drop~shadow =
shadow~xshift = 0.5mm,
shadow~yshift = -0.5mm,
fill = black!40,
opacity = 1
]
(current~bounding~box.south~west) + (-2mm, -2mm)
rectangle
( [ shift = (2mm, 2mm) ] current~bounding~box.north~east) ;
end scope
end tikzpicture
NewDocumentCommand PaletteBox m
__criw_palette_box:n #1
ExplSyntaxOff
begindocument
PaletteBox1, 103, 143quad
PaletteBox221, 109, 16quad
PaletteBox18, 54, 69quad
PaletteBox120, 121, 124
enddocument

add a comment |
Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.
documentclassarticle
usepackage[margin=2cm]geometry
usepackagexparse
usepackagetikz
usetikzlibrarypositioning, backgrounds, shadows
ExplSyntaxOn
cs_new:Nn __criw_rgbtohex:n
clist_set:Nx l_tmpa_clist #1
clist_map_inline:Nn l_tmpa_clist
int_compare:nNnT ##1 < 16 0
int_to_hex:n ##1
cs_new:Nn __criw_palette_box:n
clist_set:Nx l_tmpa_clist #1
definecolor palettecolour RGB #1
begin tikzpicture
[
node~distance = 4mm,
inner~sep = 0mm,
every~node/.style = font = sffamilyfootnotesize
]
node (colour)
[
fill = palettecolour,
minimum~width = 3cm,
minimum~height = 3cm
]
;
node (hex)
[
below = of~colour.south~west,
anchor = north~west
]
#__criw_rgbtohex:n #1 ;
node (rgb)
[
below = of~hex.south~west,
anchor = north~west
]
R: clist_item:Nn l_tmpa_clist 1 ~
G: clist_item:Nn l_tmpa_clist 2 ~
B: clist_item:Nn l_tmpa_clist 3 ;
begin scope [ on~background~layer ]
shadedraw
[
left~color = white,
right~color = black!10,
draw = black!15,
drop~shadow =
shadow~xshift = 0.5mm,
shadow~yshift = -0.5mm,
fill = black!40,
opacity = 1
]
(current~bounding~box.south~west) + (-2mm, -2mm)
rectangle
( [ shift = (2mm, 2mm) ] current~bounding~box.north~east) ;
end scope
end tikzpicture
NewDocumentCommand PaletteBox m
__criw_palette_box:n #1
ExplSyntaxOff
begindocument
PaletteBox1, 103, 143quad
PaletteBox221, 109, 16quad
PaletteBox18, 54, 69quad
PaletteBox120, 121, 124
enddocument

Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.
documentclassarticle
usepackage[margin=2cm]geometry
usepackagexparse
usepackagetikz
usetikzlibrarypositioning, backgrounds, shadows
ExplSyntaxOn
cs_new:Nn __criw_rgbtohex:n
clist_set:Nx l_tmpa_clist #1
clist_map_inline:Nn l_tmpa_clist
int_compare:nNnT ##1 < 16 0
int_to_hex:n ##1
cs_new:Nn __criw_palette_box:n
clist_set:Nx l_tmpa_clist #1
definecolor palettecolour RGB #1
begin tikzpicture
[
node~distance = 4mm,
inner~sep = 0mm,
every~node/.style = font = sffamilyfootnotesize
]
node (colour)
[
fill = palettecolour,
minimum~width = 3cm,
minimum~height = 3cm
]
;
node (hex)
[
below = of~colour.south~west,
anchor = north~west
]
#__criw_rgbtohex:n #1 ;
node (rgb)
[
below = of~hex.south~west,
anchor = north~west
]
R: clist_item:Nn l_tmpa_clist 1 ~
G: clist_item:Nn l_tmpa_clist 2 ~
B: clist_item:Nn l_tmpa_clist 3 ;
begin scope [ on~background~layer ]
shadedraw
[
left~color = white,
right~color = black!10,
draw = black!15,
drop~shadow =
shadow~xshift = 0.5mm,
shadow~yshift = -0.5mm,
fill = black!40,
opacity = 1
]
(current~bounding~box.south~west) + (-2mm, -2mm)
rectangle
( [ shift = (2mm, 2mm) ] current~bounding~box.north~east) ;
end scope
end tikzpicture
NewDocumentCommand PaletteBox m
__criw_palette_box:n #1
ExplSyntaxOff
begindocument
PaletteBox1, 103, 143quad
PaletteBox221, 109, 16quad
PaletteBox18, 54, 69quad
PaletteBox120, 121, 124
enddocument

edited Feb 15 at 14:53
answered Feb 15 at 14:48
David PurtonDavid Purton
10.6k2938
10.6k2938
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.
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%2f475007%2fdraw-a-palette-box-in-latex%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. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Stefan Pinnow
Feb 15 at 11:36
Yes, it is possible. Here are some examples, not boxed, but with palletes. texample.net/tikz/examples/tag/color-manipulation
– Sigur
Feb 15 at 11:56