0

I want gray inside $\Box$. How can we do that? I will use this as a caption of my figure like

\caption{ $\Box$ denotes ...}
Sanu
  • 39
  • 1
    Probably better to use something like \fcolorbox{black}{gray}{\ } or similar. – daleif May 31 '21 at 08:27
  • Not working. Do I need any usepackage? – Sanu May 31 '21 at 08:41
  • 2
    xcolor, though {\fboxsep=0pt\fbox{\color{gray}\rule{3mm}{3mm}}} might be better, more squareish. Please note you should never provide sniplets like this, always use minimal examples including document class and relevant preamble. Then we know what you are working with. – daleif May 31 '21 at 08:49
  • It is working! Thanks a lot for your help. – Sanu May 31 '21 at 08:54

2 Answers2

2

The easiest method is probably something like

\documentclass[a4paper]{article}
\usepackage{xcolor}
\begin{document}

{\fboxsep=0pt\fbox{\color{gray}\rule{3mm}{3mm}}}

\end{document}

\fbox has some padding, which we locally remove by setting \fboxsep to zero.

daleif
  • 54,450
1

You possibly want squares with different colors. The following \csq command will change size according to the context.

\documentclass{article}
\usepackage{xcolor}

\NewDocumentCommand{\csq}{om}{% % colored square % #1 = color model (optional) % #2 = color spec \IfNoValueTF{#1}{% \textcolor{#2}{\rule{1.2ex}{1.2ex}}% }{% \textcolor[#1]{#2}{\rule{1.2ex}{1.2ex}}% }% }

\begin{document}

\csq{gray} denotes something

\csq[rgb]{0.1,0.3,0.9} denotes something else

\csq{red!40!blue} something completely different

{\Large\csq{gray} Large}

\end{document}

enter image description here

If you're running LaTeX before the 2020-10-01 release, you also need

\usepackage{xparse}
egreg
  • 1,121,712