我已尝试多次使用\numberstringnum
和\numberstring
宏,但它似乎不完整,甚至没有出现在文本上。
因此我测试了女性版本,如下所示:
\numberstringnum{\stotal{croquis}}[f]
并且没问题,但如果我删除 [f] 或尝试其他性别 [m] 或 [n],错误仍然存在。
我怎样才能以小写形式使用此功能?
函数\Numberstringnum
或\Numberstring
工作得很好,但我无法将它转换成小写\lowercase\Numberstringnum f
。
我怎样才能做到?
这是我的代码:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}
\begin{document}
\Numberstring{page}[f]
\Numberstringnum{1}[f]
\Numberstringnum{2}[f]
\Numberstringnum{3}[f]
\Numberstringnum{4}[f]
\numberstring{page}[f]
\numberstringnum{1}[f]
\numberstringnum{2}[f]
\numberstringnum{3}[f]
\numberstringnum{4}[f]
\Numberstring{page}[m]
\Numberstringnum{1}[m]
\Numberstringnum{2}[m]
\Numberstringnum{3}[m]
\Numberstringnum{4}[m]
\numberstring{page}[m]
\numberstringnum{1}[m]
\numberstringnum{2}[m]
\numberstringnum{3}[m]
\numberstringnum{4}[m]
\end{document}
答案是:
Uma Uma Duas Três Quatro
uma uma duas três quatro
Um Um Dois Três Quatro
错误:
Error in main.tex (line 30): Argument of \@unitstring has an extra }.
<inserted text>
\par
l.30 \numberstring{page}[m]
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
我认为问题出在语言上 - 葡萄牙语,我测试了英语和法语并且没问题,但葡萄牙语的小写字母会出现这个错误,并且 \lowercase{\Numberstring{}} 没有效果。
答案1
使用包中的命令,\fmtcount
设置语言和使用计数器很重要姓名或柜台价值!
一般来说,所有以 结尾的命令都...num
需要一个计数器值,而没有后缀的类似命令则num
需要计数器名称。
如果\stotal
实际上传递了一个计数器名称,那么\numstring{
就必须使用版本,如果它产生计数器值,就\numstringnum
必须遵循该方式。
小示例代码在表格中显示了英语和法语的输出,使用几种变体和性别规范以及[m]
指定情况的小概述(或基本上没有)。
手册指出,\FCloadlang
应该在序言中使用它,但它似乎在之后也能起作用。
\documentclass{book}
\usepackage{xcolor}
\usepackage[french,english]{babel}
\usepackage{fmtcount}
\newcounter{DemoCounter}
\setcounter{DemoCounter}{3}
\newcommand{\CounterOutput}[3][]{
\footnotesize
\textcolor{blue}{#2{#3}[#1]}%
}%
\newcommand{\tableline}[4]{%
\tt{$\backslash$#1} & #3 & #4 & \CounterOutput[f]{\csname #1\endcsname}{#2} & \CounterOutput[m]{\csname #1\endcsname}{#2} & \CounterOutput[n]{\csname #1\endcsname}{#2} \tabularnewline
}%
\begin{document}
\selectlanguage{english}
\FCloadlang{english}
\small
\begin{tabular}{llllll}
\multicolumn{6}{c}{\scshape English}\tabularnewline
& Input & Value & \multicolumn{3}{c}{Gender} \tabularnewline
Macro & & & \multicolumn{1}{c}{f} & \multicolumn{1}{c}{m} & \multicolumn{1}{c}{n} \tabularnewline
\hline
\tableline{numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{Numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{NUMBERstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{Numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{NUMBERstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
& && & \setcounter{DemoCounter}{17} \tabularnewline
\tableline{numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{Numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{NUMBERstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{Numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{NUMBERstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\end{tabular}
\setcounter{DemoCounter}{5}
\begin{itemize}
\item Using the counter \textbf{\textcolor{blue}{name}} DemoCounter:
\begin{enumerate}
\item \begin{verbatim}\numberstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\numberstring{DemoCounter}}
\item \begin{verbatim}\Numberstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\Numberstring{DemoCounter}}
\item \begin{verbatim}\NUMBERstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\NUMBERstring{DemoCounter}}
\end{enumerate}
\item Using the counter \textbf{\textcolor{blue}{value}} of DemoCounter:
\begin{enumerate}
\item \begin{verbatim}\numberstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\numberstringnum{\number\value{DemoCounter}}}
\item \begin{verbatim}\Numberstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\Numberstringnum{\number\value{DemoCounter}}}
\item \begin{verbatim}\NUMBERstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\NUMBERstringnum{\number\value{DemoCounter}}}
\end{enumerate}
\end{itemize}
\newpage%
%%%% Now french
\selectlanguage{french}
\FCloadlang{french}
\small
\begin{tabular}{llllll}
\multicolumn{6}{c}{\scshape French}\tabularnewline
& Input & Value & \multicolumn{3}{c}{Gender} \tabularnewline
Macro & & & \multicolumn{1}{c}{f} & \multicolumn{1}{c}{m} & \multicolumn{1}{c}{n} \tabularnewline
\hline
\tableline{numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{Numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{NUMBERstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{Numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{NUMBERstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
& && & \setcounter{DemoCounter}{17} \tabularnewline
\tableline{numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{Numberstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{NUMBERstring}{DemoCounter}{Counter Name}{\number\value{DemoCounter}}%
\tableline{numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{Numberstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\tableline{NUMBERstringnum}{\number\value{DemoCounter}}{Counter Value}{\number\value{DemoCounter}}%
\end{tabular}
\setcounter{DemoCounter}{5}
\begin{itemize}
\item Using the counter \textbf{\textcolor{blue}{name}} DemoCounter:
\begin{enumerate}
\item \begin{verbatim}\numberstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\numberstring{DemoCounter}}
\item \begin{verbatim}\Numberstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\Numberstring{DemoCounter}}
\item \begin{verbatim}\NUMBERstring{DemoCounter}\end{verbatim} yields \textcolor{red}{\NUMBERstring{DemoCounter}}
\end{enumerate}
\item Using the counter \textbf{\textcolor{blue}{value}} of DemoCounter:
\begin{enumerate}
\item \begin{verbatim}\numberstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\numberstringnum{\number\value{DemoCounter}}}
\item \begin{verbatim}\Numberstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\Numberstringnum{\number\value{DemoCounter}}}
\item \begin{verbatim}\NUMBERstringnum{\number\value{DemoCounter}}\end{verbatim} yields \textcolor{red}{\NUMBERstringnum{\number\value{DemoCounter}}}
\end{enumerate}
\end{itemize}
\end{document}
如果相应语言中没有中性,则fmtcount
使用设置中另一种语言的相应词语babel
或(可能)english
。(见法国表格中的产量)
编辑fmtcount
对葡萄牙语的支持 似乎存在问题。
答案2
这是 中的一个错误fmtcount
。它将在下一版本(2.04)中修复,但以下是一个临时解决方案:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[portuges]{babel}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}
\makeatletter
\renewcommand*\@@unitstringportuges[1]{%
\ifcase#1\relax
zero%
\or um%
\or dois%
\or tr\^es%
\or quatro%
\or cinco%
\or seis%
\or sete%
\or oito%
\or nove%
\fi
}%
\makeatother
\begin{document}
\Numberstring{page}[f]
\Numberstringnum{1}[f]
\Numberstringnum{2}[f]
\Numberstringnum{3}[f]
\Numberstringnum{4}[f]
\numberstring{page}[f]
\numberstringnum{1}[f]
\numberstringnum{2}[f]
\numberstringnum{3}[f]
\numberstringnum{4}[f]
\Numberstring{page}[m]
\Numberstringnum{1}[m]
\Numberstringnum{2}[m]
\Numberstringnum{3}[m]
\Numberstringnum{4}[m]
\numberstring{page}[m]
\numberstringnum{1}[m]
\numberstringnum{2}[m]
\numberstringnum{3}[m]
\numberstringnum{4}[m]
\end{document}