3

I need to have embossed colorbox in latex with text within (like the \fcolorbox{border-color}{fill-color}{text} ) the same as the folowing picture? enter image description here

Is it posible?

Thanks.

7

I would be surprised if variants of this didn't exist somewhere already, but here is a way do draw such things with TikZ.

\documentclass{article}
\usepackage{tikz}
\definecolor{mygreen}{RGB}{203,222,158}
\definecolor{myblue}{RGB}{144,206,244}
\newcommand{\FFcolorbox}[2][]{\begin{tikzpicture}[FF/.cd,
    Fcol/.code={\colorlet{fcol}{##1}},Fcol=myblue,
    a/.initial=0.5ex,w/.initial=2em,h/.initial=2em,#1]
 \def\pv##1{\pgfkeysvalueof{/tikz/FF/##1}}% 
 \node[minimum width=\pv{w},minimum height=\pv{h},fill=fcol,
    align=center,outer sep=0pt](F){#2};
 \path[left color=fcol,right color=white,shading angle=180]
 (F.north west) -- ++ (-\pv{a},\pv{a}) -- 
    ([xshift=\pv{a},yshift=\pv{a}]F.north east) -- (F.north east);
 \path[left color=fcol,right color=white,shading angle=-90]
 (F.north west) -- ++ (-\pv{a},\pv{a}) -- 
    ([xshift=-\pv{a},yshift=-\pv{a}]F.south west) -- (F.south west);
 \path[left color=fcol,right color=gray!50!black,shading angle=0]
 (F.south west) -- ++ (-\pv{a},-\pv{a}) -- 
    ([xshift=\pv{a},yshift=-\pv{a}]F.south east) -- (F.south east);
 \path[left color=fcol,right color=gray!50!black,shading angle=90]
 (F.south east) -- ++ (\pv{a},-\pv{a}) -- 
    ([xshift=\pv{a},yshift=\pv{a}]F.north east) -- (F.north east);
\end{tikzpicture}}
\begin{document}
\FFcolorbox[Fcol=mygreen]{Fe}\quad\FFcolorbox{C}\quad\FFcolorbox{P}\quad\FFcolorbox{O}
\end{document}

enter image description here

It is straightforward to make this a tcolorbox.

\documentclass{article}
\usepackage[skins]{tcolorbox}
\definecolor{mygreen}{RGB}{203,222,158}
\definecolor{myblue}{RGB}{144,206,244}
\tcbset{Fcol/.code={\colorlet{fcol}{#1}}}
\newtcbox{\Embossed}[1][]{enhanced,Fcol=myblue,sharp corners,
width=2em-2pt,height=2em-0.5ex-1pt,boxrule=0pt,left=1pt,right=1pt,top=0.7ex,bottom=1pt,
on line,#1,colback=fcol,
    frame code={
    \path[left color=fcol,right color=white,shading angle=180]
 (frame.north west) -- ++ (-0.5ex,0.5ex) -- 
    ([xshift=0.5ex,yshift=0.5ex]frame.north east) -- (frame.north east);
 \path[left color=fcol,right color=white,shading angle=-90]
 (frame.north west) -- ++ (-0.5ex,0.5ex) -- 
    ([xshift=-0.5ex,yshift=-0.5ex]frame.south west) -- (frame.south west);
 \path[left color=fcol,right color=gray!50!black,shading angle=0]
 (frame.south west) -- ++ (-0.5ex,-0.5ex) -- 
    ([xshift=0.5ex,yshift=-0.5ex]frame.south east) -- (frame.south east);
 \path[left color=fcol,right color=gray!50!black,shading angle=90]
 (frame.south east) -- ++ (0.5ex,-0.5ex) -- 
    ([xshift=0.5ex,yshift=0.5ex]frame.north east) -- (frame.north east); 
    },
    }

\begin{document}
\Embossed[Fcol=mygreen]{Fe}\quad\Embossed{C}\quad\Embossed{P}\quad\Embossed{O}
\end{document}

enter image description here

|improve this answer|||||
  • This is excellent. Thanks my dear – SH.Madadpour Feb 28 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.