Linking internally to parts of a chapter?

I want to know how to link internally to a part of the document. I’m doing a Bible and links are a real big part of that. I did it in Sigil a while ago and it wasn’t simple. I would do each book and then each part of the book in the bible and then have a main book selection at the beginning of the Bible then dial it in when you got to the book you wanted. Genesis → 2 → 10 or whatever. I watched many videos on how Scrivener works and can’t seem to find that information quickly. I’ll do more searches but I wanted to ask here as well.

If you want links that compile, you need to split your documents in your project.
The links do not point to text within a document, but rather to a document.
So split where the link should lead.

Then you drag the “to” document from the binder to where you want the link to be. (In the “from” document’s text.)
You can then right-click the link and edit the text (say you don’t want it to be that target document’s title in the binder).
You can also – alternatively – select the text that is to be the link anchor, and drag the target document from the binder to that text selection.

1 Like

Ok do you suppose that’s in the documentation? I kind of got that because im Sigil you definitely, from what I remember, I had to make a bunch of anchors and then link to those which is terrible but worth it in the end.

Chapter 10
. . . . . .

I have no idea how to edit. What I did before was to make a page per chapter which is insane. Then do the anchor thing. As long as it’s in the documentation I should be good.

773 pages for the documentation. My goodness. Very nice. Thanks.

That’s how an ebook has to be. (Can’t have two chapters in the same file – unless you don’t mind not having a TOC to your book. ← But your readers will, mind.)

Ok but there’s no way to link to a point from within a page? I had to reread that like 50 times to wrap my head around that.

No.
I have my own way of doing it inside a project, but that’s just for the time I spend working on it in Scrivener. It is not some functionality that can be compiled or exported. (Nothing like a real link.)
Links only link to documents. Not to a specific place within a document.

Ok then. Not to be that guy but literal anchors exist inside of Sigil there’s anchors and I’d assume you can do the same thing. It’s just 2 pages and it’s linking to the page sure but it’s going to somewhere specific on the page so if you have a chapter in the Bible and you have 70 verses then it just goes to the 70th verse. You don’t have to just scroll all the way down every single time.
anchors exist.zip (2.2 KB)

You are not the first one to ask for it.
Yes, some other apps have that.

Here is how I do it if you are interested, and I suppose that you could leave them markers in there as a way to speed up the post-process in Sigil, and remove them once done (still in Sigil).

Check this and the previous post from me in that same thread :

. . . . . . . . . . .
Another way of handling it :

I’m just going to attempt to get a refund it that’s at all possible. I can’t believe setting an anchor and linking to that anchor on a specific page is this insanely impossible. I might probably not get a refund because I think Scrivener just makes it easier but an epub is literally xhtml pages. So is all the other ebookish type files. I don’t understand how Sigil has basic anchors yet Scrivener doesn’t. They really need to download Sigil and use it for 5 seconds. It’s a basic anchor and it’s like they are trying to over engineer linking things. I see 0 reason to link in Scrivener if it’s that autistic, and I’m autistic.

If you find Sigil meets your needs, you are of course welcome to use it.

If you already have a complete manuscript – whether a Bible or your own work – Scrivener is probably not the best tool.

Our return policy is here: FAQ | Literature & Latte

They really need to download Sigil and use it for 5 seconds.

I do (although for a considerably longer duration than 5s on average), and consider the pairing between Scrivener and Sigil / Calibre to be essential—though ultimately most of what I do in Sigil ends up encoded into Scrivener somehow, either as text, or compile settings. I.e. the Sigil environment is fantastic for design since you can work on the CSS in a real-time environment, it’s also good for testing tech solutions. But once I have either of those I plug them into Scrivener and move on, as that part is now there whenever I compile.

So to get to the point, Scrivener can of course insert HTML anchors and the links to them! There are two different major approaches to how one would do so (and slight variations within them):

  1. Firstly, consider using Pandoc to convert to ePub instead of the native exporter. It will produce a much cleaner HTML source to work from, when designing the CSS or making other modifications, but you can also type in whatever HTML you need without any fanfare and have it pass-thru verbatim into the ebook. In this case you might as well use Pandoc’s native markup for cross-referencing though, since it will handle the .xhtml addressing for you (in cases where a link jumps major sections). As generators, both Scrivener and Pandoc build out the internal files sequentially which can mean filename shifting if you shuffle sections around.
  2. If writing in Markdown, or setting up your work to compile well to Markdown doesn’t sound like something you’d be interested in, then you can make use of pass-thru styles to drop raw HTML into the output rather than having it escaped and printed as visible text.

