I'm using Texmaker from the MikTex distribution.
What I would like to do, is to
- create Latex code
- run Texmaker to do all the substituitons, e.g. from
\newcommand
- build it as pure ASCII-code rather than as pdf
Question: How to do it, how to configure Texmaker, provided it's possible?
Proposals from your comments: In chronological order:
use or combine with
pdftotext
use
tex4ebook
withDOM-filters
use the
lwarp
packageuse
pandoc
use
markup
My preliminary evaluation of these proposals:
pdftotext
works, of course, and might be useful as a fallback solution if I'd need to redo the epub file 100 % (or in parts) manually withSigil
, see flow below. Excludedlwarp
,pandoc
andmarkup
from this evaluation.I'm confident to achieve my objective by a) running
tex4ebook
with a config-file as proposed by michal.h21, b) useScrivener
to introduce some substituions beforehand, e.g. to preseve work done on\index{}
, c) letSigil
do its magic (re-formatting, TOC, metadata, etc.). // Yes, it will remain a semi-automatic process.Using 2a) alone the created epub-file seems to behave fine with Calibre's eBook reader (software), but gives strange behavior on my iPad (hardware). Haven't dug into it, but probably the
<guide>
section insidecontent.opf
misses some information for some reason. Sth. like that. // Just another reason to follow a minimal-coding strategy, i.e. avoiding as many fancy stuff in the output as possible.Using
make4ht
with the same config file and processing that HTML-file withSigil
on a new epub seems to work fine, even on my iPad.
Process in mind: From your comments please find the basic process I have in mind below. At the moment it's not clear, whether or not I can realize it, and how reliable it will be when repeated. The pdf-part is reliable, while epub-creation can lead to fragile epub code (works on some reader, but not on others). // Approach: single source, once frozen, pdf AND epub output. // The example is simplified, of course. // epub can't be any valid epub-content, to avoid problems on any eBook-reader. // "Minimal epub" means: don't include fancy things in the output file. // An example can be HTML-comments, which are allowed, but, with bad luck, irritates some eBook reader (takes forever to just load it). // Decoration with <p> </p>
- tags is done by Sigil
, if I remember correctly. So is partioning, TOC-creation, stylesheeting etc. I.e. many things pdflatex
would provide are kind of redundant.
Single frozen source, pdf AND epub (running on any eBook reader) derived from it.
I a nutshell I need to get rid of less useful bytes, and have more control to insert classes, div-tags etc. Trust me: this can be done partially with ease using Scrivener
, if needed. (If you don't know this program, think of a tool to create, organize, modify and collect a huge set of notes of various length.)
The problem is that programs/tools tend to put too much into an epub file ... which is a really weak format (may work fast and fine on one reader, but causes problems on an other one).
Example (almost obsolete now): Unfortunately I left room for some confusion about what my "ASCII"-requirement may or may not mean. Hoping, readers no longer trigger on 'ascii' or 'pdf', and starting with this simple Latex document ...
\documentclass[10pt]{book}
\begin{document}
\chapter{Lorem ipsum}
Dolor sit amet consectetuer eros sit quis mauris pretium. Phasellus penatibus interdum dolor Ut nisl.
\section{Nam amet}%<<<
Adipiscing est leo convallis nunc interdum Lorem hendrerit Vestibulum amet.%<<<
Facilisi Nulla ultrices malesuada orci nibh eget ac Aliquam eros ut.
\section{Lorem gravida}
Oorci sociis Nunc id hendrerit at ac amet Pellentesque. Eleifend risus orci sem Sed ac.
A nec pellentesque Pellentesque Morbi fringilla accumsan et metus at enim.
Eu felis Curabitur quis nibh tellus.
\end{document}
... it would be OK if the marked part turns into ...
<h3 class='myOne'>1.1 Nam amet</h3>
<p>Adipiscing est leo convallis nunc interdum Lorem hendrerit Vestibulum amet.
</p>
... but certainly not into ...
<h3 class='sectionHead'><span class='titlemark'>1.1 </span> <a id='x2-20001.1'></a>Nam amet</h3>
<!-- l. 12 --><p class='noindent'>Adipiscing est leo convallis nunc interdum Lorem hendrerit Vestibulum amet.
</p>
Anything else you might see when displaying a pdf file in an ASCII editor is not wanted here.
Background 1 (almost obsolete now): This is an alternative attempt to create HTML which is as pure, i.e. minimal, as possible. I tried tex4ebook
, which is a great tool, but unfortunately it puts all kind of extra-information and styles, mimicking Latex-appearance, which I do not want, even with the tidy-option. (Perhaps I'm missing an option to get rid of it?)
I think of a two-step process:
- ASCII-creation as given above
- run some Perl-script to resolve remaining issues
The expansion feature from Latex/Texmaker would be nice, e.g. to expand abbreviations (via \newcommand
), and references from using \ref
or \vref
the way I need as HTML. I can do this to some degree from creating a pdf AND copying relevant text from it (i.e. typset text "spoiling" with HTML-tags) - but this is not a nice solution.
There will be remaining issues like extracting and transforming e.g. list-environments. But this should be doable with Perl, which was made for this purpose.
Background 2 (almost obsolete now): The objective is to create just one big HTML-file, which I can break down as needed by Sigil
, which takes care of all epub-stuff.
Background 3 (almost obsolete now): I create my Latex document using Scrivener
, a writing tool, by inserting only relevant Latex-code AND compiling as plain text into Texmaker. This gives me full and easy control what to include or exclude or modify things.
Screenshot, showing a page opened in Sigil
, demonstrating extra-information, which is not needed, and missing tags, which need to be inserted, e.g. via my Perl-script. Top-right: tex4ebook
processing. // This is a short example where too much output is created for the epub file. Less is more, more or less.