Consider this basic document
\part{Alpha}
\chapter{Beginning A}
\section{Early Beginning A} \label{eba}
\section{Late Beginning A}
#1 See \myref{eba} then \myref{lea}
\chapter{End A}
\section{Early End A}
#2 See \myref{eba} then \myref{lea}
\section{Late End A} \label{lea}
\part{Beta}
\chapter{Beginning B}
\section{Early Beginning B}
\section{Late Beginning B}}
#3 See \myref{eba} then \myref{lea}
\chapter{End B}
\section{Early End B}
\section{Late End B}
#3 See \myref{eba} then \myref{lea}
I want myref
to produce different levels of context depending on how much context the label shares with the place of invocation.
How could I write myref
such that the output is like this?
Part I: Alpha
Chapter 1: Beginning A
1.1 Early Beginning A
1.2 Late Beginning A
#1 See Section 1 then Chapter 2 Section 2
Chapter 2: End A
2.1 Early End A
#2 See Chapter 1 Section 1 then Section 2
Part II: Beta
Chapter 1: Beginning B
1.1 Early Beginning B
1.2 Late Beginning B
#3 See Part I Chapter 1 Section 1 then Part I Chapter 2 Section 2
Chapter 2: End B
1.1 Early End B
1.2 Late End B
#3 See Part I Chapter 1 Section 1 then Part I Chapter 2 Section 2
So basically, myref
will produce
Section X
if it is called from within the same chapter of the same part,Chapter X Section Y
if it is called from within a different chapter of the same part,Part X Chapter Y Section Z
if it is called from within a different part.
How do I write such a thing? Thanks.