Debian Codegraph @

texmf-dist/doc/latex/multifootnote/multifootnote-doc.tex

raw
1 \documentclass[classical]{einfart}
2
3 \usepackage{ProjLib}
4
5 \setmonofont[Scale=.9]{Iosevka}
6
7 \usepackage[left indent, backref]{multifootnote}
8
9 %%================================
10 %% For typesetting code
11 %%================================
12 \usepackage{listings}
13 \usepackage{xcolor}
14 \usepackage{setspace}
15 \definecolor{code-main}{RGB}{70,130,180}
16 \definecolor{code-expl3}{RGB}{240,50,60}
17 \definecolor{code-option}{RGB}{40,110,20}
18 \definecolor{code-keys}{RGB}{100,130,150}
19 \definecolor{code-comment}{RGB}{20,120,80}
20 \definecolor{code-background}{gray}{0.99}
21 \lstset{
22 language = [LaTeX]TeX,
23 basicstyle = \ttfamily,
24 keywordstyle = \color{code-main},
25 commentstyle = \color{code-comment},
26 showstringspaces = false,
27 breaklines = true,
28 frame = lines,
29 backgroundcolor = \color{code-background},
30 basewidth = .5em,
31 escapeinside = {(*}{*)},
32 alsoletter = {_:},
33 % numbers = left,
34 % firstnumber = last,
35 numberstyle = \scriptsize\ttfamily,
36 stepnumber = 1,
37 numbersep = 5pt,
38 }
39 \newcommand{\meta}[1]{$\langle${\normalfont\itshape#1}$\rangle$}
40 \lstset{% LaTeX2 commands
41 classoffset = 0,
42 texcsstyle =* \color{code-main},
43 moretexcs =
44 {
45 multifootnotemark,
46 multifootnotetext,
47 multifootnotetag,
48 multifootnotetagtext,
49 multifootnote,
50 footnotenumber,
51 footnotetag,
52 multifootnotemarkmanual,
53 multifootnotetextmanual,
54 multifootnotetagmanual,
55 multifootnotetagtextmanual,
56 multifootnotemanual,
57 footnotenumbermanual,
58 footnotetagmanual,
59 }
60 }
61 \lstset{% LaTeX3 commands
62 classoffset = 1,
63 texcsstyle =* \color{code-expl3},
64 moretexcs =
65 {
66 }
67 }
68 \lstnewenvironment{code}{\setstretch{1.05}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
69 \lstnewenvironment{code*}{\setstretch{1.05}\lstset{numbers=left}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
70
71 \newcommand{\packageoption}[1]{\textcolor{code-option}{\texttt{#1}}}
72 \newcommand{\commandoption}[1]{\textcolor{code-keys}{\texttt{#1}}}
73
74 %%================================
75 %% tip
76 %%================================
77 \usepackage[many]{tcolorbox}
78 \newenvironment{tip}[1][Tip]
79 {%
80 \LocallyStopLineNumbers%
81 \begin{tcolorbox}[breakable,
82 enhanced,
83 width = \textwidth,
84 colback = paper, colbacktitle = paper,
85 colframe = gray!50, boxrule=0.2mm,
86 coltitle = black,
87 fonttitle = \sffamily,
88 attach boxed title to top left = {yshift=-\tcboxedtitleheight/2, xshift=.5cm},
89 boxed title style = {boxrule=0pt, colframe=paper},
90 before skip = 3mm,
91 after skip = 3mm,
92 top = 2.5mm,
93 bottom = 1.5mm,
94 title={\scshape\sffamily #1}]%
95 }
96 {%
97 \end{tcolorbox}%
98 \ResumeLineNumbers%
99 }
100
101
102 \newcommand{\multifootnotepackage}{{\normalfont\textsf{multifootnote}}}
103
104 \begin{document}
105
106 \def\PackageVersion{2024/03/24}
107
108 \title{\multifootnotepackage{}\\\smallskip\itshape Multiple numbers for the same footnote}
109 \author{Jinwen XU}
110 \thanks{Corresponding to: \texttt{\multifootnotepackage{} \PackageVersion}}
111 \date{\TheDate{\PackageVersion}[only-year-month], in Paris}
112
113 \maketitle
114
115 \begin{abstract}
116 \raggedleft
117 The package \multifootnotepackage{} provides two groups of commands for generating\\footnotes which correspond to multiple numbers (or marks, if you prefer).
118 \end{abstract}
119
120
121 \addtocounter{section}{-1}
122 \section{Introduction}
123
124 In some cases, you may wish for certain footnotes to correspond to several places in your text. The traditional solution usually involves writing the same footnote mark multiple times at the corresponding places. However, this approach makes it difficult to see at once how many times a footnote has been referred to. Therefore, the current package proposes another method: writing the footnote marks in linear order, and allowing a footnote text to match several of these marks.
125
126
127 \section{How to load it}
128
129 You can simply load the current package with:
130
131 \begin{code}
132 \usepackage[(*\meta{options}*)]{multifootnote}
133 \end{code}
134
135 \medskip
136 It has the following options:
137 \begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em]
138 \item \packageoption{backref}
139 \begin{itemize}
140 \item Enable backward referencing from the footnotes.
141 \end{itemize}
142 \item \packageoption{left align}
143 \begin{itemize}
144 \item Align the footnotes to the left.
145 \item Alternative names: \packageoption{left-align} \,$|$\, \packageoption{leftalign}
146 \end{itemize}
147 \item \packageoption{left indent} or \packageoption{left indent} \lstinline|=| \meta{length}
148 \begin{itemize}
149 \item Similar to \packageoption{left align}, but with an indentation \meta{length}, default to be \texttt{1.5em}.
150 \item Alternative names: \packageoption{left-indent} \,$|$\, \packageoption{leftindent}
151 \end{itemize}
152 \item \packageoption{manual}
153 \begin{itemize}
154 \item Use the manual version of the commands. This means that you shall need to manually specify the place where the footnote text should print (by placing the \lstinline|\multifootnote| commands in the appropriate places). You should only use this option when the automatic result does not fit your need.
155 \item Alternative names: \packageoption{manual-mode} \,$|$\, \packageoption{manual mode} \,$|$\, \packageoption{manualmode}
156 \end{itemize}
157 \end{itemize}
158
159 \clearpage
160 \section{How to use it}
161
162 Here are two approaches for producing a footnote with multiple numbers, and in either of them, there are two commands involved.
163
164 \subsection{First approach}
165
166 This approach is more or less traditional, with one command to produce the footnote mark and another the text.
167 \begin{itemize}
168 \item \lstinline|\multifootnotemark[|\meta{label}\lstinline|]|
169 \begin{itemize}
170 \item This command is for producing the footnote marks.
171 \item \meta{label} cannot contain commas. However, colon \textquote{\texttt{:}} and semicolon \textquote{\texttt{;}} are allowed.
172 \item Alternative name: \lstinline|\footnotenumber[|\meta{label}\lstinline|]|.
173 \end{itemize}
174 \item \lstinline|\multifootnotetext[|\meta{list of labels}\lstinline|]{|\meta{footnote text}\lstinline|}|
175 \begin{itemize}
176 \item This command is for producing the footnote text.
177 \item \meta{list of labels} is a list of labels that you specified with \lstinline|\multifootnotemark[|\meta{label}\lstinline|]|, separated with commas, like this: \commandoption{fn1,fn2,fn3}.
178 \item It should not be too far away from the corresponding marks.
179 \item Alternative name: \lstinline|\multifootnote[|\meta{list of labels}\lstinline|]{|\meta{footnote text}\lstinline|}|.
180 \end{itemize}
181 \end{itemize}
182
183 \subsection{Second approach}
184
185 This approach is considered more convenient, with one command to specify the \meta{tag} while printing the footnote mark, and another to print the footnote text for this group.
186 \begin{itemize}
187 \item \lstinline|\multifootnotetag{|\meta{tag}\lstinline|}| or \lstinline|\multifootnotetag{|\meta{list of tags}\lstinline|}|
188 \begin{itemize}
189 \item This command is for producing the footnote marks.
190 \item \meta{tag} cannot contain commas. However, colon \textquote{\texttt{:}} and semicolon \textquote{\texttt{;}} are allowed.
191 \item \meta{list of tags} is a list of tags, separated with commas, like this: \commandoption{fntag1,fntag2,fntag3}.
192 \item Alternative name: \lstinline|\footnotetag{|\meta{tag}\lstinline|}| or \lstinline|\footnotetag{|\meta{list of tags}\lstinline|}|.
193 \end{itemize}
194 \item \lstinline|\multifootnotetagtext[|\meta{tag}\lstinline|]{|\meta{footnote text}\lstinline|}|
195 \begin{itemize}
196 \item This command is for producing the footnote text.
197 \item It should not be too far away from the corresponding marks.
198 \item Alternative name: \lstinline|\multifootnote[|\meta{tag}\lstinline|]{|\meta{footnote text}\lstinline|}|.
199 \end{itemize}
200 \end{itemize}
201
202 \begin{tip}
203 \lstinline|\multifootnote| appears in both approaches for producing footnote text: it shall be interpreted as \lstinline|\multifootnotetext| if the optional argument is a comma-separated list, and as \lstinline|\multifootnotetagtext| if not. See the examples below.
204 \end{tip}
205
206 \begin{tip}[Attention]
207 Notice that in the first approach, \meta{label} appears as an optional argument of \lstinline|\footnotenumber[|\meta{label}\lstinline|]| (thus square brackets); while in the second approach, \meta{tag} is a mandatory argument of \lstinline|\footnotetag{|\meta{tag}\lstinline|}| (thus curly brackets).
208 \end{tip}
209
210 \vfill
211 \begin{center}
212 \itshape
213 If you're feeling confused, don't worry. Let's now take a look at some examples.
214 \end{center}
215 \vfill
216
217 \clearpage
218 \section{Examples}
219
220 Here are two examples of usage, with the package option \textquote{\packageoption{left indent}} enabled.
221
222 \subsection{The first approach}
223
224 \medskip
225 \begin{code}
226 Lorem ipsum\footnotenumber[(*\commandoption{fn1}*)] dolor\footnotenumber[(*\commandoption{fn2}*)] sit amet\footnotenumber[(*\commandoption{fn3}*)], consectetur\footnotenumber[(*\commandoption{fn4}*)] adipiscing elit\footnotenumber[(*\commandoption{fn5}*)].
227 \multifootnote[(*\commandoption{fn1,fn2,fn5}*)]{This is a footnote for demonstration.}
228 \multifootnote[(*\commandoption{fn1,fn3,fn4}*)]{This is another footnote for demonstration.}
229 \end{code}
230
231 Result:
232
233 \vspace{.5\baselineskip}\hrule\vspace{-.25\baselineskip}
234 Lorem ipsum\footnotenumber[fn1] dolor\footnotenumber[fn2] sit amet\footnotenumber[fn3], consectetur\footnotenumber[fn4] adipiscing elit\footnotenumber[fn5].
235 \vspace{.25\baselineskip}\hrule
236 \multifootnote[fn1,fn2,fn5]{This is a footnote for demonstration.}
237 \multifootnote[fn1,fn3,fn4]{This is another footnote for demonstration.}
238
239 \medskip
240 \subsection{The second approach}
241
242 \medskip
243 \begin{code}
244 Lorem ipsum\footnotetag{(*\commandoption{fntag1,fntag2}*)} dolor\footnotetag{(*\commandoption{fntag1}*)} sit amet\footnotetag{(*\commandoption{fntag2}*)}, consectetur\footnotetag{(*\commandoption{fntag2}*)} adipiscing elit\footnotetag{(*\commandoption{fntag1}*)}.
245 \multifootnote[(*\commandoption{fntag1}*)]{This is a footnote for demonstration.}
246 \multifootnote[(*\commandoption{fntag2}*)]{This is another footnote for demonstration.}
247 \end{code}
248
249 Result:
250
251 \vspace{.5\baselineskip}\hrule\vspace{-.25\baselineskip}
252 Lorem ipsum\footnotetag{fntag1,fntag2} dolor\footnotetag{fntag1} sit amet\footnotetag{fntag2}, consectetur\footnotetag{fntag2} adipiscing elit\footnotetag{fntag1}.
253 \vspace{.25\baselineskip}\hrule
254 \multifootnote[fntag1]{This is a footnote for demonstration.}
255 \multifootnote[fntag2]{This is another footnote for demonstration.}
256
257 \bigskip
258 \begin{tip}
259 The second approach is more recommended, as it involves fewer labels, and you shall not need to worry about the order of footnote marks in \lstinline|\multifootnote|.
260 \end{tip}
261
262 \begin{tip}
263 By default, it doesn't quite matter where you put \lstinline|\multifootnote|. However, if you have enabled the package option \packageoption{manual mode}, then the corresponding footnote text shall be added to the current page immediately at where you write \lstinline|\multifootnote|.
264 \end{tip}
265
266 \bigskip
267 \begin{tip}[Attention]
268 You should choose an approach you like and stick to it in your document. It is not recommended to use them both within the same document!
269 \end{tip}
270
271
272 \clearpage
273 \section{Regarding the manual version}\label{sec:manual-mode}
274
275 Though the manual mode is not very convenient to be used by default (via the package option \packageoption{manual}), it is still useful to be able to switch to this mode in some cases. For example, the automatic mode would not work within a box, as with the usual footnotes; also, the automatic mode would not work quite properly when the footnote text is too long to fit into the current page. In such situations, you could switch to the manual mode temporarily, with which you could write the \lstinline|\multifootnote|, and thus typeset the footnote text outside the box.
276
277 To do this, you just need to add the suffix \textquote{\lstinline|manual|} to the commands you are using, that is:
278 \begin{itemize}
279 \item \lstinline|\multifootnotemarkmanual| and \lstinline|\multifootnotetextmanual|
280 \end{itemize}
281 for the first approach, and
282 \begin{itemize}
283 \item \lstinline|\multifootnotetagmanual| and \lstinline|\multifootnotetagtextmanual|
284 \end{itemize}
285 for the second approach. Of course, we still have the alternative names to them:
286 \begin{itemize}
287 \item \lstinline|\footnotenumbermanual| for \lstinline|\multifootnotemarkmanual|,
288 \item \lstinline|\footnotetagmanual| for \lstinline|\multifootnotetagmanual|, and
289 \item \lstinline|\multifootnotemanual| for \lstinline|\multifootnotetextmanual| or \lstinline|\multifootnotetagtextmanual|.
290 \end{itemize}
291
292
293 \section{Acknowledgement}
294
295 This package arises from a question (\href{https://tex.stackexchange.com/q/645330}{\texttt{645330}}) on \texttt{TeX.StackExchange}. The author thanks user \href{https://tex.stackexchange.com/users/270985}{\textsf{@Bolzano}} for bringing up the question of producing such footnotes.
296
297 The author thanks \href{https://tex.stackexchange.com/users/2388}{\textsf{Ulrike Fischer}} for the code for fixing the broken hyperlinks generated by the first approach, and user \href{https://tex.stackexchange.com/users/73317}{\textsf{@frougon}} for his kind and helpful suggestions and comments.
298
299 The author also wishes to thank user \href{https://tex.stackexchange.com/users/213149}{\textsf{@antshar}} for proposing the second approach. The code is surprisingly simple but works just as fine as that of the first approach.
300
301 During the creation and improvement of this package, the author benefited from numerous helps and inspirations from \texttt{TeX.StackExchange}, which is greatly appreciated.
302
303 \section{Known issues}
304
305 \begin{itemize}
306 % \item When package \textsf{hyperref} is loaded, hyperlinks to those footnotes generated by the commands here cannot point to the correct place.
307 \item \multifootnotepackage{} is not compatible with the package \textsf{footnotebackref}. However, this is not a serious problem: with the package option \packageoption{backref}, you should be able to get a similar result for which \textsf{footnotebackref} is supposed to achieve.
308 \item The automatic mode cannot deal with the situation where the footnote text is printed across pages. One should consider using the manual mode in this case, as mentioned in~\S\,\labelcref{sec:manual-mode}. However, it might be preferable to use endnote instead of footnote when there are too many footnotes or when the intended footnote text is too long.
309 \end{itemize}
310
311 \medskip
312 If you run into any issue or have ideas for improvement, feel free to discuss on:
313 \begin{center}
314 \url{https://github.com/Jinwen-XU/multifootnote/issues}
315 \end{center}
316 or email me via \href{mailto:[email protected]}{\texttt{[email protected]}}.
317
318 \end{document}