Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 01-25-2010, 05:04 AM   #1
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
LaTeX, a way to PDF

I'm always looking for new (for me) formats to create my books in. I have two readers that I use regularly. One is the JE-100, an LCD, WinCE based reader, on which I use Mobipocket (for various reasons) and on which I'll probably keep on using this format. But my other reader is a BeBook Mini (Hanlin v5) on which I now also read Mobipocket format. I don't like the Epub implementation (lack of top/bottom margin, weird page number in the right margin, no progress bar visible and other irriations...). And while the Mobipocket format has less irritations, it still isn't exactly what I want (the main irritation with that format is the fact that it doesn't remember what font you've used last, I always have to select the font I want to use, every time I open the book again).

So, I was thinking about transforming my HTML sources (which I use to generate both Mobipocket and Epub books) into PDF. I first used a HTML2PDF converter, but found the lack of hyphenation in HTML (which doesn't bother me with the Mobipocket implementation) generated some highly irritating sentences in PDF (in Mobipocket, I might get a few words on a sentence with large spacings between the words, in the PDF document, I got large spacings between the letters of the words...). I finally decided to give up on the HTML2PDF directly and started looking into LaTeX.

The learning curve of LaTeX is rather steep. At least, if you have to figure out everything from scratch (with a little help from knowledgeable people). But, I won't be stopped by a few setbacks, so, I got to work.

I first installed MikTex 2.8 and then TexNicCenter (1.0 Stable RC1). And then it was time for my first LaTeX PDF document.

Code:
\documentclass[12pt,openany,oneside]{book}
\begin{document}

Hello World!

\end{document}
It's that easy! Except... I've only a Mini, which is a 5" screen. Don't even want to try this document on it! Those huge margins would eat away my screen and don't even mention the A4 document... So, after a tip from Jellby, I found out about the memoir and geometry classes. After some reading, I thought I had figured it out:

Code:
\documentclass[12pt,openany,oneside]{memoir}

\usepackage[papersize={4in,5in},margin=3mm]{geometry}

\begin{document}

Hello World!

\end{document}
I have a 5" device, so, figuring out the width and height of it wasn't too difficult (ever heard of the Pythagorean theorem?). I also did want a small margin (one of my larger irritations with epub is the lack of top and bottom margin). So, after I created the PDF again (very easily done, I must say!), I saw a nice 4x5" page, with my Hello World on it. So, my next step was to put some real text in it. Ipsum.com to the rescue. Oh, and I'll also need a chapter. So far, I've only read one book that is completely chapterless. So, chapters are kind of mandatory.

Code:
\documentclass[12pt,openany,oneside]{memoir}

\usepackage[papersize={4in,5in},margin=3mm]{geometry}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}
Lorem ipsum dolor ...

<snip>

...velit tellus vitae velit.

\end{document}
Hmm, not exactly what I wanted, It shows a huge "Chapter 1" above my "1. Lorem". I had by now also downloaded the source of a book Jellby had made ("Fábulas literarias"). While I can't read Spanish for the life of me, it did have some nice examples for chapters and such (hey, better well stolen than badly made yourself!).

Code:
\documentclass[12pt,openany,oneside]{memoir}

\usepackage[papersize={4in,5in},margin=3mm]{geometry}

\makechapterstyle{normal}{%
  \setlength{\beforechapskip}{0pt}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\printchaptername}{}
  \renewcommand{\printchapternum}{}
  \renewcommand{\chaptitlefont}{\centering\LARGE\clfamily}
  \setsecnumdepth{chapter}
}
\makechapterstyle{simple}{%
  \setlength{\beforechapskip}{50pt}
  \setlength{\midchapskip}{10pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\chapnamefont}{\normalfont\Large\bfseries}
  \renewcommand{\chapnumfont}{}
  \renewcommand{\chaptitlefont}{\chapnamefont}
  \setsecnumdepth{part}
}
\chapterstyle{simple}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}
Lorem ipsum dolor ...

<snip>

...velit tellus vitae velit.

