管理复选框表示

管理复选框表示

我尝试创建一个复选框,类似于 创建方框复选标记

这工作正确:

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

在此处输入图片描述

但是当我尝试使用十字符号代替复选标记时,它会移到底部:

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

在此处输入图片描述

  1. 如何使十字符号垂直居中?
  2. 如何改变框和内部符号的大小,使它们变大/变小?

答案1

为什么不使用已经可用的\boxtimes

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

$\boxtimes$

\end{document}

在此处输入图片描述

答案2

还有另一种可能性:

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

结果:

在此处输入图片描述

答案3

另外一个选择:

\XBoxwasysym包装一起使用

答案4

这里有一个替代方案l3draw

在此处输入图片描述

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

相关内容