Digital Translation to Ebook
Notes on how to transform a physical book to its best digital self, so it makes the trip to Mars and lives on forever.
Tools
Hardware
My first choice was to build an Archivist Quill. Due to COVID-19's impact on supply chains for electronics, collecting components will take more time.
My second choice was a new product line from Hong Kong that been expanding through crowdsourcing. A CZUR Aura, their mid-range scanner (~$300 USD), was in-stock on Amazon and arrived the next day.
Product Page: https://shop.czur.com/products/aura?variant=28598339436592
Using the Aura is easy and quick. You place the book on the mat, open to the page, and tap the foot switch to capture. Three red laser lines appear across the pages during the scan. When they disappear, you turn to the next page. Our Aura is connected to a MacBook Pro running the CZUR software. The software stores the captured images and then processes them into digital documents, PDF, DOCX, etc.
Update: Have upgraded to a CZUR ET18 Pro
Update: Upgraded to CZUR ET24 Pro
Software
WebStorm (IntelliJ)
WebStorm is an Integrated Development Environment and my current text editor of choice. There are many other options, choose wisely. (Crosses fingers—please don't spark another emacs vs. vi like-war.)
- For working with TeX files, I installed the TeXiFy IDEA plugin.
- Prettier is a code formatting library and with a plugin, it will format LaTeX documents.
- Prettier plugin for LaTeX, lets Prettier format LaTeX documents.
- LatexIndent library
brew install latexindent - In preferences, I added
\*.texto Soft-wrap these files in Editor > General > Soft-Wrap section. LaTeX prefers on newline per sentence, so soft-wrap make files easier to read. - WebStorm integrates with GitHub, so all changes to the book are tracked with git.
- Text is easier to edit using monospaced/fixed-width fonts since visual differences and corrections are easier to spot. I use PragmataPro, but there are many popular fonts for coding like Inconsolata, Fira Code, MonoLisa, Space Mono, Hack, or Source Code Pro.
- Setting > Editor > Inspections > LaTeX > turned off warnings for sentences starting on a new line to work better with Prettier formatting.
- Setting > Languages & Frameworks > Javascript > Prettier > Selected Automatic Prettier Configuration. Added
texto the list of file name extensions in the "Run for Files" field.
Pandoc
Think of this as the Babel Fish of text documents. One of
the big productivity boosts I stumbled onto was pandoc. Its creator, John McFarlane, is a long-time LaTeX user so support for it is great. Scanning a book into DOCX retains document formatting, that pandoc translates directly to LaTeX. Compared to bringing in plain text and hand decorating lines into LaTeX, pandoc saves hours of tedious, error-prone work.
TeX Live (MacTeX)
To produce TeX «tech» documents, you need to install a TeX environment. On a Mac, I use MacTex. It is a large collection of software, so they offer a smaller download as BasicTex.
TeX Live Utility helps keep all the packages updated.
TeXShop provides a basic text editor and typesets your file into a PDF.
Kindle Previewer
Kindle Previewer is how you prep a book for the Kindle Publishing platform. Once completed, books can be sold on Amazon for Kindle or as physical books with their print on demand service. I use it to convert to the latest version of the Kindle format, .kpx, to handle advanced typesetting—custom fonts and rendering math. Since I do not publish to Amazon, the Previewer file goes through another conversion step and is side-loaded to my Kindle—means I connect Kindle over USB and transfer the file from my laptop. .kpf or .kfx file types can't be uploaded via email or over WhisperNet.
To update to latest version: kindlepreviewer -update
Calibre
Calibre «cal-i-ber» is an eBook collection manager with tools for format conversions. It will convert text to html, ePub, Mobi and many other ebook types.
Skim
Unlike Adobe Acrobat Pro, Skim will refresh the PDF when it changes on disk. When generating new ebook versions with our script, the PDF is opened/reloaded for review.
The Process
- Scan the book
- Crop out images
- Convert images scans to DOCX (preferable to preserve some document formatting)
- Covert DOCX into .tex with pandoc
- Add LaTeX macros, convert content, and proofread .tex file in WebStorm (repeat, repeat, repeat)
- Typeset .tex file into PDF
- Convert .tex to html using
tex4html - Convert .html to ePub using
Calibreortex4ebook - Test ePub with ePubCheck and fix errors
- Convert .ePub to .kpf using Kindle Previewer
- Convert .kpf to .kpx using Calibre
- Convert .epub to markdown (.md)
- Alter .md into a wiki.js page.
Levels of Completeness (Galley - Editing - Typesetting - Proofreading - Distribution)
- Images of text (jpg, tiff)
- Readable text
- Images included
- Footnotes
- References
- Index
- Glossary
- List of Figures
- List of Tables
- List of Equations
Convert Content
- Chapters
- Images, Figures
- Appendixes
- Epilogue
- Index
- References
- Glossary
Proofread
- Define Paragraphs --- put extra empty line between sentences
- New line at end of each sentence --- WebStorm "Join Lines"
- Change double quotes " " to open quote `` and close quote ''
- Convert
. . .to\textellipsis - Space after abbreviations (Dr.\ , Mr.\ , Mrs.\ , Ms.\ , Fig.\ , St.\ , U.S.\ ,
U.S.S.R.\ , vs., Inc., N.\Y.\ ) - Fix scannos, OCR mistakes (
- l <-> 1
- m <-> rn (bom -> born)
- . <-> -
- . <-> ,
-
- -> ---
- die -> the
- C -> G
- `/ -> Y
- id -> ul
- 11 -> II
- Hyphens (-), en dashes(--), em dashes(--- ->
\textemdash) - Symbols --- degrees, pi, math, dots
- Lists --- environment for itemize or enumerate
- Define small fractions - 1/2 ->
\sfrac{1}{2} - Italicized/Emphasized words
- Acronym definitions
- Glossary definitions
- Equations
- Tables
- Footnotes
- Figures
- References --- beware of
#in.bibentries - Index items and links
Produce eBooks
Determine Scan Image Sizes
magick identify * | cat > images.txt
docx from scanned pages -> LaTeX with images
pandoc --extract-media ./images -s FILENAME.docx -o FILENAME.tex
HTML
make4ht -l FILENAME.tex "htm,pic-align,notoc*" -d FILENAME-html
ePub3
tex4ebook -l -c FILENAME.cfg -t -f epub3 FILENAME.tex
Check ePub file
java -jar epubcheck.jar FILENAME.epub
KPF with Kindle Previewer 3
kindlepreviewer FILENAME.epub -convert
Kindle Version
tex4ebook -l -c FILENAME.cfg -t -f azw3 FILENAME.tex- Open .epub in Kindle Previewer
- Export file as a .kpf
- Import .kpf into Calibre
- Export .kpf as a .kpx
- Side-load .kpx to a Kindle e-Reader
Install MacTex on Mac OS
- Download from https://tug.org/mactex/mactex-download.html
- Check md5 hash to confirm complete file downloaded
- Install MacTex.pkg
- Update LaTeX packages
sudo tlmgr update --selfsudo tlmgr update --all
- Install Ghostscript https://www.tug.org/mactex/morepackages.html
- Install a modern version of Tidy to clean up output HTML
brew install tidy-html5 - Install diff-pdf for visual comparison of pdfs
brew install diff-pdf - Install ePubCheck
curl -SL https://github.com/w3c/epubcheck/releases/download/v4.2.6/epubcheck-4.2.6.zip | tar -xf -