Register Guidelines E-Books Search Today's Posts Mark Forums Read

 MobileRead Forums LaTeX, a way to PDF

 01-25-2010, 08:10 AM #2 janneman Member   Posts: 13 Karma: 10 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 08:18 AM.
 01-25-2010, 08:41 AM #3 Jellby frumious Bandersnatch     Posts: 7,105 Karma: 9648489 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}
01-25-2010, 09:04 AM   #4
Sweetpea
Grand Sorcerer

Posts: 9,330
Karma: 28674208
Join Date: Dec 2008
Location: Krewerd
Device: Dell V8Pro; Asus Zenpad S8; Onyx Boox T68; Kobo Aura One
Quote:
 Originally Posted by Jellby That's a long post!
I actually wrote down the steps I did, and then decided to post them

Quote:
 Originally Posted by Jellby 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 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: 
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 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

01-25-2010, 09:23 AM   #5
Jellby
frumious Bandersnatch

Posts: 7,105
Karma: 9648489
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
 Originally Posted by Sweetpea 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.

01-25-2010, 09:43 AM   #6
Sweetpea
Grand Sorcerer

Posts: 9,330
Karma: 28674208
Join Date: Dec 2008
Location: Krewerd
Device: Dell V8Pro; Asus Zenpad S8; Onyx Boox T68; Kobo Aura One
Quote:
 Originally Posted by janneman 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:  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

01-25-2010, 12:28 PM   #7
janneman
Member

Posts: 13
Karma: 10
Join Date: Jan 2010
Device: BEBOOK
Quote:
 Originally Posted by Sweetpea 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??

using the hyperref package
Code:
\pdfbookmark[level]{Name of bookmark}{your_label}
ofcourse also add your_label somewhere (with \label{your_label} )

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 12:34 PM. Reason: added a link

01-25-2010, 12:43 PM   #8
Sweetpea
Grand Sorcerer

Posts: 9,330
Karma: 28674208
Join Date: Dec 2008
Location: Krewerd
Device: Dell V8Pro; Asus Zenpad S8; Onyx Boox T68; Kobo Aura One
Quote:
 Originally Posted by janneman 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.

 01-25-2010, 04:56 PM #9 pietvo Reader     Posts: 516 Karma: 24612 Join Date: Aug 2009 Location: Utrecht, NL Device: Kobo Aura 2, iPhone, Onyx Boox 60, iPod Touch 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.)
 01-25-2010, 05:22 PM #10 frabjous Wizard     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 06:18 PM.
 01-25-2010, 05:55 PM #11 pietvo Reader     Posts: 516 Karma: 24612 Join Date: Aug 2009 Location: Utrecht, NL Device: Kobo Aura 2, iPhone, Onyx Boox 60, iPod Touch @frabjous: What did you use to generate the HTML?
 01-25-2010, 05:58 PM #12 frabjous Wizard     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.
 01-25-2010, 06:02 PM #13 pietvo Reader     Posts: 516 Karma: 24612 Join Date: Aug 2009 Location: Utrecht, NL Device: Kobo Aura 2, iPhone, Onyx Boox 60, iPod Touch Doing the math with HTML must be quite a chore.
 01-25-2010, 06:16 PM #14 frabjous Wizard     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.

,