sectioning – Using Oldstyle Numbers in Body and Newstyle Numbers in Section Headings

oldstylenumssectioning

I'm using the eco package to get oldstyle numbers in my manuscript, but I'm trying to get the section numbers (in the mainmatter and the table of contents as well) to be "newstyle numbers" (ie. lining figures) and having a tough time with it.

Can anyone shed some light on the matter please?

PS: It would be nice to get lining figures in the table and figure numbers as well.

Edit: posting a mwe below (regarding doncherry's suggestion).

\documentclass{book}

\usepackage{eco}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\renewcommand{\thechapter}{{\fontfamily{cmr}\selectfont\arabic{chapter}}}
\renewcommand{\thesection}{{\fontfamily{cmr}\selectfont\arabic{section}}}
\renewcommand{\thesubsection}{{\fontfamily{cmr}\selectfont\arabic{subsection}}}
\renewcommand{\thesubsubsection}{{\fontfamily{cmr}\selectfont\arabic{subsubsection}}}
\renewcommand{\theparagraph}{{\fontfamily{cmr}\selectfont\arabic{paragraph}}}
\renewcommand{\thesubparagraph}{{\fontfamily{cmr}\selectfont\arabic{subparagraph}}}
\renewcommand{\thefigure}{{\fontfamily{cmr}\selectfont\arabic{figure}}}
\renewcommand{\thetable}{{\fontfamily{cmr}\selectfont\arabic{table}}}

\begin{document}

  \tableofcontents{}

  \part{One}
    \chapter{One--One}
      \section{One--One--One}
        \subsection{One--One--One--One}
          \subsubsection{One--One--One--One--One}
            \paragraph{One--One--One--One--One--One}
              \subparagraph{One--One--One--One--One--One--One}
              \subparagraph{One--One--One--One--One--One--Two}
              \subparagraph{One--One--One--One--One--One--Three}
            \paragraph{One--One--One--One--One--Two}
              \subparagraph{One--One--One--One--One--Two--One}
              \subparagraph{One--One--One--One--One--Two--Two}
              \subparagraph{One--One--One--One--One--Two--Three}

\end{document}

Output

Best Answer

Change the font back to Computer Modern (cmr) for the relevant counters, similarly as eco's \newstylenumbers{} does:

\documentclass{article}

\usepackage{eco}
\usepackage[T1]{fontenc}

\renewcommand{\thesection}{\fontfamily{cmr}\selectfont\arabic{section}}

\renewcommand{\thefigure}{{\fontfamily{cmr}\selectfont\arabic{figure}}}

\renewcommand{\thetable}{{\fontfamily{cmr}\selectfont\arabic{table}}}

\begin{document}

% setting the counters to higher values just to see some more digits
\setcounter{page}{123}
\setcounter{figure}{455}
\setcounter{table}{788}

\tableofcontents

\listoffigures

\listoftables

\section{Section 9876543210}

\begin{figure}[bh]
123456789
\caption{123456789}
\end{figure}

\subsection{Subsection 9876543210}

\begin{table}[bh]
123456789
\caption{123456789}
\end{table}

\subsubsection{Subsubsection 9876543210}
\end{document}

The page numbers are still in old style figures, I couldn't change them, you didn't ask for that either. Numbers within section (etc.) titles and captions are still in osf as well.


Edit:

There's no need to redefine more than the highest level you're using, the changed font will be used throughout the sectionlevel number, you just need to get rid of the extra { and }, which form a group, limiting the scope of the changed font. Also, notice how they're all just a single number in your example, but should be like "1.1.1.1.1.1"? Just get rid of all redefinitions except chapter (and table and figure of course). Furthermore, the page numbers won't get pushed to the side if you put in an actual title and not an unknown and awkwardly long word like "One-One-One-One-One-One-One". Replacing the dashes -- with spaces is sufficient:

\documentclass{book}

\usepackage{eco}

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\renewcommand{\thechapter}{\fontfamily{cmr}\selectfont\arabic{chapter}}
%\renewcommand{\thesection}{{\fontfamily{cmr}\selectfont\arabic{section}}}
%\renewcommand{\thesubsection}{{\fontfamily{cmr}\selectfont\arabic{subsection}}}
%\renewcommand{\thesubsubsection}{{\fontfamily{cmr}\selectfont\arabic{subsubsection}}}
%\renewcommand{\theparagraph}{{\fontfamily{cmr}\selectfont\arabic{paragraph}}}
%\renewcommand{\thesubparagraph}{{\fontfamily{cmr}\selectfont\arabic{subparagraph}}}

\renewcommand{\thefigure}{{\fontfamily{cmr}\selectfont\arabic{figure}}}
\renewcommand{\thetable}{{\fontfamily{cmr}\selectfont\arabic{table}}}

\begin{document}

  \tableofcontents{}

  \part{One}
    \chapter{One One}
      \section{One One One}
        \subsection{One One One One}
          \subsubsection{One One One One One}
            \paragraph{One One One One One One}
              \subparagraph{One One One One One One One}
              \subparagraph{One One One One One One Two}
              \subparagraph{One One One One One One Three}
            \paragraph{One One One One One Two}
              \subparagraph{One One One One One Two One}
              \subparagraph{One One One One One Two Two}
              \subparagraph{One One One One One Two Three}

\end{document}

If the titles get longer than that, they'll be broken into several lines, but you might want to consider using a short title for the ToC then, using \section[short title for ToC and header]{long title for the place in the paper where it actually appears}.