I’ve attached a sample project that shows both methods.

ebook_links.zip (179.9 KB)

Pandoc method

You will need to install the converter as it doesn’t ship with Scrivener. It’s got a simple .msi / .pkg installer for Win/Mac users respectively. After running that, restart the software so Scrivener can detect the install and add the necessary compile methods.

With that set up, load the sample project and open the compiler. It should say “Pandoc → ePub” at the very top, if the install went as it should, and the rest should already be set up for you. Give that a test compile, open it in Sigil, and compare alongside with the source.

Explanation...
  1. In the Draft folder, click on the “cross-reference examples” item, within the “Pandoc Example” book in the draft.
  2. In the first example we see the raw HTML approach. As noted you would need to know how Pandoc numbers files internally and either anticipate the target name or fetch it from a test compile.
  3. The second example demonstrates how we can leave that menial task up to Pandoc. It will build an index of all the anchors we declare, and route them automatically to the right internal .xhtml file. All we need to do then is provide the anchor ID as the link target.
  4. Now load up “link targets” to see how these are marked up. You can click between the comments to jump straight to the examples. The first example in the target section demonstrates the native Pandoc way of classing and IDing a div (which is designated with the ::: markers).
  5. The second example is straight-forward and shows the raw HTML approach. Again I wouldn’t bother with that, for not only does it require more manual labour, it clutters up the editor and reduces the flexibility of the output, in case we want something other than ePub.

Native Scrivener

Before compiling, check out the example sections in the “Scriv Example” book. The notable things here are:

  • We are using a special character style, called “Raw HTML”, to type in the link and anchor. The compiler will be set up to pass-thru verbatim anything typed into these character styles.
  • With native Scrivener, there is no indexing of IDs or routing, like Pandoc provides, so we do need to know the internal xhtml naming scheme.
Compiling an example

Now to test the output:

  1. Open the compiler again, and switch to Compile for ePub3 at the top.
  2. We’re using the stock “Ebook” compile format, which conveniently has this “Raw HTML” character style already set up for you. All you have to do is define it in the project to make use of it.
  3. To see how such a thing is set up, double-click on the “Ebook” Format to duplicate and edit it, and click into the Styles tab. Select the “Raw HTML” style, and note how the Treat as raw markup setting is enabled. That’s your pass-thru.
  4. Go ahead cancel out of that, make sure to select the “Scriv Example” book in the Contents tab, and give it a test compile.

Conclusion

Of course now that you know how this can be done in theory, no matter which method you use, you also now know how to go beyond whatever Scrivener doesn’t address natively. With the ability to insert your own HTML there are few limitations.

1 Like

Ok but again it’s over engineering something to the point that it’s like 50 hats on top of each other when all I need are socks. I get that’s not the view that Scrivener has but wrapping ones mind around an anchor and the link goes to where the anchor is, is literally A → Z. There’s not 50 steps in-between with tons of mind altering buttons you have to know what each one means. I’ll check out the zip but just add anchors in the next release because I’m sure it’s something anyone would find useful. The application has been out for a substantial amount of time and a free app has anchors. I get what Scrivener does. Just add anchors in the next update and I’ll have 0 qualms or issues about the application. That’s my only gripe.

Sorry, I’m confused? What is “over-engineered” about typing in <a id="point-here"/> and then linking to it from elsewhere? None of the things I mentioned involved anything approaching “50 steps”. And more confusing, how is that any different than Sigil?

Well, as someone else on the spectrum, I don’t have a good innate understanding of hyperbole, but I think maybe I do understand you have your mind already made up. If typing [please link to this spot](#blah) in your text and then having that point to a spot with #blah anchored is “mind altering buttons” or whatever, I have no way of communicating with you.

I’ll check out the zip…

So you didn’t even look at what I was showing. I see.

As I said. Mind Already Made Up™. :laughing:

3 Likes

Well no, it’s not. In any software, you need to make a mark where Z is, then you need to create a pointer to it at A. Which is precisely what you would do in Sigil or Word, and precisely what Ioa described in Scrivener.

Now, unlike Sigil, Scrivener also serves a large number of users who are not creating ebooks and have no need for (or interest in) digging down into the weeds of HTML. So Scrivener does require some additional work to say “yes, we’d like to handle raw HTML, please.” If you find that to be an example of “over-engineering,” well, we’re sorry, but we aren’t going to change. In fact we can’t change and still continue to serve our other users.

4 Likes