hmemcpy / milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Other
10.88k stars 578 forks source link

Can it be converted to amazon kindle format #205

Open byteshiva opened 5 years ago

byteshiva commented 5 years ago

Can it be converted to amazon kindle format, it would be nice to have it in kindle format.

toxicafunk commented 5 years ago

Doesn't Kindle have a proprietary format? I think epub is the best we can do.

On Wed, 21 Aug 2019, 12:50 Siva, notifications@github.com wrote:

Can it be converted to amazon kindle format, it would give to have it in kindle format.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hmemcpy/milewski-ctfp-pdf/issues/205?email_source=notifications&email_token=AABID2JIDAMHVQWNNLE2PALQFUMY7A5CNFSM4IOFFUH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGPJLOA, or mute the thread https://github.com/notifications/unsubscribe-auth/AABID2MDXJAGRPTHNJPYYU3QFUMY7ANCNFSM4IOFFUHQ .

byteshiva commented 5 years ago

Kindle have a proprietary format

" AZW that is based on Mobipocket; in fourth generation and later Kindles, AZW3, also called KF8; and in seventh generation and later Kindles, KFX.[1] Kindles do not support the EPUB file format used by many other e-book readers." - Kindle File Format

XVilka commented 5 years ago

Calibre can do this: https://www.epubor.com/how-to-convert-epub-to-azw.html

byteshiva commented 5 years ago

Calibre can do this: https://www.epubor.com/how-to-convert-epub-to-azw.html

I tried to convert pdf to Amazon AZW3 format(using https://pdf2kindle.com/) but the formatting and alignment are getting messed up. Here is the link to download AZW3 format. https://gofile.io/?c=eKueDK

I'll try "epub to azw" and keep you updated.

TV4Fun commented 4 years ago

I have had some success doing this with other TeX documents using tex4ebook. It uses tex4ht to convert the document to HTML, and then uses Amazon's own KindleGen tool to convert it to Kindle format.

byteshiva commented 4 years ago

I have had some success doing this with other TeX documents using tex4ebook. It uses tex4ht to convert the document to HTML, and then uses Amazon's own KindleGen tool to convert it to Kindle format.

$/home/tmp/milewski-ctfp-pdf/src]$ tex4ebook -c hej -f epub3 index.tex

Hi @TV4Fun

I'm trying to convert tex to epub3 but throws the below error.

(./index.tex
! Undefined control sequence.
l.1 \setindexprenote
                    {\normalsize
byteshiva commented 4 years ago

Doesn't Kindle have a proprietary format? I think epub is the best we can do. On Wed, 21 Aug 2019, 12:50 Siva, @.***> wrote: Can it be converted to amazon kindle format, it would give to have it in kindle format. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#205?email_source=notifications&email_token=AABID2JIDAMHVQWNNLE2PALQFUMY7A5CNFSM4IOFFUH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGPJLOA>, or mute the thread https://github.com/notifications/unsubscribe-auth/AABID2MDXJAGRPTHNJPYYU3QFUMY7ANCNFSM4IOFFUHQ .

Hi @toxicafunk How do you convert to epub? Are current scripts allows conversion to epub without messing up the structural alignments?

TV4Fun commented 4 years ago

@byteshiva, I don't think index.tex is meant to be compiled directly. It's referenced by other files. I was starting from ctfp-reader.tex. I was still running into odd errors that I couldn't immediately explain there, but at least I had some hope. I haven't been able to successfully convert this book using tex4ebook yet, but you could give it a try.

byteshiva commented 4 years ago

@byteshiva, I don't think index.tex is meant to be compiled directly. It's referenced by other files. I was starting from ctfp-reader.tex. I was still running into odd errors that I couldn't immediately explain there, but at least I had some hope. I haven't been able to successfully convert this book using tex4ebook yet, but you could give it a try.

@TV4Fun , i tried executing ctfp-reader.tex but it threw the following error!!

$/home/tmp/milewski-ctfp-pdf/src] $ tex4ebook -c hej -f epub3 ctfp-reader.tex

Error Details

! Fatal Package fontspec Error: The fontspec package requires either XeTeX or
(fontspec)                      LuaTeX.
(fontspec)                      
(fontspec)                      You must change your typesetting engine to,
(fontspec)                      e.g., "xelatex" or "lualatex"instead of
(fontspec)                      "latex" or "pdflatex".

For immediate help type H <return>.
 ...                                              

l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

? H

This is a fatal error: LaTeX will abort.

? H
Sorry, I already gave what help I could...
Maybe you should try asking a human?
An error might have occurred before I noticed any problems.
``If all else fails, read the instructions.''

First level Error: l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

Probable Fix: fontspec-cannot-use-pdftex-on-overleaf

TV4Fun commented 4 years ago

It's telling you exactly what you need to do. Just add the -l option to tex4ebook

On Fri, Sep 6, 2019, 9:15 PM Siva notifications@github.com wrote:

@byteshiva https://github.com/byteshiva, I don't think index.tex is meant to be compiled directly. It's referenced by other files. I was starting from ctfp-reader.tex. I was still running into odd errors that I couldn't immediately explain there, but at least I had some hope. I haven't been able to successfully convert this book using tex4ebook yet, but you could give it a try.

@TV4Fun https://github.com/TV4Fun , i tried executing ctfp-reader.tex but it threw the following error!!

$/home/tmp/milewski-ctfp-pdf/src] $ tex4ebook -c hej -f epub3 ctfp-reader.tex

