帮助寻找奇怪的空间

帮助寻找奇怪的空间

我伪造了一个瑞典语文件(见下文)fmtcount。它对我很有帮助,但现在我开始注意到数字前出现了奇怪的空格。我有点不知所措,不知道该找什么,所以我希望有人能给我指明正确的方向或帮助我解决这个问题。

fmtcount这里我们看到一个使用德语语言文件的例子:

没有奇怪空格的德语示例

\documentclass[
  german
]{article}
\usepackage{babel}
\usepackage{fmtcount}
\begin{document}
  \noindent A\ordinalstringnum{23}A

  \noindent A\ordinalnum{23}A
\end{document}

这里我们看到当我使用瑞典语语言文件时出现的奇怪的空格:

带有奇怪空格的瑞典示例

\documentclass[
  swedish
]{article}
\usepackage{babel}
\usepackage{fmtcount}
\FCloadlang{swedish}
\begin{document}
  \noindent A\ordinalstringnum{23}A

  \noindent A\ordinalnum{23}A
\end{document}

瑞典语文件:fc-swedish.def

\ProvidesFCLanguage{swedish}[2023/02/14]%
% % The four lines below should be uncommented for older pdfTeX versions
% \RequirePackage{iftex}
% \ifpdftex
%   \RequirePackage[utf8]{inputenc}
%   \RequirePackage[T1]{fontenc}
% \fi