\end{document}
I've no idea what it exactly do (actually, I do have an inkling, but don't ask me to explain it). For example, if I remove the {normal} template, it won't shop the {simple} correctly. Don't ask me why. It works, so I'm happy with it. I did change one thing from Jellby's example. I like to waste some space in front of my chapter, so I enlarged the size of the \beforechapskip. I also understand why the chapter doesn't get a number anymore. In LaTeX a document is divided in various elements. "Chapter" is one, and that one gets a number. "Part" is another, and that one won't get a number. So, the \setsecnumdepth{part}, tells that the chapter should get the numbering of a "part", which is none... Remember, I want to use my existing HTML files, and they already have a chapter number for chapters if required, I will have to change the format of the HTML files (replacing HTML format with LaTeX format), but I don't want to change the content of the files.

So, now I have a nice document, with a chapter and text. But I still don't have a page number (so I can see my progress in the book, it's something I really want). Back to the drawing board!

Code:
\documentclass[12pt,openany,oneside]{memoir}

\usepackage[papersize={4in,5in},margin=3mm]{geometry}

\makechapterstyle{normal}{%
  \setlength{\beforechapskip}{0pt}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\printchaptername}{}
  \renewcommand{\printchapternum}{}
  \renewcommand{\chaptitlefont}{\centering\LARGE\clfamily}
  \setsecnumdepth{chapter}
}
\makechapterstyle{simple}{%
  \setlength{\beforechapskip}{50pt}
  \setlength{\midchapskip}{10pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\chapnamefont}{\normalfont\Large\bfseries}
  \renewcommand{\chapnumfont}{}
  \renewcommand{\chaptitlefont}{\chapnamefont}
  \setsecnumdepth{part}
}
\chapterstyle{simple}

\makeoddfoot {plain}{}{}{\footnotesize page \thepage\ of \thelastpage}
\makefootrule {plain}{\textwidth}{\normalrulethickness}{\footruleskip}

\makeoddhead {plain} {}{}{\footnotesize\thetitle}
\makeheadrule {plain}{\textwidth}{\normalrulethickness}

\pagestyle{plain}

\title{Book Title}
\author{A. Uthor}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}
Lorem ipsum dolor ...

<snip>

...velit tellus vitae velit.

\end{document}
So, I make a footer and header. The footer contains "Page x of y", the header the title of the book. There's a line between the body of the text and the header and footer. I also had to add a title for the book (naturally!) and, to make it complete, I also added the author. Finally, the \pagestyle{plain} writes the header and footer. Or rather, it should! After generating, where did my header and footer go??? If I remove the "geometry" line, I do see them and it does look nice (though, the page is again A4...)! Something needs to be changed with the "geometry" line...

After some more digging (and especially some errors! as at one point I did see my header and footer, but simply lost part of my text, which were, I presume, "written" behind them...", I found my answer" "includeheadfoot". Almost done, but there's a lot of wasted space between the header and the body and the footer and the body.

Code:
\documentclass[12pt,openany,oneside]{memoir}

\usepackage[papersize={4in,5in},margin=3mm]{geometry}

\makechapterstyle{normal}{%
  \setlength{\beforechapskip}{0pt}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\printchaptername}{}
  \renewcommand{\printchapternum}{}
  \renewcommand{\chaptitlefont}{\centering\LARGE\clfamily}
  \setsecnumdepth{chapter}
}
\makechapterstyle{simple}{%
  \setlength{\beforechapskip}{50pt}
  \setlength{\midchapskip}{10pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\chapnamefont}{\normalfont\Large\bfseries}
  \renewcommand{\chapnumfont}{}
  \renewcommand{\chaptitlefont}{\chapnamefont}
  \setsecnumdepth{part}
}
\chapterstyle{simple}

\setlength{\headsep}{1mm}
\setlength{\footskip}{7mm}

\makeoddfoot {plain}{}{}{\footnotesize page \thepage\ of \thelastpage}
\makefootrule {plain}{\textwidth}{\normalrulethickness}{\footruleskip}