Error Details

! Fatal Package fontspec Error: The fontspec package requires either XeTeX or (fontspec) LuaTeX. (fontspec) (fontspec) You must change your typesetting engine to, (fontspec) e.g., "xelatex" or "lualatex"instead of (fontspec) "latex" or "pdflatex".

For immediate help type H . ...

l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

? H

This is a fatal error: LaTeX will abort.

? H Sorry, I already gave what help I could... Maybe you should try asking a human? An error might have occurred before I noticed any problems. ``If all else fails, read the instructions.''

First level Error: l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}

Probable Fix: fontspec-cannot-use-pdftex-on-overleaf https://tex.stackexchange.com/questions/400825/fontspec-cannot-use-pdftex-on-overleaf

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hmemcpy/milewski-ctfp-pdf/issues/205?email_source=notifications&email_token=ABD4ECANBNJ54P7EKBF7BHTQIMTELA5CNFSM4IOFFUH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6EPUUQ#issuecomment-529070674, or mute the thread https://github.com/notifications/unsubscribe-auth/ABD4ECHUXGTOW2S2D3XYBNLQIMTELANCNFSM4IOFFUHQ .

byteshiva commented 4 years ago

It's telling you exactly what you need to do. Just add the -l option to tex4ebook

Thanks for pointing it out, I'll try that option.

! Fatal Package fontspec Error: The fontspec package requires either XeTeX or
(fontspec)                      LuaTeX.

Ref: https://github.com/michal-h21/tex4ebook

-l,--lua

: Use LuaLaTeX as TeX engine.

I see in MakeFile, it executes

latexmk -shell-escape -interaction=nonstopmode -halt-on-error -norc -pdflatex="xelatex %O %S" -pdf $<

are there any option for epub!!

Related to: https://github.com/hmemcpy/milewski-ctfp-pdf/issues/46

Result after adding -l option (: Use LuaLaTeX as TeX engine.)

added -l option and ran tex4ebook, it seems its looking for locale, Please be noted I'm running it on ubuntu 19.04 using nix-shell, Please guide me if i'm missing something here.

milewski-ctfp-pdf/src]$ tex4ebook -l -f epub3 ctfp-reader.tex

Output dir:     
Compiler:   dvilualatex
Latex options:   -jobname=ctfp-reader 
tex4ht.sty :    xhtml,
tex4ht  
build_file  ctfp-reader.mk4
Output format   epub3
ctfp-reader-epub3/OEBPS
ctfp-reader-epub3/mimetype
No conffile
Cannot open config file ctfp-reader.mk4
dvilualatex ctfp-reader "xhtml,,charset=utf-8,epub3,html5,uni-html4" " -cmozhtf -utf8" "" " -jobname=ctfp-reader "
Output file: ctfp-reader.epub
Make4ht run
-------------------
setting param correct_exit
setting param correct_exit
setting param correct_exit
setting param ext
LaTeX call: dvilualatex  -jobname=ctfp-reader  '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}\RequirePackage{tex4ebook}\Configure{ext}{xhtml}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode xhtml,,charset=utf-8,epub3,html5,uni-html4.a.b.c.\input "\detokenize{ctfp-reader.tex}"'
Unable to read environment locale: exit now.
Make4ht: Fatal error. Command htlatex returned exit code 1
(venv) 
byteshiva commented 4 years ago

I've converted to AZW3 from epub format as stated in #46

More information can be found in the below GIST link, also I have attached AZW3 format file in it. It seems to be rendering fine in Amazon Fire HD Tablet.

https://gist.github.com/byteshiva/d1ad7377ecf2e2a625fc58960e252b10

ps:- The tex4ebook still threw errors, maybe i'm missing something here.

TV4Fun commented 4 years ago

@byteshiva, I doubt you are missing anything. tex4ebook and tex4ht are just very finicky and require a lot of messing with. I know that when I have had to convert documents in the past, I have sometimes run into bugs in tex4ht that cause a failure to compile with only very specific combinations of LaTeX sequences, so you could be running into something like that. I haven't spent enough time on this particular book to know what the issues are though.

oddg commented 4 years ago

I just tried an epub -> mobi conversion on epubconverter.com using this nice project as input. I read a few pages. So far so good.

byteshiva commented 4 years ago

@oddg, I've used the same site for conversion from epub to azw3. Its Originally posted by @onlurking in https://github.com/hmemcpy/milewski-ctfp-pdf/issues/46#issuecomment-340605105

I just tried an epub -> mobi conversion on epubconverter.com using this nice project as input. I read a few pages. So far so good.