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.

Sections are referenced in a lot of distinct places:

In table of contents. Managed by \tableofcontents In minitocs. Managed by minitoc package In headers. Managed by fancyhdr package Like a leader section. Managed by \section In text. Managed by \ref In tocs and minitocs, because of each section appears below its chapter (wits some indentation) it's not necessary to prefix the section number with the chapter number. The label scope is local; so I need a local renderization. Example:

              1. Chapter One ------------------1
                   1. First section -----------1
                   2. Second section ----------3
               2. Chapter Two -----------------5
                   1. First section ...........5

This means that sections 1.1 and 2.1 must be rendered as section 1.

When we use \section command we know what chapter we are in: it's showed in the headers of te page. So I want also local scope:

         1. First section
                    bla bla
         2. Second section
                   bla bla

In headers I want global scope:

         1. Chapter One                      1.1. First section

In text we can make a crossreference to whatever point of text. So we need global scope:

            See section 1.1 (first section in first chapter)

This is the problem: The default behavior give as global scope every where. But if I redefine \thesection to local scope, then I redefine everywhere.

This is my code:

\documentclass[catalan]{book}
\usepackage{fancyhdr}
\usepackage{nameref}
\usepackage{minitoc}
\usepackage{hyperref}

\makeindex
\dominitoc

%\renewcommand{\thesection}{\arabic{section}}

\renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}} \renewcommand{\sectionmark}[1]{\markboth{\thechapter.\thesection\ \ #1}}

\fancyhead{}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\thechapter.\rightmark}

\pagestyle{fancy}

\begin{document} \tableofcontents \chapter{One}

\minitoc[e]

\section{First section}
\label{sec:A}
aaaaaa \newpage bbbbbbbb \newpage
ccccccccccc

\chapter{Two} \minitoc[e]
\section{Second section}
\label{sec:B}

See sections \ref{sec:A} and \ref{sec:B}

\end{document}
share|improve this question
    
I might be able to help, but I don't really understand what you want. What part of the document is incorrect if you uncomment \renewcommand{\thesection}{\arabic{section}} in your example? –  Ian Thompson Dec 13 '10 at 17:09
    
If I uncomment \renewcommand{\thesection}{\arabic{section}} I obtain always local scope. But I want global scope in headers and in-text cross-references. I only want local scope in minitocs and in the begining of a section or chapter –  meren Dec 13 '10 at 17:22
    
@meren. I suspect that the reason you are struggling here is that most people would regard what you want to do as being rather confusing. Referencing 'Section 1' makes sense in a document with no chapters, but I've never seen this done in a larger document. –  Joseph Wright Dec 25 '10 at 9:24
add comment

2 Answers 2

Use \renewcommand{\thesection}{\arabic{section}} to get the numbers beside the section titles right. Changing this otherwise is difficult.

Use \renewcommand{\sectionmark}[1]{\markright{\thechapter.\thesection\ #1}} for the headers.

For the references you can use e.g. zref to set up a "fullsec" reference. But I would find it confusing. And what if you have a subsection 2.1? I would put a \label behind the chapter too and then write something like see section 1 in chapter 2.

share|improve this answer
    
Well. But what about minitoc? –  meren Dec 14 '10 at 15:15
    
And to have "see section 1 in chapter 2" how can I obtain the chapter number? –  meren Dec 14 '10 at 15:17
    
Like you optain the section number: With \label after the \chapter and \ref. –  Ulrike Fischer Dec 14 '10 at 15:27
    
But then I've to know the chapter of each reference! But I only want to know the label. –  meren Dec 14 '10 at 20:28
add comment
up vote 0 down vote accepted

Originally I posted a confused question, how-can-i-get-the-chapter-number-like-a-prefix-of-all-references. That question was the genesis of this one.

The answer posted by TH. there is the good answer to the current question

share|improve this answer
1  
Here the link to that question: tex.stackexchange.com/q/6254/2975 –  Martin Scharrer Jan 31 '11 at 15:15
    
I guess you mean "posted by TH."? –  Hendrik Vogt Jan 31 '11 at 15:16
    
@Hendrik: Heh. I'm not really attached to that period. I just needed a third character when I registered. –  TH. Feb 1 '11 at 9:13
    
@TH: I know. I just wanted to avoid further misunderstandings. –  Hendrik Vogt Feb 1 '11 at 10:52
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.