2

I am here referring to an old post: Inline boxes: alternative to pifont's non-filled-but-shadowed box?

For all the boxes, how can I define a black border?

\documentclass[11pt,a4paper]{article}%
\usepackage{xcolor}

% some color definitions
\definecolor{cblue}{RGB}{16,78,139}
\definecolor{cred}{RGB}{139,37,0}
\definecolor{cgreen}{RGB}{0,139,0} 

% normal box
\newcommand{\sqboxs}{1.2ex}% the square size
\newcommand{\sqboxf}{0.6pt}% the border in \sqboxEmpty
\newcommand{\sqbox}[1]{\textcolor{#1}{\rule{\sqboxs}{\sqboxs}}}
% empty box
\newcommand{\sqboxEmpty}[1]{%
  \begingroup
  \setlength{\fboxrule}{\sqboxf}%
  \setlength{\fboxsep}{-\fboxrule}%
  \textcolor{#1}{\fbox{\rule{0pt}{\sqboxs}\rule{\sqboxs}{0pt}}}%
  \endgroup
}

\begin{document}
I like these.
\sqbox{cred}  \sqbox{cgreen} \sqbox{cblue}

And also these.
\sqboxEmpty{cred}  \sqboxEmpty{cgreen}  \sqboxEmpty{cblue}
\end{document}
5

Add another \fbox to your boxes.

For the first one

\newcommand{\sqboxblack}[1]{\setlength{\fboxsep}{0pt}\fbox{\sqbox{#1}}}

and for the second

\newcommand{\sqboxEmptyblack}[1]{\setlength{\fboxsep}{0pt}\fbox{\sqboxEmpty{#1}}}

MWE:

\documentclass[11pt,a4paper]{article}%
\usepackage{xcolor}

% some color definitions
\definecolor{cblue}{RGB}{16,78,139}
\definecolor{cred}{RGB}{139,37,0}
\definecolor{cgreen}{RGB}{0,139,0}

% normal box
\newcommand{\sqboxs}{1.2ex}% the square size
\newcommand{\sqboxf}{0.6pt}% the border in \sqboxEmpty
\newcommand{\sqbox}[1]{\textcolor{#1}{\rule{\sqboxs}{\sqboxs}}}
\newcommand{\sqboxblack}[1]{\setlength{\fboxsep}{0pt}\fbox{\sqbox{#1}}}

% empty box
\newcommand{\sqboxEmpty}[1]{%
  \begingroup
  \setlength{\fboxrule}{\sqboxf}%
  \setlength{\fboxsep}{-\fboxrule}%
  \textcolor{#1}{\fbox{\rule{0pt}{\sqboxs}\rule{\sqboxs}{0pt}}}%
  \endgroup
}

\newcommand{\sqboxEmptyblack}[1]{\setlength{\fboxsep}{0pt}\fbox{\sqboxEmpty{#1}}}

\begin{document}
I like these.
\sqbox{cred}  \sqbox{cgreen} \sqbox{cblue} \sqbox{black}

And these.
\sqboxblack{cred}  \sqboxblack{cgreen} \sqboxblack{cblue} \sqboxblack{black}

And also these.
\sqboxEmpty{cred}  \sqboxEmpty{cgreen}  \sqboxEmpty{cblue} \sqboxEmpty{black}

And these?
\sqboxEmptyblack{cred}  \sqboxEmptyblack{cgreen}  \sqboxEmptyblack{cblue} \sqboxEmptyblack{black}

\end{document} 

Output:

enter image description here

3
  • Continuing on the previous question, how can I do the same now with other shapes like circles, triangles, and rotated squares? – abhishek Dec 30 '14 at 12:29
  • @abhishek Please open a new question for this.... – karlkoeller Dec 30 '14 at 12:32
  • Done...thanks for help with the previous one. – abhishek Dec 30 '14 at 12:45

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.