- correct page size
- no corner rules
- correct page numbers (roman and arabic)
- chapter bookmarks and hyperlinks for table of contents
- hyperlinks for index
- hyperlinks for exercises and answers
How to do it:
1) Get texbook.tex from CTAN (systems/knuth/dist/tex/texbook.tex)
2) Save patch below as texbook.patch
3) Run this (second line is to add index hyperlinks):
patch <texbook.patch
sed -i '/le space)/,/^\\<2/s/\([+@ -]\)\([0-9][0-9]*\)\([.,;-]\)/\1\&\2>\3/g' texbook.tex
pdftex texbook
4) Have fun with your new TeXbook ebook!
--- texbook.tex.orig 2009-01-01 00:00:00.000000000 +0000
+++ texbook.tex 2009-01-01 00:00:00.000000000 +0000
@@ -6,5 +6,34 @@
% from the copyright holder and also from the publisher (Addison-Wesley).
-\loop\iftrue
- \errmessage{This manual is copyrighted and should not be TeXed}\repeat
-\pausing1 \input manmac
+\input manmac
+\proofmodefalse
+\def\setcornerrules{}
+{\dimen0=\hsize\advance\dimen0 by 2in\global\pdfpagewidth=\dimen0
+\dimen0=\vsize\advance\dimen0 by 2in\global\pdfpageheight=\dimen0}
+\pdfcatalog {/PageLabels<</Nums[
+ 0 <</St 1983 /P (Title)>>
+ 1 <</St 1 /S/r>>
+ 11 <</St 1 /S/D>>
+]>>}
+\def\pdfdestx#1{\hbox to 0pt{\vbox to 0pt{\vss\vbox to 1cm{\pdfdest
+ name {#1} xyz\vss}}}}
+\def\pdflinkinternal#1#2{\pdfstartlink attr {/C [1 0 0] /Border [0 0 1]}
+ goto #1 #2\pdfendlink}
+\def\pdflinkp#1#2{{\count0=#1\advance\count0 by 11\pdflinkinternal{page
+ \the\count0 {/Fit}}{#2}}}
+\def\pdflinkx#1#2{\pdflinkinternal{name {#1}}{#2}}
+\def\pdfoutlinex#1#2{{\def\TeX{TeX}\def\hskip 1pt{}\count0=#1\advance\count0 by 11
+ \pdfoutline goto page \the\count0 {/Fit} count 0 {#2}}}
+
+\def\ansno#1.#2:{\medbreak\noindent
+ \hbox to\parindent{\bf\hss\pdflinkx{ex-#1-#2}{#1.#2}%
+ \pdfdestx{ans-#1-#2}.\enspace}\ignorespaces}
+\outer\def\exercise{\medbreak
+ \global\advance\exno by 1
+ \noindent\llap{\manual\char'170\rm\kern.15em}% triangle in margin
+ {\ninebf EXERCISE \bf\pdflinkx{ans-\chapno-\the\exno}
+ {\chapno.\the\exno}\pdfdestx{ex-\chapno-\the\exno}}\par\nobreak\noindent}
+\def\dexercise{\global\advance\exno by 1
+ \llap{\manual\char'170\rm\kern.15em}% triangle in indented space
+ {\eightbf EXERCISE \bf\pdflinkx{ans-\chapno-\the\exno}
+ {\chapno.\the\exno}\pdfdestx{ex-\chapno-\the\exno}}\hfil\break}
\ifproofmode\message{Proof mode is on!}\pausing1\fi
@@ -300,3 +329,4 @@
\hbox to\parindent{\bf\hbox to 1em{\hss#1}\hss}%
- \rm#2\diamondleaders\hfil\hbox to 2em{\hss#3}}}
+ \rm#2\diamondleaders\hfil\hbox to 2em{\hss%
+ \pdfoutlinex{#3}{#1: #2}\pdflinkp{#3}{#3}}}}
\\1. The Name of the Game. 1.
@@ -15618,3 +15648,3 @@
and each of the two long diagonals.
-Can you do the same with twenty pennies?
+\noindent\pdflinkx{ans-22-$\infty $}{Can you do the same with twenty pennies?}\pdfdestx{ex-22-$\infty $}
\author HENRY ERNEST ^{DUDENEY}, {\sl The Best Coin Problems\/} (1909)
@@ -25751,2 +25781,3 @@
\catcode`\@=\active \let@=\eightit
+\catcode`&=\active \def>{\pdflinkp{#1}{#1}}
\parindent=0pt
[ snip ]
% This manual is copyright (C) 1984 by the American Mathematical
Society.
% All rights are reserved!
% The file is distributed only for people to see its examples of TeX
input,
% not for use in the preparation of books like The TeXbook.
% Permission for any other use of this file must be obtained in
writing