2

Is there a way, with amsthm and thmtools (possibly other packages, too) to have LaTeX keep track of the numbers of a particular kind of theorem, yet not have the numbers actually appear in the printed text?

For example:

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[numbered=yes]{probs}
\declaretheorem[name=PROBLEMS,style=probs,numberwithin=section]{problems} 

\begin{document}

\section{First section}

\begin{problems}
Blah-blah
\end{problems}

\end{document}

The output I want should be:

enter image description here

Note that the answer is not simply to use numbered=no (or, without thmtools, a \newtheorem* declaration) — because I still want to reference the theorem's number (and not a name), e.g., for use with \hyperref.

[The issue is related to my question How use cleveref to get theorem-like name and list item number?

  • With other words, you want to have hyperlinks to the unnumbered theorems? – user31729 Sep 4 '16 at 21:08
  • 1
    If the theorem (or problem) has no number, what would be the use of referencing to it as “problem 42”? How would the reader find it? – egreg Sep 4 '16 at 21:09
  • Each instance of the problems environment will have an enumerated list inside. I want to be able to cross-reference particular items in such a list not just by their item number, but also by the section number in which that problems environment occurs. (And such a cross-reference may, of course, appear in an earlier section, before the section that contains the target problem.) – murray Sep 4 '16 at 21:20
  • By means of a counter, all enumerated lists of problems within several problems environments in a single section will be numbered consecutively throughout the section. Thus in, say, section 1, a reference to the 5th problem item (in any of the problem environments) in section 2 might be "Problem 2 (5)". – murray Sep 4 '16 at 21:24
  • @murray: Why do you not post such extra explanations right from the start? Your problems environment does not have enumerate list inside. I think, you are asking an X - Y - question :-( – user31729 Sep 4 '16 at 21:28
2

I don't recommend such a style, but it is possible to trick preheadhook to let \theproblems do nothing and enable it later on again with postheadhook, such that the label option (or the \label command) will use the non-empty \theproblems anyway.

The enumeration reference can be changed however with an easy enumitem list specialized for problems:

\documentclass{article}

\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{enumitem}
\usepackage{hyperref}

\declaretheoremstyle[numbered=yes]{probs}
\declaretheorem[name=PROBLEMS,style=probs,numberwithin=section,preheadhook={\let\theproblems\relax},postheadhook={\newcommand{\theproblems}{\thesection.\arabic{problems}}\leavevmode}]{problems} 

\newlist{probenum}{enumerate}{1}

\setlist[probenum,1]{label={\arabic*)},ref={Problem \thesection(\arabic*)}}


\begin{document}


\section{First section}

\begin{problems}
\begin{probenum}
  \item foo \label{foo}
  \item bar \label{bar}
\end{probenum}
\end{problems}


\section{other}

\begin{problems}
\begin{probenum}
  \item foo \label{fooother}
  \item bar \label{barother}
\end{probenum}
\end{problems}

In \ref{fooother}, \ref{bar} or in \ref{foo} it is shown that

\end{document}

enter image description here

  • As my elaboration in comments above indicates, I do not want to directly cross-reference the entire problems environment, but rather individual list items within such an environment. Hence my citation of my earlier question. I'm trying in the present question to distill out some of the essence of the issue (I hope!). – murray Sep 4 '16 at 21:26
  • 1
    @murray: Well, your comment came a little late, didn't it? – user31729 Sep 4 '16 at 21:27
  • Your trick with preheadhookmay still help in the actual, full, situation I'm facing! – murray Sep 4 '16 at 21:35
  • @murray: See the update please – user31729 Sep 4 '16 at 21:39
  • I don't think the update allows correctly referencing within the First section one of the problems' items from the other section. It does work OK within a single section, though. – murray Sep 4 '16 at 21:50

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.