23.4 PDF and HTML
To produce a PDF version of this manual, use the LyX File Menu option:
File -> Export -> PDF(pdflatex)
This will provide Table of Contents navigation and will embed the Latin Modern Fonts and the 4 or so images into the output file. The other PDF export options (dvipdfm and ps2pdf) will not work correctly.
Alternatively you can do the export to PDF from the command line:
lyx -e pdf2 a4glman.lyx
It is important to use Latin Modern as the font for PDF. Latin Modern is a scalable vector font which works well on screen as well as on the printed page. LaTeX’s default bitmap fonts are bungled by the Adobe Acrobat PDF reader program.
In order to get URLs properly typeset, similarly use the hyperref TeX package.
In order to activate PDF navigation, you need to conditionally execute the TeX \pdfcatalog statement within a TeX \ifpdf ... \fi clause.
Here is the LaTeX source included in the LyX preamble:
\usepackage{hyperref}
\usepackage{ifpdf}
\ifpdf
\usepackage{lmodern}
\pdfinfo{ /Title (Aubit4GL Manual)
/Subject(Aubit 4GL Programming)
/Author(John O’Gorman) }
\pdfcatalog{/PageMode(/UseOutlines)}
\fi
The somewhat puzzling discrepancy in the syntax above with regard to slashes is because
-
the backslashed keywords are in the TeX language
-
the forwardslashed keywords are embedded PDF language (within the TeX \pdfinfo macro)
To convert LyX/LaTeX documents into HTML format, we use the program latex2html. With some versions of latex2html the following adaptation may be needed to render tables correctly:
}
push (@pieces, $after);
+ $within_preamble=0
}
print "$replacements new-command"
In the above the + line is to be added (without the +). The rest is context which allows you to locate where to insert the $within_preamble=0 statement. As is evident, latex2html is a perl script (usually found in /usr/bin). If it is missing from your distribution, install it from the openSUSE DVD or failing that from a TeX CTAN.
To produce the HTML files from within LyX, take the following steps:
-
Create a slightly cut down version of the primary document: a4glman.lyx by stripping a few things from the LyX file: the preamble and Greek characters. The cut down version is: a4glmanhtml.lyx
-
Export a4glmanhtml to TeX format
-
Convert the TeX format to HTML using latex2html
23.4.2.1 Export LyX to TeX
Use the LyX File menu option:
File -> export -> LaTeX(pdflatex)
This will produce a file: a4glmanhtml.tex
You can also produce a tex file from the command line:
lyx -e latex a4glmanhtml.lyx
Remove the \ifpdf statement from the preamble:
sed -i ’/^\usepackage{ifpdf}/,/^\fi/d’ a4glman.tex
This last step is necessary because latex2html cannot cope with the \ifpdf statement.
In fact, we have chosen to remove the whole preamble (which is user-entered to add PDF functionality) and remove the code which produces Greek characters using the following sed commands:
sed -e ’/\\begin_preamble/,/\\end_preamble/d’ \
-e ’/In Greek:/,/\\end_inset/d’ \
a4glman.lyx > a4glmanhtml.lyx
23.4.2.2 Convert TeX to HTML
From the command line:
latex2html -split 3 \
-link 4 \
-local_icons \
-show_section_numbers \
-html_version 4.0 \
a4glman.tex
The split 3 option will cause latex2html to split the document into separate html pages for each subsection and higher partitions (sections, chapters).
The link 4 option will render a table of contents with navigation links for each subsubsection and higher partitions (subsections, sections, chapters).
The result of the above command will be the creation of a directory: a4glmanhtml which will be populated with HTML files including an index.html file - all linked appropriately with <a> tags.
Of course, when you convert to HTML, you lose all the special TeX typesetting features and rely on the standard CSS stylesheets to lay out the document. These you can edit to improve the presentation of the HTML.
The latex2html command above creates set of html files in the directory: a4glmanhml and the directory contains many dozens of files with names: index.html node1.html node2.html ... node159.html
To help automate the above translation processes, we have a Makefile:
L2H=latex2html
L2HARGS=-split +3 -link 4 -local_icons -show_section_numbers\
-html_version 4.0
all: a4glman.tex a4glman.pdf a4glmanhtml \
tarball htmltarball
clean:
rm *.log
srcclean:
rm *.pdf *.tex *.aux *.log
a4glmanhtml.lyx:a4glman.lyx
sed -e ’/\\begin_preamble/,/\\end_preamble/d’ \
-e ’/^In Greek:/,/\\end_inset/d’ \
a4glman.lyx > a4glmanhtml.lyx
a4glmanhtml.tex:a4glmanhtml.lyx
lyx -e latex a4glmanhtml.lyx
a4glmanhtml: a4glmanhtml.tex
${L2H} ${L2HARGS} a4glmanhtml.tex
a4glman.pdf:a4glman.lyx
lyx -e pdf2 a4glman.lyx
htmltarball:
tar cvfz ../a4glmanhtml.tar.gz a4glmanhtml
tarball:
tar cvfz ../a4glman.tar.gz .
Be aware that the indented lines above MUST have tabs (not spaces). Otherwise make will not work!
Finis