3

I have tried a lot to use the \numberstringnum and \numberstring macros but it appears incomplete or even do not appear on the text.

So I tested in the female version, like below:

\numberstringnum{\stotal{croquis}}[f]

and it's ok, but if I delete [f] or try another gender [m], or [n] the error persists.

How can I use this function in lowercase??

The function \Numberstringnum or \Numberstring works great, but I cannot transform it to lowercase like \lowercase\Numberstringnum f.

How can I make it?

Here is my code:

\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}

And the anwer:

Uma Uma Duas Três Quatro
uma uma duas três quatro
Um Um Dois Três Quatro

The error:

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.

I think the problem is about the language - portuguese, I tested english and french and it's ok, but portugueses I get this error for lowercase, and \lowercase{\Numberstring{}} have no effect.

  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 May 3 '14 at 4:31
  • A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Or you highlight it and press CTRL-K. – user31729 May 3 '14 at 4:32
  • Where is \stotal defined? Is it a counter value or the counter itself? – user31729 May 3 '14 at 4:38
  • \documentclass[a4paper,12pt]{article} – Sara Rodriguez May 3 '14 at 4:58
  • 1
    That is not a minimally working example. – user31729 May 3 '14 at 5:18
5

Using the commands from \fmtcount package it is important to set the language and using either the counter name or the counter value!

Generally, all commands ending with ...num expect a counter value, where as the similar commands without suffix num expect the counter name.

If \stotal delivers in fact a counter name, then the \numstring{ versions has to be used, if it yields the counter value, the \numstringnum way has to be walked.

The small example code shows the output for english and french language in tables, using several variants and gender specifications as well as a small overview for the case [m] (or basically none) is specified.

The manual states, that \FCloadlang should be used in the preamble, but it seems to work afterwards too.

\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}

enter image description here enter image description here

If there is no neutral gender in the corresponding language, fmtcount uses the corresponding word from another language in the babel setting or (probably) english. (see output in the French table)

Edit There seems to be a problem with fmtcount support for Portuguese language.

2

This is a bug in fmtcount. It will be fixed in the next version (2.04) but the following is an interim solution:

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.