소수점 이하 자릿수에서 0을 제거하는 매크로를 작성하고 싶습니다. 예를 들어 숫자 2.0
로 변환합니다 2
.
이것은 0 하나를 제거하려고 시도했지만 작동하지 않고 오류가 발생합니다.
\documentclass[borders=2cm]{standalone}
\usepackage{tikz}
\newcommand{\isinteger}[1]{\pgfmathtruncatemacro{\intvar}{#1}
\def\newx{\pgfmathparse{10*(\intvar-#1)}\pgfmathresult}
\ifnum\newx=0
\intvar
\else
#1
\fi}
\begin{document}
\isinteger{1.5}
\end{document}
오류:
Missing number, treated as zero. \isinteger{1.5}
Missing = inserted for \ifnum. \isinteger{1.5}
Missing number, treated as zero. \isinteger{1.5}
어떤 아이디어가 있나요?
답변1
정수를 정수로, 정수가 아닌 것을 정수가 아닌 것으로 인쇄하려는 경우, 이미 사용하고 있으므로pgfmath, 을 사용하는 것이 좋습니다 \pgfmathprintnumber
. 98장에 자세히 설명되어 있습니다.TikZ수동이지만 다음은 원하는 대로 작동하는 것 같습니다.
\documentclass{article}
\usepackage{tikz}
\newcommand{\isinteger}[1]{\pgfmathprintnumber[int detect,fixed]{#1}}
\begin{document}
\isinteger{1.5}
\isinteger{1.0}
\end{document}
이는 각각 1.5
및 를 인쇄합니다 1
.
또 다른 옵션은 다음 \num
에서 사용하는 것입니다.시유닉스:
\documentclass{article}
\usepackage{siunitx}
\newcommand{\isinteger}[1]{\num[zero-decimal-to-integer=true]{#1}}
\begin{document}
\isinteger{1.5}
\isinteger{1.0}
\end{document}
답변2
답변3
답변4
숫자를 "정규화"하기 위한 확장 가능한 루틴을 제공할 수 있습니다 \normalizenumber
.
작동 방식을 설명하기 위해 \normalizenumber
Backus/Naur 표기법의 TeXBook에 있는 TeX 문법에 정의된 것 외에도 수량을 정의하겠습니다.⟨소수점 구분 기호⟩:
⟨소수점 구분 기호⟩→. 12|, 12
구문은 다음과 \normalizenumber
같습니다.
\normalizenumber⟨undelimited argument⟩
사례 1:
형성되는 토큰은 ⟨undelimited argument⟩
패턴을 준수합니다.
⟨선택적 표시⟩⟨정수 상수⟩⟨선택적 공간 1개⟩
1의 경우
- ⟨선택적 표시⟩아래와 같이 변환되어 전달됩니다.
- ⟨정수 상수⟩모든 선행 0이 제거된 상태로 전달됩니다.
선행 0을 모두 제거하면 공백이 생성되는 경우 한 자리 숫자가 전달됩니다.012
- ⟨선택적 공간 1개⟩제거됩니다.
사례 2:
형성되는 토큰은 ⟨undelimited argument⟩
패턴을 준수합니다.
⟨선택적 표시⟩⟨정수 상수⟩⟨소수점 구분 기호⟩⟨정수 상수⟩⟨선택적 공간 1개⟩
사례 2의 경우
- ⟨선택적 표시⟩아래와 같이 변환되어 전달됩니다.
- 첫 번째/왼쪽⟨정수 상수⟩모든 선행 0이 제거된 상태로 제공됩니다.
선행 0을 모두 제거하면 공백이 생성되는 경우 한 자리 숫자가 전달됩니다.012
- 두 번째/오른쪽에서 모든 후행 0을 제거하는 경우⟨정수 상수⟩공허함을 낳지 않는다면⟨소수점 구분 기호⟩배달됩니다.
- 두 번째/오른쪽⟨정수 상수⟩모든 후행 0이 제거된 상태로 제공됩니다.
- ⟨선택적 공간 1개⟩제거됩니다.
다른 모든 경우에는을 형성하는 토큰은 ⟨undelimited argument⟩
변경되지 않은 채 전달됩니다.
를 구분하는 중괄호가 ⟨undelimited argument⟩
제거됩니다.
어쨌든-expansion 으로 인해 \romannumeral0
결과는 두 번의 확장 단계 후에/두 번 "타격"하여 전달 \normalizenumber
됩니다 \expandafter
.
방금 말한 것들은 예를 들어, 변경되지 않은 상태로 \normalizenumber{1.}
반환된다는 것을 의미합니다.1.
⟨무제한 인수⟩ 1.
사례 1에 대해 설명된 패턴도 아니고 사례 2에 대해 설명된 패턴도 아닙니다 \normalizenumber{1.000}
.1
⟨무제한 인수⟩ 1.000
사례 2에 대해 설명된 패턴입니다.
변환⟨선택적 표시⟩
경우에⟨선택적 표시⟩음수가 아닌 숫자를 나타내면 토큰이 전혀 반환되지 않습니다.
경우에⟨선택적 표시⟩음수를 나타내는 경우 단일 명시적 문자 토큰이 반환됩니다. 정규화할 숫자의 절대값이 0이면 부호를 얻지 못합니다. 즉, 얻지 못하지만 을 얻게 됩니다 .-12
-0
0
\normalizenumber
의 확장⟨무제한 인수⟩
\normalizenumber
꼬리 재귀 루프에서 인수를 토큰 방식으로 검사합니다.⟨무제한 인수⟩다음을 의미하지는 않습니다.⟨무제한 인수⟩사례 1의 패턴을 따르지 않고 사례 2의 패턴도 따르지 않으면 해당 항목은 다음에서 제거됩니다.⟨무제한 인수⟩다음 반복에서는 \normalizenumber
나머지 토큰의 첫 번째 토큰을 "봅니다".⟨무제한 인수⟩.
\if
-스위치 가 있습니다 \ifnormalizenumberexpandarg
.
\normalizenumberexpandargfalse
이라고 말하면 \normalizenumber
검사 중에 확장 가능한 토큰을 확장하지 않으며 확장 가능한 토큰이 나타나면 다음을 의미합니다.⟨무제한 인수⟩사례 1에 대해 설명된 패턴을 준수하지 않으며 사례 2에 대해 설명된 패턴도 준수하지 않습니다.
라고 말하면 \normalizenumberexpandargtrue
각 반복에서⟨무제한 인수⟩\expandafter
확장 가능은 결과를 검토하는 다음 반복에서 이를 "적중"하는 트리거입니다 . 첫 번째 토큰 확장⟨무제한 인수⟩후속 토큰에 영향을 미칠 수 있습니다.⟨무제한 인수⟩. 주의해서 사용하고 어느 정도 의심을 가지고
사용하세요 . 첫 번째 토큰이 unbalanced 또는 unbalanced 인 경우 모든 종류의 이상한 오류 메시지가 표시될 수 있습니다. 첫 번째 토큰이 닫는 중괄호 너머의 토큰에 영향을 미치는 항목을 트리거하도록 정의된 경우\normalizenumberexpandargtrue
\else
\fi
\csname
⟨무제한 인수⟩, 그러면 프로그램 흐름을 예측할 수 없게 될 수 있습니다. 첫 번째 토큰이 자신을 전달하도록 정의된 경우 끝없는 루프에 빠질 수 있습니다.
\errorcontextlines=10000
\documentclass{article}
\makeatletter
%%=============================================================================
%% Paraphernalia:
%% \UD@firstoftwo, \UD@secondoftwo, \UD@Exchange, \UD@Removespace
%% \UD@CheckWhetherNull, \UD@CheckWhetherLeadingSpace, \UD@ExtractFirstArg
%%=============================================================================
\newcommand\UD@firstoftwo[2]{#1}%
\newcommand\UD@secondoftwo[2]{#2}%
\newcommand\UD@Exchange[2]{#2#1}%
\@ifdefinable\UD@Removespace{\UD@Exchange{ }{\def\UD@Removespace}{}}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% \UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{%
\romannumeral0\expandafter\UD@secondoftwo\string{\expandafter
\UD@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
\UD@secondoftwo\string}\expandafter\UD@firstoftwo\expandafter{\expandafter
\UD@secondoftwo\string}\expandafter\expandafter\UD@firstoftwo{ }{}%
\UD@secondoftwo}{\expandafter\expandafter\UD@firstoftwo{ }{}\UD@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether argument's first token is a catcode-1-character
%%.............................................................................
%% \UD@CheckWhetherBrace{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked has leading
%% catcode-1-token>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked has no leading
%% catcode-1-token>}%
\newcommand\UD@CheckWhetherBrace[1]{%
\romannumeral0\expandafter\UD@secondoftwo\expandafter{\expandafter{%
\string#1.}\expandafter\UD@firstoftwo\expandafter{\expandafter
\UD@secondoftwo\string}\expandafter\expandafter\UD@firstoftwo{ }{}%
\UD@firstoftwo}{\expandafter\expandafter\UD@firstoftwo{ }{}\UD@secondoftwo}%
}%
%%-----------------------------------------------------------------------------
%% Check whether brace-balanced argument starts with a space-token
%%.............................................................................
%% \UD@CheckWhetherLeadingSpace{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked>'s 1st token is a
%% space-token>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked>'s 1st token is not
%% a space-token>}%
\newcommand\UD@CheckWhetherLeadingSpace[1]{%
\romannumeral0\UD@CheckWhetherNull{#1}%
{\expandafter\expandafter\UD@firstoftwo{ }{}\UD@secondoftwo}%
{\expandafter\UD@secondoftwo\string{\UD@CheckWhetherLeadingSpaceB.#1 }{}}%
}%
\newcommand\UD@CheckWhetherLeadingSpaceB{}%
\long\def\UD@CheckWhetherLeadingSpaceB#1 {%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo{}#1}%
{\UD@Exchange{\UD@firstoftwo}}{\UD@Exchange{\UD@secondoftwo}}%
{\UD@Exchange{ }{\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter}\expandafter\expandafter
\expandafter}\expandafter\UD@secondoftwo\expandafter{\string}%
}%
%%=============================================================================
%% Extract K-th inner undelimited argument:
%%
%% \UD@ExtractKthArg{<integer K>}{<list of undelimited args>}
%%
%% In case there is no K-th argument in <list of indelimited args> :
%% Does not deliver any token.
%% In case there is a K-th argument in <list of indelimited args> :
%% Does deliver that K-th argument with one level of braces removed.
%%
%% Examples:
%%
%% \UD@ExtractKthArg{0}{ABCDE} yields: <nothing>
%%
%% \UD@ExtractKthArg{3}{ABCDE} yields: C
%%
%% \UD@ExtractKthArg{3}{AB{CD}E} yields: CD
%%
%% \UD@ExtractKthArg{4}{{001}{002}{003}{004}{005}} yields: 004
%%
%% \UD@ExtractKthArg{6}{{001}{002}{003}} yields: <nothing>
%%
%%=============================================================================
\newcommand\UD@ExtractKthArg[1]{%
\romannumeral0%
% #1: <integer number K>
\expandafter\UD@ExtractKthArgCheck
\expandafter{\romannumeral\number\number#1 000}%
}%
\newcommand\UD@ExtractKthArgCheck[2]{%
\UD@CheckWhetherNull{#1}{ }{%
\expandafter\UD@ExtractKthArgLoop\expandafter{\UD@firstoftwo{}#1}{#2}%
}%
}%
\newcommand\UD@ExtractKthArgLoop[2]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo#2{}.}{ }{%
\UD@CheckWhetherNull{#1}{%
\UD@ExtractFirstArgLoop{#2UD@SelDOm}%
}{%
\expandafter\UD@Exchange\expandafter{\expandafter{\UD@firstoftwo{}#2}}%
{\expandafter\UD@ExtractKthArgLoop\expandafter{\UD@firstoftwo{}#1}}%
}%
}%
}%
\@ifdefinable\UD@RemoveTillUD@SelDOm{%
\long\def\UD@RemoveTillUD@SelDOm#1#2UD@SelDOm{{#1}}%
}%
\newcommand\UD@ExtractFirstArgLoop[1]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo{}#1}%
{\UD@firstoftwo{\expandafter}{} \UD@secondoftwo{}#1}%
{\expandafter\UD@ExtractFirstArgLoop\expandafter{\UD@RemoveTillUD@SelDOm#1}}%
}%
%%=============================================================================
%% Fork if argument, which must be a single token, is
%% 0/1/2/3/4/5/6/7/8/9/+/-/./,/<space token>/<expandable token>/<something else>
%% (total: 17 cases)
%%-----------------------------------------------------------------------------
\@ifdefinable\UD@GobbleToExclam{\long\def\UD@GobbleToExclam#1!{}}%
%%-----------------------------------------------------------------------------
\@ifdefinable\UD@normalizenumberfork{%
\long\def\UD@normalizenumberfork#1!0!1!2!3!4!5!6!7!8!9!+!-!,!.!#2#3!!!!{#2}%
}%
\newcommand\UD@normalizenumberloopfork[1]{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@GobbleToExclam#1!}{%
\UD@normalizenumberfork
!#1!1!2!3!4!5!6!7!8!9!+!-!,!.!{1}% <digit> 0_12
!0!#1!2!3!4!5!6!7!8!9!+!-!,!.!{2}% <digit> 1_12
!0!1!#1!3!4!5!6!7!8!9!+!-!,!.!{3}% <digit> 2_12
!0!1!2!#1!4!5!6!7!8!9!+!-!,!.!{4}% <digit> 3_12
!0!1!2!3!#1!5!6!7!8!9!+!-!,!.!{5}% <digit> 4_12
!0!1!2!3!4!#1!6!7!8!9!+!-!,!.!{6}% <digit> 5_12
!0!1!2!3!4!5!#1!7!8!9!+!-!,!.!{7}% <digit> 6_12
!0!1!2!3!4!5!6!#1!8!9!+!-!,!.!{8}% <digit> 7_12
!0!1!2!3!4!5!6!7!#1!9!+!-!,!.!{9}% <digit> 8_12
!0!1!2!3!4!5!6!7!8!#1!+!-!,!.!{10}% <digit> 9_12
!0!1!2!3!4!5!6!7!8!9!#1!-!,!.!{11}% <plus or minus> +_12
!0!1!2!3!4!5!6!7!8!9!+!#1!,!.!{12}% <plus or minus> -_12
!0!1!2!3!4!5!6!7!8!9!+!-!#1!.!{13}% <decimal constant> ,_12
!0!1!2!3!4!5!6!7!8!9!+!-!,!#1!{14}% <decimal constant> ._12
!0!1!2!3!4!5!6!7!8!9!+!-!,!.!{%
\ifcat\noexpand#1 \expandafter\UD@firstoftwo\else\expandafter\UD@secondoftwo\fi
{15}% <space token> differing from explicit character token of catcode 10
% and charcode 32; removable as undelimited argument
{%
\expandafter\ifx\noexpand#1#1%
\expandafter\UD@firstoftwo\else\expandafter\UD@secondoftwo\fi
{18}% something else which is not allowed
{17}% expandable token
}%
}%
!!!!%
}{18}% Case: #1 contains !_12 , therefore is something else which is not
% allowed
}%
%%=============================================================================
%% \normalizenumber{<argument>}
%%-----------------------------------------------------------------------------
\newcommand\normalizenumber[1]{%
\romannumeral0%
\normalizenumberloop{#1}{}{}{#1}{\UD@firstoftwo}{}{\UD@firstoftwo}{}%
}%
\newif\ifnormalizenumberexpandarg\normalizenumberexpandargfalse
\newcommand\normalizenumberloop[8]{%
% #1 - argument to iterate
% #2 - leading zero if found
% #3 - optional minus sign
% #4 - argument untouched
% #5 - decimal separator not/already found - \UD@firstoftwo/\UD@secondoftwo
% #6 - zero-decimals collected so far
% #7 - sign-check on/off - \UD@firstoftwo/\UD@secondoftwo
% #8 - significant digits collected so far
\UD@CheckWhetherNull{#1}{%
\UD@CheckWhetherNull{#8}{\UD@CheckWhetherNull{#2}{ #4}{ #2}}{ #3#8}%
}{%
\UD@ExtractKthArg{%
%-------------------------------------------------------------------------
% \UD@ExtractKthArg's <integer K>:
%-------------------------------------------------------------------------
% Code for calculating \UD@ExtractKthArg's <integer K>
\UD@CheckWhetherBrace{#1}{%
18% argument to iterate's 1st token has catcode 1, therefore is not
% allowed.
}{%
\UD@CheckWhetherLeadingSpace{#1}{%
16% explicit character token of catcode 10 and charcode 32; not
% removable as undelimited argument
}{%
\expandafter\UD@normalizenumberloopfork
\expandafter{\romannumeral0\UD@ExtractFirstArgLoop{#1UD@SelDOm}}%
}%
}%
}{%
%-------------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>:
%-------------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 1st argument:
% \UD@ExtractKthArg's 1st argument yields the number 1, thus #1's
% 1st token is <digit> 0_12
{%
#5{%
\UD@CheckWhetherNull{#8}{%
\UD@firstoftwo{%
\expandafter\normalizenumberloop\expandafter{\UD@firstoftwo{}#1}{0}{#3}{#4}{#5}{}{\UD@secondoftwo}{#8}%
}%
}{\UD@Exchange{{#80}}}%
}{%
\UD@firstoftwo{%
\expandafter\normalizenumberloop
\expandafter{\UD@firstoftwo{}#1}{#2}%
{#3}{#4}{#5}{#60}{\UD@secondoftwo}{#8}%
}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 2nd argument:
% \UD@ExtractKthArg's 1st argument yields the number 2, thus #1's
% 1st token is <digit> 1_12
{\UD@Exchange{{#8#61}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 3rd argument:
% \UD@ExtractKthArg's 1st argument yields the number 3, thus #1's
% 1st token is <digit> 2_12
{\UD@Exchange{{#8#62}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 4th argument:
% \UD@ExtractKthArg's 1st argument yields the number 4, thus #1's
% 1st token is <digit> 3_12
{\UD@Exchange{{#8#63}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 5th argument:
% \UD@ExtractKthArg's 1st argument yields the number 5, thus #1's
% 1st token is <digit> 4_12
{\UD@Exchange{{#8#64}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 6th argument:
% \UD@ExtractKthArg's 1st argument yields the number 6, thus #1's
% 1st token is <digit> 5_12
{\UD@Exchange{{#8#65}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 7th argument:
% \UD@ExtractKthArg's 1st argument yields the number 7, thus #1's
% 1st token is <digit> 6_12
{\UD@Exchange{{#8#66}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 8th argument:
% \UD@ExtractKthArg's 1st argument yields the number 8, thus #1's
% 1st token is <digit> 7_12
{\UD@Exchange{{#8#67}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 9th argument:
% \UD@ExtractKthArg's 1st argument yields the number 9, thus #1's
% 1st token is <digit> 8_12
{\UD@Exchange{{#8#68}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 10th argument:
% \UD@ExtractKthArg's 1st argument yields the number 10, thus #1's
% 1st token is <digit> 9_12
{\UD@Exchange{{#8#69}}}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 11th argument:
% \UD@ExtractKthArg's 1st argument yields the number 11, thus #1's
% 1st token is <plus or minus> +_12
{%
\UD@firstoftwo{%
#7{%
\expandafter\UD@CheckWhetherNull
\expandafter{\UD@firstoftwo{}#1}{ #4}{%
\expandafter\normalizenumberloop
\expandafter{\UD@firstoftwo{}#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
}%
}{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 12th argument:
% \UD@ExtractKthArg's 1st argument yields the number 12, thus #1's
% 1st token is <plus or minus> -_12
{%
\UD@firstoftwo{%
#7{%
\expandafter\UD@CheckWhetherNull
\expandafter{\UD@firstoftwo{}#1}{ #4}{%
\UD@CheckWhetherNull{#3}{\UD@Exchange{{-}}}{\UD@Exchange{{}}}%
{\expandafter\normalizenumberloop\expandafter{\UD@firstoftwo{}#1}{#2}}%
{#4}{#5}{#6}{#7}{#8}%
}%
}{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 13th argument:
% \UD@ExtractKthArg's 1st argument yields the number 13, thus #1's
% 1st token is <decimal constant> ,_12
{%
\UD@firstoftwo{%
#5{%
\expandafter\UD@CheckWhetherNull
\expandafter{\UD@firstoftwo{}#1}{ #4}{%
\UD@CheckWhetherNull{#2#8}{ #4}{%
\UD@CheckWhetherNull{#8}{\UD@Exchange{{#2}}}{\UD@Exchange{{#8}}}%
{%
\expandafter\normalizenumberloop\expandafter{\UD@firstoftwo{}#1}%
{#2}{#3}{#4}{\UD@secondoftwo}{,}{\UD@secondoftwo}%
}%
}%
}%
}{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 14th argument:
% \UD@ExtractKthArg's 1st argument yields the number 14, thus #1's
% 1st token is <decimal constant> ._12
{%
\UD@firstoftwo{%
#5{%
\expandafter\UD@CheckWhetherNull
\expandafter{\UD@firstoftwo{}#1}{ #4}{%
\UD@CheckWhetherNull{#2#8}{ #4}{%
\UD@CheckWhetherNull{#8}{\UD@Exchange{{#2}}}{\UD@Exchange{{#8}}}%
{%
\expandafter\normalizenumberloop\expandafter{\UD@firstoftwo{}#1}%
{#2}{#3}{#4}{\UD@secondoftwo}{.}{\UD@secondoftwo}%
}%
}%
}%
}{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 15th argument:
% \UD@ExtractKthArg's 1st argument yields the number 15, thus #1's
% 1st token is a <space token> differing from explicit character
% token of catcode 10 and charcode 32 and is removable as
% undelimited argument
{%
\UD@firstoftwo{%
#7{\UD@firstoftwo}{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@firstoftwo{}#1}%
}%
{%
\expandafter\normalizenumberloop
\expandafter{\UD@firstoftwo{}#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
}%
{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 16th argument:
% \UD@ExtractKthArg's 1st argument yields the number 16, thus #1's
% 1st token is a <space token>, more precisely an explicit
% character token of catcode 10 and charcode 32 and is not removable
% as undelimited argument
{%
\UD@firstoftwo{%
#7{\UD@firstoftwo}{%
\expandafter\UD@CheckWhetherNull\expandafter{\UD@Removespace#1}%
}%
{%
\expandafter\normalizenumberloop
\expandafter{\UD@Removespace#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}%
}%
{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 17th argument:
% \UD@ExtractKthArg's 1st argument yields the number 17, thus #1's
% 1st token is expandable.
{%
\UD@firstoftwo{%
\ifnormalizenumberexpandarg
\expandafter\UD@firstoftwo\else\expandafter\UD@secondoftwo\fi
{\expandafter\normalizenumberloop\expandafter{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
{ #4}%
}%
}%
%-----------------------------------------------------------------------
% \UD@ExtractKthArg's <list of undelimited args>'s 18th argument:
% \UD@ExtractKthArg's 1st argument yields the number 18, thus #1's
% 1st token is not allowed with numbers that can be normalized.
{%
\UD@firstoftwo{ #4}%
}%
%-------------------------------------------------------------------------
% End of \UD@ExtractKthArg's <list of undelimited args>.
%-------------------------------------------------------------------------
}%
{\expandafter\normalizenumberloop\expandafter{\UD@firstoftwo{}#1}%
{#2}{#3}{#4}{#5}{}{\UD@secondoftwo}%
}%
}%
}%
%%.............................................................................
\makeatother
% Test \normalizenumber by applying it inside the definition-text of \test:
\newcommand\Test[1]{%
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter\test
\expandafter\expandafter\expandafter{#1}%
\texttt{(\meaning\test)}%
}%
\makeatletter\let\sptoken= \@sptoken\makeatother
\begin{document}
\null\kern-2cm
The following either comply the pattern described in case 1 or comply the pattern described in case 2:
01: \Test{\normalizenumber{-\sptoken\sptoken-\sptoken++\sptoken00000.0000\sptoken}}
02: \Test{\normalizenumber{-\sptoken\sptoken-\sptoken++\sptoken - 8\sptoken}}
03: \Test{\normalizenumber{+-+00000}}
04: \Test{\normalizenumber{-++++0}}
05: \Test{\normalizenumber{---00000.000010000}}
06: \Test{\normalizenumber{--+-0003.9}}
07: \Test{\normalizenumber{+-+00087}}
08: \Test{\normalizenumber{+ -+00024}}
09: \Test{\normalizenumber{--87.0000}}
10: \Test{\normalizenumber{+--0015.00000010000700000}}
11: \Test{\normalizenumber{+98.0000 }}
12: \Test{\normalizenumber{4.50000}}
13: \Test{\normalizenumber{2.50000 }}
14: \Test{\normalizenumber{7,4}}
15: \Test{\normalizenumber{67}}
16: \Test{\normalizenumber{-15}}
17: \Test{\normalizenumber{-+ +-+ 15 }}
18: \Test{\normalizenumber{67,0000}}
19: \Test{\normalizenumber{67,0000001}}
20: \Test{\normalizenumber{68,0000 }}
21: \Test{\normalizenumber{2,80000}}
22: \Test{\normalizenumber{7,50000 }}
23: \Test{\normalizenumber{1,50000 }}
\kern\dp\strutbox
\hrule
\kern\dp\strutbox
The following don't comply any of these two patterns:
24: \Test{\normalizenumber{}}
25: \Test{\normalizenumber{--++}}
26: \Test{\normalizenumber{--++}}
27: \Test{\normalizenumber{-1.}}
28: \Test{\normalizenumber{3.7.0000 }}
29: \Test{\normalizenumber{8,5,0000 }}
30: \Test{\normalizenumber{8,9.0000 }}
31: \Test{\normalizenumber{9.3,0000 }}
32: \Test{\normalizenumber{A.0000}}
33: \Test{\normalizenumber{1{1}1}}
34: \Test{\normalizenumber{{1},6}}
35: \Test{\normalizenumber{1,}}
36: \Test{\normalizenumber{7,~ / 8()}}
37: \Test{\normalizenumber{1{1}1}}
\kern\dp\strutbox
\hrule
\kern\dp\strutbox
\verb|\def\macroa#1#2{- - + -00012\macrob}%|
\def\macroa#1#2{- - + -00012\macrob}%
\verb|\def\macrob{34.56000}%|
\def\macrob{34.56000}%
\verb|\normalizenumberexpandargfalse|
\normalizenumberexpandargfalse
32: \Test{\normalizenumber{\macroa{7}{8}}}
\verb|\normalizenumberexpandargtrue|
\normalizenumberexpandargtrue
33: \Test{\normalizenumber{\macroa{7}{8}}}
\end{document}