{"id":577,"date":"2012-08-23T23:08:42","date_gmt":"2012-08-24T06:08:42","guid":{"rendered":"http:\/\/bitingduckpress.com\/?p=577"},"modified":"2020-11-24T18:44:51","modified_gmt":"2020-11-25T02:44:51","slug":"footnotes-and-references-in-ebooks","status":"publish","type":"post","link":"https:\/\/bitingduckpress.com\/?p=577","title":{"rendered":"Footnotes and References in Ebooks"},"content":{"rendered":"<p>With a few caveats, making footnotes and similar cross-references in ebooks is pretty simple. The idea is to use html anchors, which can be inserted directly into your html (if you&#8217;re doing it that way&#8230;) or by using Sigil (if you have exported an epub file from InDesign, for example). Both your text editor used for editing the html (TextMate, BBEdit, etc) and <a title=\"Sigil\" href=\"https:\/\/code.google.com\/p\/sigil\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sigil<\/a> support the use of <a title=\"regex\" href=\"http:\/\/www.regular-expressions.info\/\" target=\"_blank\" rel=\"noopener noreferrer\">regular expressions <\/a>for searching, so that the footnotes can be identified in some unique fashion and replaced all at once.<\/p>\n<p>First, the anchors. You can learn more about <a title=\"anchor\" href=\"http:\/\/www.hypergurl.com\/anchors.html\" target=\"_blank\" rel=\"noopener noreferrer\">html anchors<\/a> elsewhere; this is just a really simple-minded introduction that assumes you have just one file, not several&#8211;so I usually do *not* break my epub or html files into chapters. The idea is to go both forward and back&#8211;so if you click the link on the note, it takes you to the list of footnotes, but then you can go back again.This works:<\/p>\n<p>At each reference, put in the following:<\/p>\n<p>&lt;a href=&#8221;#fn(number)&#8221; name=&#8221;fr(number)&#8221;&gt;[number]&lt;\/a&gt;<\/p>\n<p>Then at the footnotes themselves:<\/p>\n<p>[&lt;a name=&#8221;fn(number)&#8221; href=&#8221;#fr(number)&#8221;&gt;(number)&lt;\/a&gt;]<\/p>\n<p>where (number) is the number of your footnote, from 1 up to whatever. All this does is make a back-and-forth link to other places within the same html text. If you have other cross-references in the text, they can be handled the same way&#8211;just give them a different name, for example, use &#8220;app&#8221; for appendix instead of &#8220;fr.&#8221;<\/p>\n<p>OK, that&#8217;s easy&#8230; but how to get this rather beastly expression around each of your innocent little footnotes, which are often just a number? Here&#8217;s where the beauty of regular expressions comes in. You can do a regular expression search for any number of digits &#8220;d+&#8221;and bracket that with your reference. Watch out, though, if there are other numbers in your text! Often there is something else that identifies your footnotes: they&#8217;re in parentheses, or in superscript, or some other specific format. In my latest example, the footnotes were all in a specific style defined by InDesign. So when I opened the exported Epub in Sigil, all footnotes looked like this:<\/p>\n<p>&lt;span class= &#8220;char-style-override 7&#8221;&gt;number&lt;\/span&gt;<\/p>\n<p>So, using regular expressions:<\/p>\n<p>Search: &lt;span class= &#8220;char-style-override 7&#8243;&gt;(d+)&lt;\/span&gt;<\/p>\n<p>Replace: &lt;a href=&#8221;#fn1&#8243; name=&#8221;fr1&#8221;&gt;1&lt;\/a&gt;<\/p>\n<p>Where &#8220;1&#8221; is regular expression-ese for &#8220;that same text that you found&#8221; (some editors use $1).\u00a0 It&#8217;s important to put the &#8220;d+&#8221; inside a pair of parentheses&#8211;that tells the regular expression search to &#8220;capture&#8221; the contents of the parentheses for later use.\u00a0 the &#8220;1&#8221; tells the replace to use the contents of the capture. (note that if you have more than one set of capture parentheses, the first one captures into 1 and the second into 2, and so on.\u00a0 That&#8217;s a topic for a different day&#8230;)<\/p>\n<p>Now that that&#8217;s all done, go down to the footnotes themselves. There are lots of numbers in footnotes referring to pages and things, so you don&#8217;t want to pick them up by accident. Let&#8217;s say the numbers you want to link to are encased in square brackets. Then your life is pretty easy. Do this:<\/p>\n<p>Search: [(d+)]<\/p>\n<p>Replace: [&lt;a name=&#8221;fn1&#8243; href=&#8221;#fr1&#8243;&gt;1&lt;\/a&gt;]<\/p>\n<p>The lesson to take home from this is that if you&#8217;re exporting from a program such as Word or InDesign, you want to have tags on your footnotes that make them easily searchable. If they can be identified in a unique fashion, then formatting them for your e-book is as simple as Search &amp; Replace.\u00a0 The most important thing is to be very consistent so the search can find them!<\/p>\n<p>If there are no tags, you have to be very careful using &#8220;Replace All,&#8221; and may have to scroll through one by one to make sure only the desired targets are chosen, and not some innocent other text with numbers in it.<\/p>\n<p>Happy footnoting! Quack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With a few caveats, making footnotes and similar cross-references in ebooks is pretty simple. The idea is to use html anchors, which can be inserted directly into your html (if you&#8217;re doing it that way&#8230;) or by using Sigil (if you have exported an epub file from InDesign, for example). Both your text editor used [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_links_to":"","_links_to_target":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/posts\/577"}],"collection":[{"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=577"}],"version-history":[{"count":2,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/posts\/577\/revisions"}],"predecessor-version":[{"id":1329,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=\/wp\/v2\/posts\/577\/revisions\/1329"}],"wp:attachment":[{"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitingduckpress.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}