\makeoddhead {plain} {}{}{\footnotesize\thetitle}
\makeheadrule {plain}{\textwidth}{\normalrulethickness}

\pagestyle{plain}

\title{Book Title}
\author{A. Uthor}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}
Lorem ipsum dolor ...

<snip>

...velit tellus vitae velit.

\end{document}
The \headsep sets the separation of the header and the body. 1mm should be more than enough. The \footskip defines the distance between the footer and the body. 1mm should be enough there too, right? Wrong! Only at 7mm did the line not go over the text of my body at the first page... If anybody could explain, I'm listening.

But another problem has arisen. Now, my bottom margin is rather big. That is, the space between my page number and the bottom of the page. I couldn't figure out that one, until I put the /setlength commands above the "geometry" line. I also changed my margins a bit, so I only had a tiny margin on the top and bottom and a somewhat bigger on the side.


Code:
\documentclass[12pt,openany,oneside]{memoir}

\setlength{\headsep}{1mm}
\setlength{\footskip}{7mm}
\usepackage[papersize={4in,5in},hmargin=3mm,vmargin=1mm]{geometry}

\makechapterstyle{normal}{%
  \setlength{\beforechapskip}{0pt}
  \setlength{\midchapskip}{0pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\printchaptername}{}
  \renewcommand{\printchapternum}{}
  \renewcommand{\chaptitlefont}{\centering\LARGE\clfamily}
  \setsecnumdepth{chapter}
}
\makechapterstyle{simple}{%
  \setlength{\beforechapskip}{50pt}
  \setlength{\midchapskip}{10pt}
  \setlength{\afterchapskip}{20pt}
  \renewcommand{\chapnamefont}{\normalfont\Large\bfseries}
  \renewcommand{\chapnumfont}{}
  \renewcommand{\chaptitlefont}{\chapnamefont}
  \setsecnumdepth{part}
}
\chapterstyle{simple}

\makeoddfoot {plain}{}{}{\footnotesize page \thepage\ of \thelastpage}
\makefootrule {plain}{\textwidth}{\normalrulethickness}{\footruleskip}

\makeoddhead {plain} {}{}{\footnotesize\thetitle}
\makeheadrule {plain}{\textwidth}{\normalrulethickness}

\pagestyle{plain}

\title{Book Title}
\author{A. Uthor}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}
Lorem ipsum dolor ...

<snip>

...velit tellus vitae velit.

\end{document}

