Skip to main content
All CollectionsAuthor Help
My code samples are getting line-wrapped with backslashes. What can I do?
My code samples are getting line-wrapped with backslashes. What can I do?

Keywords: line wrap, line-wrapped, backslash

Leanpub Support avatar
Written by Leanpub Support
Updated this week
My code samples are getting line-wrapped with backslashes. What can I do?

If a line of code is too long, Leanpub's book generators will automatically line-wrap the line of code, adding a backslash "continuation character" where the line of code is being broken.

We Recommend Manually Wrapping Your Code

You can wrap at 78 columns, which is the widest you should go with the default Technical (Beta) book theme.

However, we recommend 70 or 74 column code, to be future-proof against theme changes and to ensure a happy time if you export a print-ready PDF for publishing on Amazon KDP etc.

Here's a screenshot of an example in our Browser writing mode:

Here's what that would look like in a book:

If You Don't Want to Manually Wrap Your Code Lines, Try This

Instead of manually line-wrapping your code, you try changing the "global" settings on your book, to see if that fixes the problem.

First, try changing your Book Theme to the "Technical" theme, which increases the PDF page size from the default Nonfiction Book Theme that is used for new Leanpub books.

You can learn more about changing your Book Theme here:

Second, choose the "Custom" Book Theme and try making the Font size smaller:

In the Custom Theme, you can also try changing the Code Font:

OK, that's it!


Calls to Action for Authors

If you have any feedback or questions about this article, please email the Leanpub team about it at hello@leanpub.com!

If you have any questions or thoughts on writing and self-publishing with Leanpub, please join our global community of authors in our Authors Forum here!

Interested in creating your first Leanpub book? Here are some quick tutorials for our most popular writing modes: http://help.leanpub.com/en/articles/3088382-quick-walkthroughs-for-getting-started-on-a-leanpub-book

Are you looking for great deals on Leanpub ebooks, ebook bundles, and courses? Sign up for our Weekly and Monthly newsletter sales here!

Did this answer your question?