以下代码无法编译,并出现以下错误消息
缺失
=
插入\ifnum
\documentclass[pstricks,border=4pt]{standalone}
\usepackage{multido}
\psset{linewidth=.5\pslinewidth}
\psset{xunit=2cm}
\newcommand\FixedScale[1]{%
\multips(0,0)(.1,0){\the\numexpr10*#1+1\relax}{\psline(0,0)(0,-3pt)}
\multips(0,0)(.5,0){\the\numexpr2*#1+1\relax}{\psline(0,0)(0,-6pt)}
\multips(0,0)(1,0){\the\numexpr#1+1\relax}{\psline(0,0)(0,-9pt)}
\multido{\i=0+1}{\the\numexpr#1+1\relax}{\uput[-90](\i,-5pt){$\i$}}
}
\newcommand\VernierScale[2][0.09]{%
\rput(#2,0){%
\psset{xunit=#1,linecolor=red}%
\multips(0,0)(1,0){11}{\psline(0,0)(0,3pt)}%
\multips(5,0)(5,0){1}{\psline(0,0)(0,6pt)}%
\multips(0,0)(10,0){2}{\psline(0,0)(0,9pt)}%
\ifnum#1=0.11\relax
\multido{\i=0+5}{3}{\uput[90](\i,8pt){\tiny$\the\numexpr10-\i\relax$}}
\else
\multido{\i=0+5}{3}{\uput[90](\i,8pt){\tiny$\i$}}
\fi
}
}
\begin{document}
\multido{\n=0.00+0.01}{21}{%
\begin{pspicture}(0,-.5)(2,.55)
\FixedScale{2}
\VernierScale[0.09]{\n}
\end{pspicture}}
\end{document}
出什么问题了\ifnum#1=0.09\relax
?
答案1
我认为你应该可以做类似的事情
\ifdim#1pt=0.09pt\relax
正如其他答案中提到的,\ifnum
测试整数值。
所以
\documentclass{article}
\def\testing#1{%%
\ifdim#1pt<0.09pt\relax
SMALL!
\else
not so small
\fi
}
\pagestyle{empty}
\begin{document}
\testing{10}
\testing{0.001}
\end{document}
结果是
答案2
\ifnum#1=0.09\relax?
测试数字是否按原样传递#1
,0
如果是,则扩展为.09\relax
A数字是一个整数。
答案3
读 \if_integer_number#1=another_integer_
和不是浮点数。使用百分比值:
\documentclass[pstricks,border=4pt]{standalone}
\usepackage{multido}
\psset{linewidth=.5\pslinewidth,xunit=2cm}
\newcommand\FixedScale[1]{%
\multips(0,0)(.1,0){\the\numexpr10*#1+1\relax}{\psline(0,0)(0,-3pt)}
\multips(0,0)(.5,0){\the\numexpr2*#1+1\relax}{\psline(0,0)(0,-6pt)}
\multips(0,0)(1,0){\the\numexpr#1+1\relax}{\psline(0,0)(0,-9pt)}
\multido{\i=0+1}{\the\numexpr#1+1\relax}{\uput[-90](\i,-5pt){$\i$}}%
}
\newcommand\VernierScale[2][9]{%
\rput(#2,0){%
\psset{xunit=\dimexpr#1\psunit/100,linecolor=red}%
\multips(0,0)(1,0){11}{\psline(0,0)(0,3pt)}%
\multips(5,0)(5,0){1}{\psline(0,0)(0,6pt)}%
\multips(0,0)(10,0){2}{\psline(0,0)(0,9pt)}%
\ifnum#1=11\relax
\multido{\i=0+5}{3}{\uput[90](\i,8pt){\tiny$\the\numexpr10-\i\relax$}}
\else
\multido{\i=0+5}{3}{\uput[90](\i,8pt){\tiny$\i$}}
\fi
}%
}
\begin{document}
\multido{\n=0.00+0.01}{21}{%
\begin{pspicture}(0,-.5)(2,.55)
\FixedScale{2}
\VernierScale[9]{\n}
\end{pspicture}}
\end{document}