11

I tried to create a checkbox, analogous to Creating Boxed Check Mark

This woks correctly:

\documentclass{article}
\usepackage{amssymb}
\begin{document}
\makebox[0pt][l]{$\square$}\raisebox{.15ex}{\hspace{0.1em}$\checkmark$}
\end{document}

enter image description here

But when I tried to use a cross symbol instead of checkmark, it is shifted to the bottom:

\documentclass{article}
\usepackage{amssymb}
\begin{document}
\makebox[0pt][l]{$\square$}{$\times$}
\end{document}

enter image description here

  1. How to vertically center the cross symbol?
  2. How to change the size of the box and internal symbol, making them bigger / smaller?
user4035
  • 5,035
  • 6
  • 40
  • 57
  • You might find it nice to have a pair of matching symbols for the check and the cross, see: http://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark/42620#4262 – Christoph B. May 02 '13 at 13:25

5 Answers5

9

Why not use the already available \boxtimes?

\documentclass{article}
\usepackage{amssymb}
\begin{document}

$\boxtimes$

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
8

Here is another possibility:

\documentclass{article}
\usepackage{amssymb,tikz,pdftexcmds,xparse}

\tikzset{box/.style={
    minimum size=0.225cm,
    inner sep=0pt,
    draw,
  },  
  insert mark/.style={
    append after command={%
         node[inner sep=0pt,#1]
           at (\tikzlastnode.center){$\checkmark$}
     }     
  },
  insert bad mark/.style={
    append after command={%
         [shorten <=\pgflinewidth,shorten >=\pgflinewidth]
         (\tikzlastnode.north west)edge[#1](\tikzlastnode.south east)
         (\tikzlastnode.south west)edge[#1](\tikzlastnode.north east)
     }     
  },
}

\makeatletter
\NewDocumentCommand{\tikzcheckmark}{O{} m}{%
  \ifnum\pdf@strcmp{#2}{mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{bad mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,insert bad mark={#1},#1]{};%
  \fi%
  \ifnum\pdf@strcmp{#2}{no mark}=\z@%
    \tikz[baseline=-0.5ex]\node[box,#1]{};%
  \fi%
}
\makeatother

\begin{document}


\tikzcheckmark[scale=0.75]{mark}\quad\tikzcheckmark[scale=0.75]{no mark}\quad\tikzcheckmark[scale=0.75]{bad mark}

\vspace{1cm}

\tikzcheckmark{mark}\quad\tikzcheckmark{no mark}\quad\tikzcheckmark{bad mark}

\vspace{1cm}

\tikzcheckmark[scale=2,red]{mark}\quad\tikzcheckmark[scale=2,red]{no mark}\quad\tikzcheckmark[scale=2,red]{bad mark}

\end{document}

The result:

enter image description here

1

Another option:

\makebox[0pt][l]{$\square$}{\raisebox{0.1\height}{$\times$}}

(use \raisebox as in the first symbol you use)

azetina
  • 28,884
1

Another option:

use \XBox with the wasysym package

Romain Picot
  • 6,730
  • 4
  • 28
  • 58
user95439
  • 402
0

Here is an alternative with l3draw.

enter image description here

\documentclass{article}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage{l3draw,xparse}
\ExplSyntaxOn
%---------------------------------------------------------
\NewDocumentCommand{\xpboxedtimes}{O{1ex}O{black}}
 {
  \fp_set:Nn \l__xp_boxed_line_width_fp { 0.08ex }  
  \raisebox{0pt}[#1][0pt]{\color{#2}\xp_boxedtimes:n { #1 }}
 }

\NewDocumentCommand{\xpboxedempty}{O{1ex}O{black}} { \fp_set:Nn \l__xp_boxed_line_width_fp { 0.08ex } \raisebox{0pt}[#1][0pt]{\color{#2}\xp_boxedempty:n { #1 }} }

\dim_new:N \l__xp_boxed_size_dim % dimension of the box \fp_new:N \l__xp_boxed_line_width_fp %linewidth set to 0.08ex by default

\cs_new_protected:Nn \xp_boxedtimes:n { \dim_set:Nn \l__xp_boxed_size_dim { #1 } \draw_begin: \draw_linewidth:n { \l__xp_boxed_line_width_fp } \draw_path_moveto:n { 0\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_lineto:n { 0\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_close: \draw_path_use_clear:n { stroke } \draw_path_moveto:n { 0\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_use_clear:n { stroke } \draw_path_moveto:n { 0\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_use_clear:n { stroke } \draw_end: }

\cs_new_protected:Nn \xp_boxedempty:n { \dim_set:Nn \l__xp_boxed_size_dim { #1 } \draw_begin: \draw_linewidth:n { \l__xp_boxed_line_width_fp }
\draw_path_moveto:n { 0\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 0\l__xp_boxed_size_dim } \draw_path_lineto:n { 1\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_lineto:n { 0\l__xp_boxed_size_dim , 1\l__xp_boxed_size_dim } \draw_path_close: \draw_path_use_clear:n { stroke } \draw_end: } %--------------------------------------------------------- \ExplSyntaxOff

\begin{document} {\xpboxedtimes\quad \xpboxedempty} \begin{itemize}[label={\xpboxedtimes[1ex][red]},leftmargin=*] \item test \item test \item test \end{itemize} \end{document}

azetina
  • 28,884