summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty
blob: 00019db61aa60aaee834e92799909f93d4abf001 (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
%%
%% This is file `sidenotes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sidenotes.dtx  (with options: `package')
%% 
%% IMPORTANT NOTE:
%% 
%% This is a generated file and you are not allowed to distribute it
%% without the source of the work.  See below about more informations
%% about the files the work consists of.
%% 
\ProvidesPackage{sidenotes}[%
  2011/08/21 v0.2 footnotes in the margin for LaTeX]
\RequirePackage{marginnote} % puts the stuff in the margin and provides an offset option instead of a float
\RequirePackage{caption} % handles the figure caption (in the margin)
\RequirePackage{environ} % to define new environments more easily
\RequirePackage{xifthen} % provide an if command
\RequirePackage{twoopt} % cite in the biblatex package has 2 optional arguments
\newcommand*{\sidestyle}{\footnotesize}
\newcounter{sidenote} % make counter
\newcounter{@sidenotes@buffer}
\setcounter{sidenote}{1} % init counter

\newcommand*{\sidenote}[2][]{%
\begingroup%
\@ifnextchar [{\@sidenotes@sidenote[{#1}]{#2}}{\@sidenotes@sidenote[{#1}]{#2}[]}%
}

\newcommand{\@sidenotes@sidenote}{}
\def\@sidenotes@sidenote[#1]#2[#3]{%
\endgroup%
\@sidenotes@@sidenote[{#1}]{#2}[{#3}]%
}

\newcommand{\@sidenotes@@sidenote}{}
\def\@sidenotes@@sidenote[#1]#2[#3]{%
\ifthenelse{\isempty{#1}}%
{\sidenotemark%
\sidenotetext{#2}[#3]}%
{\sidenotemark[#1]%
\sidenotetext[#1]{#2}}%
}
\newcommand{\sidenotemark}[1][]{%
\nobreak\hspace{0.1pt}\nobreak%
\ifthenelse{\isempty{#1}}%
{\textsuperscript{\thesidenote}%
\refstepcounter{sidenote}}% if no argument is given use sidenote counter%
{\setcounter{@sidenotes@buffer}{\value{sidenote}}%
\setcounter{sidenote}{#1}%
\textsuperscript{\thesidenote}% print out the argument otherwise
\setcounter{sidenote}{\value{@sidenotes@buffer}}}%
\ignorespaces%
}%
\newcommand*{\sidenotetext}[2][]{%
\begingroup%
\@ifnextchar [{\@sidenotes@sidenotetext[{#1}]{#2}}{\@sidenotes@sidenotetext[{#1}]{#2}[]}%
}

\newcommand{\@sidenotes@sidenotetext}{}
\def\@sidenotes@sidenotetext[#1]#2[#3]{%
\endgroup%
\@sidenotes@@sidenotetext[{#1}]{#2}[{#3}]%
}

\newcommand{\@sidenotes@@sidenotetext}{}
\def\@sidenotes@@sidenotetext[#1]#2[#3]{%
\ifthenelse{\isempty{#1}}{% sitenotemark given?
\addtocounter{sidenote}{-1}%
\ifthenelse{\isempty{#3}}{% offset?
\marginpar{\textsuperscript{\thesidenote}{} \sidestyle#2}}% no offset
{\marginnote{\textsuperscript{\thesidenote}{} \sidestyle#2}[#3]} % with offest
\addtocounter{sidenote}{1}}%
{\ifthenelse{\isempty{#3}}% offset?
{\marginpar{\textsuperscript{#1} \sidestyle#2}}% no offset
{\marginnote{\textsuperscript{\thesidenote}{} \sidestyle#2}}% with offset
}% fi
}%
\newcommandtwoopt{\sidecite}[3][][]{%
\begingroup%
\@ifnextchar [{\@sidenotes@sidecite[{#1}][{#2}]{#3}}{\@sidenotes@sidecite[{#1}][{#2}]{#3}[]}%
}
\newcommand{\@sidenotes@sidecite}{}
\def\@sidenotes@sidecite[#1][#2]#3[#4]{%
\endgroup%
\@sidenotes@@sidecite[{#1}][{#2}]{#3}[{#4}]%
}

\newcommand{\@sidenotes@@sidecite}{}
\def\@sidenotes@@sidecite[#1][#2]#3[#4]{%
\sidenote{\fullcite[#1][#2]{#3}}[#4]%
}%
\newcommand{\sidecaption}[2][]{%
\ifthenelse{\isempty{#1}}%
{\marginnote{\caption{#2}}}%
{\marginnote{\caption[#1]{#2}}}%
}%
\NewEnviron{sidefigure}[1][]{%
\ifthenelse{\isempty{#1}} % offset?
{\marginpar{\captionsetup{type=figure}\BODY}} % no offset
{\marginnote{\captionsetup{type=figure}\BODY}[#1]} % with offset
}%
\NewEnviron{sidetable}[1][]{%
\ifthenelse{\isempty{#1}} % offset?
{\marginpar{\captionsetup{type=table}\sidestyle\BODY}} % no offset
{\marginnote{\captionsetup{type=table}\sidestyle\BODY}[#1]} % with offset
}%
\endinput
%%
%% End of file `sidenotes.sty'.