对于表示“A分裂b“,我通常使用\divides
\newcommand{\zerodel}{.\kern-\nulldelimiterspace} %removes extraneous spacing after \right etc.
\newcommand{\divides}[2]{\left\zerodel#1\ \middle|\ #2\right\zerodel}.
这会产生一个分割条|
,它可以通过内联数学和显示模式的参数很好地缩放。它还具有适当的间距。以下是一个例子(见左图或上图):
left-hand (or top) picture
\divides
right-hand (or bottom) picture
\notdiv
如何定义一条行为相似的垂直线来表示“不是除以 b"?该命令\nmid
很常用,但不随参数缩放。
我尝试了以下无效的选项
%\newcommand{\notdiv}[2]{\left\zerodel#1\ \middle\nmid\ #2\right\zerodel} %does not work
\newcommand{\notdiv}[2]{\left\zerodel#1\ \nmid\ #2\right\zerodel} % also does not work (image with this)
给出了右侧(或底部)的图片。
正如我们所见,\notdiv
与论点不符。
- 问题:解决这个问题的一个好办法是什么?
注:希望扩大规模仅有的垂直线,不是斜线。
以下是用于生成图像的 MWE。
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\newcommand{\zerodel}{.\kern-\nulldelimiterspace} %removes extraneous spacing after \right etc.
\newcommand{\divides}[2]{\left\zerodel#1\ \middle|\ #2\right\zerodel}
%modify \notdiv as you see fit
%\newcommand{\notdiv}[2]{\left\zerodel#1 \middle\nmid #2\right\zerodel} %does not work
\newcommand{\notdiv}[2]{\left\zerodel#1\nmid#2\right\zerodel} %does not work
\begin{document}
\centering
inline: $\divides{c}{d}$, $\divides{\dfrac{a}{b}}{c}$
\[\divides{c}{d}\]
\[\divides{\frac{a}{b}}{c}\]
inline: $\notdiv{c}{d}$, $\notdiv{\dfrac{a}{b}}{c}$
\[\notdiv{c}{d}\]
\[\notdiv{\frac{a}{b}}{c}\]
\end{document}
答案1
一种非常简单的方法。
\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{pict2e}
\newcommand{\PicSlash}[0]{\begin{picture}(0,0)
%\linethickness{0.4pt}
\put(-0.75,1){\line(1,1){4.5pt}}
\end{picture}}
%\show\delimsize
\newcommand{\zerodel}{.\kern-\nulldelimiterspace} %removes extraneous spacing after \right etc.
\newcommand{\divides}[2]{\left\zerodel#1\nonscript\;\middle|\nonscript\;#2\right\zerodel}
%modify \notdiv as you see fit
%\newcommand{\notdiv}[2]{\left\zerodel#1 \middle\nmid #2\right\zerodel} %does not work
\newcommand{\notdiv}[2]{\left\zerodel#1\nonscript\;\mathrlap{\PicSlash}\middle|\nonscript\;#2\right\zerodel}
\begin{document}
\centering
inline: $\divides{c}{d}$, $\divides{\dfrac{a}{b}}{c}$
\[\divides{c}{d}\]
\[\divides{\frac{a}{b}}{c}\]
inline: $\notdiv{c}{d}$, $\notdiv{\dfrac{a}{b}}{c}$
\[\notdiv{c}{d}\]
\[\notdiv{\frac{a}{b}}{c}\]
\end{document}