Article View: comp.text.tex
Article #11698HOWTO build a TeXbook.pdf with interactive features
From: Kulin Remailer
Date: Thu, 23 Jul 2009 16:45
Date: Thu, 23 Jul 2009 16:45
77 lines
3976 bytes
3976 bytes
This short text describes how to create texbook.pdf that supports the
interactive PDF features we got used to. Like:
- 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
Technical Details
Message-ID:
<7FSG8D0F40018.031412037@reece.net.au>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!peer1.news.newnet.co.uk!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.dizum.com!sewer-output!mail2news-x3!mail2news-x2!mail2newsShow Full Headers
Complete Article Headers
X-Google-Thread: dbc56467f1,dc35537380111a0b,start X-Google-Attributes: giddbc56467f1,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!peer1.news.newnet.co.uk!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news.dizum.com!sewer-output!mail2news-x3!mail2news-x2!mail2news From: Kulin Remailer <remailer@reece.net.au> Date: 23 Jul 2009 16:45:14 -0000 Message-ID: <7FSG8D0F40018.031412037@reece.net.au> Subject: HOWTO build a TeXbook.pdf with interactive features Newsgroups: comp.text.tex,de.comp.text.tex,fr.comp.text.tex X-Remailer-Contact: abuse@reece.net.au Mail-To-News-Contact: abuse@dizum.com Organization: mail2news@dizum.com