Motivation: I want to declare a command \tbc (without arguments) to use it inside an environment. I want this command to produce a text like Problem 2 continues on the next page, start a new page and produce Problem 2 continued... I use a variety of environments, such as Problem, Question, Exercise, etc, but all use a continuous numbering with the counter theorem. Naturally, I want my \tbc to produce Problem 2 when it's used between \begin{problem} and \end{problem}, and Question 3 when it's used between \begin{question} and \end{question}.

Question: I know that I can get the environment number with \the\value{theorem}. I can't figure out how to get an environment name.

I am aware that there are other packages for this, but having my own small command allows me to better merge it with the style of my documents.


A hack that exploits amsthm: when typesetting the header, I redefine \tbcname to expand to #1 (the theorem name).


  {\topsep}   % ABOVESPACE
  {\topsep}   % BELOWSPACE
  {\upshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries} % HEADFONT
  {.}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {\gdef\tbcname{#1}\thmname{#1} \thmnumber{#2}\thmnote{ (#3)}} % CUSTOM-HEAD-SPEC


  \textit{\tbcname~\thetheorem\ continues on the next page}\clearpage
  \textit{\tbcname~\thetheorem\ continued}\dots\par




enter image description here


In case the names of your environments are the same as the names of the counters in use for these environments, you can use \@currenvir for obtaining the name of an environment and the counter associated to that environment.

Besides this:

  1. The varioref-package can be used for obtaining phrases like "on the next page" or "on the following page". That brings a bit of variety to the text.

  2. I think, for referencing from outside the environment the \autoref-command of the hyperref-package will be your friend.

    It will prepend names associated to counters to references.

    The names come from macros whose names are of pattern
    or—in case the further macro is not defined—
    (See section 4, Additional User Macros, of the manual of the hyperref-package.)

    But there is one small problem:

    When you use the same counter for several theorem-like environments, you need several names / several macros \⟨counter⟩autorefname for that counter.

    That problem is addressed by the package aliascnt by Heiko Oberdiek.

Here is a small example:


%===================[adjust margins/layout for the example]====================
\paperheight=5.25 cm
\csname @ifundefined\endcsname{pagewidth}{}{\pagewidth=\paperwidth}%
\csname @ifundefined\endcsname{pdfpagewidth}{}{\pdfpagewidth=\paperwidth}%
\csname @ifundefined\endcsname{pageheight}{}{\pageheight=\paperheight}%
\csname @ifundefined\endcsname{pdfpageheight}{}{\pdfpageheight=\paperheight}%
%==================[eof margin-adjustments]====================================


% In case you wish no hyperlinks and no bookmarks:
% In case you wish hyperlinks and bookmarks:



% Create fake-counters that use the same count-register as the
% theorem-counter:

% Define the autoref-names of the fake-counters when referencing then
% via \autoref

% Create theorem-environments that use the fake-counters:

% Apply the fix provided by the package aliascnt for \newtheorem when
% being used with a fake-counter -- see section 1, "User Interface" of
% the manual of the aliascnt-package, URL:
% <http://mirrors.ctan.org/macros/latex/contrib/oberdiek/aliascnt.pdf>

% \tbc or \tbc[<referencing-command>]
  % globally step \tbccnt:
  % You probably wish to adjust varioref's behaviour:
  % \def\reftextfaceafter{on the next page}%
  % \def\reftextafter{on the next page}%
    \csname\@currenvir autorefname\endcsname~%
    \csname the\@currenvir\endcsname\ continues \null%
    \csname\@currenvir autorefname\endcsname~%
    \csname the\@currenvir\endcsname\ continued%


This is a theorem.
This is a theorem.


This is a problem.
This is a problem.


This is a question.
This is a question.


This is an exercise.
\tbc[on page~\pageref*]
This is an exercise.


\noindent Referencing:

\verb|\autoref{Firsttheorem}|: \autoref{Firsttheorem}

\verb|\autoref{Firstproblem}|: \autoref{Firstproblem}

\verb|\autoref{Firstquestion|: \autoref{Firstquestion}

\verb|\autoref{Firstexercise}|: \autoref{Firstexercise}


enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

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.