summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/minorrevision/minorrevision.sty
blob: 53fb956de5f796b618477dba50900a2f0899e413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%% Copyright (C) 2013 by Matthieu Guillaumin
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.2 of this license or (at your option) any later
%% version. The latest version of this license is in:
%%    http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{minorrevision}
    [ 2013/11/15 v1.1 minorrevision package ]

% Package requirements
\RequirePackage{xkeyval}
\RequirePackage{lineno}
\RequirePackage{xr}
\DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{lineno,xr}} % pass options to other packages
\ProcessOptionsX

%%% Package commands %%%

% Define .mrv extension for auxiliary files, creating/opening the output file
\def\MRV@prefix{ MRV}
\def\MRV@ext{.mrv}
\def\MRV@outputfile{\jobname\MRV@ext}
\typeout{minorrevision: creating \MRV@outputfile}
\newwrite\outputmrv
\immediate\openout\outputmrv=\MRV@outputfile

% Macro for writing macros in the .mrv file
\newcommand{\MRV@Write}[3]{%
  \protected@write\outputmrv{}{\string\expandafter\string\def\string\csname\MRV@prefix/\jobname/#1@#2\string\endcsname{#3}}%
}

%%% User commands %%%

% Define \mrvdocument: adds external document for xr, reads the .mrv file
\newcommand{\mrvdocument}[1]{
  \def\MRV@lastrefdoc{#1}
  \def\MRV@lastrefmrv{#1\MRV@ext}
  \typeout{minorrevision: reference ``\MRV@lastrefdoc'' declared, loading \MRV@lastrefmrv}
  \externaldocument[\MRV@lastrefdoc-]{\MRV@lastrefdoc}
  \input \MRV@lastrefmrv
}

\newcommand{\mrvref}[2]{\ref{#1-mrv:#2}}

\newcommand{\mrvold}[2]{\csname\MRV@prefix/#1/old@#2\endcsname}

\newcommand{\mrvnew}[2]{\csname\MRV@prefix/#1/new@#2\endcsname}

\newcommand{\revref}[1]{\mrvref{\MRV@lastrefdoc}{#1}}

\newcommand{\revold}[1]{\mrvold{\MRV@lastrefdoc}{#1}}

\newcommand{\revnew}[1]{\mrvnew{\MRV@lastrefdoc}{#1}}

\newcommand{\revisionrm}[2]{\linelabel{mrv:#1}\MRV@Write{old}{#1}{#2}}

\newcommand{\revisionadd}[2]{\linelabel{mrv:#1}#2\MRV@Write{new}{#1}{#2}}

\newcommand{\revision}[3]{\linelabel{mrv:#1}#2\MRV@Write{new}{#1}{#2}\MRV@Write{old}{#1}{#3}}

%% End of user commands %%

\endinput
%%
%% End of file `minorrevision.sty'.