: How do I insert programming code snippets within Scrivener? I'm trying out Scrivener, as I intend to write some technical material. I'm a Software Developer and what I intend to write is programming
I'm trying out Scrivener, as I intend to write some technical material. I'm a Software Developer and what I intend to write is programming related.
I still wasn't able to figure out how can I insert code snippets in Scrivener so they look nice.
Here's an example of a code snippet:
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
Here is an example of how I want it to look, with syntax highlighting:
Is this possible with Scrivener? I know I could just insert images of the code, but I don't want to follow this approach, as when I export the PDF it can make the life of the reader much harder (maybe a reader just want to copy and paste), and it can also make my life much harder, as if I want to change a code snippet I can't just edit within scrivener.
It's worth mentioning that I'm using Scrivener for Windows.
More posts by @Voss1744584
: How to survive editing I am currently trying to edit a one my most recent novel. Trying is the keyword. I asked a few people to read my book as beta readers, but all of them have been
: Do writers copy other writers? Good artists copy; great artists steal. This famous Picasso quote often reminds me that the best artworks are rather a mix of many other artworks instead
1 Comments
Sorted by latest first Latest Oldest Best
A quick Google reveals some possible solutions:
"set up your code snippets in a syntactic editor then copy and paste into a Scrivener document, rather than try to replicate that formatting in Scrivener. Each snippet could sit in its own document in the binder, so you could compile those in their prepared format, but then let the rest of the text follow your chosen compile settings."
Another commenter on the same link points out that, if you're using LaTeX for your final output, there are "packages for LaTeX that can do code highlighting within verbatim environments".
"Scrivener 3 has Styles. You can use the Code Block style which switches to a monospaced font suitable for code. When you compile the document, the exact font used can be chosen in the compile settings except for HTML and Epub export where it will use HTML Code tags."
The first option (or LaTeX) seems the better one in my opinion. As a commenter on the first link remarks, Scrivener is a writing program, not a layout program, so you'll likely need to rely on other tools that integrate.
Terms of Use Privacy policy Contact About Cancellation policy © selfpublishingguru.com2024 All Rights reserved.