tags:

views:

76

answers:

4

In a certain document, I want to make the two counters "theorem" and "subsection" to be one and the same thing. Any ideas?

Edit: Since the math parts are potentially confusing, I rephrase the question as follows without any such references.

I use a certain counter "mycounter" for counting something, and this counter is predefined in a certain package. When the subsection goes up, I want "mycounter" to go up. And vice-versa. When subsection is reset, I want "mycounter" to be reset.

This is what I hope to achieve by identifying the two counters.

+1  A: 

It's not obvious, but this initially appears to be a near-duplicate of another question; but it's not quite the same problem. What you're specifically asking for could potentially be addressed in a similar hacky way, but it's not completely clear what you're asking for -- is there a more 'meta' version of your question?

Is the idea that you want to declare each theorem in a subsection of its own, and so want to refer to it by that number? In which case, ...see Theorem~\ref{sec:foo} might get you at least half-way there without any special customisation.

Norman Gray
No, no, that's not the idea. But that would achieve the look I wanted to some extent. I have given an example as a comment to the question. I hope it will make clear what I want.
George Scaria
+2  A: 

I think one way to do it would be to create a user-defined counter (say, 'mycounter') and then modify the section and theorems commands to both (1) use that counter instead of the built-ins \thesection or \thetheorem and (2) to automatically increment your shared user-defined counter each time it's used.

I believe the titlesec or secsty packages would allow you to redefine section styles to use and increment your user-defined counter. Not sure about theorems, but I assume there's some package that would let you modify those too.

This is just one approach. Not sure if there's something that would be cleaner or more straightforward. This seems a pretty clean and straightforward method to me, although I would have to review docs on how to use user-defined counters, not sure where it is on the web, I know there's plenty of info in Kopka's Guide to Latex.

EDIT: Sorry, maybe the above is way more than is needed, I don't do math with LaTeX and know nothing about Theorem command/environment. Could it be that you can define a theorem environment that automatically uses section numbering? I'm wondering that after looking at this page: http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Theorems.html

EDIT_2: After looking at Kopka's Guide, yes, it does look like you can use \newtheorem command to create a theorem environment that uses the section counter. E.g., '\newtheorem{theorem}{Theorem}[subsection]' would create new 'theorem' environment that uses the subsection counter. Not sure if it then can be interspersed with subsections and have both increment properly and reset at each new 'section', but I expect that's the idea.

Herbert Sitz
+1 for the pointer to `\newtheorem` -- it's good to be reminded to use existing functionality where possible
Norman Gray
@Normal: Hey, thanks. On the theme of not reinventing the wheel I just noticed that the exact question has been asked and answered before on SO: http://stackoverflow.com/questions/2100481/can-one-make-theorem-numbers-behave-like-subsubsection-numbers-in-latex
Herbert Sitz
+2  A: 

Herbert Sizt is almost there.

\newtheorem{theorem}{Theorem}[subsection] would number theorems within subsections (ie, the theorems within Section 1.2 would be 1.2.1, 1.2.2, etc). Instead \newtheorem{theorem}[subsection]{Theorem} appears to do what the OP requires. Section 1.5 (say) would be followed by theorem 1.6, which would be followed by section 1.7. The theorem is formatted differently from sections.

An alternative way is to do

\def\theorem#1{\begingroup
  \let\tempsubsection\thesubsection
  \def\thesubsection{Thm.~\tempsubsection}%
  \subsection{#1}%
  \endgroup
}

That's slightly more 'home-made', but makes the theorems have exactly the same layout as \subsection, which may or may not be what's required.

Norman Gray
Yeah, this works, but with a small problem. But that's due to another issue and I suppose I will ask it separately. Thanks.
George Scaria
+1  A: 

This is an example of the answer that Norman Gray gave, which looks great to me when I run it. Very nice Norman, thanks. (You can interchange the [subsection] and {Theorem} elements on the \newtheorem line to see how it affects things.) :

\documentclass{article}

\newtheorem{theorem}[subsection]{Theorem}

\begin{document}
\section{My Section}
\subsection{A subsection}

\begin{theorem}adfadfadf
\end{theorem}

\subsection{A subsection}

\begin{theorem}adfadfadf
\end{theorem}
\begin{theorem}adfadfadf
\end{theorem}

\begin{theorem}
\emph{(Lagrange's Theorem)}
\label{Lagrange}
Let $G$ be a finite group, and let $H$ be a subgroup
of $G$.  Then the order of $H$ divides the order of $G$.
\end{theorem}

\end{document}
Herbert Sitz