Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding local labels capability for managing labels across multiple papers. #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions thesis.tex
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,34 @@
%\widowpenalty=10000
%\clubpenalty=10000

%% This attempts to give us a redefinition of \label and \ref so that we can fix
%% the problem arising from having multiple sections with the same label.
%% That is, we should be able to have \label{intro} within a chapter refer to the
%% intro of that chapter, not the introduction chapter of the whole thesis.
%%
%% NOTE: when referring to a section in another chapter, you'll need to do e.g. \origref{intro:section_name}
%%
%% WARNING: some issues arise from using hyperref
%% taken from: https://tex.stackexchange.com/questions/82091/can-i-re-use-section-labels-across-chapters/82115#82115
%
% see also: https://tex.stackexchange.com/questions/135883/using-custom-locallabels-command-with-custom-eqref-command

\makeatletter
\AtBeginDocument{%
\let\origref\ref
\let\origpageref\pageref
\let\origlabel\label
% \let\origeqref\eqref
\let\origlabel@in@display\label@in@display
\newcommand\locallabels[1]{%
\renewcommand\label[1]{\origlabel{#1##1}}%
\renewcommand\ref[1]{\origref{#1##1}}%
\renewcommand\pageref[1]{\origpageref{#1##1}}%
% \renewcommand\eqref[1]{\origeqref{#1##1}}%
\renewcommand\label@in@display[1]{\origlabel@in@display{#1##1}}%
}}
\makeatother

% Modify or extend these at will.
\newtheorem{theorem}{\textsc{Theorem}}[chapter]
\newtheorem{definition}{\textsc{Definition}}[chapter]
Expand Down