summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sidenotes/sidenotes.sty
blob: 0337e8ee4d8adc15f51729a4f4e619bd014e8feb (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
%%
%% 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/11/29 v0.81 rich text 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{xifthen} % provide an if command
\newboolean{@sidenotes@bibtex}%
\setboolean{@sidenotes@bibtex}{false}%
\DeclareOption{bibtex}{\setboolean{@sidenotes@bibtex}{true}}%
\ProcessOptions
\ifthenelse{\boolean{@sidenotes@bibtex}}{\RequirePackage{bibentry}}{}
\newcommand*{\sidestyle}{\footnotesize}
\newcounter{sidenote} % make counter
\newcounter{@sidenotes@buffer}
\setcounter{sidenote}{1} % init counter

\newcommand{\sidenote}[2][]{%
\ifthenelse{\isempty{#1}}%
{\sidenotemark%
\sidenotetext{#2}}%
{\sidenotemark[#1]%
\sidenotetext[#1]{#2}}%
\@ifnextchar\sidenote{\kern-0.07em\textsuperscript{,}}{\@ifnextchar\sidecite{\kern-0.07em\textsuperscript{,}}{ }}%
}
\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}}}%
\@ifnextchar\sidenote{\textsuperscript{,}}{}%
\ignorespaces%
}%
\newcommand{\sidenotetext}[2][]{%
\ifthenelse{\isempty{#1}}{% sitenotemark given?
\addtocounter{sidenote}{-1}%
\marginpar{\textsuperscript{\thesidenote}{} \sidestyle#2}%
\addtocounter{sidenote}{1}}%
{\marginpar{\textsuperscript{#1} \sidestyle#2}%
}% fi
}%
\ifthenelse{\boolean{@sidenotes@bibtex}}
{\newcommand{\sidecite}[1]{%
\sidenote{\bibentry{#1}}%
}}
{\newcommand{\sidecite}[1][]{%
  \@ifnextchar[{%
    \expandafter\@sidenotes@sidecitedo\@sidenotes@getnextopt{#1}%
  }{%
    \@sidenotes@sidecitedo{#1}{}%
  }%
}
\newcommand{\@sidenotes@getnextopt}{}
\long\def\@sidenotes@getnextopt#1[#2]{{#1}{#2}}
\newcommand{\@sidenotes@sidecitedo}[3]{%
\sidenote{\fullcite[#1][#2]{#3}}%
}}%
\newcommand{\sidecaption}[2][]{%
\ifthenelse{\isempty{#1}}%
{\marginnote{\caption{#2}}}%
{\marginnote{\caption[#1]{#2}}}%
}%
\newsavebox{\@sidenotes@sidefigurebox}
\newenvironment{sidefigure}[1][]%
{\begin{lrbox}{\@sidenotes@sidefigurebox}%
\begin{minipage}{\marginparwidth}%
\captionsetup{type=figure}}%
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\@sidenotes@sidefigurebox}}
}
\newsavebox{\@sidenotes@sidetablebox}
\newenvironment{sidetable}[1][]%
{\begin{lrbox}{\@sidenotes@sidetablebox}%
\begin{minipage}{\marginparwidth}%
\captionsetup{type=table}%
\sidestyle}%
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\@sidenotes@sidetablebox}}
}%    \end{macrocode}
\endinput
%%
%% End of file `sidenotes.sty'.