我定义了一个 \newcommand 如下:
\newcommand{\boxup}{\ooalign{$\Box$\cr\hss\raisebox{0ex}{\scriptsize $\shortuparrow$}\hss}}
它是一个里面有箭头的盒子。
然后我想在数学模式中用常规框 \Box 使用它。如果我这样写,$\Box\boxup$
我会得到大小相等的框。
然后我写成同样的方式K_{\Box\boxup}
得到
大小不等的盒子。这是我的文件的序言:
\documentclass[a4paper]{easychair}
\newtheorem{theorem}{Proposition}
\newtheorem{corollary}{Corollary}[theorem]
\newcommand{\boxfut}{\ooalign{$\Box$\cr\hss\raisebox{0.3ex}{\scriptsize $\shortrightarrow$}\hss}}
\newcommand{\boxpast}{\ooalign{$\Box$\cr\hss\raisebox{0.3ex}{\scriptsize $\shortleftarrow$}\hss}}
\newcommand{\diafut}{\ooalign{$\Diamond$\cr\hss\raisebox{0.3ex}{\scriptsize $\shortrightarrow$}\hss}}
\newcommand{\diapast}{\ooalign{$\Diamond$\cr\hss\raisebox{0.3ex}{\scriptsize $\shortleftarrow$}\hss}}
\newcommand{\diaup}{\ooalign{$\Diamond$\cr\hss\raisebox{0ex}{\scriptsize $\shortuparrow$}\hss}}
\newcommand{\boxup}{\ooalign{$\Box$\cr\hss\raisebox{0ex}{\scriptsize $\shortuparrow$}\hss}}
\usepackage{comment}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{stmaryrd,graphicx}
有人能建议我如何调整错误吗?
答案1
获得正确的测量结果并不容易。
\documentclass[a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage{stmaryrd}
\makeatletter
\newcommand{\boxup}{%
\mathord{% or \mathbin or \mathrel
\vphantom{\Box}%
\text{\kuzne@box\shortuparrow}
}%
}
\newcommand{\boxfut}{%
\mathord{% or \mathbin or \mathrel
\vphantom{\Box}%
\text{\kuzne@box\shortrightarrow}%
}%
}
\newcommand{\boxpast}{%
\mathord{% or \mathbin or \mathrel
\vphantom{\Box}%
\text{\kuzne@box\shortleftarrow}%
}%
}
\newsavebox{\kuzne@box@box}
\newsavebox{\kuzne@box@base}
\newlength{\kuzne@box@raise}
\newcommand{\kuzne@box}[1]{%
\sbox\kuzne@box@base{$\m@th\Box$}%
\sbox\kuzne@box@box{$\m@th\text{\check@mathfonts\raisebox{-\fontdimen22\textfont2}{$#1$}}$}%
\kuzne@box@raise=.5\dimexpr\ht\kuzne@box@base+\dp\kuzne@box@base\relax
\ooalign{%
\box\kuzne@box@base\cr
\hidewidth\raisebox{\kuzne@box@raise}{\box\kuzne@box@box}\hidewidth\cr
}%
}
\makeatother
\begin{document}
$\Box\boxup\boxfut\boxpast_{\Box\boxup\boxfut\boxpast_{\Box\boxup\boxfut\boxpast}}$
\end{document}
\diafut
和的代码\diapast
(在二级下标中不起作用);将其添加在\makeatletter
和之间\makeatother
。
\newcommand{\diafut}{%
\mathord{% or \mathbin or \mathrel
\vphantom{\Diamond}%
\text{\kuzne@dia\shortrightarrow}%
}%
}
\newcommand{\diapast}{%
\mathord{% or \mathbin or \mathrel
\vphantom{\Diamond}%
\text{\kuzne@dia\shortleftarrow}%
}%
}
\newcommand{\kuzne@dia}[1]{%
\sbox\kuzne@box@base{$\m@th\Diamond$}%
\sbox\kuzne@box@box{$\m@th\text{\check@mathfonts\raisebox{-\fontdimen22\textfont2}{$\scriptstyle#1$}}$}%
\kuzne@box@raise=.45\dimexpr\ht\kuzne@box@base+\dp\kuzne@box@base\relax
\ooalign{%
\box\kuzne@box@base\cr
\hidewidth\raisebox{\kuzne@box@raise}{\box\kuzne@box@box}\hidewidth\cr
}%
}
以下是输出$\diafut\diapast_{\diafut\diapast}$