summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/marginnote/marginnote.sty
blob: a3df8036f9100bc5a3e17dc498144570e8ab25be (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
%%
%% This is file `marginnote.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% marginnote.dtx  (with options: `package')
%% 
%% IMPORTANT NOTE:
%% 
%% This is a generated file and you are not allowed to distribute it
%% without the source ot the work.  See below about more informations
%% about the files the work consists of.
%% 
%% Copyright (c) Markus Kohm  2005-2006
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The author of the initial version of these work was
%% Markus Kohm <komascript@gmx.info>
%%
%% This work consists of the files marginnote.dtx, marginnote.ins,
%% and REAMDE.
%%
\ProvidesPackage{marginnote}[%
  2006/02/06 v1.0a non floating margin notes for LaTeX]
\ProcessOptions\relax
\newcommand*{\newmarginnote}{\@newl@bel{mn}}
\newcommand*{\@mn@thispage}{}
\let\@mn@thispage\@empty
\newcounter{mn@abspage}
\AtBeginDocument{\setcounter{mn@abspage}{1}%
  \g@addto@macro\@outputpage{\stepcounter{mn@abspage}}}
\newcommand*{\@mn@margintest}{%
  \expandafter\ifx\csname @mn@thispage\endcsname\@empty
    \gdef\@mn@atthispage{1}%
  \else\expandafter\ifnum \@mn@thispage=\value{mn@abspage}%
      \begingroup
        \@tempcnta\@mn@atthispage\advance\@tempcnta by \@ne
        \xdef\@mn@atthispage{\the\@tempcnta}%
      \endgroup
    \else
      \gdef\@mn@atthispage{1}%
    \fi
  \fi
  \xdef\@mn@thispage{\themn@abspage}%
  \protected@write\@auxout{\let\themn@abspage\relax}{%
    \string\newmarginnote{note.\@mn@thispage.\@mn@atthispage}{\themn@abspage}%
  }%
  \if@twoside
    \@ifundefined{mn@note.\@mn@thispage.\@mn@atthispage}{%
      \PackageInfo{marginnote}{Suggest that margin
        note \@mn@thispage.\@mn@atthispage\space will be on\MessageBreak
        absolute page \themn@abspage.\MessageBreak
        This may be wrong}%
      \ifodd\value{mn@abspage}\@tempswatrue\else\@tempswafalse\fi
    }{%
      \PackageInfo{marginnote}{Margin note \@mn@thispage.\@mn@atthispage\space
        is on absolute page \@nameuse{mn@note.\@mn@thispage.\@mn@atthispage}}%
      \ifodd\@nameuse{mn@note.\@mn@thispage.\@mn@atthispage}
        \@tempswatrue
      \else
        \@tempswafalse
      \fi
    }%
  \else
    \PackageInfo{marginnote}{right page because not two side mode}%
    \@tempswatrue
  \fi
}
\newcommand*{\marginnote}{%
  \@dblarg\@mn@marginnote
}
\newcommand{\@mn@marginnote}[2][]{%
  \ifhmode
    \@bsphack
    \begingroup
    \ifdim\@savsk>\z@\else
      \def\:{\@xifnch}\expandafter\def\: { \futurelet\@let@token\@ifnch}%
    \fi
  \else
    \begingroup
  \fi
  \@ifnextchar [{\@mn@@marginnote[{#1}]{#2}}{\@mn@@marginnote[{#1}]{#2}[\z@]}%
}
\newcommand{\@mn@@marginnote}{}
\def\@mn@@marginnote[#1]#2[#3]{%
  \endgroup
  \ifhmode
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
    \@esphack
  \else
    \@mn@@@marginnote[{#1}]{#2}[{#3}]%
  \fi
}
\newcommand{\@mn@@@marginnote}{}
\def\@mn@@@marginnote[#1]#2[#3]{%
   \begingroup
     \ifmmode\strut\let\@tempa\vadjust\else
       \if@inlabel\leavevmode\fi
       \ifhmode\strut\let\@tempa\vadjust\else\let\@tempa\mn@vlap\fi
     \fi
     \@tempa{%
       \vbox to\z@{%
         \vss
         \@mn@margintest
         \if@reversemargin\if@tempswa
             \@tempswafalse
           \else
             \@tempswatrue
         \fi\fi
         \if@tempswa
           \rlap{\kern\textwidth\kern\marginparsep\kern\marginnoterightadjust
             \vbox to\z@{\kern #3
               \vbox to\z@{%
                 \hsize\marginparwidth
                 \kern-\baselineskip\kern-\parskip
                 \marginfont\raggedrightmarginnote\hspace{\z@}\strut#2\endgraf
                 \vss}%
               \vss}%
           }%
         \else
           \llap{%
             \vbox to\z@{\kern #3
               \vbox to\z@{%
                 \hsize\marginparwidth
                 \kern-\baselineskip\kern-\parskip
                 \marginfont\raggedleftmarginnote\hspace{\z@}\strut#1\endgraf
                 \vss}%
               \vss}%
             \kern\marginparsep\kern\marginnoteleftadjust
           }%
         \fi
       }%
     }%
   \endgroup
}
\newcommand*{\marginnoterightadjust}{}
\newcommand*{\marginnoteleftadjust}{}
\let\marginnoterightadjust\z@
\let\marginnoteleftadjust\z@
\newcommand{\mn@vlap}[1]{%
  \setbox\@tempboxa\vbox to \ht\strutbox{#1\vss}%
  \box\@tempboxa\vskip-\baselineskip\ifhmode\typeout{FALSCH!}\fi
}
\providecommand*{\marginfont}{}
\newcommand*{\raggedleftmarginnote}{\raggedleft}
\newcommand*{\raggedrightmarginnote}{\raggedright}
\endinput
%%
%% End of file `marginnote.sty'.