Draw a palette box in LaTeX












7















Is there a way to build a structure like the following in Latex?



Color palette



They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.










share|improve this question























  • 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
















7















Is there a way to build a structure like the following in Latex?



Color palette



They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.










share|improve this question























  • 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














7












7








7


1






Is there a way to build a structure like the following in Latex?



Color palette



They're probably just boxes, but I have very little experience with Latex and I'm not sure how to get this result.










share|improve this question














Is there a way to build a structure like the following in Latex?



Color palette



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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










2 Answers
2






active

oldest

votes


















14














documentclass{article}
usepackage{xcolor,stackengine}
newcommandpalbox[2]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorbox{gray!50}{gray!10}{%
stackengine{8pt}{%
colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
}{%
color{black!60}stackengine{12pt}{##2}{saycolors{#1}}{U}{l}{F}{F}{S}%
}{U}{l}{F}{F}{S}%
}%
}}
newcommandsaycolors[1]{saycolorsaux#1relax}
defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
begin{document}
palbox{1 103 143}{01678f}quad
palbox{221 109 16}{dd6d10}quad
palbox{18 54 69}{123645}quad
palbox{120 121 124}{78797c}
end{document}


enter image description here



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.



documentclass{article}
usepackage{xcolor,stackengine}
input binhex.tex
newcommandpalbox[1]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
fcolorbox{gray!50}{gray!10}{%
stackengine{8pt}{%
colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
}{%
color{black!60}stackengine{12pt}{intohex{#1}}{saycolors{#1}}{U}{l}{F}{F}{S}%
}{U}{l}{F}{F}{S}%
}%
}}
newcommandsaycolors[1]{saycolorsaux#1relax}
defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
newcommandintohex[1]{#intohexaux#1relax}
defintohexaux#1 #2 #3relax{twodigithex{#1}twodigithex{#2}twodigithex{#3}}
newcommandtwodigithex[1]{ifnum#1<16relax0fiMakeLowercase{hex{#1}}}
begin{document}
palbox{1 103 143}quad
palbox{221 109 16}quad
palbox{18 54 69}quad
palbox{120 121 124}
end{document}





share|improve this answer


























  • 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 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



















8














Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.



documentclass{article}
usepackage[margin=2cm]{geometry}
usepackage{xparse}
usepackage{tikz}
usetikzlibrary{positioning, 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
begin{document}
PaletteBox{1, 103, 143}quad
PaletteBox{221, 109, 16}quad
PaletteBox{18, 54, 69}quad
PaletteBox{120, 121, 124}
end{document}


output






share|improve this answer

























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    14














    documentclass{article}
    usepackage{xcolor,stackengine}
    newcommandpalbox[2]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{##2}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    begin{document}
    palbox{1 103 143}{01678f}quad
    palbox{221 109 16}{dd6d10}quad
    palbox{18 54 69}{123645}quad
    palbox{120 121 124}{78797c}
    end{document}


    enter image description here



    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.



    documentclass{article}
    usepackage{xcolor,stackengine}
    input binhex.tex
    newcommandpalbox[1]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{intohex{#1}}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    newcommandintohex[1]{#intohexaux#1relax}
    defintohexaux#1 #2 #3relax{twodigithex{#1}twodigithex{#2}twodigithex{#3}}
    newcommandtwodigithex[1]{ifnum#1<16relax0fiMakeLowercase{hex{#1}}}
    begin{document}
    palbox{1 103 143}quad
    palbox{221 109 16}quad
    palbox{18 54 69}quad
    palbox{120 121 124}
    end{document}





    share|improve this answer


























    • 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 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
















    14














    documentclass{article}
    usepackage{xcolor,stackengine}
    newcommandpalbox[2]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{##2}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    begin{document}
    palbox{1 103 143}{01678f}quad
    palbox{221 109 16}{dd6d10}quad
    palbox{18 54 69}{123645}quad
    palbox{120 121 124}{78797c}
    end{document}


    enter image description here



    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.



    documentclass{article}
    usepackage{xcolor,stackengine}
    input binhex.tex
    newcommandpalbox[1]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{intohex{#1}}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    newcommandintohex[1]{#intohexaux#1relax}
    defintohexaux#1 #2 #3relax{twodigithex{#1}twodigithex{#2}twodigithex{#3}}
    newcommandtwodigithex[1]{ifnum#1<16relax0fiMakeLowercase{hex{#1}}}
    begin{document}
    palbox{1 103 143}quad
    palbox{221 109 16}quad
    palbox{18 54 69}quad
    palbox{120 121 124}
    end{document}





    share|improve this answer


























    • 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 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














    14












    14








    14







    documentclass{article}
    usepackage{xcolor,stackengine}
    newcommandpalbox[2]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{##2}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    begin{document}
    palbox{1 103 143}{01678f}quad
    palbox{221 109 16}{dd6d10}quad
    palbox{18 54 69}{123645}quad
    palbox{120 121 124}{78797c}
    end{document}


    enter image description here



    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.



    documentclass{article}
    usepackage{xcolor,stackengine}
    input binhex.tex
    newcommandpalbox[1]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{intohex{#1}}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    newcommandintohex[1]{#intohexaux#1relax}
    defintohexaux#1 #2 #3relax{twodigithex{#1}twodigithex{#2}twodigithex{#3}}
    newcommandtwodigithex[1]{ifnum#1<16relax0fiMakeLowercase{hex{#1}}}
    begin{document}
    palbox{1 103 143}quad
    palbox{221 109 16}quad
    palbox{18 54 69}quad
    palbox{120 121 124}
    end{document}





    share|improve this answer















    documentclass{article}
    usepackage{xcolor,stackengine}
    newcommandpalbox[2]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{##2}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    begin{document}
    palbox{1 103 143}{01678f}quad
    palbox{221 109 16}{dd6d10}quad
    palbox{18 54 69}{123645}quad
    palbox{120 121 124}{78797c}
    end{document}


    enter image description here



    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.



    documentclass{article}
    usepackage{xcolor,stackengine}
    input binhex.tex
    newcommandpalbox[1]{{sffamilyfboxsep=5ptrelaxfboxrule=1ptrelaxfootnotesize%
    fcolorbox{gray!50}{gray!10}{%
    stackengine{8pt}{%
    colorbox[RGB]{#1}{rule{60pt}{0pt}rule{0pt}{60pt}}%
    }{%
    color{black!60}stackengine{12pt}{intohex{#1}}{saycolors{#1}}{U}{l}{F}{F}{S}%
    }{U}{l}{F}{F}{S}%
    }%
    }}
    newcommandsaycolors[1]{saycolorsaux#1relax}
    defsaycolorsaux#1 #2 #3relax{R:#1 G:#2 B:#3}
    newcommandintohex[1]{#intohexaux#1relax}
    defintohexaux#1 #2 #3relax{twodigithex{#1}twodigithex{#2}twodigithex{#3}}
    newcommandtwodigithex[1]{ifnum#1<16relax0fiMakeLowercase{hex{#1}}}
    begin{document}
    palbox{1 103 143}quad
    palbox{221 109 16}quad
    palbox{18 54 69}quad
    palbox{120 121 124}
    end{document}






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 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



















    • 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 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

















    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











    8














    Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.



    documentclass{article}
    usepackage[margin=2cm]{geometry}
    usepackage{xparse}
    usepackage{tikz}
    usetikzlibrary{positioning, 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
    begin{document}
    PaletteBox{1, 103, 143}quad
    PaletteBox{221, 109, 16}quad
    PaletteBox{18, 54, 69}quad
    PaletteBox{120, 121, 124}
    end{document}


    output






    share|improve this answer






























      8














      Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.



      documentclass{article}
      usepackage[margin=2cm]{geometry}
      usepackage{xparse}
      usepackage{tikz}
      usetikzlibrary{positioning, 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
      begin{document}
      PaletteBox{1, 103, 143}quad
      PaletteBox{221, 109, 16}quad
      PaletteBox{18, 54, 69}quad
      PaletteBox{120, 121, 124}
      end{document}


      output






      share|improve this answer




























        8












        8








        8







        Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.



        documentclass{article}
        usepackage[margin=2cm]{geometry}
        usepackage{xparse}
        usepackage{tikz}
        usetikzlibrary{positioning, 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
        begin{document}
        PaletteBox{1, 103, 143}quad
        PaletteBox{221, 109, 16}quad
        PaletteBox{18, 54, 69}quad
        PaletteBox{120, 121, 124}
        end{document}


        output






        share|improve this answer















        Here's a solution using tikz. It uses expl3 to automatically calculate the hex value.



        documentclass{article}
        usepackage[margin=2cm]{geometry}
        usepackage{xparse}
        usepackage{tikz}
        usetikzlibrary{positioning, 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
        begin{document}
        PaletteBox{1, 103, 143}quad
        PaletteBox{221, 109, 16}quad
        PaletteBox{18, 54, 69}quad
        PaletteBox{120, 121, 124}
        end{document}


        output







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 15 at 14:53

























        answered Feb 15 at 14:48









        David PurtonDavid Purton

        10.7k2939




        10.7k2939






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            How do I know what Microsoft account the skydrive app is syncing to?

            When does type information flow backwards in C++?

            Grease: Live!