summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ximera/src/footnotes.dtx
blob: cd37a086e4fdcbdc4f0f0e1f045f18e97732a460 (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
% \subsection{How to handle footnotes in this setting.}
% \DescribeMacro{\footnote}{% Written by Jason Nowell Standard Footnotes in pdf, but expandable parenthetical online. Supports different coloring by using |\colorlet{fncolor}{COLOR}| and setting COLOR to whatever color you want (Default is blue).}%
% 
%    \begin{macrocode}
%<*htXimera>
\newcounter{footnoteNum}% This will track footnote numbering for the superscript and for the ID.
\colorlet{fncolor}{red!30!blue}% This is the footnote text coloring. This will allow users to renew this coloring to their own preference if they want to. The default here is a blue coloring. NOTE: Currently; trying to use `footnotecolor' (as a more descriptive color name) breaks everything on my system pretty spectacularly for some reason. This may be just mine or a clash somewhere in the ximera package, so for now I'm leaving it as `fncolor'.
\renewcommand{\footnote}[1]{\ifvmode\ShowPar\fi
    \stepcounter{footnoteNum}% Step the counter to make a new footnote
    %% The following HCode should setup the javascript function that shows or hides the footnote. If you want to change the footnote location, you may want to change the 'inline' part of x.style.display = 'inline'; to another CSS display type, like 'block' or 'inherit'. Current the `x.display.color' seems to not be working.
    \HCode{
    <script type="text/javascript">
            function footnotefunction(ID) {
              var x = document.getElementById(ID);
              if (x.style.display === "none") {
                x.style.color = "blue";
                x.style.display = "inline";
              } else {
                x.style.display = "none";
              }
            }
    </script>
    }
    %% The next command needs \expandafter in order to expand the counter footnoteNum into a roman character for the footnote ID. These seem to work better than arabic numerals in some cases, although why is not clear.
    %% The next HCode controls the formatting for the actual footnote reference number (ie the superscript), but not the footnote itself.
    \expandafter\HCode{
    <span style=
            "position=relative;
            vertical-align=baseline;"
            >
            <button onclick="footnotefunction('footnote\roman{footnoteNum}')"
                style=
                "background:none!important;
                 color:inherit;
                 border:none; 
                 padding:0!important;
                 font: inherit;
                 cursor: pointer;"
                >
            	<sup>}[\arabic{footnoteNum}]\HCode{</sup></button>
        }
    %% The next command needs \expandafter in order to expand the counter footnoteNum into a roman character for the footnote ID. These seem to work better than arabic numerals in some cases, although why is not clear. Note that the ID counter style choice (roman vs arabic etc) needs to match the previous HCode choice.
    %% Currently most of the formatting doesn't seem to work as intended, so that still needs to be figured out and fixed. Ideally we would have the footnote appear as a bubble above the footnote superscript when the footnote superscript is clicked.
    \expandafter\HCode{
            <span id="footnote\roman{footnoteNum}"
                style=
                "display:none;
                min-width:20em;
                position:relative;
                left:2px;
                padding:5px;
                color:blue;
                word-wrap:break-word;
                z-index=9999;
                overflow=auto;"
                >
            }
            \textcolor{fncolor}{(#1)}% Display the actual footnote here with color `fncolor' and within ()'s.
        \HCode{</span></span>}
    }% End of footnote definition.
%</htXimera>
%    \end{macrocode}