
我需要在 ifeqcase 外部的 ifeqcase 中設定的變數值。例如這段程式碼不起作用
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{geometry}
\usepackage{calculator,calculus}
\usepackage{multido}
\usepackage{xstring}
\usepackage[fontsize=22pt]{scrextend}
\setmainfont{Latin Modern Sans Quotation}
\geometry{papersize{30cm,19.35cm},left=1cm,right=1cm,top=1cm,bottom=1cm}
\pagestyle{empty}
\newcommand{\valeurcal}[2]{
\SUBTRACT{1}{\ra}{\partiell}
\MULTIPLY{\partiell}{#1}{\partielll}
\MULTIPLY{\ra}{#2}{\partiell}
\ADD{\partiell}{\partielll}{\leresultat}
}
\begin{document}
\multido{\ra=0.0+0.2}{1}{
\valeurcal{0}{5}
\ROUND[0]{\leresultat}{\coupe}
\IfEqCase{\coupe}{%
{1}{ \COPY{5}{\nouvcoupe}}% test with calculator
{2}{ \def\nouvcoupe{6}}}% test with def, edef and gdef (thank for the answer)
value of nouvcoupe : \nouvcoupe}
\end{document}
給我:未定義的控制序列。 (用xelatex編譯)
問題似乎隨之而來\valeurcal{0}{5}
。如果我替換\valeurcal{0}{5}
為,\COPY{2}{\leresultat}
我可以編譯它(但它不起作用)!
\valeurcal{0}{5}
計算一下 你對我有什麼建議0*(1-\ra)+5*\ra
?\ra
先感謝您。
答案1
使用
\gdef\nouvcoupe{6}
G局部的定義起始
答案2
OK[\def\nouvcoupe{6}]
丟失了
\IfEqCase{\coupe}{%
{1}{ \COPY{5}{\nouvcoupe}}% test with calculator
{2}{ \def\nouvcoupe{6}}}[\def\nouvcoupe{6}]
沒問題