[Tex/LaTex] How to draw a square of 1cm in LaTeX filled with color

boxescolor

How to draw a square of 1cm in LaTeX filled with colour? I found mdframed and framebox does this, but there need to write text inside it. I just need to draw a box.

Best Answer

Use the simple \rule command:

\documentclass{article}
\usepackage{xcolor}
\newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\begin{document}

\crule{1cm}{1cm} \crule[blue]{1cm}{1cm} \crule[red!50!white!100]{1cm}{1cm}  

\end{document}

enter image description here