Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a document with the class amsbook. I have several chapters, and inside the sections only (no subsections). I've used

\swapnumbers
\theoremstyle{theorem}
\newtheorem{corollary}{Corollary}[section]
\newtheorem{teo}[corollary]{Théorème}
\newtheorem{lem}[corollary]{Lemme}

and so on.

Now, in chapter 1, section 2 I have "2.2 Theorem : ..." Also, in chapter 2, section 2 I have "2.2. Lemma : ..." Each of those has its label, and when I quote one of those in some other chapter i only get "see 2.2", so the reader would not know whether I am talking about I.2.2 or II.2.2.

Any suggestions?

share|improve this question
    
Replace [section] by [chapter]. –  Sigur May 6 '13 at 0:07
1  
@Sigur but then the section number will be missing from the counters for the theorem-like structures; from what I understand from the question, this is not desired. –  Gonzalo Medina May 6 '13 at 0:20
1  
Not to forget this: Welcome to TeX.sx! A suggestion: Do us a favour and change your username to something more telling than "user1234". –  Speravir May 6 '13 at 0:28
add comment

1 Answer

You can redefine \p@corollary (controlling the prefix used in cross-references) and add the Roman representation for the chapter number:

\documentclass{amsbook}
\usepackage[frenchb]{babel}
\swapnumbers 
\theoremstyle{theorem} 
\newtheorem{corollary}{Corollary}[section] 
\newtheorem{teo}[corollary]{Théorème} 
\newtheorem{lem}[corollary]{Lemme}

\makeatletter
\renewcommand\p@corollary{\Roman{chapter}.}
\makeatother

\begin{document}

\chapter{Test Chapter One}
\ref{cortest} and \ref{lemtest}
\section{Test Section One One}
\section{Test Section One Two}
\begin{corollary}
\label{cortest}
test
\end{corollary}

\chapter{Test Chapter Two}
\ref{cortest}
\section{Test Section Two One}
\section{Test Section Two Two}
\begin{lem}
\label{lemtest}
test
\end{lem}

\end{document}

enter image description here

A new requirement has been made in a comment: to add the chapter number only if the referenced object appears in a different chapter from the one in which \ref is used; this can be done with some string manipulation:

\documentclass{amsbook}
\usepackage[frenchb]{babel}
\usepackage{refcount}
\usepackage{xstring}

\newcommand\currentchapter{}
\newcommand\thmref{}

\newcommand\Thmref[1]{%
  \renewcommand\currentchapter{\thechapter}
  \StrBefore{\getrefnumber{#1}}{.}[\thmrefbefore]%\thmrefbefore\currentchapter%
  \StrBehind{\getrefnumber{#1}}{.}[\thmrefbehind]%\thmrefbehind\currentchapter%
  \IfStrEq{\currentchapter}{\thmrefbefore}{\thmrefbehind}{\uppercase\expandafter{\romannumeral 0\thmrefbefore\relax}.\thmrefbehind} 
}

\swapnumbers 
\newtheorem{corollary}{Corollary}[section] 
\newtheorem{teo}[corollary]{Théorème} 
\newtheorem{lem}[corollary]{Lemme}

\makeatletter
\renewcommand\p@corollary{\arabic{chapter}.}
\makeatother

\begin{document}

\chapter{Test Chapter One}
\section{Test Section One One}
\section{Test Section One Two}
Corollary~\Thmref{cortesta} and Lemme~\Thmref{lemtestb}... On the other hand, Corollary~\Thmref{cortestb} and Lemme~\Thmref{lemtesta}...
\begin{corollary}
\label{cortesta}
test
\end{corollary}
\begin{lem}
\label{lemtesta}
test
\end{lem}

\chapter{Test Chapter Two}
\section{Test Section Two One}
\section{Test Section Two Two}
Corollary~\Thmref{cortesta} and Lemme~\Thmref{lemtestb}... On the other hand, Corollary~\Thmref{cortestb} and Lemme~\Thmref{lemtesta}...
\begin{corollary}
\label{cortestb}
test
\end{corollary}
\begin{lem}
\label{lemtestb}
test
\end{lem}

\end{document}

The image for chapter one:

enter image description here

and the image for chapter two:

enter image description here

This second approach doesn't cooperate with hyperref.

share|improve this answer
    
Great!What you suggest perfectly works! Would it be possible to intorduce something more : If I am in chapter 1, then Theorem 2.2. should be enough, but if I am refering to it in the other chapters the I.2.2 would be needed. –  user30238 May 6 '13 at 0:53
    
@user30238 Yes, this can be done. Please see my updated answer. An approach that is compatible with hyperref will require a different approach. –  Gonzalo Medina May 6 '13 at 1:50
    
Rather than hacking \p@corollary, use the fncylab package and the command \labelformat{corollary}{\Roman{chapter}.#1}. (It does the same thing, also with the option to produce a more general piece of text with the counter value embedded.) –  Ryan Reich May 6 '13 at 22:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.