2

I know that \newcounter{newctr}[oldctr] will reset newctr to 0 whenever oldctr is incremented. How can I have newctr to have exactly the same value as oldctr at all times?

In other words, how can I specify newctr to be not reset but incremented whenever oldctr is incremented?

You may wonder why I need to counters with exactly the same value at all times. It is because I have defined \subsubsection to have italic title but straight number:

\renewcommand\thesubsubsection
            {\textup{\thesubsection.\arabic{subsubsection}}}

But then, when I define a \newtheorem{foo}[subsubsection]{Something} then the number of the foo statement is typeset straight (although I want it to be italic) simply because \thesubsubsection contains the \textup command. So I thought that if I have another counter subsubsectionitalics with the same value as subsubsection but with a different \thesubsubsectionitalics then my problem is solved, I just need to define the foo statement as \newtheorem{foo}[subsubsectionitalics]{Something}.

I tried to define a new counter subsubsectionitalics with the following \thesubsubsectionitalics:

\newcounter{subsubsectionitalics}[subsection]
\renewcommand\thesubsubsectionitalics
            {\thesubsection.\arabic{subsubsection}}

but it doesn't work: although in the \thesubsubsectionitalics command definition I do not use the value of the subsubsectionitalics counter, I get a zero value nevertheless. (Why?)

  • 1
    You're approaching the problem from the wrong side. In general, \the<counter> should not contain typesetting instructions. Can you please add a minimal document showing the problem? – egreg Nov 30 '15 at 13:17
  • If I use \def\subsubsection{\@startsection{subsubsection}{3}% \z@{.4\linespacing}{-.5ex}% {\normalfont\itshape}} how can I get the number of the subsubsection in straight and its title in italics, without fiddling with \thesubsubsection? – yannis Nov 30 '15 at 13:34
  • That's not adding a minimal document. You marked as correct David's answer, but I still think there are much better ways to do what you seem to want and that don't involve abusing the system. – egreg Nov 30 '15 at 13:55
  • I agree with @egreg (and I don't say that very often:-) – David Carlisle Nov 30 '15 at 14:18
  • \documentclass{article} \catcode`\@=11 \renewcommand\thesubsubsection {\textup{\thesubsection.\arabic{subsubsection}}} \def\subsubsection{\@startsection{subsubsection}{3}% \z@{.4em}{-.5ex}% {\normalfont\itshape}} \begin{document} \subsubsection{This is a title in italics.} Bla bla. \end{document} This is a minimal document. Could you please show me how to obtain the subsubsection number 0.0.1 in roman while the title of the subsection is in italic, without placing \textup into \thesubsubsection? – yannis Nov 30 '15 at 18:24
3

It's an abuse of the system really, it would be better just to have \thesubsection be the number and leave the font changing to your section layout.

but if you go

\makeatletter
\let\c@foo\c@subsection
\newcommand\thefoo{\arabic{foo}}

then \thesubsection and \thefoo can be separately specified and incrementing either foo or subsection increments both.

  • IIRC the aliascnt package by Heiko has an interface for this – clemens Nov 30 '15 at 13:48

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.