I now have a nice basic template for my books. I've tried to change the default font, and managed doing that, but the font I really like doesn't seem to work (http://www.tug.dk/FontCatalogue/venturis2/). I did install it, but I get an error when I try to create the PDF. I finally did manage to install the TTF I'm using on my Mini with mobipocket books so, at least that's working (only took me the entire weekend to get it working )

Now, this works on my computer screen, but how does it look on my BeBook Mini?

Well, apparently, a 5" screen doesn't mean my screen is 4" by 3". When I put the ruler beside the screen, it measures 10cm by 7.5cm (more or less). Which is less than 4x5". But when I put those numbers in, it looks horrible. So, after a lot of tweaks, I settled on 4x5.3". That way the page is large enough, the top and bottom margins aren't huge and the font size is comfortable to read (for me).

Now I can write an application which can transform my HTML files into TeX files (not only replacing HTML tags, but also the HTML characters, such as &mdash; and all those accented letters...) But I think that part will be easier than figuring out the LaTeX commands, as my HTML is all custom made and very simple in syntax. After that, I'll need to really figure out how to make new chapter templates, as not all chapters are created equal... Also, how to make links (if that actually works in PDF) for my TOC's...

------------------------

If anybody has some comments, improvements, hints, tips, extras, anything, I'm here, listening! (or rather, watching...)
Sweetpea is offline   Reply With Quote
Old 01-25-2010, 09:10 AM   #2
janneman
Member
janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.
 
Posts: 13
Karma: 2136218
Join Date: Jan 2010
Device: BEBOOK
a bebook (e-reader) latex class

I created a bebook class, to make pdf's that are perfect to read on my bebook.

And it really reads incredibly well, pleasant and smooth. I even forget about the rather small paper/screen size.

Maybe you can use this as a start to implement your template as a class file.

This will make your tex file(s) cleaner. Like this:

Code:
\documentclass{bebook}
\begin{document}
\chapter{Your chapter title}
some text ...
\end{document}
The bebook.cls file:
Code:
% TODO: del. pagenumbers, pass options, set position of title


% PART I: Identification
%**************************************
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{bebook}[2010/01/19 Jans Bebook Class]

% PART II: Preliminary declarations
%**************************************
\LoadClass{book}

% Specify which packages to use:
	% fancyhdr		-   used for the header and footer
	%\usepackage{fancyhdr}
	% lastpage		-   used to get the number of pages for making a page 1 of 3 footer
	%\usepackage{lastpage}	
	% graphicx		-   used to include graphics   
	\usepackage{graphicx}
	% geometry		-   used to set up the layout   
	\usepackage[lmargin=2mm, rmargin=2mm,tmargin=2mm,bmargin=2mm]{geometry}
	% xcolor		-   used to enable colors!    
	%\usepackage{xcolor}	
	% colortbl		-   used to enable tablecolors!    
	%\usepackage{colortbl}		
	% multirow		-   for tables with rowspan cells    
	%\usepackage{multirow}
	% ifthen			-   used for declaring some commands with variables
	%\usepackage{ifthen}
	% sectsty			-   used to change the section headers a bit (sectionstyle package)
	%\usepackage{sectsty}
	
	% hyperref		-   used to include a clickable email address with mailto.
	\usepackage[pdftex,a4paper]{hyperref}
	\hypersetup{
    bookmarks=true,         % show bookmarks bar?
    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        % show Acrobat’s toolbar?
    pdfmenubar=true,        % show Acrobat’s menu?
    pdffitwindow=false,     % window fit to page when opened
    pdfstartview={Fit},    % fits the width of the page to the window
    pdftitle={My Book title},    % title
    pdfauthor={your name},     % author
    pdfsubject={title},   % subject of the document
    pdfcreator={your name},   % creator of the document
    pdfproducer={your name}, % producer of the document
    pdfkeywords={some keywords, in a list, with commas}, % list of keywords
    pdfnewwindow=false,      % links in new window
    colorlinks=false,       % false: boxed links; true: colored links
    linkcolor=black,          % color of internal links
    citecolor=black,        % color of links to bibliography
    filecolor=magenta,      % color of file links
    urlcolor=black           % color of external links
	}

	\setlength\paperheight{120mm}%
	\setlength\paperwidth{90mm}%
	\setlength{\textwidth}{86mm}
	\setlength{\textheight}{116mm}
	
% PART III: Options
%**************************************


% this passes unkown options to the book class	
\DeclareOption*{
	\PassOptionsToClass{\CurrentOption}{book}
} 
% process all options
\ProcessOptions 

% PART IV: More declarations
%**************************************

% New and renewed commands

% define some stuff to do at the begin of the document
\AtBeginDocument{ 
}
you can add your options to this class, or just keep using the template.

A table of contents is done by the command (surprise surprise): \tableofcontents

On my bebook the structure is also nicely reflected in the menu (button 7)

The only downside is copying all the text in the chapters and putting brackets around it which is a little too timeconsuming.

note: fancyhdr is also a great package to get your headers and footers the way you want.

Last edited by janneman; 01-25-2010 at 09:18 AM.
janneman is offline   Reply With Quote
Advert
Old 01-25-2010, 09:41 AM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
That's a long post!

Well... first: have you tried Prince to convert HTML to PDF? It has hyphenation, kerning, proper paragraph justification... You could even use my epub2pdf.sh script (or similar) to directly convert ePUB to PDF.

As for the LaTeX template, if you are using the memoir class, you don't have to use the geometry package, but use the class's methods instead. I admit I don't fully grasp how the different paramaters interact with each other, but this seems to work:

Code:
\usepackage{calc} %just to be able to use + in the dimensions
\setstocksize{5in}{4in} %set the paper size
\settrimmedsize{\stockheight}{\stockwidth}{*} %the used space is just the paper size
\setheadfoot{10pt}{7mm} %header and footer separations
\setheaderspaces{*}{1mm}{1}
\setlrmarginsandblock{3mm}{3mm}{*} %horizontal margins
\setulmarginsandblock{1mm+\headheight+\headsep}{\footskip+\baselineskip}{*} %vertical margins
\checkandfixthelayout %make everything consistent (this is needed)
The \setsecnumdepth command actually sets the deepest type of division that will get a number, deeper divisions will be unnumbered, so that \setsecnumdepth{part} makes chapters unnumbered (without having to use \chapter*, which has other effects). If you always want this, you can put it outside the chapter style definition. And I can remove the "normal" style definition with no problems. This works fine for me:

Code:
\documentclass[12pt,oneside]{memoir} %you don't need "openany" with "oneside"

\usepackage{calc}

\setstocksize{5in}{4in}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\setheadfoot{10pt}{7mm}
\setheaderspaces{*}{1mm}{1}
\setlrmarginsandblock{3mm}{3mm}{*}
\setulmarginsandblock{1mm+\headheight+\headsep}{\footskip+\baselineskip}{*}
\checkandfixthelayout

\chapterstyle{simple}
\setsecnumdepth{part}

\makeoddfoot {plain}{}{}{\footnotesize page \thepage\ of \thelastpage}
\makefootrule {plain}{\textwidth}{\normalrulethickness}{\footruleskip}

\makeoddhead {plain} {}{}{\footnotesize\thetitle}
\makeheadrule {plain}{\textwidth}{\normalrulethickness}

\pagestyle{plain}

\title{Book Title}
\author{A. Uthor}

\begin{document}

\chapter{1. Lorem}
\label{sec:1. Lorem}

...
\end{document}
Jellby is offline   Reply With Quote
Old 01-25-2010, 10:04 AM   #4
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
Quote:
Originally Posted by Jellby View Post
That's a long post!
I actually wrote down the steps I did, and then decided to post them

Quote:
Originally Posted by Jellby View Post
Well... first: have you tried Prince to convert HTML to PDF? It has hyphenation, kerning, proper paragraph justification... You could even use my epub2pdf.sh script (or similar) to directly convert ePUB to PDF.
I'm a software developer, so I like to work with programming languages. And ideally, I'd incorporate it into my book generating script. Which started from just creating a mobipocket book to splitting my main HTML file into seperate files, create an epub, including a custom font and a toc file, check that epub and finally create a mobipocket file... And I'd like to add PDF to that script... All with only one source...

Quote:
Originally Posted by Jellby View Post
As for the LaTeX template, if you are using the memoir class, you don't have to use the geometry package, but use the class's methods instead. I admit I don't fully grasp how the different paramaters interact with each other, but this seems to work:

Code:
<snip>
I copied that part from your book first, but only got some weird errors that some variable was too large... And as I wanted some output, I gave up and tried the other way I'll try again, now that I finally have the document I want...

Quote:
Originally Posted by Jellby View Post
The \setsecnumdepth command actually sets the deepest type of division that will get a number, deeper divisions will be unnumbered, so that \setsecnumdepth{part} makes chapters unnumbered (without having to use \chapter*, which has other effects). If you always want this, you can put it outside the chapter style definition.
Ah, so that works a bit different than I thought! Thanks for explaining
Sweetpea is offline   Reply With Quote
Old 01-25-2010, 10:23 AM   #5
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Sweetpea View Post
I'm a software developer, so I like to work with programming languages. And ideally, I'd incorporate it into my book generating script. Which started from just creating a mobipocket book to splitting my main HTML file into seperate files, create an epub, including a custom font and a toc file, check that epub and finally create a mobipocket file... And I'd like to add PDF to that script... All with only one source...
I'd appreciate a tool to convert ePUB to PDF using LaTeX

I prefer ePUB as a source rather than HTML because ePUB is better for distribution (it's already an ebook format). Since ePUB has HTML under the hood, you don't have to lose anything either.
Jellby is offline   Reply With Quote
Advert
Old 01-25-2010, 10:43 AM   #6
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
Quote:
Originally Posted by janneman View Post
I created a bebook class, to make pdf's that are perfect to read on my bebook.

And it really reads incredibly well, pleasant and smooth. I even forget about the rather small paper/screen size.

Maybe you can use this as a start to implement your template as a class file.

This will make your tex file(s) cleaner. Like this:

Code:
<snip>
you can add your options to this class, or just keep using the template.

A table of contents is done by the command (surprise surprise): \tableofcontents

On my bebook the structure is also nicely reflected in the menu (button 7)

The only downside is copying all the text in the chapters and putting brackets around it which is a little too timeconsuming.

note: fancyhdr is also a great package to get your headers and footers the way you want.
A class like that wouldn't be ideal for me. I want to transform my current HTML files into LaTeX. I have three files, one "titlepage", one "toc page" and one "text page". I already found out about the \tableofcontents and it actually works (at least, once I found out I had to build my PDF twice ). But I intend to make an application that will replace my HTML code with LaTeX code. And as my HTML code already contains things like book title and author and series (all those things that are in my title page), it's easy to generate a base.tex which will contain my preamble and two includes (and the toc, naturally). Then I have to replace the HTML elements with LaTeX elements, all done with regular expression search&replace. I already do exactly the same with the generation of my epub files, as I have one huge HTML file (much easier to maintain) which I split into chapter based files only for the book generation.

But I'd love to know how you get the structure in the menu button! Can you point out what part of your class does that?

Quote:
Originally Posted by Jellby
I prefer ePUB as a source rather than HTML because ePUB is better for distribution (it's already an ebook format). Since ePUB has HTML under the hood, you don't have to lose anything either.
I prefer HTML. Much easier to maintain because I don't have to unzip it... My base is HTML, and from that I can generate epub and mobipocket (which is the main format for me, as three from the four of my readers don't read epub). But my source is essentially an unpacked epub file
Sweetpea is offline   Reply With Quote
Old 01-25-2010, 01:28 PM   #7
janneman
Member
janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.janneman ought to be getting tired of karma fortunes by now.
 
Posts: 13
Karma: 2136218
Join Date: Jan 2010
Device: BEBOOK
Quote:
Originally Posted by Sweetpea View Post
I'd love to know how you get the structure in the menu button! Can you point out what part of your class does that?
If you use the book class and define parts, chapters, ... The pdf automatically has bookmarks for each section. And so they also appear under the menu button of your bebook.

The memoir class doesn't do this??

You can always add additional bookmarks manually (or with your script)
using the hyperref package
Code:
\pdfbookmark[level]{Name of bookmark}{your_label}
ofcourse also add your_label somewhere (with \label{your_label} )


Then they show up in the bookmarks menu of your pdf and thus also in the menu of your bebook.

This might be of interest to you, describes options when making a pdf from latex:
http://www.mpch-mainz.mpg.de/~joeckel/pdflatex/

And this one might be what you are trying to program??:
http://html2latex.sourceforge.net/

Last edited by janneman; 01-25-2010 at 01:34 PM. Reason: added a link
janneman is offline   Reply With Quote
Old 01-25-2010, 01:43 PM   #8
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
Quote:
Originally Posted by janneman View Post
And this one might be what you are trying to program??:
http://html2latex.sourceforge.net/
Yes, except I can't use Perl... Don't even know how to install it... I want to add it in my HTML splitter application, so I can create all three formats at the same time (epub, mobi and pdf).

The page on hyperlinks is useful, though.
Sweetpea is offline   Reply With Quote
Old 01-25-2010, 05:56 PM   #9
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
AFAIK the memoir class has similar commands for headers and footers as fancyhdr. On the other hand fancyhdr also works with memoir. (BTW, I am the author of the fancyhdr package.)
pietvo is offline   Reply With Quote
Old 01-25-2010, 06:22 PM   #10
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
If you'd like to see code for another ebook created in LaTeX, I have the source code for my version of Introduction to Mathematical Philosophy posted here. It's a mess by comparison, however, since I use the same .tex file for 6 different PDF outputs. I used a reader.sty file I found here in MobileRead some time back, though it doesn't do anything you can't do easily with the geometry package. Fancyhdr and titlesec can cover the rest.

Last edited by frabjous; 01-25-2010 at 07:18 PM.
frabjous is offline   Reply With Quote
Old 01-25-2010, 06:55 PM   #11
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
@frabjous:
What did you use to generate the HTML?
pietvo is offline   Reply With Quote
Old 01-25-2010, 06:58 PM   #12
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
I actually made the HTML first, and then converted it (with RegExs) to LaTeX -- took forever. I don't recommend doing it the way I did.
frabjous is offline   Reply With Quote
Old 01-25-2010, 07:02 PM   #13
pietvo
Reader
pietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notespietvo can name that song in three notes
 
pietvo's Avatar
 
Posts: 520
Karma: 24612
Join Date: Aug 2009
Location: Utrecht, NL
Device: Kobo Aura 2, iPhone, iPad
Doing the math with HTML must be quite a chore.
pietvo is offline   Reply With Quote
Old 01-25-2010, 07:16 PM   #14
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
It's more philosophy than math -- while there is some, the mathematical notation is fairly light.

Actually, I had a much worse time converting this web page here from LaTeX to HTML, which, even though it's not my area, I took on since I'm the only one on the editorial staff who knows both mark-up languages.

Needless to say, this would get much easier once MathML becomes more widely supported, but in the meantime, I had to make do with CSS tricks to try to emulate things LaTeX does effortlessly.
frabjous is offline   Reply With Quote
Old 01-26-2010, 07:10 AM   #15
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
I made some minor adjustments to my preamble and document structure and now I have something into which I can put my HTML sources.

I added:

\usepackage[bookmarks,bookmarksopen,bookmarksopenlevel=0,color links,linkcolor=black,urlcolor=black,pdfhighlight= {/N},pdfstartview={100},pdfpagelabels=true]{hyperref}

And I think this one caused my TOC to show in my reader menu.

I removed the makechapterstyle{normal} (still can't figure out why it didn't work earlier...)

I added:

\begin{center}
\thispagestyle{empty}
\includegraphics[width=95mm,height=118mm]{images/cover.jpg}
\clearpage
\end{center}


so I now even have a cover page! But, how can I make this cover page ignore the margins, header and footer of my document? The header and footer don't get shown (\thispagestyle{empty}) but the space is still reserved...

and I added:

\tableofcontents

But I don't like the way the chapter names are shown. Also, the header "Content" has the same layout as the other chapters of the book. How can I make it different? (so, no spacing above the Content header, for example, and a smaller font for the chapter names?)

and I did look at the fancyhdr package but couldn't make hear nor tails out of it... And what I did also seem to work

The conversion from the HTML into LaTeX isn't too hard, in my case, as my HTML setup is very simple, only using <p>, <div> and <h2> mostly. I'll figure out the footnotes (<a>), images (<img>) and subchapters (<h3>) at a later date . Things like <i> and <b> and such are easy to replace.
Sweetpea is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Latex, PDF and the PRS-600 Dictionary s3ntient PDF 4 11-06-2009 10:35 AM
Chaîne complète d'édition : HTML, LaTeX, PDF, EPUB à venir. Randy11 Software 2 04-05-2009 12:42 PM
PDF Generated with LaTeX for the iLiad Hadrien iRex 17 07-25-2008 10:59 AM
latex template for sony reader pdf technicolor Sony Reader 10 07-25-2008 10:51 AM
PDF creation from Latex using CJK fonts alanine iRex 0 10-14-2007 12:45 AM


All times are GMT -4. The time now is 01:04 PM.


MobileRead.com is a privately owned, operated and funded community.