3

My question is motivated by the amssymb package not having a checkmark in a box symbol. Fortunately, I have found in Creating Boxed Check Mark a way to create a checkmark in a box.

However, how to make it compatible with a box with no checkmark? Consider this example:

\documentclass{article}
\usepackage{amssymb}

\begin{document}
\noindent
\makebox[0pt][l]{$\square$}\raisebox{0.15ex}{\hspace{0.1em}$\checkmark$} A\\
\makebox[0pt][l]{$\square$}{\hspace{0.5em}} B\\

\end{document}

The output is:

enter image description here

I am trying to manipulate the parameter in \hspace to bring "B" aligned with "A" lacking a precise solution. Can you help?

1
  • 1
    you can use \phantom{\raisebox{0.15ex}{\hspace{0.1em}$\checkmark$}} instead of the \hspace{0.5em} Oct 24, 2020 at 20:26

1 Answer 1

6

Probably reversing the logic:

\documentclass{article}
\usepackage{amssymb}

\newcommand{\checkbox}[1]{%
  \ifnum#1=1
    \makebox[0pt][l]{\raisebox{0.15ex}{\hspace{0.1em}$\checkmark$}}%
  \fi
  $\square$%
}

\begin{document}

\checkbox{1} A

\checkbox{0} B

\end{document}

enter image description here

I added an argument so there are no issues with spaces after the macro. It's also easier to manage the appearance of the check mark if you so prefer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .