Is there a way to 'reference plain text' like with ‘reference Inline Footnotes’?

UPDATE 10 Nov 2021 … See below at: Is there a way to 'reference plain text' like with ‘reference Inline Footnotes’? - #6 by scrive for the updated steps to create endnotes when compiling for Plain Text (.txt) to a LaTeX *.tex file.


The ability to ‘reference Inline Footnotes’ (in § 18.2.2 of the manual) to keep the main text clear of long and complex footnotes is a useful feature for footnotes.

Question: Is there a way to reference plain text (not a link) within Scrivener?

For example, if I have a standard text phrase that is:

  1. repeated in many places throughout my project,
  2. is long in length, and
  3. is required in the final document, but also
  4. distracts or otherwise interrupts the flow when reading through the body of pre-compiled text

It would be nice to be able to have a short, unique text phrase as a stand-in for the standard text phrase in the pre-compiled text that (like with ‘reference Inline Footnotes’) is replaced by the standard text phrase when compiled.

Thanks for reading,
scrive
:thinking:

An Update:

I’ve been working on a way to create endnotes in a Scrivener-LaTeX project for those chapters and sections with footnotes that consume the better part of a page in the PDF printout. (See Is there a way to rename a character or paragraph Style? - #31 by scrive).

The solution includes a kludge that uses ‘reference Inline Footnotes’ (in § 18.2.2 of the manual) instead with referenced endnotes that are placed at the end of the appropriate chapter or section (instead of at the bottom of the page) where the endnote marker exists.

I’m left with one last kludgy manual step, however, that I don’t know how to incorporate into the compile process.

The kludge includes adding a short, unique text string that is prepended to each of the endnotes. The unique text string can be searched for and replaced. I prepended the unique text string <[@@]> to each endnote as a ‘referenced Inline Footnote’. Once compiled, the endnote appears as ‘\footnote{[@@]…’ followed by the balance of the endnote text.

What I haven’t been able to automate is to replace the prepended unique text string of the endnote\footnote{[@@]…’ with ‘\endnote{…’ so that after compilation, I’m left with properly formatted endnotes located at the end of the chapter or section.

I’ve tried adding Replacements in both the Project Format screen:

and in the Compile screen:

but neither attempt to replace ‘\footnote{[@@]…’ with ‘\endnote{…’ in the final *.tex file worked as I thought it would.

I suspect the reason why neither of the above attempts at replacements worked is that they both occurred in the internal Scrivener compile process prior to the ‘referenced Inline Footnote’ replacement that creates the ‘\footnote{[@@]…’ text string to begin with.

So, I’m left with manually replacing the ‘\footnote{[@@]…’ text string with ‘\endnote{…’ for any endnotes in the final *.tex file.

If anyone has an idea how I might automate the last step to replace the ‘\footnote{[@@]…’ text string with ‘\endnote{…’, it would eliminate a manual step I’ll need to add after each compile. Not a big deal … I can certainly do a ‘replace all’ easily enough in the post-compile, pre-Typeset Latex screen if there are no other options.

Otherwise, I’m relieved that, even with the added manual replacement step, that I’ll be able to use endnotes in lieu of footnotes for those chapters and sections where there are bulky or numerous footnotes that consume a better part of a page in the PDF printout.

Thanks for reading,
scrive
:thinking:

I think what you may be looking for is documented in §10.1.5, Including Text From Other Documents. There are two ways of using it:

  1. <$include> where the placeholder tag is selected and hyperlinked to the target that should be included at that spot.
  2. <$include:Name of Binder Item> which does not require a link.

There are pros and cons to each method of course. One adapts to item name changes automatically and the other does not, but the second can be influenced by Replacements, which may be of use if you have different sets of prefab text to insert depending on the compile target.

These placeholders can be placed almost anywhere, even inside of footnotes, and when using the “plain-text” form, even in compile settings such as the Section Layout prefix/suffix fields.

1 Like

Hi AmberV,

Thanks for the tip!

I used the second method to achieve the endnotes I needed. To do so, I created small, individual ‘LaTeX Chunk’ Section types, each with a unique name, such as ‘Endnote-XX’ with each Section containing one endnote.

The syntax for the endnote in each Section takes the form:

\endnote{\,<endnote text>}

The \, is LaTeX code to provide a narrow space between the endnote mark (e.g. A, B or C…) and the body of the endnote.

I then included the <$include:Endnote-XX> syntax within the body of the text where ever I needed the endnote mark to appear.

What I still have to learn is how to include the ‘LaTeX Chunk’ Section types in the project for the <$include:Endnote-XX> syntax, but NOT have the Section show up in the PDF output file.

Thank you again for the tip on the <$include:Name of Binder Item> syntax,
scrive
:thinking:

Consider that the text you are including can come from anywhere in the binder, it does not have to be in the draft. You could keep all of these in a folder just below it.

Hi AmberV,

UPDATED - 10 Nov 2021 … see UPDATED summary of 7 steps below:

Actually, I’ve tested a kludge that will eliminate the endnote in the Endnote-XX Section from showing up in the PDF output file.

  1. I prepended the <$include:Endnote-XX> syntax with the text

         '\end'
    

instead to have it appear as:

         \end<$include:Endnote-XX>
  1. I deleted the text ‘\end’ from the syntax for the endnote in each Section to simply:

         note{\,<endnote text>}
    

so that after the ‘\end<$include:Endnote-XX>’ is replaced with the text in Endnote-XX, the compiled text appears as a complete \endnote:

      \endnote{\,<endnote text> }

This way, the whole term ‘\endnote’ does not appear in the Endnote-XX Section which for some reason was triggering that Section to show up in the PDF output file.

Now, with only the word ‘note{’ (and not \endnote{ ) appearing (in the Endnote-XX Section) before the text of the endnote, nothing from the Endnote-XX Section appears in the PDF output file, and the text of the \end + note{\,<endnote text>} appears as endnote at the end of the respective chapter.

Yea! Mission accomplished!! A bit kludgy, but it works!!

Thanks for all your help, including the tip on the <$include:> command.

UPDATED (my apologies) - In summary, to create endnotes in my Scrivener + LaTeX project, I had to:

  1. Move each footnote that I wanted to turn into an endnote from Comments & Footnotes in the Inspector, to a separate ‘Latex Chunk’ type Section (with one and only one endnote per Section) in the Binder.
  2. Give the ‘Latex Chunk’ type Section in the Binder a unique label such as ‘Endnote-XX’ where XX is a sequential alpha or numeric code for each Section, e.g. Endnote-01, Endnote-02 …etc…
  3. Prepend the text of each endnote in each ‘Latex Chunk’ type Section with the syntax ‘\endnote{\,’ (the \, is LaTeX code for a narrow space to provide a slender space between the endnote mark, e.g. A, B or C …, and the endnote text), and add a close curly-bracket, ’ } ’ at the end of the endnote text in the ‘Latex Chunk’ type Section.
  4. In the main body of the text where the endnote mark (e.g. A, B or C…) is to appear, add the following syntax: ‘<$include:Endnote-XX>’. Be sure the sequential alpha or numeric code XX matches what was used to label the ‘Latex Chunk’ type Section as ‘Endnote-XX’ in the Binder, e.g. Endnote-01, Endnote-02 …etc…
  5. If working with LaTeX, be sure to include ‘\usepackage{endnotes}’ in your Setup Preamble Module, and include ‘\theendnotes’ at the end of the chapter or section where the endnotes are to appear.
  6. In an attempt to keep my Binder less cluttered (a constant struggle) for those chapters with multiple endnotes, I moved the endnote ‘Latex Chunk’ type Sections into a separate folder just beneath the corresponding chapter.
  7. A trick I discovered, almost by accident, one that is a bit counter-intuitive for me, is to turn the Include in Compile toggle for the ‘Latex Chunk’ type Sections, OFF!! Yes, OFF, e.g. image.
    As long as the ‘Latex Chunk’ type Sections that contain the endnotes are included in the Binder, the ‘<$include:Endnote-XX>’ code WILL find the endnotes and appropriately include them in the compiled LaTeX .tex file, despite the fact that they are not Included in the Compile. Go figure. Don’t ask me how this works, but it does … and it is the only way I found to prevent the endnote from appearing a second time in the PDF output file.

Now, compile, typeset, and enjoy your new endnotes!

Note: For those using LaTeX and compiling to Plain Text (.txt) files, there may be a much less involved, more straightforward way to create endnotes, but I need to further explore what, if any, Scrivener options can be made available to do so.

scrive
:thinking:

P.S. Here is what the endnotes look like after compiling and typesetting using the method above:

There’s <$include>, but it includes a document, not part of a document.

Hi drmajorbob

Thank you for your feedback.

I hope with my updated 7 steps (to create an endnote) that I outlined above, I was specific enough that each endnote needs to go in a:

Let me know if I need to adjust any of the 7 steps to be clear how Scrivener + LaTeX users can create endnotes.

Thanks again for your feedback,
scrive
:thinking:

I don’t know anything about LaTex.

It seems to me you should just be doing this part in LaTeX. Suppose you just prepended each intended endnote with ‘ZZZ’, and then on the LaTeX side…

% Relies on packages endnotes, ifthen, and xstring.

\let\fnote\footnote
\renewcommand{\footnote}[1]{
  \IfBeginWith{#1}{ZZZ}
  	{\endnote{\StrDel[1]{#1}{ZZZ}}}
	{\fnote{#1}}
}

Voila! We get the desired split between footnotes and endnotes in the typeset output. Also notice your prepended string need not be totally unique — it just needs to be something that you would never start a foot/endnote with.

Works for me.

gr

Addendum: What the code does, line by line:

  • Use the let cmd to set aside original footnote cmd under new name fnote (cuz we still need to call on it).
  • Co-opt footnote cmd so we can adjudicate by contents.
  • Is the content of the note prepended by ‘ZZZ’?
  • If so, push it out as an endnote, but first delete the prepended ‘ZZZ’ marker.
  • Otherwise, send it out as an fnote.
2 Likes

Hi gr,

Thank you for your suggestion.

I’d love to be able to use LaTeX to enable endnotes. There is so much I don’t know about LaTeX, so I appreciate the effort you put into the code you suggested.

I’m running a bit low on energy at the moment, so I’d like to work your suggestion into my project when I’m thinking more clearly.

Let me have a look and get back to you.

Thanks again,
scrive
:thinking:

Somehow, I never realized LaTeX is a programming language.

2 Likes

Hi drmajorbob,

And what a language it is … the typesetting of equations afforded by LaTeX is unassailable … I looked into the way that MathType does equations and realized it would not be enough for what I wanted to do … but that was only the teaser …

LaTeX offers over 6000 separate packages (and counting) with such a wide range of functions, with support on StackExchange et al. … but make no mistake, the learning curve is STEEP. If you have the time and patience, however, the rewards can be endless.

Except for endnotes, for which I have spent weeks trying to accommodate, Scrivener (among other benefits) is the perfect front end for LaTeX.

That said, I am a bit surprised how little feedback I see from other Scriveners regarding the Scrivener + LaTeX interface, e.g. the use of Scrivener Styles to leverage LaTeX macros and to create their own user-defined objects. Scrivener Styles are like Matryoshka dolls - they can provide for entirely new degree of freedom with layers of user defined coding. Quite astonishing once you get the drift of what is possible when Scrivener Styles are combined with LaTeX.

I don’t have data on the number of scientific, research and engineering papers that are created with Scrivener + LaTeX, but I also don’t hear a lot of chatter (there is some chatter, but not what I would expect with such an outstanding application such as Scrivener) on this site regarding scientific, research and engineering papers and PhD thesis, etc.

From my own experience, I wonder if there is, and how large, an untapped market there may be for Scrivener + LaTeX in the scientific, research and engineering fields of study.

Thanks for your comment,
scrive
:thinking:

I’d need an expert to walk me through a LaTeX workflow. That’s how you make the learning curve steep (which is a good thing).

1 Like

Hi drmajorbob,

Thanks for your comment.

The way I got started with Scrivener + LaTeX was with the General Non-Fiction (LaTeX) template that is included in the Mac version of Scrivener (I don’t know about the Windows version).

Without the General Non-Fiction (LaTeX) template, I don’t think I’d be anywhere near where I am today. The Scrivener LaTeX template is even where I learned (with a few guesses along the way) about how to implement the dozens of user-defined Styles that I’ve developed.

And the development continues: just yesterday I figured out how to apply a footnote to an Epigraph … something I’ve wanted to do for a while now as I often use Epigraphs with quotations to set the stage for each section. A nice touch!

Kudos to whomever had the foresight to include the General Non-Fiction (LaTeX) template in the base set of Scrivener templates. Someone was thinking longer term about how to help jumpstart users to include LaTeX when using Scrivener. Thank you to whomever that person was! (I’ve been meaning to do so for some time now.)

Thanks again for your comment!

HTH,
scrive
:thinking:

1 Like

I would bet a :beer: that this person was @AmberV :grinning:

2 Likes

What content do you need in your epigraph footnotes?

@JimRac gets the beer. :slight_smile:

And to @Scrive, you’re most welcome!

I think the important thing to be aware of here is that the choice between endnotes and footnotes (or having both) is fundamentally a LaTeX layout decision and not a Scrivener thing, since Scrivener itself is ignorant of LaTeX. We must teach it everything, and we do so through the configuration of our content and the compile settings.

The project template provides a healthy start on that process of training the software, and by intention it does so in a way that is as vanilla as possible so one can more easily make those decisions and implement them.

So that is why there is no endnote checkbox in the compile overview area, because from that context Scrivener is ignorant of what an endnote is in LaTeX. For it to successfully implement them it would need to know how to do so, and doing so is not always straightforward. Using the endnotes package is a fairly simple tweak, but using both is not, and often require a bespoke setup to accomplish it.

From my own experience, I wonder if there is, and how large, an untapped market there may be for Scrivener + LaTeX in the scientific, research and engineering fields of study.

There very likely is, but the challenge we face is two-fold:

  1. On the surface Scrivener looks like how word processors look, which typically are fairly awful for authoring technical formats like this. You have to dig pretty deep to get past that first impressions in the tutorial and default UI, and into novel areas that few tools address, like using styles for syntax injection, which is very unorthodox and unexpected.

    When you consider how hard-won some people’s workflows are, how much sunk cost fallacy you have to fight against in some cases, it can be difficult to present an alternative that is so different.

  2. We have a reputation for being a tool for novel writers, despite insisting everywhere otherwise, even in the breadth of its offerings for non-fiction work on the surface. I would guess that a lot of that has to do with a preconception of what “software for writers” tends to be. If you look around at many of what people consider to be “competition” for Scrivener, you’ll mostly find tools that really do not work for anything other than novel writing. There are very few writing tools that strive toward general writing. So that it gets lumped together with what the genre seems to on the whole address, makes sense.

These problems aside, the fact is that Scrivener is a very unique tool for authoring technical formats, such as LaTeX. It is largely unknown for that, but you will not find much of anything out there that provides that kind of “front end”. As I’ve mentioned elsewhere, LyX is probably the closest thing to it, but we wouldn’t think of it so much as being a “tool for writers” in the modern sense. It’s closer to a word processor in how it presents the writing workflow. Beyond that, tools for LaTeX are invariably closer to coding editors, where all of the syntax is right in your face and only made less obstructive through conventions such as syntax highlighting—to help make the content easier to find among the symbols.

It would be more accurate to say that TeX is the Turing-complete programming language for typesetting, while LaTeX is a massive corpus of automation (what we refer to as macros) built from that language, that enable those who are not specialist programmers to make use of the system in a relatively comfortable environment for doing so. So in that sense it is closer to how we might think of Cocoa or Qt, which Scrivener is created with on Mac and PC respectively. It’s not a perfect analogy by any stretch, but if know you the relationship between those and Objective-C or C++, it’s a better way of thinking about the relationship.

3 Likes

The citation.

I try doing my best not to forget or miss a proper citation. Just because a quotation exists within an epigraph, I assume it still requires a citation (my knowledge and memory of The Elements of Style is somewhat limited).

N’est pas?

Thanks for your note,
scrive
:thinking:

A citation in what form? A footnote or endnote?