% % The three lines below should be uncommented if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
% \let\fc@swedishoptions@thousands@after\@empty
% \let\fc@swedishoptions@thousands@before\@empty
% \def\fc@swedishoptions@one{#1}

% LANGUAGE OPTIONS (begin)
% This section (together with SET DEFAULTS section at the bottom) must be commented out if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
\ifcsundef{fc@gl@let}{\global\let\fc@gl@let\let}{\PackageError{fmtcount}{Command already defined}{Command
\protect\fc@gl@let\space already defined.}}
\ifcsundef{fc@gl@def}{\global\let\fc@gl@def\def}{\PackageError{fmtcount}{Command already defined}{Command
\protect\fc@gl@def\space already defined.}}

\define@choicekey*+{fcswedish}{space}[\val\nr]{neither,after,both}[neither]{%
  \ifcase\nr\relax
    \let\fc@swedishoptions@thousands@after\@empty
    \let\fc@swedishoptions@thousands@before\@empty
  \or
    \let\fc@swedishoptions@thousands@after\space
    \let\fc@swedishoptions@thousands@before\@empty
  \or
    \let\fc@swedishoptions@thousands@after\space
    \let\fc@swedishoptions@thousands@before\space
  \fi
}{%
  \PackageError{fmtcount}{Invalid value `#1' to Swedish space key}{%
    Swedish option `space' expects `neither', `after' or `both'%
  }%
}%

\define@choicekey*+{fcswedish}{one}{neither,hundred,thousand,both}[neither]{%
  \def\fc@swedishoptions@one{#1}
}{%
  \PackageError{fmtcount}{Invalid value `#1' to Swedish one key}{%
    Swedish option `one' expects `neither', `hundred', `thousand' or `both'
  }%
}%
% LANGUAGE OPTIONS (end)

% \FCordinal
\newcommand{\@ordinalMswedish}[2]{%
  \edef#2{\number#1\relax:e}%
}%
\global\let\@ordinalMswedish\@ordinalMswedish
\newcommand*\@ordinalFswedish[2]{%
  \def\@fc@ord{}%
  \@orgargctr=#1\relax
  \@ordinalctr=#1%
  \@FCmodulo{\@ordinalctr}{100}%
  \ifnum\@ordinalctr=11\relax
    \def\@fc@ord{:e}%
  \else
    \ifnum\@ordinalctr=12\relax
      \def\@fc@ord{:e}%
    \else
      \@FCmodulo{\@ordinalctr}{10}%
      \ifcase\@ordinalctr
        \def\@fc@ord{:e}%      case 0
        \or \def\@fc@ord{:a}%  case 1
        \or \def\@fc@ord{:a}%  case 2
      \else
        \def\@fc@ord{:e}%      default case
      \fi
    \fi
  \fi
  \edef#2{\number#1\relax\noexpand\@fc@ord}% The ordinal suffix is never raised in Swedish
}%
\global\let\@ordinalFswedish\@ordinalFswedish
\global\let\@ordinalNswedish\@ordinalFswedish

% \numberstring
\newcommand*\@@unitstringMswedish[1]{%
  \ifcase#1%
    noll%
    \or en%
    \or två%
    \or tre%
    \or fyra%
    \or fem%
    \or sex%
    \or sju%
    \or åtta%
    \or nio%
  \fi
}%
\global\let\@@unitstringMswedish\@@unitstringMswedish
\global\let\@@unitstringFswedish\@@unitstringMswedish
\newcommand*\@@unitstringNswedish[1]{%
  \ifcase#1%
    noll%
    \or ett%
    \or två%
    \or tre%
    \or fyra%
    \or fem%
    \or sex%
    \or sju%
    \or åtta%
    \or nio%
  \fi
}%
\global\let\@@unitstringNswedish\@@unitstringNswedish
\newcommand*\@@tenstringswedish[1]{%
  \ifcase#1%
    \or tio%
    \or tjugo%
    \or trettio%
    \or fyrtio%
    \or femtio%
    \or sextio%
    \or sjuttio%
    \or åttio%
    \or nittio%
    \or etthundra%
  \fi
}%
\global\let\@@tenstringswedish\@@tenstringswedish
\newcommand*\@@teenstringswedish[1]{%
  \ifcase#1%
    tio%
    \or elva%
    \or tolv%
    \or tretton%
    \or fjorton%
    \or femton%
    \or sexton%
    \or sjutton%
    \or arton%
    \or nitton%
  \fi
}%
\global\let\@@teenstringswedish\@@teenstringswedish

\newcommand*\@@numberunderhundredswedish[2]{%
  \ifnum#1>99\relax
    \PackageError{fmtcount}{Out of range}%
    {This submacro should only deal with values less than 100}%
  \fi
  \ifnum#1<10\relax
    \eappto#2{\@unitstring{#1}}%
  \else
    \ifnum#1<20\relax
      \@tmpstrctr=#1\relax
      \@FCmodulo{\@tmpstrctr}{10}%
      \eappto#2{\@teenstring{\@tmpstrctr}}%
    \else
      % tens
      \@tmpstrctr=#1\relax
      \divide\@tmpstrctr by 10\relax
      \eappto#2{\@tenstring{\@tmpstrctr}}%
      % singles
      \@tmpstrctr=#1\relax
      \@FCmodulo{\@tmpstrctr}{10}%
      \ifnum\@tmpstrctr>0\relax
        \eappto#2{\@unitstring{\@tmpstrctr}}%
      \fi
    \fi
  \fi
}%
\global\let\@@numberunderhundredswedish\@@numberunderhundredswedish

\newcommand*\@@numberstringswedish[2]{%
  \ifnum#1>99999\relax
    \PackageError{fmtcount}{Out of range}%
    {This macro only works for values less than 100000}%
  \fi
  \ifnum#1<0\relax
    \PackageError{fmtcount}{Negative numbers not permitted}%
    {This macro does not work for negative numbers, however
    you can try typing "minus" first, and then pass the modulus of
    this number}%
  \fi
  % Incorporate language options
  \show\fc@swedishoptions@one
  \ifthenelse{\equal{\fc@swedishoptions@one}{neither}}{%
    \def\fc@swedishoptions@one@hundred{hundra}
    \def\fc@swedishoptions@one@thousand{tusen}
  }{%
    \ifthenelse{\equal{\fc@swedishoptions@one}{hundred}}{%
      \def\fc@swedishoptions@one@hundred{etthundra}
      \def\fc@swedishoptions@one@thousand{tusen}
    }{%
      \ifthenelse{\equal{\fc@swedishoptions@one}{thousand}}{%
        \def\fc@swedishoptions@one@hundred{hundra}
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}
        }
      }{%both
        \def\fc@swedishoptions@one@hundred{etthundra}
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}
        }
      }%
    }%
  }%
  \show\fc@swedishoptions@one@hundred
  \show\fc@swedishoptions@one@thousand
  % Initialize
  \def#2{}%
  % Thousands
  \@strctr=#1\relax
  \divide\@strctr by 1000\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \eappto#2{\fc@swedishoptions@one@thousand}%
    \else
      \let\@tmpunitstring\@unitstring% Temporary store gendered unit string
      \let\@unitstring\@@unitstringMswedish% Thousands above 1 are given in "masculine" units (21,000 is "tjugoentusen" and not "tjugoettusen")
      \@@numberunderhundredswedish{\@strctr}{#2}%
      \let\@unitstring\@tmpunitstring% Restore gendered unit string
      \eappto#2{\fc@swedishoptions@thousands@before}%
      \appto#2{tusen}%
    \fi
    \@strctr=#1\relax
    \@FCmodulo{\@strctr}{1000}%
    \ifnum\@strctr>0\relax
      \eappto#2{\fc@swedishoptions@thousands@after}%
    \fi
  \fi
  % Hundreds
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{1000}%
  \divide\@strctr by 100\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \eappto#2{\fc@swedishoptions@one@hundred}%
    \else
      \eappto#2{\@unitstring{\@strctr}}%
      \appto#2{hundra}%
    \fi
  \fi
  % Tens and singles
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{100}%
  \ifnum\@strctr>0\relax% Trailing zeros are silent
    \@@numberunderhundredswedish{\@strctr}{#2}%
  \else
    \ifnum#1=0\relax% Unless the number is in fact 0
      \eappto#2{\@unitstring{\@strctr}}%
    \fi
  \fi
}%
\global\let\@@numberstringswedish\@@numberstringswedish

\newcommand*{\@numberstringMswedish}[2]{%
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@numberstringswedish{#1}{#2}%
}%
\global\let\@numberstringMswedish\@numberstringMswedish
\global\let\@numberstringFswedish\@numberstringMswedish
\newcommand*{\@numberstringNswedish}[2]{%
  \let\@unitstring\@@unitstringNswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@numberstringswedish{#1}{#2}%
}%

\newcommand*{\@NumberstringMswedish}[2]{%
  \@numberstringMswedish{#1}{\@@num@str}%
  \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@NumberstringMswedish\@NumberstringMswedish
\global\let\@NumberstringFswedish\@NumberstringMswedish
\newcommand*{\@NumberstringNswedish}[2]{%
  \@numberstringNswedish{#1}{\@@num@str}%
  \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@NumberstringNswedish\@NumberstringNswedish

% ordinalstring
\newcommand*\@@unitthstringMswedish[1]{%
  \ifcase#1%
    nollte%
    \or förste%
    \or andre%
    \or tredje%
    \or fjärde%
    \or femte%
    \or sjätte%
    \or sjunde%
    \or åttonde%
    \or nionde%
  \fi
}%
\global\let\@@unitthstringMswedish\@@unitthstringMswedish
\newcommand*\@@unitthstringFswedish[1]{%
  \ifcase#1%
    nollte%
    \or första%
    \or andra%
    \or tredje%
    \or fjärde%
    \or femte%
    \or sjätte%
    \or sjunde%
    \or åttonde%
    \or nionde%
  \fi
}%
\global\let\@@unitthstringFswedish\@@unitthstringFswedish
\global\let\@@unitthstringNswedish\@@unitthstringFswedish
\newcommand*\@@tenthstringswedish[1]{%
  \ifcase#1%
    \or tionde%
    \or tjugonde%
    \or trettionde%
    \or fyrtionde%
    \or femtionde%
    \or sextionde%
    \or sjuttionde%
    \or åttionde%
    \or nittionde%
  \fi
}%
\global\let\@@tenthstringswedish\@@tenthstringswedish
\newcommand*\@@teenthstringswedish[1]{%
  \ifcase#1%
    tionde%
    \or elfte%
    \or tolfte%
    \or trettonde%
    \or fjortonde%
    \or femtonde%
    \or sextonde%
    \or sjuttonde%
    \or artonde%
    \or nittonde%
  \fi
}%
\global\let\@@teenthstringswedish\@@teenthstringswedish

\newcommand*\@@numberunderhundredthswedish[2]{%
  \ifnum#1<10\relax
    \eappto#2{\@unitthstring{#1}}%
  \else
    \@tmpstrctr=#1\relax
    \@FCmodulo{\@tmpstrctr}{10}%
    \ifnum#1<20\relax
      \eappto#2{\@teenthstring{\@tmpstrctr}}%
    \else
      \ifnum\@tmpstrctr=0\relax
        \@tmpstrctr=#1\relax
        \divide\@tmpstrctr by 10\relax
        \eappto#2{\@tenthstring{\@tmpstrctr}}%
      \else
        \@tmpstrctr=#1\relax
        \divide\@tmpstrctr by 10\relax
        \eappto#2{\@tenstring{\@tmpstrctr}}%
        \@tmpstrctr=#1\relax
        \@FCmodulo{\@tmpstrctr}{10}%
        \eappto#2{\@unitthstring{\@tmpstrctr}}%
      \fi
    \fi
  \fi
}%
\global\let\@@numberunderhundredthswedish\@@numberunderhundredthswedish

\newcommand*\@@ordinalstringswedish[2]{%
  \ifnum\@orgargctr>99999\relax
    \PackageError{fmtcount}{Out of range}%
    {This macro only works for values less than 100000}%
  \fi
  \ifnum\@orgargctr<0\relax
    \PackageError{fmtcount}{Negative numbers not permitted}%
    {This macro does not work for negative numbers, however
    you can try typing "minus" first, and then pass the modulus of
    this number}%
  \fi
  % Incorporate language options
  \ifthenelse{\equal{\fc@swedishoptions@one}{neither}}{%
    \def\fc@swedishoptions@one@hundred{hundra}
    \def\fc@swedishoptions@one@hundredth{hundrade}
    \def\fc@swedishoptions@one@thousand{tusen}
    \def\fc@swedishoptions@one@thousandth{tusende}
  }{%
    \ifthenelse{\equal{\fc@swedishoptions@one}{hundred}}{%
      \def\fc@swedishoptions@one@hundred{etthundra}
      \def\fc@swedishoptions@one@hundredth{etthundrade}
      \def\fc@swedishoptions@one@thousand{tusen}
      \def\fc@swedishoptions@one@thousandth{tusende}
    }{%
      \ifthenelse{\equal{\fc@swedishoptions@one}{thousand}}{%
        \def\fc@swedishoptions@one@hundred{hundra}
        \def\fc@swedishoptions@one@hundredth{hundrade}
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}
          \def\fc@swedishoptions@one@thousandth{ett tusende}
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}
          \def\fc@swedishoptions@one@thousandth{ettusende}
        }
      }{%both
        \def\fc@swedishoptions@one@hundred{etthundra}
        \def\fc@swedishoptions@one@hundredth{etthundrade}
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}
          \def\fc@swedishoptions@one@thousandth{ett tusende}
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}
          \def\fc@swedishoptions@one@thousandth{ettusende}
        }
      }%
    }%
  }%
  % Initialize
  \def#2{}%
  % Thousands
  \@strctr=#1\relax
  \divide\@strctr by 1000\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{1000}%
      \ifnum\@strctr>0\relax
        \eappto#2{\fc@swedishoptions@one@thousand}%
        \eappto#2{\fc@swedishoptions@thousands@after}%
      \else
        \eappto#2{\fc@swedishoptions@one@thousandth}%
      \fi
    \else
      \let\@tmpunitstring\@unitstring% Temporary store gendered unit string
      \let\@unitstring\@@unitstringMswedish% Thousands above 1 are given in "masculine" units (21,000 is "tjugoentusen" and not "tjugoettusen")
      \@@numberunderhundredswedish{\@strctr}{#2}%
      \let\@unitstring\@tmpunitstring% Restore gendered unit string
      \eappto#2{\fc@swedishoptions@thousands@before}%
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{1000}%
      \ifnum\@strctr>0\relax
        \appto#2{tusen}%
        \eappto#2{\fc@swedishoptions@thousands@after}%
      \else
        \appto#2{tusende}%
      \fi
    \fi
  \fi
  % Hundreds
  \@strctr=#1
  \@FCmodulo{\@strctr}{1000}%
  \divide\@strctr by 100\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{100}%
      \ifnum\@strctr>0\relax
        \eappto#2{\fc@swedishoptions@one@hundred}%
      \else
        \eappto#2{\fc@swedishoptions@one@hundredth}%
      \fi
    \else
      \eappto#2{\@unitstring{\@strctr}}% Hundreds are given in "neutrum" units
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{100}%
      \ifnum\@strctr>0\relax
        \appto#2{hundra}%
      \else
        \appto#2{hundrade}%
      \fi
    \fi
  \fi
  % Tens and singles
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{100}%
  \ifnum\@strctr>0\relax% Trailing zeros are silent
    \@@numberunderhundredthswedish{\@strctr}{#2}%
  \else
    \ifnum#1=0\relax% Unless the number is in fact 0
      \eappto#2{\@unitthstring{\@strctr}}%
    \fi
  \fi
}%
\global\let\@@ordinalstringswedish\@@ordinalstringswedish

\newcommand*{\@ordinalstringMswedish}[2]{%
  \let\@unitthstring\@@unitthstringMswedish
  \let\@teenthstring\@@teenthstringswedish
  \let\@tenthstring\@@tenthstringswedish
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@ordinalstringswedish{#1}{#2}%
}%
\global\let\@ordinalstringMswedish\@ordinalstringMswedish
\newcommand*{\@ordinalstringFswedish}[2]{%
  \let\@unitthstring\@@unitthstringFswedish
  \let\@teenthstring\@@teenthstringswedish
  \let\@tenthstring\@@tenthstringswedish
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@ordinalstringswedish{#1}{#2}%
}%
\global\let\@ordinalstringFswedish\@ordinalstringFswedish
\global\let\@ordinalstringNswedish\@ordinalstringFswedish

\newcommand*{\@OrdinalstringMswedish}[2]{%
 \@ordinalstringMswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringMswedish\@OrdinalstringMswedish
\newcommand*{\@OrdinalstringFswedish}[2]{%
 \@ordinalstringFswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringFswedish\@OrdinalstringFswedish
\newcommand*{\@OrdinalstringNswedish}[2]{%
 \@ordinalstringNswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringNswedish\@OrdinalstringNswedish

% SET DEFAULTS (begin)
% This section (together with LANGUAGE OPTIONS section at the top) must be commented out if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
\newcommand*\fc@swedishoptions@setdefaults{%
  \fc@gl@let\fc@swedishoptions@thousands@after\@empty%
  \fc@gl@let\fc@swedishoptions@thousands@before\@empty%
  \fc@gl@def\fc@swedishoptions@one{neither}%
}%
\global\let\fc@swedishoptions@setdefaults\fc@swedishoptions@setdefaults
{%
  \let\fc@gl@def\gdef
  \def\fc@gl@let{\global\let}%
  \fc@swedishoptions@setdefaults
}%
% SET DEFAULTS (end)

\iffalse Local variables: \fi
\iffalse mode: docTeX     \fi
\iffalse End:             \fi
\endinput

答案1

第 55 行:\@ordinalctr=#1%应该是\@ordinalctr=#1\relax

第 181 行:\show\fc@swedishoptions@one应删除;其他所有\show命令也一样

从第 182 行开始:多条未受保护的端线

    182   \ifthenelse{\equal{\fc@swedishoptions@one}{neither}}{%
    183     \def\fc@swedishoptions@one@hundred{hundra}% <---
    184     \def\fc@swedishoptions@one@thousand{tusen}% <---
    185   }{%
    186     \ifthenelse{\equal{\fc@swedishoptions@one}{hundred}}{%
    187       \def\fc@swedishoptions@one@hundred{etthundra}% <---
    188       \def\fc@swedishoptions@one@thousand{tusen}% <---
    189     }{%
    190       \ifthenelse{\equal{\fc@swedishoptions@one}{thousand}}{%
    191         \def\fc@swedishoptions@one@hundred{hundra}% <---
    192         \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
    193           \def\fc@swedishoptions@one@thousand{ett tusen}% <---
    194         }{%
    195           \def\fc@swedishoptions@one@thousand{ettusen}% <---
    196         }% <---
    197       }{%both
    198         \def\fc@swedishoptions@one@hundred{etthundra}
    199         \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
    200           \def\fc@swedishoptions@one@thousand{ett tusen}% <---
    201         }{%
    202           \def\fc@swedishoptions@one@thousand{ettusen}% <---
    203         }% <---
    204       }%
    205     }%
    206   }%

同样从第 383 行到第 417 行

完成编辑:

\ProvidesFCLanguage{swedish}[2023/02/14]%
% % The four lines below should be uncommented for older pdfTeX versions
% \RequirePackage{iftex}
% \ifpdftex
%   \RequirePackage[utf8]{inputenc}
%   \RequirePackage[T1]{fontenc}
% \fi

% % The three lines below should be uncommented if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
% \let\fc@swedishoptions@thousands@after\@empty
% \let\fc@swedishoptions@thousands@before\@empty
% \def\fc@swedishoptions@one{#1}

% LANGUAGE OPTIONS (begin)
% This section (together with SET DEFAULTS section at the bottom) must be commented out if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
\ifcsundef{fc@gl@let}{\global\let\fc@gl@let\let}{\PackageError{fmtcount}{Command already defined}{Command
\protect\fc@gl@let\space already defined.}}
\ifcsundef{fc@gl@def}{\global\let\fc@gl@def\def}{\PackageError{fmtcount}{Command already defined}{Command
\protect\fc@gl@def\space already defined.}}

\define@choicekey*+{fcswedish}{space}[\val\nr]{neither,after,both}[neither]{%
  \ifcase\nr\relax
    \let\fc@swedishoptions@thousands@after\@empty
    \let\fc@swedishoptions@thousands@before\@empty
  \or
    \let\fc@swedishoptions@thousands@after\space
    \let\fc@swedishoptions@thousands@before\@empty
  \or
    \let\fc@swedishoptions@thousands@after\space
    \let\fc@swedishoptions@thousands@before\space
  \fi
}{%
  \PackageError{fmtcount}{Invalid value `#1' to Swedish space key}{%
    Swedish option `space' expects `neither', `after' or `both'%
  }%
}%

\define@choicekey*+{fcswedish}{one}{neither,hundred,thousand,both}[neither]{%
  \def\fc@swedishoptions@one{#1}
}{%
  \PackageError{fmtcount}{Invalid value `#1' to Swedish one key}{%
    Swedish option `one' expects `neither', `hundred', `thousand' or `both'
  }%
}%
% LANGUAGE OPTIONS (end)

% \FCordinal
\newcommand{\@ordinalMswedish}[2]{%
  \edef#2{\number#1\relax:e}%
}%
\global\let\@ordinalMswedish\@ordinalMswedish
\newcommand*\@ordinalFswedish[2]{%
  \def\@fc@ord{}%
  \@orgargctr=#1\relax
  \@ordinalctr=#1\relax
  \@FCmodulo{\@ordinalctr}{100}%
  \ifnum\@ordinalctr=11\relax
    \def\@fc@ord{:e}%
  \else
    \ifnum\@ordinalctr=12\relax
      \def\@fc@ord{:e}%
    \else
      \@FCmodulo{\@ordinalctr}{10}%
      \ifcase\@ordinalctr
        \def\@fc@ord{:e}%      case 0
        \or \def\@fc@ord{:a}%  case 1
        \or \def\@fc@ord{:a}%  case 2
      \else
        \def\@fc@ord{:e}%      default case
      \fi
    \fi
  \fi
  \edef#2{\number#1\relax\noexpand\@fc@ord}% The ordinal suffix is never raised in Swedish
}%
\global\let\@ordinalFswedish\@ordinalFswedish
\global\let\@ordinalNswedish\@ordinalFswedish

% \numberstring
\newcommand*\@@unitstringMswedish[1]{%
  \ifcase#1%
    noll%
    \or en%
    \or två%
    \or tre%
    \or fyra%
    \or fem%
    \or sex%
    \or sju%
    \or åtta%
    \or nio%
  \fi
}%
\global\let\@@unitstringMswedish\@@unitstringMswedish
\global\let\@@unitstringFswedish\@@unitstringMswedish
\newcommand*\@@unitstringNswedish[1]{%
  \ifcase#1%
    noll%
    \or ett%
    \or två%
    \or tre%
    \or fyra%
    \or fem%
    \or sex%
    \or sju%
    \or åtta%
    \or nio%
  \fi
}%
\global\let\@@unitstringNswedish\@@unitstringNswedish
\newcommand*\@@tenstringswedish[1]{%
  \ifcase#1%
    \or tio%
    \or tjugo%
    \or trettio%
    \or fyrtio%
    \or femtio%
    \or sextio%
    \or sjuttio%
    \or åttio%
    \or nittio%
    \or etthundra%
  \fi
}%
\global\let\@@tenstringswedish\@@tenstringswedish
\newcommand*\@@teenstringswedish[1]{%
  \ifcase#1%
    tio%
    \or elva%
    \or tolv%
    \or tretton%
    \or fjorton%
    \or femton%
    \or sexton%
    \or sjutton%
    \or arton%
    \or nitton%
  \fi
}%
\global\let\@@teenstringswedish\@@teenstringswedish

\newcommand*\@@numberunderhundredswedish[2]{%
  \ifnum#1>99\relax
    \PackageError{fmtcount}{Out of range}%
    {This submacro should only deal with values less than 100}%
  \fi
  \ifnum#1<10\relax
    \eappto#2{\@unitstring{#1}}%
  \else
    \ifnum#1<20\relax
      \@tmpstrctr=#1\relax
      \@FCmodulo{\@tmpstrctr}{10}%
      \eappto#2{\@teenstring{\@tmpstrctr}}%
    \else
      % tens
      \@tmpstrctr=#1\relax
      \divide\@tmpstrctr by 10\relax
      \eappto#2{\@tenstring{\@tmpstrctr}}%
      % singles
      \@tmpstrctr=#1\relax
      \@FCmodulo{\@tmpstrctr}{10}%
      \ifnum\@tmpstrctr>0\relax
        \eappto#2{\@unitstring{\@tmpstrctr}}%
      \fi
    \fi
  \fi
}%
\global\let\@@numberunderhundredswedish\@@numberunderhundredswedish

\newcommand*\@@numberstringswedish[2]{%
  \ifnum#1>99999\relax
    \PackageError{fmtcount}{Out of range}%
    {This macro only works for values less than 100000}%
  \fi
  \ifnum#1<0\relax
    \PackageError{fmtcount}{Negative numbers not permitted}%
    {This macro does not work for negative numbers, however
    you can try typing "minus" first, and then pass the modulus of
    this number}%
  \fi
  % Incorporate language options
  \ifthenelse{\equal{\fc@swedishoptions@one}{neither}}{%
    \def\fc@swedishoptions@one@hundred{hundra}%
    \def\fc@swedishoptions@one@thousand{tusen}%
  }{%
    \ifthenelse{\equal{\fc@swedishoptions@one}{hundred}}{%
      \def\fc@swedishoptions@one@hundred{etthundra}%
      \def\fc@swedishoptions@one@thousand{tusen}%
    }{%
      \ifthenelse{\equal{\fc@swedishoptions@one}{thousand}}{%
        \def\fc@swedishoptions@one@hundred{hundra}%
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}%
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}%
        }%
      }{%both
        \def\fc@swedishoptions@one@hundred{etthundra}%
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}%
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}%
        }%
      }%
    }%
  }%
  % Initialize
  \def#2{}%
  % Thousands
  \@strctr=#1\relax
  \divide\@strctr by 1000\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \eappto#2{\fc@swedishoptions@one@thousand}%
    \else
      \let\@tmpunitstring\@unitstring% Temporary store gendered unit string
      \let\@unitstring\@@unitstringMswedish% Thousands above 1 are given in "masculine" units (21,000 is "tjugoentusen" and not "tjugoettusen")
      \@@numberunderhundredswedish{\@strctr}{#2}%
      \let\@unitstring\@tmpunitstring% Restore gendered unit string
      \eappto#2{\fc@swedishoptions@thousands@before}%
      \appto#2{tusen}%
    \fi
    \@strctr=#1\relax
    \@FCmodulo{\@strctr}{1000}%
    \ifnum\@strctr>0\relax
      \eappto#2{\fc@swedishoptions@thousands@after}%
    \fi
  \fi
  % Hundreds
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{1000}%
  \divide\@strctr by 100\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \eappto#2{\fc@swedishoptions@one@hundred}%
    \else
      \eappto#2{\@unitstring{\@strctr}}%
      \appto#2{hundra}%
    \fi
  \fi
  % Tens and singles
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{100}%
  \ifnum\@strctr>0\relax% Trailing zeros are silent
    \@@numberunderhundredswedish{\@strctr}{#2}%
  \else
    \ifnum#1=0\relax% Unless the number is in fact 0
      \eappto#2{\@unitstring{\@strctr}}%
    \fi
  \fi
}%
\global\let\@@numberstringswedish\@@numberstringswedish

\newcommand*{\@numberstringMswedish}[2]{%
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@numberstringswedish{#1}{#2}%
}%
\global\let\@numberstringMswedish\@numberstringMswedish
\global\let\@numberstringFswedish\@numberstringMswedish
\newcommand*{\@numberstringNswedish}[2]{%
  \let\@unitstring\@@unitstringNswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@numberstringswedish{#1}{#2}%
}%

\newcommand*{\@NumberstringMswedish}[2]{%
  \@numberstringMswedish{#1}{\@@num@str}%
  \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@NumberstringMswedish\@NumberstringMswedish
\global\let\@NumberstringFswedish\@NumberstringMswedish
\newcommand*{\@NumberstringNswedish}[2]{%
  \@numberstringNswedish{#1}{\@@num@str}%
  \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@NumberstringNswedish\@NumberstringNswedish

% ordinalstring
\newcommand*\@@unitthstringMswedish[1]{%
  \ifcase#1%
    nollte%
    \or förste%
    \or andre%
    \or tredje%
    \or fjärde%
    \or femte%
    \or sjätte%
    \or sjunde%
    \or åttonde%
    \or nionde%
  \fi
}%
\global\let\@@unitthstringMswedish\@@unitthstringMswedish
\newcommand*\@@unitthstringFswedish[1]{%
  \ifcase#1%
    nollte%
    \or första%
    \or andra%
    \or tredje%
    \or fjärde%
    \or femte%
    \or sjätte%
    \or sjunde%
    \or åttonde%
    \or nionde%
  \fi
}%
\global\let\@@unitthstringFswedish\@@unitthstringFswedish
\global\let\@@unitthstringNswedish\@@unitthstringFswedish
\newcommand*\@@tenthstringswedish[1]{%
  \ifcase#1%
    \or tionde%
    \or tjugonde%
    \or trettionde%
    \or fyrtionde%
    \or femtionde%
    \or sextionde%
    \or sjuttionde%
    \or åttionde%
    \or nittionde%
  \fi
}%
\global\let\@@tenthstringswedish\@@tenthstringswedish
\newcommand*\@@teenthstringswedish[1]{%
  \ifcase#1%
    tionde%
    \or elfte%
    \or tolfte%
    \or trettonde%
    \or fjortonde%
    \or femtonde%
    \or sextonde%
    \or sjuttonde%
    \or artonde%
    \or nittonde%
  \fi
}%
\global\let\@@teenthstringswedish\@@teenthstringswedish

\newcommand*\@@numberunderhundredthswedish[2]{%
  \ifnum#1<10\relax
    \eappto#2{\@unitthstring{#1}}%
  \else
    \@tmpstrctr=#1\relax
    \@FCmodulo{\@tmpstrctr}{10}%
    \ifnum#1<20\relax
      \eappto#2{\@teenthstring{\@tmpstrctr}}%
    \else
      \ifnum\@tmpstrctr=0\relax
        \@tmpstrctr=#1\relax
        \divide\@tmpstrctr by 10\relax
        \eappto#2{\@tenthstring{\@tmpstrctr}}%
      \else
        \@tmpstrctr=#1\relax
        \divide\@tmpstrctr by 10\relax
        \eappto#2{\@tenstring{\@tmpstrctr}}%
        \@tmpstrctr=#1\relax
        \@FCmodulo{\@tmpstrctr}{10}%
        \eappto#2{\@unitthstring{\@tmpstrctr}}%
      \fi
    \fi
  \fi
}%
\global\let\@@numberunderhundredthswedish\@@numberunderhundredthswedish

\newcommand*\@@ordinalstringswedish[2]{%
  \ifnum\@orgargctr>99999\relax
    \PackageError{fmtcount}{Out of range}%
    {This macro only works for values less than 100000}%
  \fi
  \ifnum\@orgargctr<0\relax
    \PackageError{fmtcount}{Negative numbers not permitted}%
    {This macro does not work for negative numbers, however
    you can try typing "minus" first, and then pass the modulus of
    this number}%
  \fi
  % Incorporate language options
  \ifthenelse{\equal{\fc@swedishoptions@one}{neither}}{%
    \def\fc@swedishoptions@one@hundred{hundra}%
    \def\fc@swedishoptions@one@hundredth{hundrade}%
    \def\fc@swedishoptions@one@thousand{tusen}%
    \def\fc@swedishoptions@one@thousandth{tusende}%
  }{%
    \ifthenelse{\equal{\fc@swedishoptions@one}{hundred}}{%
      \def\fc@swedishoptions@one@hundred{etthundra}%
      \def\fc@swedishoptions@one@hundredth{etthundrade}%
      \def\fc@swedishoptions@one@thousand{tusen}%
      \def\fc@swedishoptions@one@thousandth{tusende}%
    }{%
      \ifthenelse{\equal{\fc@swedishoptions@one}{thousand}}{%
        \def\fc@swedishoptions@one@hundred{hundra}%
        \def\fc@swedishoptions@one@hundredth{hundrade}%
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}%
          \def\fc@swedishoptions@one@thousandth{ett tusende}%
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}%
          \def\fc@swedishoptions@one@thousandth{ettusende}%
        }%
      }{%both
        \def\fc@swedishoptions@one@hundred{etthundra}%
        \def\fc@swedishoptions@one@hundredth{etthundrade}%
        \ifthenelse{\equal{\fc@swedishoptions@thousands@before}{\space}}{%
          \def\fc@swedishoptions@one@thousand{ett tusen}%
          \def\fc@swedishoptions@one@thousandth{ett tusende}%
        }{%
          \def\fc@swedishoptions@one@thousand{ettusen}%
          \def\fc@swedishoptions@one@thousandth{ettusende}%
        }%
      }%
    }%
  }%
  % Initialize
  \def#2{}%
  % Thousands
  \@strctr=#1\relax
  \divide\@strctr by 1000\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{1000}%
      \ifnum\@strctr>0\relax
        \eappto#2{\fc@swedishoptions@one@thousand}%
        \eappto#2{\fc@swedishoptions@thousands@after}%
      \else
        \eappto#2{\fc@swedishoptions@one@thousandth}%
      \fi
    \else
      \let\@tmpunitstring\@unitstring% Temporary store gendered unit string
      \let\@unitstring\@@unitstringMswedish% Thousands above 1 are given in "masculine" units (21,000 is "tjugoentusen" and not "tjugoettusen")
      \@@numberunderhundredswedish{\@strctr}{#2}%
      \let\@unitstring\@tmpunitstring% Restore gendered unit string
      \eappto#2{\fc@swedishoptions@thousands@before}%
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{1000}%
      \ifnum\@strctr>0\relax
        \appto#2{tusen}%
        \eappto#2{\fc@swedishoptions@thousands@after}%
      \else
        \appto#2{tusende}%
      \fi
    \fi
  \fi
  % Hundreds
  \@strctr=#1
  \@FCmodulo{\@strctr}{1000}%
  \divide\@strctr by 100\relax
  \ifnum\@strctr>0\relax
    \ifnum\@strctr=1\relax
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{100}%
      \ifnum\@strctr>0\relax
        \eappto#2{\fc@swedishoptions@one@hundred}%
      \else
        \eappto#2{\fc@swedishoptions@one@hundredth}%
      \fi
    \else
      \eappto#2{\@unitstring{\@strctr}}% Hundreds are given in "neutrum" units
      \@strctr=#1\relax
      \@FCmodulo{\@strctr}{100}%
      \ifnum\@strctr>0\relax
        \appto#2{hundra}%
      \else
        \appto#2{hundrade}%
      \fi
    \fi
  \fi
  % Tens and singles
  \@strctr=#1\relax
  \@FCmodulo{\@strctr}{100}%
  \ifnum\@strctr>0\relax% Trailing zeros are silent
    \@@numberunderhundredthswedish{\@strctr}{#2}%
  \else
    \ifnum#1=0\relax% Unless the number is in fact 0
      \eappto#2{\@unitthstring{\@strctr}}%
    \fi
  \fi
}%
\global\let\@@ordinalstringswedish\@@ordinalstringswedish

\newcommand*{\@ordinalstringMswedish}[2]{%
  \let\@unitthstring\@@unitthstringMswedish
  \let\@teenthstring\@@teenthstringswedish
  \let\@tenthstring\@@tenthstringswedish
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@ordinalstringswedish{#1}{#2}%
}%
\global\let\@ordinalstringMswedish\@ordinalstringMswedish
\newcommand*{\@ordinalstringFswedish}[2]{%
  \let\@unitthstring\@@unitthstringFswedish
  \let\@teenthstring\@@teenthstringswedish
  \let\@tenthstring\@@tenthstringswedish
  \let\@unitstring\@@unitstringMswedish
  \let\@teenstring\@@teenstringswedish
  \let\@tenstring\@@tenstringswedish
  \@@ordinalstringswedish{#1}{#2}%
}%
\global\let\@ordinalstringFswedish\@ordinalstringFswedish
\global\let\@ordinalstringNswedish\@ordinalstringFswedish

\newcommand*{\@OrdinalstringMswedish}[2]{%
 \@ordinalstringMswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringMswedish\@OrdinalstringMswedish
\newcommand*{\@OrdinalstringFswedish}[2]{%
 \@ordinalstringFswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringFswedish\@OrdinalstringFswedish
\newcommand*{\@OrdinalstringNswedish}[2]{%
 \@ordinalstringNswedish{#1}{\@@num@str}%
 \edef#2{\MakeTitlecase{\@@num@str}}%
}%
\global\let\@OrdinalstringNswedish\@OrdinalstringNswedish

% SET DEFAULTS (begin)
% This section (together with LANGUAGE OPTIONS section at the top) must be commented out if the setup for Swedish language options is not done in `fmtcount.sty` or the .tex document
\newcommand*\fc@swedishoptions@setdefaults{%
  \fc@gl@let\fc@swedishoptions@thousands@after\@empty%
  \fc@gl@let\fc@swedishoptions@thousands@before\@empty%
  \fc@gl@def\fc@swedishoptions@one{neither}%
}%
\global\let\fc@swedishoptions@setdefaults\fc@swedishoptions@setdefaults
{%
  \let\fc@gl@def\gdef
  \def\fc@gl@let{\global\let}%
  \fc@swedishoptions@setdefaults
}%
% SET DEFAULTS (end)

\iffalse Local variables: \fi
\iffalse mode: docTeX     \fi
\iffalse End:             \fi
\endinput

相关内容