1

Thanks to this macro

\makeatletter
\let\old@makechapterhead\@makechapterhead
\def\@makechapterhead{\def\thechapter{\words{chapter}}\old@makechapterhead}
\makeatother


\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
one\or
two\or
three\or
four\or
five\else
I need more words\fi}

which comes from this question "Literal" numbering of chapters

All feel well, and I obtain what I want in the first page of each chapter, "Chapter one", "Chapter two",...etc but in the table of contents, it uses the same numerotation of the chapters, so litteral, that I don't want, evidently. So how can I use the usual numbering (\arabic{chapter}) for the contents ?

1 Answers1

0

It is best to use the package fmtcount to get the spelled out value of a counter. In this case you will need to use the tocstyle package to adjust the margins in the table of contents.

If you want to use this for chapters, just replace every occurrence of section by chapter.

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{fmtcount,tocstyle}
\renewcommand\thesection{\Numberstring{section}}
\begin{document}
\tableofcontents
\section{First section}
\section{Second section}
\subsection{A subsection}
\section{Third section}
\end{document}

enter image description here

Henri Menke
  • 109,596
  • Hello, I use the package titlesec and the solution you propose produces a conflict with this package. – Faouzi Bellalouna May 08 '14 at 13:16
  • I don't get any conflicts, when I just \usepackage{titlesec}. Can you elaborate? – Henri Menke May 08 '14 at 13:53
  • I give an example of file – Faouzi Bellalouna May 08 '14 at 19:19
  • \documentclass[14pt,a4paper]{extbook}

    \usepackage{titlesec} \usepackage{titletoc} \usepackage{etoolbox} \usepackage{multicol} \usepackage{amsmath,amssymb} \usepackage[most]{tcolorbox} \usepackage{boxedminipage} \usepackage{slashbox} \usepackage{titlesec} \usepackage{enumitem} \usepackage{minitoc} \usepackage{rotating} \usepackage{fmultico} \setlength{\columnseprule}{0.1pt} \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{pdflscape} \usepackage{array}

    – Faouzi Bellalouna May 08 '14 at 19:28
  • \usepackage{polyglossia} \setmainlanguage[numerals=maghrib]{arabic} \setotherlanguage{english}

    \newfontfamily\arabicfont[Script=Arabic, AutoFakeSlant=-0.02]{Traditional Arabic} \setsansfont[Script=Arabic,Scale=1.5]{Traditional Arabic}

    \usepackage{MyBoxes} \usepackage{MyRoss}

    \gappto\captionsarabic{\renewcommand{\chaptername}{الباب}} % probably can use titlesec's \titleformat but I don't know that package:-}

    \makeatletter \let\old@makechapterhead@makechapterhead \def@makechapterhead{\def\thechapter{\words{chapter}}\old@makechapterhead} \makeatother

    – Faouzi Bellalouna May 08 '14 at 19:29
  • \newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname} \def\xwords#1{\ifcase#1\or الأول\or
    الثاني\or
    الثالث\or
    الرابع\or
    الخامس\or
    السادس\or
    السابع\or
    الثامن\or
    التاسع\or
    العاشر\or
    \else I need more words\fi}

    \begin{document} \tableofcontents \chapter{المحاكاة} \section{مقدمة} %sec10.1

    كيف يمكننا إيجاد احتمال الفوز في لعبة
    السوليتير؟
    \chapter{المحاكاة} كيف يمكننا إيجاد احتمال الفوز في لعبة من الباب
    \end{document}

    – Faouzi Bellalouna May 08 '14 at 19:30
  • This is an example of my file. It gives me chapters "one" and "two" in the first pages of chapters, and in the contents "1" and "two". I want to obtain the same thing in the text but, in the contents, "1" and "two" – Faouzi Bellalouna May 08 '14 at 19:41
  • After removing all the packages unnecessary to the problem (BTW: you were loading titlesec twice) and using an arabic font I have installed it compiles for me without any problem. The other problem is, that I can't read arabic and therefore can't tell if there is a problem with the output. – Henri Menke May 08 '14 at 19:48
  • It's not a problem of arabic... I give you another example without arabic.. I want that the numbering is "literal", i.e. "one" "two" etc.. but for the chapterhead I want it numeric... 1.1 for the section 1 not one.1 like in the contents... – Faouzi Bellalouna May 08 '14 at 20:19
  • \documentclass[14pt,a4paper]{extbook}

    \usepackage{titletoc} \usepackage{etoolbox} \usepackage{multicol} \usepackage{amsmath,amssymb} \usepackage[most]{tcolorbox} \usepackage{boxedminipage} \usepackage{slashbox} \usepackage{titlesec} \usepackage{enumitem} \usepackage{minitoc} \usepackage{rotating} \usepackage{fmultico} \setlength{\columnseprule}{0.1pt} \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{pdflscape} \usepackage{array}

    \usepackage{polyglossia} \setmainlanguage{english} \setotherlanguage[numerals=maghrib]{arabic}

    – Faouzi Bellalouna May 08 '14 at 20:19
  • \makeatletter \let\old@makechapterhead@makechapterhead \def@makechapterhead{\def\thechapter{\words{chapter}}\old@makechapterhead} \makeatother

    \newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname} \def\xwords#1{\ifcase#1\or one\or
    two\or
    three\or
    \else I need more words\fi}

    \begin{document} \tableofcontents \chapter{Simulation} \section{Introduction 1} Simulation \section{Introduction 2} \chapter{Simulation} Simulation \end{document}

    – Faouzi Bellalouna May 08 '14 at 20:20
  • I write all the packages for preventing eventual conflicts because I use all this packages in my book (of probability in arabic) – Faouzi Bellalouna May 08 '14 at 20:21