|
92 | 92 | % CITATION COMMANDS
|
93 | 93 | %----------------------------------------------------------------------------------------
|
94 | 94 |
|
| 95 | +% Command to format the marginnote created for cited items |
| 96 | +\NewDocumentCommand{\formatmargincitation}{m}{% The parameter is a single citation key |
| 97 | + \parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}% |
| 98 | +} |
| 99 | + |
| 100 | +% The following command needs to be redefined every time \sidecite is called in order for \DeclareCiteCommand's wrapper to work correctly |
| 101 | +\NewDocumentCommand{\kaobiblio@marginnote}{m}{% |
| 102 | + \marginnote{#1}% |
| 103 | +} |
| 104 | + |
95 | 105 | % biblatex-like commands that also print a citation in the margin
|
96 | 106 | % Usage:
|
97 | 107 | % First optional argument is always vertical shift and must be given as an (empty) argument when using following a postnote and/or prenote
|
|
105 | 115 | % Third optional argument: postnote
|
106 | 116 | % Mandatory argument: citation key
|
107 | 117 | \NewDocumentCommand{\sidecite}{o o o m}{%
|
| 118 | + \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% |
| 119 | + \marginnote[#1]{##1}% |
| 120 | + }% |
| 121 | + \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% |
| 122 | + }{% |
| 123 | + \formatmargincitation{\thefield{entrykey}}% |
| 124 | + }{% |
| 125 | + \\% separator between multiple citations |
| 126 | + }{% |
| 127 | + }% |
108 | 128 | % With this we print the marker in the text and add the item to the bibliography at the end
|
109 |
| - \IfNoValueOrEmptyTF{#2} |
110 |
| - {\cite{#4}} |
111 |
| - {\IfNoValueOrEmptyTF{#3} |
112 |
| - {\IfNoValueTF{#3} |
113 |
| - {\cite[#2]{#4}} |
114 |
| - {\cite[#2][]{#4}}% postnote is empty, so pass empty postnote |
115 |
| - } |
116 |
| - {\cite[#2][#3]{#4}}% |
| 129 | + \IfNoValueOrEmptyTF{#2}% |
| 130 | + {\cite{#4}\kaobiblio@sidecite{#4}}% |
| 131 | + {\IfNoValueOrEmptyTF{#3}% |
| 132 | + {\IfNoValueTF{#3}% |
| 133 | + {\cite[#2]{#4}\kaobiblio@sidecite{#4}}% |
| 134 | + {\cite[#2][]{#4}\kaobook@sidecite{#4}}% postnote is empty, so pass empty postnote |
| 135 | + }% |
| 136 | + {\cite[#2][#3]{#4}\kaobiblio@sidecite{#4}}% |
117 | 137 | }%
|
118 |
| - \def\itemdelim{---}% |
119 |
| - \margincitation[#1]{#4}% We then pass the cited items to this command, \margincitation |
120 | 138 | }
|
121 | 139 |
|
122 | 140 | % Command to \textcite and print a citation in the margin
|
|
125 | 143 | % Third optional argument: postnote
|
126 | 144 | % Mandatory argument: citation key
|
127 | 145 | \NewDocumentCommand{\sidetextcite}{o o o m}{%
|
| 146 | + \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% |
| 147 | + \marginnote[#1]{##1}% |
| 148 | + }% |
| 149 | + \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% |
| 150 | + }{% |
| 151 | + \formatmargincitation{\thefield{entrykey}}% |
| 152 | + }{% |
| 153 | + \\% separator between multiple citations |
| 154 | + }{% |
| 155 | + }% |
128 | 156 | % With this we print the marker in the text and add the item to the bibliography at the end
|
129 |
| - \IfNoValueOrEmptyTF{#2} |
130 |
| - {\textcite{#4}} |
131 |
| - {\IfNoValueOrEmptyTF{#3} |
132 |
| - {\IfNoValueTF{#3} |
133 |
| - {\textcite[#2]{#4}} |
134 |
| - {\textcite[#2][]{#4}}% postnote is empty, so pass empty postnote |
135 |
| - } |
136 |
| - {\textcite[#2][#3]{#4}}% |
| 157 | + \IfNoValueOrEmptyTF{#2}% |
| 158 | + {\textcite{#4}\kaobiblio@sidecite{#4}}% |
| 159 | + {\IfNoValueOrEmptyTF{#3}% |
| 160 | + {\IfNoValueTF{#3}% |
| 161 | + {\textcite[#2]{#4}\kaobiblio@sidecite{#4}}% |
| 162 | + {\textcite[#2][]{#4}\kaobook@sidecite{#4}}% postnote is empty, so pass empty postnote |
| 163 | + }% |
| 164 | + {\textcite[#2][#3]{#4}\kaobiblio@sidecite{#4}}% |
137 | 165 | }%
|
138 |
| - \def\itemdelim{---}% |
139 |
| - \margincitation[#1]{#4}% We then pass the cited items to this command, \margincitation |
140 | 166 | }
|
141 | 167 |
|
142 | 168 | % Command to \parencite or \parencite* and print a citation in the margin
|
|
146 | 172 | % Fourth optional argument: postnote
|
147 | 173 | % Mandatory argument: citation key
|
148 | 174 | \NewDocumentCommand{\sideparencite}{s o o o m}{%
|
| 175 | + \RenewDocumentCommand{\kaobiblio@marginnote}{m}{% |
| 176 | + \marginnote[#2]{##1}% |
| 177 | + }% |
| 178 | + \DeclareCiteCommand{\kaobiblio@sidecite}[\kaobiblio@marginnote]{% |
| 179 | + }{% |
| 180 | + \formatmargincitation{\thefield{entrykey}}% |
| 181 | + }{% |
| 182 | + \\% separator between multiple citations |
| 183 | + }{% |
| 184 | + }% |
149 | 185 | % With this we print the marker in the text and add the item to the bibliography at the end
|
150 | 186 | \IfBooleanTF#1
|
151 | 187 | {\IfNoValueOrEmptyTF{#3}
|
|
168 | 204 | {\parencite[#3][#4]{#5}}%
|
169 | 205 | }%
|
170 | 206 | }%
|
171 |
| - \def\itemdelim{---}% |
172 |
| - \margincitation[#2]{#5}% We then pass the cited items to this command, \margincitation |
173 |
| -} |
174 |
| - |
175 |
| - |
176 |
| -% Command to split the cited items and execute an action for each of them |
177 |
| -\newcommand\margincitedelim{\\} % Choose the default separator for multiple citations |
178 |
| -\NewDocumentCommand{\margincitation}{o >{\SplitList{,}}m}{% The mandatory parameter is a comma-separated list of citation keys, which is splitted into single items |
179 |
| - % Redefine the \margincitedelim with a delay (https://tex.stackexchange.com/questions/110898/package-xparse-splitlist-last-token). Users can 'renew' the \margincitedelim command in their main.tex. |
180 |
| - \let\origmargincitedelim\margincitedelim% |
181 |
| - \renewcommand\margincitedelim{\renewcommand\margincitedelim{\origmargincitedelim}}% |
182 |
| - \marginnote[#1]{\ProcessList{#2}{\formatmargincitation}}% Create a marginnote for each item |
183 |
| - \let\margincitedelim\origmargincitedelim% Reset |
184 | 207 | }
|
185 | 208 |
|
186 |
| -% Command to format the marginnote created for cited items |
187 |
| -\NewDocumentCommand{\formatmargincitation}{m}{% The parameter is a single citation key |
188 |
| - \margincitedelim\parencite{#1}: \citeauthor*{#1} (\citeyear{#1}), \citetitle{#1}% |
189 |
| -} |
190 | 209 |
|
191 | 210 | %----------------------------------------------------------------------------------------
|
192 | 211 | % CITATION ENVIRONMENTS
|
|
0 commit comments