带黑色边框的方框

带黑色边框的方框

我在这里引用一篇旧帖子:内联框:pifont 的非填充但有阴影的框的替代品?

对于所有的框,我如何定义黑色边框?

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

答案1

将另一个添加\fbox到您的盒子中。

第一个

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

第二个

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

梅威瑟:

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

输出:

在此处输入图片描述

相关内容