答案1
图片模式!
\documentclass{article}
\usepackage{pict2e}
\makeatletter
\newcommand{\YES}{\mathord{\mathpalette\nicoud@YESNO\relax}}
\newcommand{\NO}{\mathord{\mathpalette\nicoud@YESNO{\nicoud@path{\fillpath}}}}
\newcommand{\nicoud@YESNO}[2]{%
\begingroup
\settoheight{\unitlength}{$#1X$}%
\begin{picture}(0.7,1)
\linethickness{\variable@rule{#1}}%
\roundcap\roundjoin
\nicoud@path{\strokepath}
#2
\Line(0.35,0)(0.35,0.5)
\end{picture}%
\endgroup
}
\newcommand{\nicoud@path}[1]{%
\moveto(0.1,0.5)
\lineto(0.1,1)\lineto(0.6,1)\lineto(0.6,0.5)
\closepath
#1
}
\newcommand{\variable@rule}[1]{%
\fontdimen8
\ifx#1\displaystyle\textfont3\else
\ifx#1\textstyle\textfont3\else
\ifx#1\scriptstyle\scriptfont3\else
\scriptscriptfont3\relax
\fi\fi\fi
}
\makeatletter
\begin{document}
$\YES\NO_{\YES\NO}$
{\LARGE$\YES\NO_{\YES\NO}$}
\end{document}
只是为了好玩和学习,这里有一个带有绘图命令的版本expl3
。
\documentclass{article}
\usepackage{l3draw}
\ExplSyntaxOn
\NewDocumentCommand{\YES}{}
{
\mathord{\mathpalette{\nicoud_yesno:nn}{stroke}}
}
\NewDocumentCommand{\NO}{}
{
\mathord{\mathpalette{\nicoud_yesno:nn}{fill}}
}
\dim_new:N \l_nicoud_yesno_ht_dim
\cs_new_protected:Nn \nicoud_yesno:nn
{% #1 = math style, #2 = stroke or fill the path
\group_begin:
\mkern 0.5mu
\draw_begin:
\draw_cap_round:
\draw_join_round:
\draw_linewidth:n { \nicoud_line_thickness:n { #1 } }
\hbox_set:Nn \l_tmpa_box { $#1X$ }
\dim_set:Nn \l_nicoud_yesno_ht_dim
{% the height of X minus the line thickness
\box_ht:N \l_tmpa_box - \nicoud_line_thickness:n { #1 }
}
% the top part
\nicoud_path:n { #2 }
% the bottom part
\draw_path_moveto:n {0.35\l_nicoud_yesno_ht_dim,0.0\l_nicoud_yesno_ht_dim}
\draw_path_lineto:n {0.35\l_nicoud_yesno_ht_dim,0.5\l_nicoud_yesno_ht_dim}
\draw_path_use_clear:n { stroke }
\draw_end:
\mkern 0.5mu
\group_end:
}
\cs_new_protected:Nn \nicoud_path:n
{
\draw_path_moveto:n {0.1\l_nicoud_yesno_ht_dim,0.5\l_nicoud_yesno_ht_dim}
\draw_path_lineto:n {0.1\l_nicoud_yesno_ht_dim,1.0\l_nicoud_yesno_ht_dim}
\draw_path_lineto:n {0.6\l_nicoud_yesno_ht_dim,1.0\l_nicoud_yesno_ht_dim}
\draw_path_lineto:n {0.6\l_nicoud_yesno_ht_dim,0.5\l_nicoud_yesno_ht_dim}
\draw_path_close:
\draw_path_use_clear:n { #1 }
}
\cs_new:Nn \nicoud_line_thickness:n
{
\str_case:nn { #1 }
{
{\displaystyle}{\the\fontdimen8\textfont3}
{\textstyle}{\the\fontdimen8\textfont3}
{\scriptstyle}{\the\fontdimen8\scriptfont3}
{\scriptscriptstyle}{\the\fontdimen8\scriptscriptfont3}
}
}
\ExplSyntaxOff
\begin{document}
$X\YES\NO_{X\YES\NO}$
{\LARGE X$\YES\NO_{X\YES\NO}$}
\end{document}
答案2
你可以用tikz
\documentclass{article}
\usepackage{tikz}
\newcommand{\myclosedsymbol}{%
\tikz[baseline]{\fill[draw] (0,0) -- ++(0,1ex) ++(-0.25ex,0) rectangle (0.25ex,1.5ex) }%
}
\newcommand{\myopensymbol}{%
\tikz[baseline]{\draw (0,0) -- ++(0,1ex) ++(-0.25ex,0) rectangle (0.25ex,1.5ex) }%
}
\begin{document}
{\Huge $F \myopensymbol $}
{\normalsize $F \myopensymbol $}
{\tiny $ F \myopensymbol $}
{\Huge $F \myclosedsymbol $}
{\normalsize $F \myclosedsymbol $}
{\tiny $ F \myclosedsymbol $}
\end{document}