From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/exptl/biblatex | 1 + macros/latex/exptl/biblatex-contrib | 1 + macros/latex/exptl/delimtxt/delimtxt.dtx | 330 ++++ macros/latex/exptl/delimtxt/delimtxt.ins | 6 + macros/latex/exptl/delimtxt/delimtxt.pdf | Bin 0 -> 55074 bytes macros/latex/exptl/delimtxt/resulta.dat | 2 + macros/latex/exptl/delimtxt/resultb.dat | 2 + macros/latex/exptl/delimtxt/resultc.dat | 2 + macros/latex/exptl/delimtxt/test1.tex | 31 + macros/latex/exptl/delimtxt/test2.tex | 29 + macros/latex/exptl/delimtxt/test3.tex | 33 + macros/latex/exptl/gcite/CHANGES | 20 + macros/latex/exptl/gcite/README | 36 + macros/latex/exptl/gcite/gcite.dtx | 392 +++++ macros/latex/exptl/gcite/gcite.ins | 32 + macros/latex/exptl/gcite/gcite.pdf | Bin 0 -> 203393 bytes macros/latex/exptl/graphicp/descend.1 | 23 + macros/latex/exptl/graphicp/descend.mp | 34 + macros/latex/exptl/graphicp/div16b.sty | 490 ++++++ macros/latex/exptl/graphicp/epstopdf | 476 ++++++ macros/latex/exptl/graphicp/f2cletter.eps | 35 + macros/latex/exptl/graphicp/f2cletter.pdf | Bin 0 -> 934 bytes macros/latex/exptl/graphicp/f2mletter.eps | 23 + macros/latex/exptl/graphicp/f2mletter.pdf | Bin 0 -> 582 bytes macros/latex/exptl/graphicp/ficletter.jpg | Bin 0 -> 590 bytes macros/latex/exptl/graphicp/ficletter.pbm | Bin 0 -> 116 bytes macros/latex/exptl/graphicp/ficletter.png | Bin 0 -> 199 bytes macros/latex/exptl/graphicp/files | 22 + macros/latex/exptl/graphicp/graphicp.sty | 407 +++++ macros/latex/exptl/graphicp/graphicpdoc.pdf | Bin 0 -> 86972 bytes macros/latex/exptl/graphicp/graphicpdoc.tex | 146 ++ macros/latex/exptl/graphicp/img_bbox.pl | 2079 +++++++++++++++++++++++ macros/latex/exptl/graphicp/keyvalx.sty | 76 + macros/latex/exptl/graphicp/laemu.sty | 206 +++ macros/latex/exptl/graphicp/laltest.tex | 166 ++ macros/latex/exptl/graphicp/laxtest.bbx | 18 + macros/latex/exptl/graphicp/pdfboxes.pl | 863 ++++++++++ macros/latex/exptl/graphicp/pts_bbox.sty | 418 +++++ macros/latex/exptl/graphicp/pts_img.sty | 801 +++++++++ macros/latex/exptl/mem/Mtp/allmtp.py | 27 + macros/latex/exptl/mem/Mtp/ellintex.mtp | 249 +++ macros/latex/exptl/mem/Mtp/ellinviu.mtp | 15 + macros/latex/exptl/mem/Mtp/ellmedb.mtp | 13 + macros/latex/exptl/mem/Mtp/ellpsili.mtp | 15 + macros/latex/exptl/mem/Mtp/fratext.mtp | 16 + macros/latex/exptl/mem/Mtp/inputtex.mtp | 16 + macros/latex/exptl/mem/Mtp/lat2ru.mtp | 113 ++ macros/latex/exptl/mem/Mtp/lgr-com.mtp | 67 + macros/latex/exptl/mem/Mtp/lgr-dec.mtp | 539 ++++++ macros/latex/exptl/mem/Mtp/lgr-rec.mtp | 459 +++++ macros/latex/exptl/mem/Mtp/ot1-com.mtp | 70 + macros/latex/exptl/mem/Mtp/ot1-dec.mtp | 1023 +++++++++++ macros/latex/exptl/mem/Mtp/ot1-rec.mtp | 149 ++ macros/latex/exptl/mem/Mtp/spguill.mtp | 9 + macros/latex/exptl/mem/Mtp/sppcent.mtp | 8 + macros/latex/exptl/mem/Mtp/t1-com.mtp | 71 + macros/latex/exptl/mem/Mtp/t1-dec.mtp | 1023 +++++++++++ macros/latex/exptl/mem/Mtp/t1-rec.mtp | 303 ++++ macros/latex/exptl/mem/Mtp/t2a-com.mtp | 71 + macros/latex/exptl/mem/Mtp/t2a-dec.mtp | 133 ++ macros/latex/exptl/mem/Mtp/t2a-rec.mtp | 226 +++ macros/latex/exptl/mem/Mtp/ucnoacc.mtp | 254 +++ macros/latex/exptl/mem/Mtp/ucy-com.mtp | 141 ++ macros/latex/exptl/mem/Mtp/ucy-dec.mtp | 127 ++ macros/latex/exptl/mem/Mtp/ucy-rec.mtp | 128 ++ macros/latex/exptl/mem/Mtp/uel-com.mtp | 137 ++ macros/latex/exptl/mem/Mtp/uel-dec.mtp | 533 ++++++ macros/latex/exptl/mem/Mtp/uel-rec.mtp | 308 ++++ macros/latex/exptl/mem/Mtp/ula-com.mtp | 137 ++ macros/latex/exptl/mem/Mtp/ula-dec.mtp | 1017 +++++++++++ macros/latex/exptl/mem/Mtp/ula-rec.mtp | 573 +++++++ macros/latex/exptl/mem/Mtp/utf8.mtp | 14 + macros/latex/exptl/mem/Tools/charset2otp.py | 99 ++ macros/latex/exptl/mem/Tools/fontenc2mtp.py | 433 +++++ macros/latex/exptl/mem/Tools/lgr.mmap | 245 +++ macros/latex/exptl/mem/Tools/mtp2ocp.py | 53 + macros/latex/exptl/mem/Tools/ot1.mmap | 130 ++ macros/latex/exptl/mem/Tools/t1.mmap | 254 +++ macros/latex/exptl/mem/Tools/t2a.mmap | 216 +++ macros/latex/exptl/mem/Tools/ts1.mmap | 59 + macros/latex/exptl/mem/ar.sd | 5 + macros/latex/exptl/mem/ara.ld | 17 + macros/latex/exptl/mem/arabic.pdf | Bin 0 -> 26189 bytes macros/latex/exptl/mem/arabic.tex | 98 ++ macros/latex/exptl/mem/bugs.txt | 35 + macros/latex/exptl/mem/cp1251.ocp | Bin 0 -> 1180 bytes macros/latex/exptl/mem/cp1252.ocp | Bin 0 -> 796 bytes macros/latex/exptl/mem/cp1253.ocp | Bin 0 -> 1180 bytes macros/latex/exptl/mem/cp1256.ocp | Bin 0 -> 1180 bytes macros/latex/exptl/mem/cp1257.ocp | Bin 0 -> 1180 bytes macros/latex/exptl/mem/cy.sd | 37 + macros/latex/exptl/mem/el.sd | 39 + macros/latex/exptl/mem/ell.ld | 210 +++ macros/latex/exptl/mem/ellintex.ocp | Bin 0 -> 8244 bytes macros/latex/exptl/mem/ellinviu.ocp | Bin 0 -> 184 bytes macros/latex/exptl/mem/ellmedb.ocp | Bin 0 -> 288 bytes macros/latex/exptl/mem/ellpsili.ocp | Bin 0 -> 312 bytes macros/latex/exptl/mem/eng.ld | 98 ++ macros/latex/exptl/mem/esp.ld | 51 + macros/latex/exptl/mem/espisolat1.id | 10 + macros/latex/exptl/mem/fra.ld | 129 ++ macros/latex/exptl/mem/fratext.ocp | Bin 0 -> 1284 bytes macros/latex/exptl/mem/greek.pdf | Bin 0 -> 88734 bytes macros/latex/exptl/mem/greek.tex | 307 ++++ macros/latex/exptl/mem/inputtex.ocp | Bin 0 -> 320 bytes macros/latex/exptl/mem/isoara.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/isocyr.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/isoell.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/isolat1.ocp | Bin 0 -> 616 bytes macros/latex/exptl/mem/isolat2.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/isolat4.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/koi8ru.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/koi8uk.ocp | Bin 0 -> 1052 bytes macros/latex/exptl/mem/la.sd | 67 + macros/latex/exptl/mem/lat2ru.ocp | Bin 0 -> 1676 bytes macros/latex/exptl/mem/lgr-com.ocp | Bin 0 -> 2568 bytes macros/latex/exptl/mem/lgr-dec.ocp | Bin 0 -> 6868 bytes macros/latex/exptl/mem/lgr-rec.ocp | Bin 0 -> 16352 bytes macros/latex/exptl/mem/lgr.ed | 6 + macros/latex/exptl/mem/macstd.ocp | Bin 0 -> 1180 bytes macros/latex/exptl/mem/mem-comm.sty | 112 ++ macros/latex/exptl/mem/mem.cfg | 17 + macros/latex/exptl/mem/mem.pdf | Bin 0 -> 213362 bytes macros/latex/exptl/mem/mem.sty | 1439 ++++++++++++++++ macros/latex/exptl/mem/mem.tex | 1197 +++++++++++++ macros/latex/exptl/mem/ot1-com.ocp | Bin 0 -> 3968 bytes macros/latex/exptl/mem/ot1-dec.ocp | Bin 0 -> 12612 bytes macros/latex/exptl/mem/ot1-rec.ocp | Bin 0 -> 8476 bytes macros/latex/exptl/mem/ot1.ed | 6 + macros/latex/exptl/mem/readme.txt | 258 +++ macros/latex/exptl/mem/rus.ld | 71 + macros/latex/exptl/mem/russian.pdf | Bin 0 -> 31721 bytes macros/latex/exptl/mem/russian.tex | 82 + macros/latex/exptl/mem/shared.sd | 99 ++ macros/latex/exptl/mem/spguill.ocp | Bin 0 -> 276 bytes macros/latex/exptl/mem/spguill.sty | 15 + macros/latex/exptl/mem/spguill.tex | 20 + macros/latex/exptl/mem/sppcent.ocp | Bin 0 -> 132 bytes macros/latex/exptl/mem/t1-com.ocp | Bin 0 -> 3984 bytes macros/latex/exptl/mem/t1-dec.ocp | Bin 0 -> 12612 bytes macros/latex/exptl/mem/t1-rec.ocp | Bin 0 -> 12512 bytes macros/latex/exptl/mem/t1.ed | 5 + macros/latex/exptl/mem/t1comp.ocp | Bin 0 -> 23548 bytes macros/latex/exptl/mem/t2a-com.ocp | Bin 0 -> 3904 bytes macros/latex/exptl/mem/t2a-dec.ocp | Bin 0 -> 1476 bytes macros/latex/exptl/mem/t2a-rec.ocp | Bin 0 -> 9436 bytes macros/latex/exptl/mem/t2a.ed | 5 + macros/latex/exptl/mem/testmisc.pdf | Bin 0 -> 22012 bytes macros/latex/exptl/mem/testmisc.tex | 81 + macros/latex/exptl/mem/uar.ed | 5 + macros/latex/exptl/mem/uaromarb.fd | 45 + macros/latex/exptl/mem/ucnoacc.ocp | Bin 0 -> 5212 bytes macros/latex/exptl/mem/ucy-com.ocp | Bin 0 -> 11148 bytes macros/latex/exptl/mem/ucy-dec.ocp | Bin 0 -> 1416 bytes macros/latex/exptl/mem/ucy-rec.ocp | Bin 0 -> 3320 bytes macros/latex/exptl/mem/ucy.ed | 5 + macros/latex/exptl/mem/ucyomlgc.fd | 45 + macros/latex/exptl/mem/uel-com.ocp | Bin 0 -> 10732 bytes macros/latex/exptl/mem/uel-dec.ocp | Bin 0 -> 6808 bytes macros/latex/exptl/mem/uel-rec.ocp | Bin 0 -> 9080 bytes macros/latex/exptl/mem/uel.ed | 9 + macros/latex/exptl/mem/uelomlgc.fd | 45 + macros/latex/exptl/mem/ula-com.ocp | Bin 0 -> 10692 bytes macros/latex/exptl/mem/ula-dec.ocp | Bin 0 -> 12552 bytes macros/latex/exptl/mem/ula-rec.ocp | Bin 0 -> 17520 bytes macros/latex/exptl/mem/ula.ed | 10 + macros/latex/exptl/mem/ulaomlgc.fd | 45 + macros/latex/exptl/mem/utf8.ocp | Bin 0 -> 448 bytes macros/latex/exptl/mem/verbatim.pdf | Bin 0 -> 14099 bytes macros/latex/exptl/mem/verbatim.tex | 25 + macros/latex/exptl/mem/yatest.pdf | Bin 0 -> 25665 bytes macros/latex/exptl/mem/yatest.tex | 125 ++ macros/latex/exptl/siunitx | 1 + macros/latex/exptl/texpower | 1 + macros/latex/exptl/thmtools/COPYING | 416 +++++ macros/latex/exptl/thmtools/README | 21 + macros/latex/exptl/thmtools/TODO | 3 + macros/latex/exptl/thmtools/VERSION.tex | 1 + macros/latex/exptl/thmtools/aliasctr.dtx | 114 ++ macros/latex/exptl/thmtools/parseargs.dtx | 80 + macros/latex/exptl/thmtools/thm-amsthm.dtx | 162 ++ macros/latex/exptl/thmtools/thm-autoref.dtx | 119 ++ macros/latex/exptl/thmtools/thm-beamer.dtx | 44 + macros/latex/exptl/thmtools/thm-kv.dtx | 486 ++++++ macros/latex/exptl/thmtools/thm-listof.dtx | 222 +++ macros/latex/exptl/thmtools/thm-llncs.dtx | 90 + macros/latex/exptl/thmtools/thm-ntheorem.dtx | 131 ++ macros/latex/exptl/thmtools/thm-patch.dtx | 252 +++ macros/latex/exptl/thmtools/thm-restate.dtx | 336 ++++ macros/latex/exptl/thmtools/thmdef-mdframed.dtx | 28 + macros/latex/exptl/thmtools/thmdef-shaded.dtx | 109 ++ macros/latex/exptl/thmtools/thmdef-thmbox.dtx | 36 + macros/latex/exptl/thmtools/thmtools-manual.tex | 1154 +++++++++++++ macros/latex/exptl/thmtools/thmtools.dtx | 90 + macros/latex/exptl/thmtools/thmtools.ins | 61 + macros/latex/exptl/thmtools/thmtools.pdf | Bin 0 -> 225947 bytes macros/latex/exptl/thmtools/unique.dtx | 173 ++ macros/latex/exptl/xdoc | 1 + 198 files changed, 25679 insertions(+) create mode 120000 macros/latex/exptl/biblatex create mode 120000 macros/latex/exptl/biblatex-contrib create mode 100644 macros/latex/exptl/delimtxt/delimtxt.dtx create mode 100644 macros/latex/exptl/delimtxt/delimtxt.ins create mode 100644 macros/latex/exptl/delimtxt/delimtxt.pdf create mode 100644 macros/latex/exptl/delimtxt/resulta.dat create mode 100644 macros/latex/exptl/delimtxt/resultb.dat create mode 100644 macros/latex/exptl/delimtxt/resultc.dat create mode 100644 macros/latex/exptl/delimtxt/test1.tex create mode 100644 macros/latex/exptl/delimtxt/test2.tex create mode 100644 macros/latex/exptl/delimtxt/test3.tex create mode 100644 macros/latex/exptl/gcite/CHANGES create mode 100644 macros/latex/exptl/gcite/README create mode 100644 macros/latex/exptl/gcite/gcite.dtx create mode 100644 macros/latex/exptl/gcite/gcite.ins create mode 100644 macros/latex/exptl/gcite/gcite.pdf create mode 100644 macros/latex/exptl/graphicp/descend.1 create mode 100644 macros/latex/exptl/graphicp/descend.mp create mode 100644 macros/latex/exptl/graphicp/div16b.sty create mode 100755 macros/latex/exptl/graphicp/epstopdf create mode 100644 macros/latex/exptl/graphicp/f2cletter.eps create mode 100644 macros/latex/exptl/graphicp/f2cletter.pdf create mode 100644 macros/latex/exptl/graphicp/f2mletter.eps create mode 100644 macros/latex/exptl/graphicp/f2mletter.pdf create mode 100644 macros/latex/exptl/graphicp/ficletter.jpg create mode 100644 macros/latex/exptl/graphicp/ficletter.pbm create mode 100644 macros/latex/exptl/graphicp/ficletter.png create mode 100644 macros/latex/exptl/graphicp/files create mode 100644 macros/latex/exptl/graphicp/graphicp.sty create mode 100644 macros/latex/exptl/graphicp/graphicpdoc.pdf create mode 100644 macros/latex/exptl/graphicp/graphicpdoc.tex create mode 100755 macros/latex/exptl/graphicp/img_bbox.pl create mode 100644 macros/latex/exptl/graphicp/keyvalx.sty create mode 100644 macros/latex/exptl/graphicp/laemu.sty create mode 100644 macros/latex/exptl/graphicp/laltest.tex create mode 100644 macros/latex/exptl/graphicp/laxtest.bbx create mode 100755 macros/latex/exptl/graphicp/pdfboxes.pl create mode 100644 macros/latex/exptl/graphicp/pts_bbox.sty create mode 100644 macros/latex/exptl/graphicp/pts_img.sty create mode 100755 macros/latex/exptl/mem/Mtp/allmtp.py create mode 100644 macros/latex/exptl/mem/Mtp/ellintex.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ellinviu.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ellmedb.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ellpsili.mtp create mode 100644 macros/latex/exptl/mem/Mtp/fratext.mtp create mode 100644 macros/latex/exptl/mem/Mtp/inputtex.mtp create mode 100644 macros/latex/exptl/mem/Mtp/lat2ru.mtp create mode 100644 macros/latex/exptl/mem/Mtp/lgr-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/lgr-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/lgr-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ot1-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ot1-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ot1-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/spguill.mtp create mode 100644 macros/latex/exptl/mem/Mtp/sppcent.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t1-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t1-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t1-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t2a-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t2a-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/t2a-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ucnoacc.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ucy-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ucy-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ucy-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/uel-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/uel-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/uel-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ula-com.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ula-dec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/ula-rec.mtp create mode 100644 macros/latex/exptl/mem/Mtp/utf8.mtp create mode 100755 macros/latex/exptl/mem/Tools/charset2otp.py create mode 100755 macros/latex/exptl/mem/Tools/fontenc2mtp.py create mode 100644 macros/latex/exptl/mem/Tools/lgr.mmap create mode 100755 macros/latex/exptl/mem/Tools/mtp2ocp.py create mode 100644 macros/latex/exptl/mem/Tools/ot1.mmap create mode 100644 macros/latex/exptl/mem/Tools/t1.mmap create mode 100644 macros/latex/exptl/mem/Tools/t2a.mmap create mode 100644 macros/latex/exptl/mem/Tools/ts1.mmap create mode 100644 macros/latex/exptl/mem/ar.sd create mode 100644 macros/latex/exptl/mem/ara.ld create mode 100644 macros/latex/exptl/mem/arabic.pdf create mode 100644 macros/latex/exptl/mem/arabic.tex create mode 100644 macros/latex/exptl/mem/bugs.txt create mode 100644 macros/latex/exptl/mem/cp1251.ocp create mode 100644 macros/latex/exptl/mem/cp1252.ocp create mode 100644 macros/latex/exptl/mem/cp1253.ocp create mode 100644 macros/latex/exptl/mem/cp1256.ocp create mode 100644 macros/latex/exptl/mem/cp1257.ocp create mode 100644 macros/latex/exptl/mem/cy.sd create mode 100644 macros/latex/exptl/mem/el.sd create mode 100644 macros/latex/exptl/mem/ell.ld create mode 100644 macros/latex/exptl/mem/ellintex.ocp create mode 100644 macros/latex/exptl/mem/ellinviu.ocp create mode 100644 macros/latex/exptl/mem/ellmedb.ocp create mode 100644 macros/latex/exptl/mem/ellpsili.ocp create mode 100644 macros/latex/exptl/mem/eng.ld create mode 100644 macros/latex/exptl/mem/esp.ld create mode 100644 macros/latex/exptl/mem/espisolat1.id create mode 100644 macros/latex/exptl/mem/fra.ld create mode 100644 macros/latex/exptl/mem/fratext.ocp create mode 100644 macros/latex/exptl/mem/greek.pdf create mode 100644 macros/latex/exptl/mem/greek.tex create mode 100644 macros/latex/exptl/mem/inputtex.ocp create mode 100644 macros/latex/exptl/mem/isoara.ocp create mode 100644 macros/latex/exptl/mem/isocyr.ocp create mode 100644 macros/latex/exptl/mem/isoell.ocp create mode 100644 macros/latex/exptl/mem/isolat1.ocp create mode 100644 macros/latex/exptl/mem/isolat2.ocp create mode 100644 macros/latex/exptl/mem/isolat4.ocp create mode 100644 macros/latex/exptl/mem/koi8ru.ocp create mode 100644 macros/latex/exptl/mem/koi8uk.ocp create mode 100644 macros/latex/exptl/mem/la.sd create mode 100644 macros/latex/exptl/mem/lat2ru.ocp create mode 100644 macros/latex/exptl/mem/lgr-com.ocp create mode 100644 macros/latex/exptl/mem/lgr-dec.ocp create mode 100644 macros/latex/exptl/mem/lgr-rec.ocp create mode 100644 macros/latex/exptl/mem/lgr.ed create mode 100644 macros/latex/exptl/mem/macstd.ocp create mode 100644 macros/latex/exptl/mem/mem-comm.sty create mode 100644 macros/latex/exptl/mem/mem.cfg create mode 100644 macros/latex/exptl/mem/mem.pdf create mode 100644 macros/latex/exptl/mem/mem.sty create mode 100644 macros/latex/exptl/mem/mem.tex create mode 100644 macros/latex/exptl/mem/ot1-com.ocp create mode 100644 macros/latex/exptl/mem/ot1-dec.ocp create mode 100644 macros/latex/exptl/mem/ot1-rec.ocp create mode 100644 macros/latex/exptl/mem/ot1.ed create mode 100644 macros/latex/exptl/mem/readme.txt create mode 100644 macros/latex/exptl/mem/rus.ld create mode 100644 macros/latex/exptl/mem/russian.pdf create mode 100644 macros/latex/exptl/mem/russian.tex create mode 100644 macros/latex/exptl/mem/shared.sd create mode 100644 macros/latex/exptl/mem/spguill.ocp create mode 100644 macros/latex/exptl/mem/spguill.sty create mode 100644 macros/latex/exptl/mem/spguill.tex create mode 100644 macros/latex/exptl/mem/sppcent.ocp create mode 100644 macros/latex/exptl/mem/t1-com.ocp create mode 100644 macros/latex/exptl/mem/t1-dec.ocp create mode 100644 macros/latex/exptl/mem/t1-rec.ocp create mode 100644 macros/latex/exptl/mem/t1.ed create mode 100644 macros/latex/exptl/mem/t1comp.ocp create mode 100644 macros/latex/exptl/mem/t2a-com.ocp create mode 100644 macros/latex/exptl/mem/t2a-dec.ocp create mode 100644 macros/latex/exptl/mem/t2a-rec.ocp create mode 100644 macros/latex/exptl/mem/t2a.ed create mode 100644 macros/latex/exptl/mem/testmisc.pdf create mode 100644 macros/latex/exptl/mem/testmisc.tex create mode 100644 macros/latex/exptl/mem/uar.ed create mode 100644 macros/latex/exptl/mem/uaromarb.fd create mode 100644 macros/latex/exptl/mem/ucnoacc.ocp create mode 100644 macros/latex/exptl/mem/ucy-com.ocp create mode 100644 macros/latex/exptl/mem/ucy-dec.ocp create mode 100644 macros/latex/exptl/mem/ucy-rec.ocp create mode 100644 macros/latex/exptl/mem/ucy.ed create mode 100644 macros/latex/exptl/mem/ucyomlgc.fd create mode 100644 macros/latex/exptl/mem/uel-com.ocp create mode 100644 macros/latex/exptl/mem/uel-dec.ocp create mode 100644 macros/latex/exptl/mem/uel-rec.ocp create mode 100644 macros/latex/exptl/mem/uel.ed create mode 100644 macros/latex/exptl/mem/uelomlgc.fd create mode 100644 macros/latex/exptl/mem/ula-com.ocp create mode 100644 macros/latex/exptl/mem/ula-dec.ocp create mode 100644 macros/latex/exptl/mem/ula-rec.ocp create mode 100644 macros/latex/exptl/mem/ula.ed create mode 100644 macros/latex/exptl/mem/ulaomlgc.fd create mode 100644 macros/latex/exptl/mem/utf8.ocp create mode 100644 macros/latex/exptl/mem/verbatim.pdf create mode 100644 macros/latex/exptl/mem/verbatim.tex create mode 100644 macros/latex/exptl/mem/yatest.pdf create mode 100644 macros/latex/exptl/mem/yatest.tex create mode 120000 macros/latex/exptl/siunitx create mode 120000 macros/latex/exptl/texpower create mode 100644 macros/latex/exptl/thmtools/COPYING create mode 100644 macros/latex/exptl/thmtools/README create mode 100644 macros/latex/exptl/thmtools/TODO create mode 100644 macros/latex/exptl/thmtools/VERSION.tex create mode 100644 macros/latex/exptl/thmtools/aliasctr.dtx create mode 100644 macros/latex/exptl/thmtools/parseargs.dtx create mode 100644 macros/latex/exptl/thmtools/thm-amsthm.dtx create mode 100644 macros/latex/exptl/thmtools/thm-autoref.dtx create mode 100644 macros/latex/exptl/thmtools/thm-beamer.dtx create mode 100644 macros/latex/exptl/thmtools/thm-kv.dtx create mode 100644 macros/latex/exptl/thmtools/thm-listof.dtx create mode 100644 macros/latex/exptl/thmtools/thm-llncs.dtx create mode 100644 macros/latex/exptl/thmtools/thm-ntheorem.dtx create mode 100644 macros/latex/exptl/thmtools/thm-patch.dtx create mode 100644 macros/latex/exptl/thmtools/thm-restate.dtx create mode 100644 macros/latex/exptl/thmtools/thmdef-mdframed.dtx create mode 100644 macros/latex/exptl/thmtools/thmdef-shaded.dtx create mode 100644 macros/latex/exptl/thmtools/thmdef-thmbox.dtx create mode 100644 macros/latex/exptl/thmtools/thmtools-manual.tex create mode 100644 macros/latex/exptl/thmtools/thmtools.dtx create mode 100644 macros/latex/exptl/thmtools/thmtools.ins create mode 100644 macros/latex/exptl/thmtools/thmtools.pdf create mode 100644 macros/latex/exptl/thmtools/unique.dtx create mode 120000 macros/latex/exptl/xdoc (limited to 'macros/latex/exptl') diff --git a/macros/latex/exptl/biblatex b/macros/latex/exptl/biblatex new file mode 120000 index 0000000000..5824d9c628 --- /dev/null +++ b/macros/latex/exptl/biblatex @@ -0,0 +1 @@ +../contrib/biblatex \ No newline at end of file diff --git a/macros/latex/exptl/biblatex-contrib b/macros/latex/exptl/biblatex-contrib new file mode 120000 index 0000000000..2e38bcfa06 --- /dev/null +++ b/macros/latex/exptl/biblatex-contrib @@ -0,0 +1 @@ +../contrib/biblatex-contrib \ No newline at end of file diff --git a/macros/latex/exptl/delimtxt/delimtxt.dtx b/macros/latex/exptl/delimtxt/delimtxt.dtx new file mode 100644 index 0000000000..28b11ed95a --- /dev/null +++ b/macros/latex/exptl/delimtxt/delimtxt.dtx @@ -0,0 +1,330 @@ +% \iffalse +%<*drv> +\documentclass{ltxdoc} +\usepackage{doc} +\usepackage[T1]{fontenc} +\usepackage[ansinew]{inputenc} +\CodelineIndex +\parindent0pt +\setcounter{IndexColumns}{2} +\begin{document} +%\OnlyDescription %Comment out for Desription only +\setlength\hfuzz{15pt} +\sloppy +\DocInput{delimtxt.dtx} +\end{document} +% +%\fi +% \MakeShortVerb{\|} +% \CheckSum{270} +% Copyright 1999 Bjoern Pedersen +% This program can be redistributed and/or modified under the terms +% of the LaTeX Project Public License Distributed from CTAN +% archives in directory macros/latex/base/lppl.txt; either +% version 1 of the License, or any later version. +% +% +%% This is heavily based on: +%% textmerg.dtx (with options: `textmerg') +%% +%% Copyright (C) 1992,1994 Mike Piff, University of Sheffield, England +% \section{Intro} +% This package tries do deal with single character delimited table +% files. It was mainly inspired and is heavily based on Mike Piff's +% textmerg package. +% +% Note for package writers: +% As this package is still under development, the interface is not g +% guaranteed to be stable. Please consider this if you want to use this +% package in your style files +% +% \section{Description} +% \DescribeMacro{\SetDel} +% The |\SetDel| set the character used as +% a delimiter in the input file. The default is \texttt{\char126}. +% If the character does not have |\catcode=12|, you should adjust this +% before setting it as in this example: +% \begin{verbatim} +% {\catcode`\^^I=12 +% \SetDel^^I} +% \end{verbatim} +% This would set del to the -character +% +% \DescribeMacro{\Fields} +% The |\Fields| macor takes a list of control sequence, which will be +% assigned during the read in process. +% Example: +% \begin{verbatim} +% \Fields{\Title\Forenames\Surname\Address\Grade} +% \end{verbatim} +% +% \DescribeMacro{\DelimRead} +% After defining the |\Fields|, a file is read in with +% |\DelimRead{File}{Template}|, +% where |File| is the filename of the data file, and |Template| is the +% text, in which occurences of the csnames in the |\Fields|-macro +% should be replaced by text from the data file. +% +% \StopEventually +% \section{Code} +% \subsection{Header} +% Announce the file. +% \begin{macrocode} +%<*delimtxt> +\def\fileversion{1.02} +\def\filedate{1999/05/03} +\def\filename{delimtxt.dtx} +\def\Copyright{Copyright 1999 Bjoern Pedersen} +\NeedsTeXFormat{LaTeX2e}[1998/06/01] +\ProvidesPackage{delimtxt}[\filedate] +\typeout{Package `delimtxt´ <\filedate>.} +\typeout{\Copyright} +% \end{macrocode} +% \subsection{Utility macros} +% \begin{macrocode} +\def\glet{\global\let} + +% \end{macrocode} +%\subsection{File Handling} +% This opens a file and reads it line by line into |\InputBuffer|. +% \begin{macrocode} +\newread\DelimFile + +\def\InputFile#1{% + \openin\DelimFile=#1 + \ifeof\DelimFile + \errmessage{Empty Delim file}% + \closein\DelimFile + \long\def\MakeTemplate##1{% + \def\Template{}}% + \else\GetInput + \fi} +% \end{macrocode} +% +% Adjust the catcode of the delimiter temporarily, and read one line +% of input. +% \begin{macrocode} +\def\GetInput{{ + \global\LF@false + \endlinechar=-1% + \expandafter\catcode\expandafter`\the\Del=12 + \global\read\DelimFile to\InputBuffer}} +% \end{macrocode} +% +% Check, if there is anything left in the Input file. If not, stop +% Iterating. Empty lines in the file are silently skipped. +% +% \begin{macrocode} +\def\SeeIfEof{% + \let\NextLook\relax + \ifeof\DelimFile + \else + \ifx\InputBuffer\empty + \LookAgain + \fi + \fi + \NextLook} + +\def\LookAgain{\GetInput + \let\NextLook\SeeIfEof} +% \end{macrocode} + + +% \begin{macro}{\ifNonBlank} +% \begin{macro}{\AllowBlank} +% \begin{macro}{\DontAllowBlank} +%We can now prepare to read actual fields from the merge file. A conditional +%is used to indicate whether or not the field we are about to read is +%allowed to be blank. We also set up a mechanism for changing its value. +% \begin{macrocode} +\newif\ifNonBlank \NonBlankfalse +\def\AllowBlank{\global\NonBlankfalse} +\def\DontAllowBlank{\global\NonBlanktrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} + + + +% \subsection{Parsing the Input Buffer} +% This is the difficult part of the processing. +% \subsubsection{Helper macros and registers} +% We need some token registers to save the Input, the delimiter, and +% some of the definitions for dynamic parameter lists +% \begin{macrocode} +\newif\ifLF@ +\def\mark{\relax} +\newtoks\InPutField +\newtoks\Del +\newtoks\StripT@k +\newtoks\NextFieldT@k +% \end{macrocode} +%\subsubsection{Strip mark helper} +% A helper macro to strip of a marker, we placed in the input +% stream. It is put in |\StripT@k| and the actual definiton will take +% place on execution of |\SetDel| as we need to know what the +% delimiter actually is. +% +% \begin{macrocode} +\StripT@k={% +{% +\aftergroup\gdef% +\aftergroup\StripMark% +\aftergroup#\aftergroup1% +\expandafter\aftergroup\the\Del% +\aftergroup\mark% +}{\gdef\InputBuffer{#1}}} +% \end{macrocode} +% \subsubsection{Get the next Field value from the input stream } +% On execution of |\SetDel| this mess will define a macro +% |\GetNextInputField#1#2\lineend|. +% This will perform somthing similar to the C language |strtok| function. +% This macro gets the contents of the |\InputBuffer| plus an extra +% delimiter, a mark and a lineend marker. +% On Exit |\InputBuffer| is reassigned with one less Field after +% stripping of all markers. +% If nothing is left, a flag is set and |\InputBuffer| is set empty. +% This flag is currently unused, but could be used for better error +% handling in case of missing fields in the input. +% \begin{macrocode} + +\NextFieldT@k={% +{%begin of aftergroup group +\aftergroup\gdef% +\aftergroup\GetNextInputField% +\aftergroup#\aftergroup1% +\expandafter\aftergroup\the\Del% +\aftergroup#\aftergroup2% +\aftergroup\lineend}%end of aftergroup group +{% + \if\mark #2% + \global\LF@true% + \glet\InputBuffer=\empty% + \else% + \global\LF@false% + \StripMark#2% + \fi% + \InPutField={#1}% + \if!#1!% check if Field is empty (Ref: D.Carlise in comp.text.tex) + \ifNonBlank% + \MissingField% + \InPutField={???}% + \else% + \InPutField={#1}% + \fi% + \else + \relax + \fi% +}} +% \end{macrocode} +% +% This macro sets the Delimiter. As this may be called at any time, +% we need to redefine the macros |\GetNextInputField| +% and |\StripMark|. The definitions have been stored in two token +% registers, so we have just to execute them. The trickery with +% |\aftergroup| in the token list enables expansion of |\the\Del| in +% the macro parameter list. +% +% +% \begin{macrocode} +\def\SetDel#1{\global\Del={#1}% +\the\StripT@k% +\the\NextFieldT@k% +} +\SetDel| + + +% \end{macrocode} +% \subsection{Parsing the fields} +% Here we parse the inout fields as in the textmerg package, but +% getting values from our new parser. Probably, the treatment of +% missing items is not very good( in fact it is completly missing) +% We have to put a |\mark| and |\lineend| in the stream, do detect +% the end of the input line. +% +% \begin{macrocode} + +\def\ReadIn#1{% + \expandafter\expandafter\expandafter% + \GetNextInputField% + \expandafter\InputBuffer\the\Del% + \mark\lineend% + \global\edef#1{\the\InPutField}% +} +% \end{macrocode} +% This is not used yet. +% \begin{macrocode} +\def\MissingField{% + \message{Missing field in file}} +% \end{macrocode} +% +% Here begins the field parsing, as in the textmerg-package. +% +% \begin{macrocode} + +\newtoks\GlobalFields +% +\def\Fields#1{\GlobalFields{#1}} +% +\def\ParseFields#1{% + \ifx#1\EndParseFields% + \let\NextParse\relax% + \ifLF@% + \message{ Line was OK}% + \else% + {\message{ There were more items than fields on line + \the\Iteratecounter. They will be skipped.} + \glet\InputBuffer=\empty}% + \fi% + \else% + \let\NextParse\ParseFields% + \ifx#1+\DontAllowBlank% + \else% + \ifx#1-\AllowBlank% + \else\ReadIn#1% + \fi% + \fi% + \fi\NextParse}% + +\let\EndParseFields\ParseFields% +% \end{macrocode} +% \begin{macrocode} +\def\ReadFields#1{ +\ifeof\DelimFile% + \else% +\expandafter\ParseFields% + \the#1\EndParseFields% +\fi}% +% \end{macrocode} +%\subsection{The iteration code} +% \begin{macrocode} +\long\def\DelimRead#1#2{\begingroup% + \InputFile{#1}% + \def\Fields##1{% + \ParseFields##1\EndParseFields}% + \MakeTemplate{#2}\Iterate}% +% \end{macrocode} +% \begin{macrocode} +\long\def\MakeTemplate#1{\def\Template{#1}} +% \end{macrocode} +% \begin{macrocode} +\countdef\Iteratecounter=1% + +\Iteratecounter=0 +\def\Iterate{% + \global\advance\Iteratecounter by1% + \ReadFields\GlobalFields% + \Template% + \SeeIfEof% + \ifeof\DelimFile% + \def\NextIteration{% + \endgroup\closein\DelimFile}% + \else% + \let\NextIteration\Iterate% + \fi% + \NextIteration} +\endinput +% \end{macrocode} +% +%\Finale diff --git a/macros/latex/exptl/delimtxt/delimtxt.ins b/macros/latex/exptl/delimtxt/delimtxt.ins new file mode 100644 index 0000000000..b093b8760b --- /dev/null +++ b/macros/latex/exptl/delimtxt/delimtxt.ins @@ -0,0 +1,6 @@ +%% DocStrip driver for ffmbg +\input docstrip +%\askonceonly +\generate{\file{delimtxt.sty}{\from{delimtxt.dtx}{delimtxt}}} +\endbatchfile + diff --git a/macros/latex/exptl/delimtxt/delimtxt.pdf b/macros/latex/exptl/delimtxt/delimtxt.pdf new file mode 100644 index 0000000000..16cb56228b Binary files /dev/null and b/macros/latex/exptl/delimtxt/delimtxt.pdf differ diff --git a/macros/latex/exptl/delimtxt/resulta.dat b/macros/latex/exptl/delimtxt/resulta.dat new file mode 100644 index 0000000000..540f89b9f9 --- /dev/null +++ b/macros/latex/exptl/delimtxt/resulta.dat @@ -0,0 +1,2 @@ +Miss|Iusta|Mo|34 Winchester Road\\Sheffield\\England|9 +Mr|Arthur|Minit|43 Sheffield Road\\Winchester\\England|8 diff --git a/macros/latex/exptl/delimtxt/resultb.dat b/macros/latex/exptl/delimtxt/resultb.dat new file mode 100644 index 0000000000..390c6eb972 --- /dev/null +++ b/macros/latex/exptl/delimtxt/resultb.dat @@ -0,0 +1,2 @@ +Miss Iusta Mo 34 Winchester Road\\Sheffield\\England 2 7 xxx +Mr Arthur Minit 43 Sheffield Road\\Winchester\\England 3 6 diff --git a/macros/latex/exptl/delimtxt/resultc.dat b/macros/latex/exptl/delimtxt/resultc.dat new file mode 100644 index 0000000000..ff6817938b --- /dev/null +++ b/macros/latex/exptl/delimtxt/resultc.dat @@ -0,0 +1,2 @@ +Miss|Iusta|Mo|34 Winchester Road\\Sheffield\\England|11 22 33 +Mr|Arthur|Minit|43 Sheffield Road\\Winchester\\England|C diff --git a/macros/latex/exptl/delimtxt/test1.tex b/macros/latex/exptl/delimtxt/test1.tex new file mode 100644 index 0000000000..74f76101df --- /dev/null +++ b/macros/latex/exptl/delimtxt/test1.tex @@ -0,0 +1,31 @@ +%% +%% This is file `tmexamp1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% textmerg.dtx (with options: `examp') +%% +\documentclass[12pt]{letter} +\usepackage[ansinew]{inputenc} + +\usepackage{delimtxt} +\begin{document} +\Fields{\Title\Forenames\Surname + \Address\Grade} +{\catcode`\^^I=12 +\SetDel^^I} +\DelimRead{resultb.dat}{% +\begin{letter}{\Title\ \Forenames\ + \Surname\\\Address} + \opening{Dear \Title\ \Surname,} + This letter is to inform you + that you obtained grade \Grade\ in + your recent examinations. + \closing{Yours faithfully,} +\end{letter} +} +\end{document} +\endinput +%% +%% End of file `tmexamp1.tex'. diff --git a/macros/latex/exptl/delimtxt/test2.tex b/macros/latex/exptl/delimtxt/test2.tex new file mode 100644 index 0000000000..1958cfb22a --- /dev/null +++ b/macros/latex/exptl/delimtxt/test2.tex @@ -0,0 +1,29 @@ +%% +%% This is file `tmexamp1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% textmerg.dtx (with options: `examp') +%% +\documentclass[12pt]{letter} +\usepackage[ansinew]{inputenc} + +\usepackage{delimtxt} +\begin{document} +\Fields{\Title\Forenames\Surname + \Address\Grade} +\DelimRead{resulta.dat}{% +\begin{letter}{\Title\ \Forenames\ + \Surname\\\Address} + \opening{Dear \Title\ \Surname,} + This letter is to inform you + that you obtained grade \Grade\ in + your recent examinations. + \closing{Yours faithfully,} +\end{letter} +} +\end{document} +\endinput +%% +%% End of file `tmexamp1.tex'. diff --git a/macros/latex/exptl/delimtxt/test3.tex b/macros/latex/exptl/delimtxt/test3.tex new file mode 100644 index 0000000000..6a97c946e4 --- /dev/null +++ b/macros/latex/exptl/delimtxt/test3.tex @@ -0,0 +1,33 @@ +%% +%% This is file `tmexamp1.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% textmerg.dtx (with options: `examp') +%% +\documentclass[12pt]{letter} +\usepackage[latin1]{inputenc} + +\usepackage{delimtxt} +\begin{document} +\Fields{\Title\Forenames\Surname + \Address-\Grade} +%{\catcode`\^^I=12 +%\SetDel^^I} +\tracingmacros=2 +\tracingcommands=2 +\DelimRead{resultc.dat}{% +\begin{letter}{\Title\ \Forenames\ + \Surname\\\Address} + \opening{Dear \Title\ \Surname,} + This letter is to inform you + that you obtained grade \Grade\ in + your recent examinations. + \closing{Yours faithfully,} +\end{letter} +} +\end{document} +\endinput +%% +%% End of file `tmexamp1.tex'. diff --git a/macros/latex/exptl/gcite/CHANGES b/macros/latex/exptl/gcite/CHANGES new file mode 100644 index 0000000000..6e463aabf3 --- /dev/null +++ b/macros/latex/exptl/gcite/CHANGES @@ -0,0 +1,20 @@ +The gcite Package +================== + +Copyright 2007--2009 Matthew Tylee Atkinson, Iain Phillips +Distributed under the LPPL 1.3 (http://www.latex-project.org/lppl.txt) + +Changes +-------- + +v1.0.1 -- 3rd July 2009 + * Don't crash TeX if [normalcite] is passed to the package and \origcite is used. + * Allow an optional argument to be passed to \cite (as with the command in standard LaTeX). + * Authors should write using the standard LaTeX ``~\cite'' convention. + * Minor documentation improvements (consistency with other documentation; improved navigation and clarification of some issues). + +v1.0.0 -- 2nd September 2007 + * Initial release. + + +== END == diff --git a/macros/latex/exptl/gcite/README b/macros/latex/exptl/gcite/README new file mode 100644 index 0000000000..b56ca6c91d --- /dev/null +++ b/macros/latex/exptl/gcite/README @@ -0,0 +1,36 @@ +The gcite Package +================== + +Copyright 2007--2009 Matthew Tylee Atkinson, Iain Phillips +Distributed under the LPPL 1.3 (http://www.latex-project.org/lppl.txt) + +Abstract +--------- + +This package allows you to make citations in the German style, which +is considered by many to be particularly reader-friendly. The citation +provides a small amount of bibliographic information in a footnote on +the page where each citation is made. It combines a desire to eliminate +unnecessary page-turning with the look-up efficiency afforded by numeric +citations. + +Installation +------------- + +If you wish to install the latest version of gcite locally... + +1. mkdir -pv ~/texmf/tex/latex/gcite/ +2. cp gcite.dtx gcite.ins ~/texmf/tex/latex/gcite/ +3. cd ~/texmf/tex/latex/gcite/ +4. latex gcite.ins +5. Compile the manual... + a. pdflatex gcite.dtx + b. bibtex gcite + c. pdflatex gcite.dtx + d. pdflatex gcite.dtx +6. Read the manual ;-). + +Please contact us if you have any problems or suggestions. + + +== END == diff --git a/macros/latex/exptl/gcite/gcite.dtx b/macros/latex/exptl/gcite/gcite.dtx new file mode 100644 index 0000000000..c225cdbc92 --- /dev/null +++ b/macros/latex/exptl/gcite/gcite.dtx @@ -0,0 +1,392 @@ +%\iffalse +% gcite.dtx generated using makedtx version 0.94b (c) Nicola Talbot +% Command line args: +% -setambles "gcite\.bib=>\nopreamble\nopostamble" +% -src "gcite\.sty=>gcite.sty" +% -src "gcite\.bib=>gcite.bib" +% -doc "gcite.tex" +% -author "Matthew Tylee Atkinson and Iain Phillips" +% -license "lppl" +% gcite +% Created on 2009/7/4 13:22 +%\fi +%\iffalse +%<*package> +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +% +%\fi +% \iffalse +% Doc-Source file to use with LaTeX2e +% Copyright (C) 2009 Matthew Tylee Atkinson and Iain Phillips, all rights reserved. +% \fi +% \iffalse +%<*driver> +%%% +%%% gcite manual +%%% Matthew Tylee Atkinson +%%% Package code written with Iain Phillips +%%% +\documentclass[british,a4paper]{ltxdoc} +\usepackage{babel,color} +\usepackage[hyperref=true]{biblatex} +\definecolor{darkblue}{rgb}{0, 0, 0.5} +\definecolor{darkgreen}{rgb}{0, 0.5, 0} +\usepackage[colorlinks,linkcolor=darkblue,citecolor=darkgreen,breaklinks,linktocpage,pdftitle={The gcite Package},pdfauthor={Matthew Tylee Atkinson and Iain Phillips},pdfsubject={}]{hyperref} +\usepackage{gcite} + +\title{The \pkg{gcite} Package\\\large Citations in the German\footnote{footnotes containing brief information and standard numeric links to bibliography entries with full information}~~Style \\ Version 1.0.1} +\author{Matthew Tylee Atkinson\\\email{M.T.Atkinson@lboro.ac.uk} \and Iain Phillips\\\email{I.W.Phillips@lboro.ac.uk}} +\date{3rd July 2009} + +\newcommand{\pkg}[1]{% + \textsf{#1}} +\newcommand{\opt}[1]{% + \texttt{#1}} +\newcommand{\email}[1]{% + \texttt{#1}} +\newcommand{\biblatexSecPage}[2]{% + (section #1; page #2)} + +\bibliography{gcite} +\begin{document} +\DocInput{gcite.dtx} +\end{document} +% +%\fi +%\maketitle +%\begin{abstract} +%This package allows you to make citations in the German style, which is considered by many to be particularly reader-friendly. The citation provides a small amount of bibliographic information in a footnote on the page where each citation is made. It combines a desire to eliminate unnecessary page-turning with the look-up efficiency afforded by numeric citations. +%\end{abstract} +% +%\tableofcontents +% +%\section{Introduction} +% +%When writing a document, the aim should be to make the reading process as smooth as possible. You may well enjoy using the numeric style of citations, but this means that no information on the cited works is made available at the point of citation in the text. +% +%One answer to this the German citation style, which is implemented by the \pkg{gcite} package. It will print some limited information about cited works\cite{Dhiensa2005} in a footnote and still provide a traditional numeric link to the bibliography. Using \pkg{gcite} offers more information than the author-year citation format and keeps the fast indexing ability of using numeric citations. +% +%The package can also deal with multi-key citations, as with the traditional \LaTeX\ |\cite| command\cite{opcit,AGRIP}. +% +%\section{Prerequisites} +% +%The \pkg{gcite} package requires that you use \pkg{biblatex}. This package implements most of the functionality of \BibTeX\ in \LaTeX\ and provides commands that allow lower-level access to bibliographic data than the standard |\cite| command. +% +%It is recommended that you read the documentation for the \pkg{biblatex} package\cite{biblatex}. However, what follows is a short overview of the few steps needed to turn a standard \LaTeX\ document into one that will work with \pkg{biblatex}. +% +%\begin{enumerate} +%\item |\usepackage[hyperref=true]{biblatex}| \emph{before} \pkg{hyperref} is loaded, if you're using it (if not you can ignore the \opt{hyperref} option completely). +% +%\item Move your |\bibliography| command to the document's preamble (e.g. directly before |\begin{document}|). +% +%\item Remove the |\bibliographystyle| command. +% +%\item Add |\printbibliography| where you want the bibliography to be generated. Use |\printbibliography[heading=bibintoc]| if you want the bibliography section to show up in the table of contents of your document. +%\end{enumerate} +% +%\section{Usage} +% +%\DescribeMacro{\usepackage\{gcite\}} To use the \pkg{gcite} package, simply load it. There is only one package option, detailed in section~\ref{sec:pkgopt}. +% +%All of your citation commands will then be overridden with the new behaviour (even those with non-breaking spaces before them, as is customary for citations in \LaTeX\ documents). +% +%\subsection{Recommended Citation Style} +% +%All of the examples in this manual were created using \pkg{biblatex}'s default style of citation markers. This is the same as the ``plain'' bibliography style in normal \LaTeX/\BibTeX\ and is the recommended style for use with \pkg{gcite}, because it allows for fast indexing into the bibliography section. +% +%You are, however, free to choose whichever style of citation you like---\pkg{gcite} will still encapsulate it into a footnote as in the examples presented here. +% +%\subsection{Multi-Key Citations} +% +%Sometimes you will wish to cite only one piece of work to prove a point and, at other times, multiple works ought to be cited. The traditional |\cite| command groups multi-key citations together (i.e. multiple numbers, separated by commas, can be found inside the square brackets). +% +%\pkg{gcite} groups multi-key citations similarly, outputting the minimal bibliographic details for each work in turn, then the grouped numeric citation at the end. Section~\ref{sec:customisation:multi} contains information on how the separator used may be customised. +% +%\subsection{Citations Within Footnotes} +% +%There may be occasions when you may wish to make a citation from within a |\footnote|. In this case, \pkg{gcite} will not create a new footnote, but continue using the existing one\footnote{as shown in this example\cite{AGRIP}}. Section~\ref{sec:customisation:foot} contains some information on how this behaviour may be customised. +% +%\subsection{Reverting to the Standard Behaviour} +% +%It is possible to revert to the standard \LaTeX/\BibTeX\ citation behaviour. Two methods are provided (to cater for global and local reversion). +% +%\subsubsection{The \opt{normalcite} Option\label{sec:pkgopt}} +% +%\DescribeMacro{normalcite} Simply specify the \opt{normalcite} option when loading \pkg{gcite} and the standard behaviour will be restored for all citations in your document. +% +%Please note that if you use this method, you'll not be required to re-insert spaces before each |\cite| command---\pkg{gcite} will insert them for you. +% +%\subsubsection{One-Off Citations in the Standard Style} +% +%\DescribeMacro{\origcite\{\}} If you wish to make relatively few citations in the standard, non-footnote style, you can use this command. It will affect only the current citation being made and \emph{does} require that a space (non-breaking or otherwise) be inserted before it. +% +%This command is provided for special cases (such as an appendix to a thesis that lists prior publications) where adding the footnotes would be repeating information. It is not intended to be used often, or even at all, by most users. +% +%\section{Customisation} +% +%There are a few customisation options provided by the \pkg{gcite} package. They allow some control over the way that citations are presented. +% +%\subsection{Multi-Key Item Separator} +%\label{sec:customisation:multi} +% +%\DescribeMacro{\gciteitemsep\{\}} The default separator between items (cited works) in a multi-key citation is the semicolon, followed by a space. This can be easily changed by using the |\gciteitemsep| command. The example below shows the separator being set to the bullet point symbol, with a space on either side. +% +%\gciteitemsep{ \textbullet\ } +%\begin{verbatim} +%\gciteitemsep{ \textbullet\ } +%\end{verbatim} +% +%It is possible to use this command anywhere in your document. After doing so, the effects of having adjusted the citation separator can be seen\cite{biblatex,Dhiensa2005,Stone2004}. +% +%\subsection{Footnote Citation Separators} +%\label{sec:customisation:foot} +% +%\DescribeMacro{\gcitefoot*sep\{\}} As discussed above, citations may be made inside footnotes. In this case, a separator is placed between the footnote text and citation text \emph{and} at the end of the citation text. The default pre-citation text separator is the em-dash (``---'') and the default post-citation text separator is literally nothing. As with the multi-key separator above, both of these may be customised. Some examples follow. +% +%In this example, we redefine only the pre-citation text separator. +% +%\gcitefootpresep{: } +%\begin{verbatim} +%\gcitefootpresep{: } +%\end{verbatim} +% +%These commands may also be used anywhere in your document\footnote{and here is an example\cite{makedtx}}. Below is an example where both the pre- and post- separators are set. +% +%\gcitefootpresep{ (} +%\gcitefootpostsep{)} +%\begin{verbatim} +%\gcitefootpresep{ (} +%\gcitefootpostsep{)} +%\end{verbatim} +% +%Once again, the effect of executing these commands can be seen below\footnote{Setting both a pre- and post-citation separator has an effect like this\cite{AGRIP}.}. +% +%\printbibliography[heading=bibnumbered] +%\appendix +%\section{Help for Newcomers to \pkg{biblatex}} +% +%\begin{quote} +%``Don't Panic!''\\ +%---Douglas Adams, ``The Hitchhiker's Guide to the Galaxy'' +%\end{quote} +% +%\gcitefootpresep{} +%\gcitefootpostsep{; } +% +%Below is a list of things that people new to the \pkg{biblatex} package need to be aware of. Information on how to solve some potential problems is given, along with section and page number links to the \pkg{biblatex} documentation\footnote{\cite{biblatex}referenced manual section and page numbers are correct for version 0.6 beta (6th January 2007)} that you can use to find out more. +% +%\gcitefootpresep{---} +%\gcitefootpostsep{} +% +%\subsection{No Classic \BibTeX\ Custom Styles} +% +%Only styles made for \pkg{biblatex} may be used. This is not foreseen to be a problem in reality, as using \pkg{gcite} implies that the user has a particular (implemented) style in mind, but it is worth mentioning \biblatexSecPage{2}{2}. +% +%\subsection{More \BibTeX\ Fields Displayed} +% +%\pkg{biblatex} by default prints out more information from your |.bib| file(s). Fields such as ``howpublished'', ``doi'' and ``url'' are typeset by default \biblatexSecPage{2.1.1}{3--5}. +% +%It is possible to create your own bibliography style that suppress this extra information. The manual provides details \biblatexSecPage{4.2 [specifically 4.2.1 and 4.2.3]}{67--73} and the file |biblatex/bbx/standard.bbx| provides a useful template. +% +%\subsection{``Missing \$ inserted'' Compilation Error} +% +%This can be caused by invalid (special) characters appearing in certain fields in the |.bib| file(s). It may have gone un-noticed until now due to \pkg{biblatex}'s default inclusion of more field types than \BibTeX\ in the typeset document. One example cause is the special characters (such as: `\_'; `\&' and `\%') in a URL, if one is present in a field other than ``url'' (those \emph{inside} a ``url'' field will be automatically escaped). +% +%Make sure URLs are specified only in the ``url'' field and that special characters\footnote{see \url{http://theoval.cmp.uea.ac.uk/~nlct/latex/novices/node30.html}; last accessed 1st September 2007} in any other fields are escaped. The error message may tell you the line in any external file to the document (such as the intermediate |.bbl| file) where the error occurred. +% +%\subsection{When Non-US Localisation is Required\ldots} +% +%As \pkg{biblatex} prints out more fields than \BibTeX\ by default, including URL access dates, you may need to carry out some localisation to ensure these fields are typeset in an appropriate way for your country. +% +%A simple way to do this is to use the \pkg{babel} package\footnote{\url{http://www.ctan.org/tex-archive/macros/latex/required/babel/}; last accessed 1st September 2007}. Specify your language string (as listed in the \pkg{babel} documentation) as one of the options to |\documentclass|, then ensure you |\usepackage{babel}|. This way, all packages that support automatic localisation will pick up your language option. \pkg{biblatex} will reflect this too (and will do things such as use your local date format and provide some string translations as a result). +% +%\subsection{Not All Author Names Displayed in Bibliography} +% +%This is caused by \pkg{biblatex}'s default style only showing a certain number of author names by default, in contrast to what most people expect to see in the bibliography (a full list). You can solve this by use of the \opt{maxnames} package option for \pkg{biblatex}. +% +% +% +%\StopEventually{} +%\section{The Code} +%\iffalse +% \begin{macrocode} +%<*gcite.sty> +% \end{macrocode} +%\fi +% Package definition. +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gcite}[2009/07/03 1.0.1] +\RequirePackage{biblatex} +% \end{macrocode} +% Define our \opt{normalcite} option and set it to false by default. +% \begin{macrocode} +\newif\ifgcite@normalcite +\gcite@normalcitefalse +\DeclareOption{normalcite}{\gcite@normalcitetrue} +\ProcessOptions\relax +% \end{macrocode} +% \subsection{Minor Bits} +% Move the traditional |\cite{}| command out of the way. +% \begin{macrocode} +\let\origcite\cite +% \end{macrocode} +% Provide a way to customise the separator used between individual cited works. +% \begin{macrocode} +\providecommand{\gciteitemsep}[1]{\def\gcite@itemsep{#1}} +% \end{macrocode} +% Default multi-item separator is semicolon with a space following. +% \begin{macrocode} +\def\gcite@itemsep{; } +% \end{macrocode} +% Provide a way to customise the separator used between the footnote text and the citation text when a citation is made from inside a footnote. +% \begin{macrocode} +\providecommand{\gcitefootpresep}[1]{\def\gcite@foot@presep{#1}} +\providecommand{\gcitefootpostsep}[1]{\def\gcite@foot@postsep{#1}} +% \end{macrocode} +% Default footnote citation text pre-separator is an em-dash; default post-seperator is literally nothing. +% \begin{macrocode} +\def\gcite@foot@presep{---} +\def\gcite@foot@postsep{} +% \end{macrocode} +% \subsection{Core Commands} +% The core commands of the German citation style produce the short version(s) of the bibliographical information, followed by a pointer to the full citation in the bibliography. They are called internally. +% +% Each individual cited work's details must be treated atomically. +% \begin{macrocode} +\def\gcite@one#1{\citeauthor{#1}, \citetitle{#1}, \citeyear{#1}} +% \end{macrocode} +% We need a loop to output the details of each cited work in turn, then display the numerical link(s) at the end. +% \begin{macrocode} +\def\gcite@core#1#2{% + \newif\ifgcite@nfirst + \gcite@nfirstfalse% + \@for\@c:=#1\do{% + \ifgcite@nfirst{\gcite@itemsep}\else\gcite@nfirsttrue\fi% + \gcite@one\@c}~\origcite[#2]{#1}} +% \end{macrocode} +% \subsection{Citation Command Replacement} +% If the \opt{normalcite} option was specified, simply emulate the standard \LaTeX\ behaviour (including the non-breaking space). +% \begin{macrocode} +\ifgcite@normalcite% +% (do nothing) +\else% +% \end{macrocode} +% Otherwise, we use the \pkg{gcite} behaviour. As of version 1.0.1 we can handle an option passed in to this command to allow, for example, the document's author to refer the reader to a particular part of the cited document. +% \begin{macrocode} + \renewcommand{\cite}[2][]{% +% \end{macrocode} +% Here is a wrapper to decide if we're in a footnote or not. The idea was gained from the \pkg{opcit} package\cite{opcit}. +% \begin{macrocode} + \ifnum\interlinepenalty=\interfootnotelinepenalty% +% \end{macrocode} +% We are in a footnote---just add the text of the footnote citation to the end of the current footnote, separating it from the rest of the footnote text, if the user wishes. We pass the optional argument in as the second argument to our core routine (this is an aesthetic design decision and was made to signify the optional argument to this command being less important than the cite key(s)). +% \begin{macrocode} + \gcite@foot@presep\gcite@core{#2}{#1}\gcite@foot@postsep% + \else% +% \end{macrocode} +% Otherwise, we're not in a footnote, so create a new one. Again, the optional argument is passed in last. We use |\unskip| so that the author can put spaces (even non-breaking ones) before the citation, as they normally would. +% \begin{macrocode} + \unskip\footnote{\gcite@core{#2}{#1}}% + \fi% + } +\fi +% \end{macrocode} +% That's all, folks! +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%<*gcite.bib> +% \end{macrocode} +%\fi +% \iffalse +% \begin{macrocode} +@Misc{ makedtx, + author = "Nicola Talbot", + title = "{makedtx : a Perl script to help create a DTX file from + source code}", + url = "http://www.ctan.org/tex-archive/support/makedtx/", + urldate = {2007-09-02}, + year = "2005" +} + +@Misc{ opcit, + author = "Federico Garcia", + title = "{opcit (version 2.0) a package for footnote-style + bibliographical references}", + url = "http://www.ctan.org/tex-archive/macros/latex/contrib/opcit/" + , + urldate = {2007-09-02}, + year = "2006" +} + +@Misc{ biblatex, + author = "Philipp Lehman", + title = "{The biblatex package}", + url = "http://www.ctan.org/tex-archive/macros/latex/exptl/biblatex/" + , + urldate = {2007-09-02}, + year = "2006" +} + +@Misc{ agrip, + author = "Matthew Tylee Atkinson and Sabahattin Gucukoglu", + title = "{Accessible Gaming Rendering Independence Possible}", + url = "http://www.agrip.org.uk/", + month = "05", + year = "2003" +} + +@InProceedings{ dhiensa2005, + author = "Jatinder Dhiensa and Colin Machin and Francesca Smith and + Roger Stone", + title = "Optimizing the User Environment: Leading Towards an + Accessible and Usable Experience", + booktitle = "Accessible Design in the Digital World Conference 2005", + year = "2005", + issn = "1477-9358", + location = "Dundee, Scotland", + pdf = "paper3.pdf" +} + +@InProceedings{ stone2004, + author = "R. G. Stone and J. Dhiensa", + title = "Proving the validity and accessibility of dynamic + web-pages", + booktitle = "W4A '04: Proceedings of the 2004 international + cross-disciplinary workshop on Web accessibility (W4A)", + year = "2004", + pages = "45--49", + address = "New York, NY, USA", + publisher = "ACM Press", + doi = "http://doi.acm.org/10.1145/990657.990665", + isbn = "1-58113-903-9", + pdf = "p45-stone.pdf" +} +% \end{macrocode} +% \fi +%\iffalse +% \begin{macrocode} +% +% \end{macrocode} +%\fi +%\Finale +\endinput diff --git a/macros/latex/exptl/gcite/gcite.ins b/macros/latex/exptl/gcite/gcite.ins new file mode 100644 index 0000000000..5fab61b8b5 --- /dev/null +++ b/macros/latex/exptl/gcite/gcite.ins @@ -0,0 +1,32 @@ +% gcite.ins generated using makedtx version 0.94b 2009/7/4 13:22 +\input docstrip + +\preamble + + gcite.dtx + Copyright 2009 Matthew Tylee Atkinson and Iain Phillips + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license of (at your option) any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is Matthew Tylee Atkinson and Iain Phillips. + + This work consists of the files gcite.dtx and gcite.ins and the derived files gcite.sty, gcite.bib. + +\endpreamble + +\askforoverwritefalse + +\generate{\file{gcite.sty}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{gcite.dtx}{gcite.sty,package}} +\file{gcite.bib}{\nopreamble\nopostamble\from{gcite.dtx}{gcite.bib}} +} + +\endbatchfile diff --git a/macros/latex/exptl/gcite/gcite.pdf b/macros/latex/exptl/gcite/gcite.pdf new file mode 100644 index 0000000000..0a3edb1179 Binary files /dev/null and b/macros/latex/exptl/gcite/gcite.pdf differ diff --git a/macros/latex/exptl/graphicp/descend.1 b/macros/latex/exptl/graphicp/descend.1 new file mode 100644 index 0000000000..68d10eee40 --- /dev/null +++ b/macros/latex/exptl/graphicp/descend.1 @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: -6 -29 29 29 +%%Creator: MetaPost +%%CreationDate: 2002.12.24:2244 +%%Pages: 1 +%%EndProlog +%%Page: 1 1 +%%HiResBoundingBox: -5.25 -28.25 28.59645 28.25 + 0 0.5 dtransform truncate idtransform setlinewidth pop [] 0 setdash + 1 setlinejoin 10 setmiterlimit +newpath -5 -28 moveto +28.34645 -28 lineto +-5 28 lineto + closepath stroke + 1 setlinecap +newpath 11.67323 -28 moveto +-5 28 lineto stroke +newpath 11.67322 0 moveto +-5 -28 lineto stroke +newpath -5 0 moveto +28.34645 -28 lineto stroke +showpage +%%EOF diff --git a/macros/latex/exptl/graphicp/descend.mp b/macros/latex/exptl/graphicp/descend.mp new file mode 100644 index 0000000000..193612a443 --- /dev/null +++ b/macros/latex/exptl/graphicp/descend.mp @@ -0,0 +1,34 @@ +% +% descend.mp -- a MetaPost figure that descends far below the baseline +% by pts@fazekas.hu at Wed Feb 5 00:28:41 CET 2003 +% + +% input plain; + +% message jobname; + +extra_endfig := extra_endfig + & "special (" + & ditto & "%%HiResBoundingBox: " & ditto + & "&decimal xpart llcorner currentpicture &" & ditto & " " & ditto + & "&decimal ypart llcorner currentpicture &" & ditto & " " & ditto + & "&decimal xpart urcorner currentpicture &" & ditto & " " & ditto + & "&decimal ypart urcorner currentpicture );"; + +prologues:=2; % 2 == TeX + +%beginfig(-1) +beginfig(1) +%string extra_endfig; + %boxit a (btex Essai etex); + %fill bpath a witchcolor .5[red,white]; + %drawboxed(a); + pair A, B, C; + A:=(-5bp,-28bp); B:=(1cm,-28bp); C:=(-5bp,28bp); + draw A--B--C--cycle; + draw 1/2[A,B] -- C; + draw 1/2[B,C] -- A; + draw 1/2[C,A] -- B; +endfig; + +end; diff --git a/macros/latex/exptl/graphicp/div16b.sty b/macros/latex/exptl/graphicp/div16b.sty new file mode 100644 index 0000000000..523fa75026 --- /dev/null +++ b/macros/latex/exptl/graphicp/div16b.sty @@ -0,0 +1,490 @@ +% +% div16.tex -- perform 16.16 bit fixed point division +% by pts@fazekas.hu at Fri Dec 27 22:40:52 CET 2002 --- ... +% +% This .tex file contains TeX macros for double precision multiplication, +% division of integer and real numbers and image size scaling. The most +% remarkable macro in this file is \@@muldivletposdim (see the comments in +% front of it for detailed documentation). +% +% If you process this file with +% Plain TeX, the unit regression testsuite will be run, and the results of +% the operations issued at the end of this file will be printed to the +% terminal and into the .log file. +% +% The documentation of this macro package is scattered through this file as +% embedded TeX comments. +% +% History +% ~~~~~~~ +% started at Fri Dec 27 22:40:52 CET 2002 +% --- Sat Dec 28 01:26:52 CET 2002 +% 31.31 bit arithmetic: Tue Jan 7 18:12:53 CET 2003 +% skippable, partial \@@muldivpos at Tue Jan 7 21:00:17 CET 2003 +% skippable, finished, doesn't work at Tue Jan 7 21:43:25 CET 2003 +% first successful test case at Tue Jan 7 22:34:32 CET 2003 +% all test cases OK at Tue Jan 7 23:30:32 CET 2003 +% Fri Jan 24 12:56:23 CET 2003 +% uses laemu.sty +% + +\expandafter\ifx\csname ifLaTeX\endcsname\relax\input laemu.sty\relax\fi% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{div16b}[2003/01/24 v0.0 high precision div and mul] + +% +% SUXX: `\count0=2\count1' and `\advance\count0 by 2\count1' disallowed +% Dat: `\count0=-\count1' and `\advance\count0 by -\count1' OK +% +% Imp: @@ namespace +% + +% \def\@empty{} % from laemu.sty +% \catcode`\@=11 % \makeatletter + +%\def\loop#1\repeat{% +% \def\iterate{#1\relax\expandafter\iterate\fi}% +% \iterate \let\iterate\relax% +%}% +%\let\repeat\fi% + +% vvv so we can nest a \@@loop inside \loop or vica versa +\def\@@loop#1\@@repeat{% + \def\@@iterate{#1\relax\expandafter\@@iterate\fi}% + \@@iterate \let\@@iterate\relax% +}% +\let\@@repeat\fi% + +%\repeat +%alma +%\iftrue +%korte +%\loop + +\def\@@gobbleend#1\end{}% + +%** `\@@aftergroupbegin ... \end' types `...' token-by-token \aftergroup +%** Argument of \@@aftergroupbegin must not contain \end, {, or } +\def\@@aftergroupbegin#1{% + \ifx#1\end% + %\message{done} + \else% + %\message{\string#1}% + \aftergroup#1% + \expandafter\@@aftergroupbegin% + \fi% +}% + +%** Doesn't make a \global assignment to #1, but keeps its value after the +%** the next `}'. +%** @param #1 name of a \count, \dimen or \skip register (i.e \count0 or +%** \jot) +\def\@@noresetaftergroup#1{% + \@@aftergroupbegin#1=\end% + \expandafter\@@aftergroupbegin\the#1 \end% + % ^^^ The space before \end is required, because in LaTeX, \end is expandable + \aftergroup\relax% finish assignment +}% +%** Doesn't work if the definition of #1 contains strange tokens +%** @param #1 a macro \cs name +\def\@@keepdefaftergroup#1{% + \aftergroup\def% + \aftergroup#1% + \aftergroup{% + \expandafter\@@aftergroupbegin#1\end% + \aftergroup}% +}% + +%** Performs the `#1 := #2' assignment, avoids `Dimension too large' error if +%** both #1 and #2 are \counts. +%** @param #1 a \count or \dimen register specification +%** @param #2 a \count or \dimen register specification, an integer, a real +%** number or a dimension. Numbers are assumed to have unit `sp'. +\def\@@letdimcount#1#2{{% + \afterassignment\@@letdimcount@a\count0=#2 \end% + % Dat: now \@@letdimcount@c contains any of "", "sp", ".45", ".45pt" + \afterassignment\@@gobbleend\dimen0=1\@@letdimcount@c sp \end% "1", "1sp" "1.45sp" "1.45pt" + % Dat: 1.99999999sp == 1sp + \ifdim\dimen0=1sp% + %\showthe\count0 \message{\the\count0-sp}% + \afterassignment\@@gobbleend#1=\count0 sp \end% + \else% + \afterassignment\@@gobbleend\dimen0=#2 sp \end% + \afterassignment\@@gobbleend#1=\dimen0 sp \end% + \fi% + \@@noresetaftergroup{#1}% return(\T) +}}% +\def\@@letdimcount@a#1\end{\def\@@letdimcount@c{#1}}% +%** Performs the `#1 := #2' assignment, doesn't avoid `Dimension too large' +%** error if both #1 and #2 are \counts. +%** `\@@letdimcount#1#2' is the same as `\@@letdimcountany#1#2{sp}', but +%** \@@letdimcount avoids the error. +%** @param #1 a \count or \dimen register specification +%** @param #2 a \count or \dimen register specification, an integer, a real +%** number or a dimension. Numbers are assumed to have unit `#3'. +%** @param #3 default metric unit +\def\@@letdimcountany#1#2#3{{% + \afterassignment\@@letdimcount@a\dimen0=#2 #3 bp\end% + #1=\dimen0% + \@@noresetaftergroup{#1}% return(\T) +}}% + +\iffalse +% Regression test for \@@letdimcount: +\@@letdimcount{\count0}{2147483647} \message{\the\count0} +\@@letdimcount{\count0}{2147483647sp} \message{\the\count0} +\@@letdimcount{\count0}{2147483647.0sp} \message{\the\count0} +\@@letdimcount{\count0}{2147483647.999999sp} \message{\the\count0} +\@@letdimcount{\count0}{16383.99999pt} \message{\the\count0} +\@@letdimcount{\dimen0}{16383.99999pt} \message{\the\dimen0} +%\@@letdimcount{\count0}{16384pt} % Dimension too large. +%\@@letdimcount{\dimen0}{2000000000} % Dimension too large. +\@@letdimcount{\dimen0}{\count0} \message{\the\dimen0} +\fi + +% --- + +% !! why no \space in \write? +%** Performs the assignment `#1 := \dimen0 / \dimen1', +%** @param #1 is a name of a TeX dimen/count register (i.e \jot or \count7). +%** If dimen, then it contains quotient in dimension `pt' (i.e 1in / 1cm +%** is 2.54pt). If count, then its value divided by 65536 is the quotient +%** (so this is 16.16 bit fixed-point notation). +%** \dimen0 must not be negative. \dimen1 must be positive. +%** Overwrites \dimen2. +\def\@@divletpos#1{% + \dimen2=1pt\relax% + \multiply#1 0% `#1 := 0' works for both \dimen and \count registers + \loop\ifdim\dimen0>0pt% + \immediate\write16{0 a=\the\dimen0:b=\the\dimen1:m=\the\dimen2:q=\the#1} + \@@loop\ifdim\dimen1<0.5\dimen0% + \advance\dimen1\dimen1% + \advance\dimen2\dimen2% + % ^^^ this is the only statement where an arithmetic overflow can occur. + % an arithmetic overflow means that the divisor is zero is very + % small positive, so the result will be a ``dimen too large'' + \@@repeat% + \immediate\write16{1 a=\the\dimen0\space b=\the\dimen1\space m=\the\dimen2\space q=\the#1} + \@@loop\ifdim\dimen1>\dimen0% + \divide\dimen1 2% + \divide\dimen2 2% + \ifdim\dimen2=0pt% + \dimen0\dimen2% + \dimen1\dimen2% + \fi% + \@@repeat% + \immediate\write16{2 a=\the\dimen0\space b=\the\dimen1\space m=\the\dimen2\space q=\the#1} + \ifdim\dimen0>0pt% + \@@loop\ifdim\dimen0<8192pt% + \multiply\dimen0 2% + \multiply\dimen1 2% + \@@repeat% + \fi% + \immediate\write16{3 a=\the\dimen0\space b=\the\dimen1\space m=\the\dimen2\space q=\the#1} + \advance\dimen0-\dimen1% + \advance#1\dimen2% + % ^^^ Dat: because of this, \dimen2 must be a dimen (and not a count) + \immediate\write16{4 a=\the\dimen0\space b=\the\dimen1\space m=\the\dimen2\space q=\the#1} + \repeat% + %\ifdim\dimen0>0pt \message{SUXX}\fi% +}% + +%** The same as \@@divletpos, except for #2 and #3 may be either positive or +%** negative, and they might be either dimen or count registers. (A count is +%** measured in sp.) +%** Please don't pass \dimen0, \dimen1 or \dimen2 as argument. +%** @param #1 is a name of a TeX dimen/count register (i.e \jot or \count7). +%** If dimen, then it contains quotient in dimension `pt' (i.e 1in / 1cm +%** is 2.54pt). If count, then its value divided by 65536 is the quotient +%** (so this is 16.16 bit fixed-point notation). +%** @param #2 and #3 are token lists +%** containing a _positive_ integer or floating point value +%** (measured in sp, must be specified explicitly), or a dimen such as `2.54cm'. +\def\@@divletdim#1#2#3{{% + \afterassignment\@@gobbleend\dimen0=#2 sp\end% \dimen0 := #1, convert count -> sp + \afterassignment\@@gobbleend\dimen1=#3 sp\end% + \ifdim\dimen1=0pt% + \divide\dimen0 by0% trigger a TeX division-by-zero error + \else% + \ifdim\dimen1<0pt% + \dimen1-\dimen1% + \ifdim\dimen0<0pt% + \dimen0-\dimen0% + \@@divletpos{#1}% + \else + \@@divletpos{#1}% + #1-#1% + \fi% + \else% + \ifdim\dimen0<0pt% + \dimen0-\dimen0% + \@@divletpos{#1}% + #1-#1% + \else + \@@divletpos{#1}% + \fi% + \fi% + \fi% + % Imp: round to nearest integer + \@@noresetaftergroup{#1}% +}}% + +% --- Dobule (high) precision multiplication and division. + +% The type co31.31 denotes two \count registers, representing a nonnegative +% value in 31.31 bit fixed point notation. The sign bits of the registers +% are unused. + +%** Subtracts #3#4 from #1#2, modifies #1#2 in place +%** @param #1 \control-sequence on less +%** @param #2 \control-sequence on greater-or-equal +%** @param #3#4 co31.31 +%** @param #5#6 co31.31 +\def\@@dolt#1#2#3#4#5#6{% + \ifnum#3<#5% + \expandafter#1% + \else% + \ifnum#3>#5% + \expandafter#2% + \else% + \ifnum#4<#6% + \expandafter#1% + \else% + \expandafter#2% + \fi% + \fi% + \fi% +}% + +%** Subtracts #3#4 from #1#2, modifies #1#2 in place +%** @param #1#2 co31.31 +%** @param #3#4 co31.31 +\def\@@letsub#1#2#3#4#5{% + \ifnum#2<#4% + \advance#1-1% + \advance#2-#4% + \advance#2-#5% #2 += 0x80000000 + \else% + \advance#2-#4% + \fi% + \advance#1-#3% +}% + +%** Adds #3#4 to #1#2, modifies #1#2 in place +%** @param #1#2 co31.31 +%** @param #3#4 co31.31 +%** @param #5 \countx, whose value is -0x80000000 (-2147483648) +\def\@@letadd#1#2#3#4#5{% + % \message{add:\the#3:\the#4}% + \advance#2#5% #2 -= 0x80000000 + \ifnum#2<-#4% orig#2-0x80000000<-#4 <=> orig#2+#4 < 0x80000000 + \advance#2-#5% #2 += 0x80000000 + \else% + \advance#1 1% + \fi% + \advance#2#4% + \advance#1#3% +}% + +%** Multiplies #1#2 by two, modifies #1#2 in place +%** @param #1#2 co31.31 +\def\@@lettwice#1#2{% + \advance#1#1% + \ifnum#2>1073741823% + \advance#1 1% + \advance#2-1073741824% + \fi% + \advance#2#2% +}% + +%** Divides #1#2 by two, discards LSB, modifies #1#2 in place +%** @param #1#2 co31.31 +\def\@@lethalf#1#2{% + \divide#2 2% + \ifodd#1% + \advance#2 1073741824% + \fi% + \divide#1 2% +}% + +% vvv SUXX: \newif is `\outer' +\newif\ifLOOP +% \def\x{ \expandafter\newif\csname ifLOOP\endcsname}% + +%** `\@@muldivletposdim#1#2#3#4' performs the assignment `#1 := #2 * #3 / #4'. +%** `\@@muldivletposdim#1{1pt}#3#4' performs the assignment `#1 := #3 / #4'. +%** `\@@muldivletposdim#1#2#3{1pt}' performs the assignment `#1 := #2 * #3'. +%** +%** All source arguments (#2, #3, #4) can be valid TeX dimen/count values, or +%** \dimen / \count register specifications. Input values may be negative or +%** positive or zero. +%** +%** -- Before each multiplication and division, the arguments are converted +%** to `pt' (if the argument is a bare number or a \count register, it is +%** treated as being a dimension in `sp'), the operation is performed on +%** the numbers, and `pt' is added +%** to the resulting number, so the result will be a dimension. +%** -- The default unit of measure is `sp'. That is, all bare numbers and +%** \count registers are treated as being a dimension in `sp'. This +%** applies to both source and target argument. (You may notice that 1pt +%** == 65536sp. So the operations are performed in a fixed-point +%** arithmetic with 16 bits in the fraction.) +%** -- The multiplication is performed exactly (i.e without loss of +%** precision). However, the division and the 31.31 -> 15.16 rounding +%** after the division may degrade precision. Internal calculations are +%** performed in fixed-point arithmetic with 31 bits in the fraction. +%** -- The following constants are valid source arguments, and represent the +%** same number (one and a half): `1.5pt', `98304sp', `98304 sp', +%** `98304', `98304.1sp', `98304.9sp'. +%** -- To specify the real number `1.5', please specify `1.5 pt'. +%** -- To specify the integer `42', please specify `42 pt'. +%** -- If you do only division, set #2 := `1pt'. In that special case you may +%** specify bare integers (or `... sp') for _both_ #3 and #4. +%** -- The following are valid arguments: `\count0', +%** `\dimen7', `\jot', `\interdisplaylinepenalty' +%** -- Due to a limitation of TeX's fixed-precision arithmetic, it is +%** impossible to specify exactly `1.5pt' in inches. `0.02075958251953in' +%** is `1.49974pt', and `0.02075958251954in' is `1.50084pt'. (Of course, +%** `1.5pt' is `1.5pt'.) That's because TeX converts the real constant +%** 0.02075958251953 to the fraction `1360/65536' and +%** 0.02075958251954 to the fraction `1361/65536', before multiplying. +%** -- If you specify >=2 of \dimen0, \dimen1 and \dimen2 as input, please +%** specify them in this order. +%** +%** @param #1 target, must be a \dimen or \count register +%** specification (including `\count0' and `\jot'). If a \dimen register, +%** its maximum will be 1073741823sp. If a \count register, its maximum +%** will be 2147483647. +%** @param #2 must be >=0 +%** @param #3 must be >=0 +%** @param #4 must be >0 +%** +\def\@@muldivletposdim#1#2#3#4{{% + %\afterassignment\@@gobbleend\dimen0=#2 sp\end% \dimen0 := #1, convert count -> sp + %\afterassignment\@@gobbleend\dimen1=#3 sp\end% + %\afterassignment\@@gobbleend\dimen2=#4 sp\end% + \countdef\Y 2 \@@letdimcount\Y{#4}% + \countdef\F 14 \ifnum\Y<0 \Y-\Y \F-1 \else \F1 \fi% +% \showthe\Y% + \ifnum0=\Y % SUXX: \ifnum\Y=0 doesn't work + \divide\Y0% trigger a TeX division-by-zero error (`arithmetic overflow') + \else% + % vvv declare my input arguments as local variables + \countdef\XA 0 \@@letdimcount\XA{#2}% treat dimen as in `sp' + \ifnum\XA<0 \XA-\XA \F-\F\fi% + \countdef\XB 1 \@@letdimcount\XB{#3}% + \ifnum\XB<0 \XB-\XB \F-\F\fi% + %\countdef\XA 0 \XA\dimen0% treat dimen as in `sp' + %\countdef\XB 1 \XB\dimen1% + %\countdef\Y 2 \Y \dimen2% + % vvv declare local variables + \countdef\C 3% + \countdef\B 4% + \countdef\R 5% + \countdef\S 6% + \countdef\T 7% + \countdef\U 8% + \countdef\D 9% + \countdef\A 10% + \countdef\L 11% + \countdef\M 12% + % vvv ++++ comment out the line below to get rid of the error ++++ + \countdef\G 13 \relax \G-1073741824 \advance\G\G% G := -0x80000000 + % + % Imp: support negative numbers here + \ifnum\XB=\Y% shortcut + \T\XA% + \else% + \ifnum\XA=\Y% shortcut + \T\XB% + \else% really multiply and divide + \@@muldivpos% + % + % vvv convert (round) \T\U: co31.31 -> \T: dimen15.16 + % return (\U>=0x7fffc000) ? ((\T+1)<<16) : (\T<<16)+((\U+0x4000)>>15) + \multiply\T65536% result too large + \ifnum\U<2147467264% 0x80000000-0x4000 + \advance\U16384% + \divide\U32768% + \advance\T\U% + \else% + \advance\T65536% + \fi% + \fi% + \fi% + \ifnum\F<0 \T-\T\fi% + %\afterassignment\@@gobbleend#1=\T sp\end% works if #1 is a dimen/count + \@@letdimcount{#1}\T% + \@@noresetaftergroup{#1}% return(\T) + \fi% else of division-by-zero +}}% + +%** Performs the assignment `\T\U := \XA * \XB / \Y'. Destroys contents of +%** \XA \XB \Y \C \B \R \S \T \U \D \A \L and \M during operations. All +%** control sequences mentioned in this paragraph must be predefined \count +%** registers. +%** Assumes \newif\LOOP, sets \LOOPfalse upon return +%** Inputs are: \XA \XB \Y and \G. \XA \XB \Y must be in 15.16 bit +%** fixed-point notation (i.e dimension in `pt' converted to a \count). +%** \G must be -0x80000000. +%** Outputs are \T and \U. \T\U is a real number in 31.31 bit fixed-point +%** notation (the sign bits are unused). +%** This is helper routine called by \@@muldivletposdim. +\def\@@muldivpos{% + %\message{A}% + \R\XA \divide\R65536 \S-\R \multiply\S65536 \advance\S\XA% my(\R,\S)=(( \XA >>16), \XA &0xffff); + %\message{A.S=\the\S,R=\the\XA}% + \T\XB \divide\T65536 \U-\T \multiply\U65536 \advance\U\XB% my(\T,\U)=(( \XB >>16), \XB &0xffff); + \D0 \A\Y \divide\A65536 \multiply\A32768 % my (\D,\A)=(0, ((( \Y >>16)&0xffff)<<15)); % round() final result + \L\R \advance\L\L \multiply\L\T \M0 \@@letadd\D\A\L\M\G% \@@letadd( (\D,\A), ((\R*\T)<<1, 0) + \L\R \multiply\L\U \M\L \divide\L32768 \multiply\L32768 \advance\M-\L \divide\L32768 \multiply\M65536 \@@letadd\D\A\L\M\G% \@@letadd( (\D,\A), ((\R*\U)>>15, ((\R*\U)&0x7fff)<<16) + \L\S \multiply\L\T \M\L \divide\L32768 \multiply\L32768 \advance\M-\L \divide\L32768 \multiply\M65536 \@@letadd\D\A\L\M\G% \@@letadd( (\D,\A), ((\S*\T)>>15, ((\S*\T)&0x7fff)<<16) + \ifnum\S>32767 % + \L0 \M\U \multiply\M32768 \@@letadd\D\A\L\M\G% \@@letadd( (\D,\A), (0, \U<<15) + \advance\S-32768% + \fi% + %\message{B.S=\the\S,U=\the\U}% + \L0 \M\S \multiply\M\U \@@letadd\D\A\L\M\G% \@@letadd( (\D,\A), (0, \S*\U) + \C\Y \divide\C 32768 \B-\C \multiply\B32768 \advance\B\Y \multiply\B65536 % my(\C,\B)=(( \Y >>15),(( \Y &0x7fff)<<16)); + \L1 \M0 \T0 \U0% my (\L,\M)=(1,0); (\T,\U)=(0,0); + %\showthe\D \showthe\A \showthe\C \showthe\B + %\message{C}% + \loop% vvv while (\D!=0 or \A!=0) % DA != 0 % \D!=0 <=> \D>0 + %\message{if}% + \LOOPfalse% + \ifnum\D>0 \LOOPtrue \fi% Dat: must have a space after `>0' + \ifnum\A>0 \LOOPtrue \fi% + \ifLOOP% loop condition + \R\D \S\A \@@lethalf\R\S% (\R,\S)=(\D,\A); _Half(\R,\S); + \@@loop% vvv while (_lt((\C,\B),(\R,\S))) % while (CB32767\divide\T0\fi% die "overflow2 or division by 0" if \T>=0x8000 + % ^^^ !! Imp: more meaningful overflow error message (here and at other places) + % return value: \T\U: co31.31 + % to convert it to \dimen, do: (\U>=0x7fffc000) ? ((\T+1)<<16) : (\T<<16)+((\U+0x4000)>>15) +}% + +\endinput% diff --git a/macros/latex/exptl/graphicp/epstopdf b/macros/latex/exptl/graphicp/epstopdf new file mode 100755 index 0000000000..f7b5b1675c --- /dev/null +++ b/macros/latex/exptl/graphicp/epstopdf @@ -0,0 +1,476 @@ +#! /bin/sh +eval '(exit $?0)' && eval 'PERL_BADLANG=x;export PERL_BADLANG;: \ +;exec perl -x -S -- "$0" ${1+"$@"};#'if 0; +eval 'setenv PERL_BADLANG x;exec perl -x -S -- "$0" $argv:q;#'.q +#!perl -w ++($0=~/(.*)/s);do$1;die$@if$@;__END__+if 0; +# Don't touch/remove lines 1--7: http://www.inf.bme.hu/~pts/Magic.Perl.Header + +use strict; + +# Change by Thomas Esser, Sept. 1998: The above lines allows us to find +# perl along $PATH rather than guessing a fixed location. The above +# construction should work with most shells. +# Modified by pts@fazekas.hu at and before Sun Feb 2 12:57:10 CET 2003 + +# A script to transform an EPS file so that: +# a) it is guarenteed to start at the 0,0 coordinate +# b) it sets a page size exactly corresponding to the BoundingBox +# This means that when Ghostscript renders it, the result needs no +# cropping, and the PDF MediaBox is correct. +# c) the result is piped to Ghostscript and a PDF version written +# +# -- It needs a Level 2 PS interpreter. +# -- If the bounding box is not right, of course, you have problems... +# -- BoundingBox: (atend) is perfectly supported. +# -- recommended options: --below --hires +# +# Sebastian Rahtz, for Elsevier Science +# +# now with extra tricks from Hans Hagen's texutil. +# +# History +# 1999/05/06 v2.5 (Heiko Oberdiek) +# * New options: --hires, --exact, --filter, --help. +# * Many cosmetics: title, usage, ... +# * New code for debug, warning, error +# * Detecting of cygwin perl +# * Scanning for %%{Hires,Exact,}BoundingBox. +# * Scanning only the header in order not to get a wrong +# BoundingBox of an included file. +# * (atend) supported. +# * uses strict; (earlier error detecting). +# * changed first comment from '%!PS' to '%!'; +# * corrected (atend) pattern: '\s*\(atend\)' +# * using of $bbxpat in all BoundingBox cases, +# correct the first white space to '...Box:\s*$bb...' +# * corrected first line (one line instead of two before 'if 0;'; +# 2000/11/05 v2.6 (Heiko Oberdiek) +# * %%HiresBoundingBox corrected to %%HiResBoundingBox +# 2001/03/05 v2.7 (Heiko Oberdiek) +# * Newline before grestore for the case that there is no +# whitespace at the end of the eps file. +# 2003/02/02 (Szabó Péter) +# * option --below +# * removes DOS EPSF binary junk correctly +# * adds all 3 BoundingBox DSC comments +# * reads all 3 BoundingBox DSC comments, and picks the best +# * forces BoundingBox to be an integer +# * adds %%EndComments and proper %!PS-Adobe-?-? EPSF-?.? header +# * adds %%Pages: +# +# Dat: calling ``showpage'' is not required, gs 6.50 works without it +# Imp: detect error messages from GS, abort... +# Imp: make it work for PDF input +# Imp: make it work for PS non-EPS files + +### program identification +my $program = "epstopdf"; +my $filedate="2003/02/02"; # my $filedate="2001/03/05"; +my $fileversion="2.7p"; +my $copyright = "Copyright 1998-2001 by Sebastian Rahtz et al.\nContains modifications by pts\@fazekas.hu"; +my $title = "\U$program\E $fileversion, $filedate - $copyright\n"; + +### ghostscript command name +my($quote,$GS)=("'","gs"); +($quote,$GS) = ("\"","gswin32c") if $^O eq 'MSWin32' or $^O =~ /cygwin/i; + +### options +$::opt_help=0; +$::opt_debug=0; +$::opt_compress=1; +$::opt_gs=1; +$::opt_hires=0; +$::opt_exact=0; +$::opt_filter=0; +$::opt_outfile=""; +$::opt_below=0; + +### usage +my @bool = ("false", "true"); +my $usage = <<"END_OF_USAGE"; +${title}Syntax: $program [options] +Options: + --help: print usage + --outfile=: write result to + --(no)filter: read standard input (default: $bool[$::opt_filter]) + --(no)gs: run Ghostscript to create PDF (default: $bool[$::opt_gs]) + --(no)compress: use compression (default: $bool[$::opt_compress]) + --(no)hires: scan HiResBoundingBox (default: $bool[$::opt_hires]) + --(no)exact: scan ExactBoundingBox (default: $bool[$::opt_exact]) + --(no)debug: debug informations (default: $bool[$::opt_debug]) + --(no)below: allow below baseline (default: $bool[$::opt_below]) +Examples for producing 'test.pdf': + * $program test.eps + * produce postscript | $program --filter >test.pdf + * produce postscript | $program -f -d -o=test.pdf +Example: look for HiResBoundingBox and produce corrected PostScript: + * $program -d --nogs -hires test.ps>testcorr.ps +END_OF_USAGE + +### process options +use Getopt::Long; +GetOptions ( + "help!", + "debug!", + "filter!", + "compress!", + "gs!", + "hires!", + "below!", + "exact!", + "outfile=s", +) or die $usage; + +### help functions +sub debug { + print STDERR "* @_\n" if $::opt_debug; +} +sub warning { + print STDERR "==> Warning: @_!\n"; +} +sub error { + die "$title!!! Error: @_!\n"; +} +sub errorUsage { + die "$usage\n!!! Error: @_!\n"; +} + +### option help +die $usage if $::opt_help; + +### get input filename +my $InputFilename = ""; +if ($::opt_filter) { + @ARGV == 0 or + errorUsage "Input file cannot be used with filter option"; + $InputFilename = "-"; + debug "Input file: standard input"; +} else { + @ARGV > 0 or errorUsage "Input filename missing"; + @ARGV < 2 or errorUsage "Unknown option or too many input files"; + $InputFilename = $ARGV[0]; + if ($ARGV[0] eq '-') { + $::opt_filter=1; + debug "Input file: standard input"; + } else { + -f $InputFilename or error "'$InputFilename' does not exist"; + debug "Input filename:", $InputFilename; + } +} + +### option compress +my $GSOPTS; +$GSOPTS = "-dUseFlateCompression=".($::opt_compress?"true":"false")." "; +# $GSOPTS.=" -r72 -g99999x99999 "; +$GSOPTS.=" -r72 -sPAPERSIZE=a4 "; # default +$GSOPTS.=" -dCompatibilityLevel=1.2"; + +### option BoundingBox types +#**** pts **** +# scan all of them and find the best +{ my $BBprint = "%%BoundingBox:"; + $BBprint = "%%HiResBoundingBox:" if $::opt_hires; + $BBprint = "%%ExactBoundingBox:" if $::opt_exact; + debug "strongest BoundingBox comment:", $BBprint; +} +my $BBregex='%%(Hi[Rr]es|Exact|)BoundingBox:'; + +### option outfile +my $OutputFilename = $::opt_outfile; +if ($OutputFilename eq "") { + if ($::opt_gs) { + $OutputFilename = $InputFilename; + if (!$::opt_filter) { + $OutputFilename =~ s/\.[^\.]*$//; + $OutputFilename .= ".pdf"; + } + } + else { + $OutputFilename = "-"; # standard output + } +} +if ($::opt_filter) { + debug "Output file: standard output"; +} +else { + debug "Output filename:", $OutputFilename; +} + +### option gs +if ($::opt_gs) { + debug "Ghostscript command:", $GS; + debug "Compression:", ($::opt_compress) ? "on" : "off"; +} + +### open input file +if ($::opt_filter) { + open(IN, "<&STDIN") or error "Cannot open standard input"; +} else { + open(IN,"< $InputFilename") or error "Cannot open '$InputFilename'"; +} +binmode IN; + + +#**** pts **** +sub read_error() { error "read $InputFilename: $!" } +my $bytes_left=-1; +#** @param $_[0] number of bytes to read, or undef to read a line +#** @return the string read +sub readIN(;$) { + my $S; + return "" if $bytes_left==0; + ## print STDERR "READ\n"; + if (defined $_[0]) { read_error if 0>read IN, $S, $_[0] } + else { + $S=; + read_error if !defined($S) and $!; + $S="" if !defined $S; + } + if ($bytes_left<0) { # unlimited + } elsif (length($S)>=$bytes_left) { + $S=substr($S, 0, $bytes_left); + $bytes_left=0; + } else { $bytes_left-=length($S) } + $S +} + +### scan first line, check for DOS eps (and remove DOS headers) +#**** pts **** +my $header=""; +$_=""; +{ my $S; + read_error if 0>read IN, $S, 1; + error "$InputFilename: empty file" if 0==length($S); + if ($S eq "\305") { # DOS EPSF header + read_error if 29>read IN, $S, 29, 1; + my ($eheader,$ps_ofs,$ps_len,$wmf_ofs,$wmf_len,$tif_ofs,$tif_len,$checksum)= + unpack"A4VVVVVVv", $S; + error "$InputFilename: bad DOS EPS" if $eheader ne "\305\320\323\306" or $ps_ofs<30; + my($ps_end, $wmf_end, $tif_end)=($ps_ofs+$ps_len, $wmf_ofs+$wmf_len, $tif_ofs+$tif_len); + $ps_ofs-=30; + if (!seek IN, $ps_ofs, 1) { + while ($ps_ofs>4096) { $ps_ofs-=4096; readIN 4096 } + read_in $ps_ofs if $ps_ofs>0; + } + $bytes_left=($ps_end>$wmf_end and $ps_end>$tif_end) ? -1 : $ps_len; + $S=readIN(1); + } + if ($S eq '%') { + $S.=readIN; + error "$InputFilename: won't read a PDF file" if substr($S,0,4)eq'%PDF'; + error "$InputFilename: EPS DSC must be %!PS-Adobe" if substr($S,0,4)ne'%!PS'; + # ^^^ Dat: mpost outputs "%!PS\n" + } else { + warning "$InputFilename: no PS ADSC header, BoundingBox not found\n" + } + $header=$S; +} + +### open output file +if ($::opt_gs) { + my $fn=$OutputFilename; + $fn=~s@'@\\'@g if $quote eq "'"; + my $pipe = "$GS -q -dBATCH -sDEVICE=pdfwrite $GSOPTS " . + "-sOutputFile=$quote$OutputFilename$quote -"; + debug "Ghostscript pipe:", $pipe; + open(OUT,"|$pipe") or error "Cannot open Ghostscript for piped input"; +} else { + open(OUT,"> $OutputFilename") or error "Cannot write '$OutputFilename"; +} +die unless binmode OUT; + +### variables and pattern for BoundingBox search +my $bbxpatt = '[0-9eE\.\-]'; + # protect backslashes: "\\" gets '\' +my $BBValues = "\\s*($bbxpatt+)\\s+($bbxpatt+)\\s+($bbxpatt+)\\s+($bbxpatt+)"; + +#** @return arg rounded down to int +sub floor($) { + # Dat: Perl int() rounds towards zero + $_[0] < 0 ? -int(-$_[0]) : int($_[0]) +} + +#** @return arg rounded up to int +sub ceil($) { + $_[0] > 0 ? -int(-$_[0]) : int($_[0]) +} + +my ($xoffset, $yoffset) = (0, 0); +my $do_translate=0; +#** @return PostScript code to be printed after the header +sub CorrectBoundingBox($$$$) { + my ($llx, $lly, $urx, $ury) = @_; + debug "Old BoundingBox:", $llx, $lly, $urx, $ury; + my ($width, $height) = ($urx - $llx, $ury - $lly); + ($xoffset, $yoffset) = (-$llx, -$lly); + # Dat: it is inherently impossible to tell GS that it shouldn't + # recompress the images already compressed in the EPS file, but keep + # them in their original, compressed form. So we rather instruct GS to + # recompress + my $pagedevice2set=" +/AutoRotatePages /None +/CompatibilityLevel 1.2 +/UseFlateCompression true +/AutoPositionEPSFiles false +/AutoFilterGrayImages false +/ConvertImagesToIndexed false +/DownsampleMonoImages false +/DownsampleGrayImages false +/DownsampleColorImages false +/AutoFilterColorImages false +/EncodeMonoImages true +/EncodeGrayImages true +/EncodeColorImages true +/AntiAliasMonoImages false +/AntiAliasGrayImages false +/AntiAliasColorImages false\n"; + + $::opt_below=0 if $lly>=0; + ($llx,$lly,$urx,$ury)=(0,0,$urx-$llx,$ury-$lly) if !$::opt_below; + my $bbx="%%BoundingBox: ".floor($llx)." ".floor($lly)." ". + ceil ($urx)." ".ceil ($ury)."\n". + "%%HiResBoundingBox: $llx $lly $urx $ury\n". + "%%ExactBoundingBox: $llx $lly $urx $ury\n%%EndComments\n"; + if ($::opt_below) { #**** pts **** + # vvv we output a second /MediaBox here, and we'll remove the first one + # (written by GS) later + return "$bbx<< /PageSize [$width $height] $pagedevice2set >> setpagedevice +mark /MediaBox [$llx $lly $urx $ury] /PAGE pdfmark +mark /CropBox [$llx $lly $urx $ury] /PAGE pdfmark\n"; + } + debug "New BoundingBox: 0 0", $width, $height; + debug "Offset:", $xoffset, $yoffset; + if ($xoffset==0 and $yoffset==0) { + return "$bbx<< /PageSize [$width $height] $pagedevice2set >> setpagedevice +mark /CropBox [0 0 $width $height] /PAGE pdfmark\n" + } + $xoffset=0 if $xoffset==0; # get rid of `-0' + $yoffset=0 if $yoffset==0; # get rid of `-0' + $do_translate=1; + "$bbx<< /PageSize [$width $height] $pagedevice2set >> setpagedevice +mark /CropBox [0 0 $width $height] /PAGE pdfmark +gsave $xoffset $yoffset translate\n" +} + +### scan header +if (14096) { + die unless seek(IN, $bytes_left-4096, 1); + $bytes_left=4096; + } elsif ($bytes_left<0) { + die unless seek(IN, -4096, 2); + } + $doing_atend=1; goto read_again; + } + print OUT "%%Pages: 1\n" if !$had_pages; + if ($bbtype ne'-') { print OUT CorrectBoundingBox $llx, $lly, $urx, $ury } + else { warning "BoundingBox not found"; print OUT "%%EndComments\n" } + print OUT $BBCorrected; +} + +### print rest of file +print OUT while length($_=readIN 4096); + +### close files +error "running gs" unless close(IN); +# ^^^ SUXX: gs always exit(0), if exists +print OUT "\ngrestore\n" if $do_translate; +close(OUT); + +if ($::opt_below and $::opt_gs) { + ### ****pts**** remove incorrect /MediaBox produced by gs + die unless open F, "> $OutputFilename.tgs"; # Imp: in temp dir + die unless print F ' + % this is temporary gs command file created by epstopdf + GS_PDF_ProcSet begin + pdfdict begin + FN (r) file pdfopen begin + % vvv keep file offsets, because `pdffindpageref` overrides it with contents + /OFT Objects 0 get dup length array copy def + % vvv Dat: the generation number is assumed to be 0 + % vvv Dat: modifies Objects[0] + 1 pdffindpageref 0 get + Objects 0 OFT put + readxrefentry === + currentdict pdfclose end end end + '; + die unless close F; + + my $offset=`$GS -dNODISPLAY -dSAFER -dBATCH -sFN=$quote$OutputFilename$quote -q $quote$OutputFilename.tgs$quote`; + chomp $offset; + unlink "$OutputFilename.tgs"; + die unless $offset=~/\A\d+\Z(?!\n)/; + # Dat: now $offsets is a file position in $OutputFilename containing our /Page object + + die unless open F, "+< $OutputFilename"; + die unless binmode F; + die unless seek F, $offset+=0, 0; + my $pageobj; + die unless 32 +%%EndData +end restore showpage +%%Trailer +%%EOF diff --git a/macros/latex/exptl/graphicp/f2cletter.pdf b/macros/latex/exptl/graphicp/f2cletter.pdf new file mode 100644 index 0000000000..267f853dfa Binary files /dev/null and b/macros/latex/exptl/graphicp/f2cletter.pdf differ diff --git a/macros/latex/exptl/graphicp/f2mletter.eps b/macros/latex/exptl/graphicp/f2mletter.eps new file mode 100644 index 0000000000..3310d86cf4 --- /dev/null +++ b/macros/latex/exptl/graphicp/f2mletter.eps @@ -0,0 +1,23 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Pages: 1 +%%BoundingBox: -8 5 12 35 +%%DocumentData: Clean7Bit +%%LanguageLevel: 2 +%%EndComments +%%Page: 1 1 +save 9 dict begin +-8 5 translate +{/T currentfile/ASCII85Decode filter def/DeviceGray setcolorspace +/F T/LZWDecode filter def +<> image + F closefile T closefile} +%%BeginData: +exec +J,gVj":O-1_gW";&?&6mr,?_LU''V23[!QE2ujPXgR^+^M`KdZ'8.tF&-,=6:\K.On7Qu."RcSWc=h +9D4Pju]bFVrDGWu5t#Pe8V!<~> +%%EndData +end restore showpage +%%Trailer +%%EOF diff --git a/macros/latex/exptl/graphicp/f2mletter.pdf b/macros/latex/exptl/graphicp/f2mletter.pdf new file mode 100644 index 0000000000..4a78a6c166 Binary files /dev/null and b/macros/latex/exptl/graphicp/f2mletter.pdf differ diff --git a/macros/latex/exptl/graphicp/ficletter.jpg b/macros/latex/exptl/graphicp/ficletter.jpg new file mode 100644 index 0000000000..958f35809d Binary files /dev/null and b/macros/latex/exptl/graphicp/ficletter.jpg differ diff --git a/macros/latex/exptl/graphicp/ficletter.pbm b/macros/latex/exptl/graphicp/ficletter.pbm new file mode 100644 index 0000000000..13db3eddff Binary files /dev/null and b/macros/latex/exptl/graphicp/ficletter.pbm differ diff --git a/macros/latex/exptl/graphicp/ficletter.png b/macros/latex/exptl/graphicp/ficletter.png new file mode 100644 index 0000000000..6a803b1c91 Binary files /dev/null and b/macros/latex/exptl/graphicp/ficletter.png differ diff --git a/macros/latex/exptl/graphicp/files b/macros/latex/exptl/graphicp/files new file mode 100644 index 0000000000..1423b1331b --- /dev/null +++ b/macros/latex/exptl/graphicp/files @@ -0,0 +1,22 @@ +files +div16b.sty +graphicp.sty +keyvalx.sty +laemu.sty +pts_img.sty +pts_bbox.sty +descend.mp +descend.1 +laltest.tex +ficletter.pbm +f2cletter.eps +f2cletter.pdf +f2mletter.eps +f2mletter.pdf +ficletter.png +ficletter.jpg +laxtest.bbx +epstopdf +img_bbox.pl +pdfboxes.pl +graphicpdoc.tex diff --git a/macros/latex/exptl/graphicp/graphicp.sty b/macros/latex/exptl/graphicp/graphicp.sty new file mode 100644 index 0000000000..001aaad978 --- /dev/null +++ b/macros/latex/exptl/graphicp/graphicp.sty @@ -0,0 +1,407 @@ +% +% graphicp.tex -- a graphics.sty replacement for LaTeX and laemu.sty +% by pts@fazekas.hu at Fri Jan 24 13:26:22 CET 2003 +% +% GraphicP is a system that provides an easy, fast and reliable method for +% including external images into LaTeX and plain TeX documents. The +% \includegraphics macro of GraphicP is a drop-in replacement of the same +% command of LaTeX graphics.sty and graphicx.sty, but with many enhancements. +% Input images are ususally in EPS or PDF format. Drivers for xdvi, dvips, +% pdftex and dvipdfm are included. Perl scripts are provided for +% faster bounding box manipulations. +% +% This is version 0.12. +% +% Features over LaTeX `\usepackage{graphicx}': +% +% -- both plain TeX and LaTeX support +% -- specified width=... and height=... are strictly enforced, without rounding +% -- image scaling calculations are much more accurate +% -- works with `dvips -E' bounding-box calculations, even with buggy dvips +% 5.86e +% -- doesn't have to open the .eps file for reading the bbox +% -- xdvi doesn't forcibly crop (clip) the image to the bbox +% -- Below feature: allows the image descend below the baseline +% (supports depth, not only width and height) +% -- drop dependency on Perl, parse Adobe DSC comments in EPS files +% -- non-standard, quick, DSC-like parsing for special PDF files +% -- an enhanced `epstopdf' utility +% -- the `img_bbox.pl' utility +% -- the `pdfboxes.pl' utility +% -- voluntary clipping (cropping) +% -- all 8 mirror and rotate transformation (must be a multipe of 90 degrees) +% -- does not rely on the filename to determine the FileFormat +% -- embeds each image file only once with pdfTeX and dvipdfm +% -- imtrix: unified PSTricks/PSFrag support for EPS and PDF +% +% Q1. Can I use the Below feaure with dvipdfm+EPS? +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% Use the epstopdf untility shipped with graphicP instead of the default one +% shipped with teTeX. +% To do it, please update /etc/texmf/dvipdfm/config first with the line: +% +% D "zcat -f %i | ./epstopdf --below --hires --outfile=%o -" +% +% Substitute the `./epstopdf' with the real, absolute path to our epstopdf. +% +% Don't forget to specify \includegraphics[...,below]{...} +% +% Which characters can I have in the filename? +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% For dvips, xdvi and dvipdfm: +% -- You must avoid the double quote ("), because it is the filename terminator +% of the PSFile \special. +% For pdftex: +% -- You must also avoid the dollar sign +% ($), because kpsewhich interprets it as a variable substitution, and +% pdftex calls KPSE to look up image file names. +% For old pdftex 0.12 shipped with Debian Slink (pdftex >=0.14 is OK): +% -- You must avoid space, because stupid \pdfimage cannot parse it. +% For xdvi and dvipdfm: +% -- You must also avoid the +% backslash (\), because xdvi removes it from the filename (dvips doesn't). +% +% All other characters can be used, but you have to quote some of them to +% avoid wrong category codes and/or expansion: +% +% All characters [\000-\037\177-\377] should be input as hex: \expandafter\@secondoftwo\string\^^HL +% All characters [\040-\176] can be written as-is, except for: +% $ is OK +% & is OK +% _ is OK +% a space should be input as '\iftrue\space\fi '; # won't collapse two spaces into one +% \ { } % # ^ ~ ` " should be input as \expandafter\@secondoftwo\string\\ etc. +% +% Note that `\noexpand"' is not good enough for `"', because `\noexpand"e' +% would expand to an accented letter if expanded twice under +% \usepackage[german]{babel}. +% +% I've verified these characters on the file name +% +% ugly_"$&_ \}%#^^aáéb{%#^~` +% +% which was input as +% +% ugly_"$&_\iftrue\space\fi \iftrue\space\fi \iftrue\space\fi \expandafter\@secondoftwo\string\\\expandafter\@secondoftwo\string\}\expandafter\@secondoftwo\string\%\expandafter\@secondoftwo\string\#\expandafter\@secondoftwo\string\^\expandafter\@secondoftwo\string\^a\expandafter\@secondoftwo\string\^^e1\expandafter\@secondoftwo\string\^^e9b\expandafter\@secondoftwo\string\{\expandafter\@secondoftwo\string\%\expandafter\@secondoftwo\string\#\expandafter\@secondoftwo\string\^\expandafter\@secondoftwo\string\~\expandafter\@secondoftwo\string\` +% +% Can I embed MetaPost output? +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% Yes, \includegraphics{ajobname.1} works fine with all drivers. (ajobname.1 +% is the output file of MetaPost when ajobname.mp contains `beginfig(1)'.) +% +% How do I specify an output filename for MetaPost? +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% Basicly you invoke MetaPost as `mpost ajobname.mp', where ajobname.mp is +% the MetaPost source file. MetaPost writes the log file ajobname.log. If +% you say `beginfig(42)' in ajobname.mp, the output EPS file `ajobname.42' +% will be created. If you say `beginfig(-1)' (or any negative number), +% `ajobname.ps' will be created. You cannot force any other filename -- +% these are hard-wired to the MetaPost executable. +% +% How do I make MetaPost emit a HiResBoundingBox? +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% Just add +% +% extra_endfig := extra_endfig +% & "special (" +% & ditto & "%%HiResBoundingBox: " & ditto +% & "&decimal xpart llcorner currentpicture &" & ditto & " " & ditto +% & "&decimal ypart llcorner currentpicture &" & ditto & " " & ditto +% & "&decimal xpart urcorner currentpicture &" & ditto & " " & ditto +% & "&decimal ypart urcorner currentpicture );"; +% +% to the beginning of ajobname.mp. context/mp-tool.mp does this already. +% You cannot force it before %%EndProlog or %%Page:. This is an inherent +% limitation of the MetaPost executable. +% +% --- +% +% Dat: dvipdfm crops EPS images below y==0; it doesn't crop PDF images. See +% FAQ answer Q1 to overcome it. +% Dat: works with `dvips', `dvipdfm', `xdvi' and `pdftex' +% Dat: works with pdftex 3.14159-0.12r (Slink), 0.14 (Potato), 1.00a (Woody) +% OK : use bbox cache by img_bbox.pl +% OK : verify slink -- potato -- woody +% OK : sam2p Below feature +% OK : verify and document various filename chars +% OK : bbox read directly from image +% OK : respect best of BoundingBox, HiResBoundingBox and ExactBoundingBox +% OK : pdfboxes.pl: Perl script to inject PDF bbox near beginning +% OK : guess extension if unspecified, automatic filename.ext +% OK : pts_bbox.sty handles PDF, EPS, MPS +% OK : pts_bbox.sty handles TIFF, JPEG and PNG -- only with pdfTeX +% OK : pts_img.sty handles JPEG and PNG for pdfTeX and dvipdfm, TIFF for pdfTeX +% OK : MetaPost EPS is recognised properly by the pdftex driver (dvipdfm already did it right) +% OK : warning if FileFormat not supported by driver +% OK : \usepackage[nopdftexmpost]{graphicp} disables loading of ConTeXt supp-pdf.tex +% OK : \usepackage[forceunknown]{graphicp}. If an unknown FileFormat is not +% forced, an \errmessage is displayed, and the reference point is moved +% without drawing the image. +% OK : \includegraphics[raise=20]{...} or lower=-20 specifies raising in image +% dimensions (pixels) +% OK : \includegraphics[lower=0] disables autobelow +% OK : needed sam2p "Q endstream", because we say \pdfliteral{ Q}, so +% the embedding bug pdfTeX Version 3.14159-0.12r won't manifest. +% In sam2p-0.42 /Length+=1 on the content stream fixed the problem. +% OK : dvipdfm usexobj +% OK : sam2p 0.43 pre-/MediaBox feature (object reordering) +% OK : move reference point for \convertMPtoPDF in Debian Slink +% OK : below option is not default since Sun Feb 9 22:27:23 CET 2003 +% OK : proven not to work: PDF XObject on old pdftexs (Potato, Slink) +% OK : frame, namedframe, invisible and blackbox drivers, only show the bboxes and the filename +% Imp: documentation .tex +% Imp: use pdfTeX to read the bounding box (non-negative below feature) +% Imp: better \usepackage{graphicx} compatibility: clip=, bb=, totalheight=, +% keepaspectratio=, type=, ext=, read=, viewport=, clip=, `gunzip +% Imp: allow user select from BoundingBox, HiResBoundingBox and ExactBoundingBox +% Imp: add clipping support +% Imp: add rotation + mirroring support +% Imp: advanced \textascii for driver=namedframe +% Imp: imtrix ? + +\expandafter\ifx\csname ifLaTeX\endcsname\relax\input laemu.sty\relax\fi% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{graphicp}[2003/01/24 v0.0 graphics.sty replacement] +\RequirePackage{keyvalx} +\RequirePackage{pts_bbox} + +%\errmessage{O(\csname opt@graphicp.sty\endcsname)}% +%\errmessage{D(\@declaredoptions)}% +%\errmessage{C(\@curroptions)}% +%\errmessage{C(\@unprocessedoptions)}% +%\expandafter\def\csname opt@graphicp.sty\endcsname{}% +%\def\@declaredoptions{}% +%\expandafter\let\csname ds@alma\endcsname\relax% +%\show\@unprocessedoptions +%\let\@unprocessedoptions\relax +%\AtEndOfPackage{\def\@unprocessedoptions{}}% + +%** \def's #1 to 1 if #2 contains a true boolean value; 0 otherwise. A true +%** value is a value beginning with `t', `y' or `1'. +\def\@@gp@boolpon#1#2{% + \expandafter\@@gp@boolpon@low#2f\\#1% + %\message{ponated(#1)}% +}% +\def\@@gp@boolpon@low#1#2\\#3{% + \edef#3{% + \if\noexpand#1t1% true + \else\if\noexpand#1y1% yes + \else\if\noexpand#111% 1 + \else0\fi\fi\fi% + }% +}% +%** Similar to \@@gp@boolpon, but inverts the condition +\def\@@gp@boolneg#1#2{% + \@@gp@boolpon{#1}{#2}% + \edef#1{\if#101\else0\fi}% +}% + +%\LaemuProcessOptions\errmessage +\define@key{graphicp}{driver}{\edef\@@gp@driver{#1}}% +\define@key{graphicp}{pdftex}{\edef\@@gp@driver{pdftex}}% +\define@key{graphicp}{dvi}{\edef\@@gp@driver{dvi}}% +\define@key{graphicp}{dvips}{\edef\@@gp@driver{dvips}}% +\define@key{graphicp}{dvipdfm}{\edef\@@gp@driver{dvipdfm}}% +\define@key{graphicp}{pdftexmpost}[true]{\@@gp@boolpon\@@gp@pdftexmpost{#1}}% +\define@key{graphicp}{nopdftexmpost}[true]{\@@gp@boolneg\@@gp@pdftexmpost{#1}}% +%\define@key{graphicp}{forceunknown}[true]{\@@gp@boolpon\@@gp@forceunknown{#1}}% +\define@key{graphicp}{forceunknown}[2]{\def\@@gp@forceunknown{#1}}% +\define@key{graphicp}{forceunknown}[true]{\@@gp@boolneg\@@gp@forceunknown{#1}}% +\def\@@gp@pdftexmpost{1}% +\def\@@gp@driver{}% +\def\@@gp@forceunknown{0}% +\LaemuProcessOptions{\setkeys{graphicp}}% + +\if0\@@gp@pdftexmpost \def\graphicPnopdftexmpost{}\fi% +\if1\@@gp@forceunknown \def\@@img@forceunknown{1}\fi% +\let\@@gp@pdftexmpost\relax% +\RequirePackage{pts_img}% uses \graphicPnopdftexmpost +\@@img@setdriver{\@@gp@driver}% +\let\@@gp@driver\relax% +%\let\@@gp@forceunknown\relax% + +% --- Mon Feb 3 18:12:46 CET 2003 + +%** Expands to the filename extension of #1, e.g 'ePs' for `a.b/cd.ePs' +\def\@@gp@getext#1{% + \@@gp@getexta#1/\@empty% +}% + +\def\@@gp@getexta#1/#2{% + \ifx#2\@empty% \@empty itself or a macro with empty expansion + \@@gp@getextb#1.\@empty% + %\expandafter\@gobble% needed unless \@empty is the delimiter + \else% + \expandafter\@@gp@getexta + \fi% + #2% +}% +\def\@@gp@getextb#1.#2{% + \ifx#2\@empty% + % Extension not found, expand to nothing + %\expandafter\@gobble% needed unless \@empty is the delimiter + \else% + %:#2%\@@gp@getextc#2\\% + \expandafter\@@gp@getextc% + \fi% + #2% +}% +\def\@@gp@getextc#1.#2{% + \ifx#2\@empty% + #1% found extension + %\expandafter\@gobble% needed unless \@empty is the delimiter + \else% + \expandafter\@@gp@getextc + \fi% + #2% +}% + +%** Adds extension #1 to filename #2, unless #2 already has an extension. +%** Example: `\@@gp@addext{eps}{my.document/myfigure}' expands to +%** `my.document/myfigure.eps' +\def\@@gp@addext#1#2{% + #2\if.\@@gp@getext{#2}..#1\fi% + % ^^^ we use the fact that the first unexpandable token of the expansion of + % \@@gp@getext is either nonexistent, or it is a char other than `.' +} + +% --- + +%** Doesn't work if the 1st token of #1 is expandable or it is a control +%** sequence. +%\def\@@gp@isempty#1{% +% \if\noexpand\noexpand\noexpand#1\noexpand% +% empty% +% \else% +% not% +% \fi% +%}% + +%** Expands #1 iff #2 is empty. +%** @param #2 may not contain an extra (unbalanced) \else +\def\@@gp@isempty#1#2{% + \@@gp@isemptyi{#1}#2\else\fi% +}% +%** Same as \@@gp@isempty{#2}{#1} +\def\@@gp@isemptyr#1#2{% + \message{(\noexpand#1:#2)}% + \@@gp@isemptyi{#2}#1\else\fi% +}% +\def\@@gp@isemptyi#1#2{\iffalse#2#1}% + +% Regression test: +%\message{g(\@@gp@getext{hello})} +%%\tracingmacros=1 +%\message{g(\@@gp@getext{hel.lo/barna})} +%\message{g(\@@gp@getext{hel.lo/you/barna.ePs})} +%\message{g(\@@gp@getext{hel.lo/you/barna.ePs.gz})} +%\message{e(\@@gp@isempty{empty}{})}% +%\message{e(\@@gp@isempty{empty}{foo})}% +%\message{e(\@@gp@isempty{empty}{,alma})}% +%\message{e(\@@gp@isempty{empty}{\relax,korte})}% +%\message{e(\@@gp@isempty{empty}{\iftrue\else\fi})}% +%\message{a(\@@gp@addext{alma}{kor.te})} +%\message{a(\@@gp@addext{alma}{korte})} +%\message{a(\@@gp@addext{eps}{my.document/myfigure})} +%\@@gp@addext{alma}{korte} + +% --- GraphicP implementation begins + +\def\@@gp@setbbox#1#2#3#4{% + %\message{bb:(#1)(#2)(#3)(#4).}% + \def\@@gp@llx{#1}% + \def\@@gp@lly{#2}% + \def\@@gp@urx{#3}% + \def\@@gp@ury{#4}% +}% +\def\@@gp@question{?}% +\def\@@gp@PDF{PDF}% +\def\@@gp@setfbbox#1#2#3#4#5{% + %\message{(ff=#1)(#2)(#3)(#4)(#5).}% + \def\@@gp@format{#2}% assign temporarily + \ifx\@@gp@format\@@gp@question\else + % ^^^ assign only other than `?', so \@@GetBBox can override @@gp@format + \def\@@gp@llx{#2}% + \def\@@gp@lly{#3}% + \def\@@gp@urx{#4}% + \def\@@gp@ury{#5}% + \fi% + \edef\@@gp@format{#1}% FileFormat +}% + +%** Must be bbox={{0bp}{0bp}{72bp}{72bp}} +\define@key{incgP}{bbox}{\@@gp@setbbox#1}% +%** Must be fbbox={{TIFF}{0bp}{0bp}{72bp}{72bp}} +\define@key{incgP}{fbbox}{\@@gp@setfbbox#1}% +\define@key{incgP}{format}{\def\@@gp@format{#1}}% +\define@key{incgP}{width}{\def\@@gp@width{#1}}% +\define@key{incgP}{height}{\def\@@gp@height{#1}}% +\define@key{incgP}{raise}{\def\@@gp@raise{#1}}% +\define@key{incgP}{lower}{\def\@@gp@raise{-#1}}% +\define@key{incgP}{below}[]{\def\@@gp@raise{-#1}}% +\define@key{incgP}{clip}[true]{\csname if#1\endcsname\let\@@dp@clip1\else\let\@@dp@clip0\fi}% +\define@key{incgP}{noclip}[true]{\csname if#1\endcsname\let\@@dp@clip0\else\let\@@dp@clip1\fi}% +\define@key{incgP}{forceunknown}[2]{\def\@@gp@forceunknown{#1}}% + +\def\@@gp@checkbbox{% + \edef\@@gp@havebbox{% + \ifx\@@gp@llx\@@gp@question\else% + \ifx\@@gp@lly\@@gp@question\else% + \ifx\@@gp@urx\@@gp@question\else% + \ifx\@@gp@ury\@@gp@question\else% + 1\fi\fi\fi\fi% + }% +}% + +\def\@@gp@runpdfboxes{\MessageBreak Run pdfboxes.pl to fix the file.}% + +\def\includegraphicP{\@ifnextchar[\@@gp@includegraphics{\@@gp@includegraphics[]}}% +\let\includegraphics\includegraphicP +\def\@@gp@includegraphics[#1]#2{% + % Imp: change space tokens to `\space' in the filename + \begingroup + %\def\@@gp@bbox{{invalid}{}{}{}}% + %\def\@@gp@raise{}% dimension to raise above the baseline -- or empty + \def\@@gp@raise{0bp}% \usepackage{graphicx} compatibility + \def\@@gp@llx{?}% source image bbox and size + \def\@@gp@lly{?}% + \def\@@gp@urx{?}% + \def\@@gp@ury{?}% + \def\@@gp@format{?}% + \def\@@gp@width{0pt}% + \def\@@gp@height{0pt}% desired target width+height + \def\@@gp@clip{0}% + %\def\space{\noexpand\space}%expandafter\string\csname space \endcsname}% + \chardef\space0 % \space will expand to `\space ' + \edef\@@gp@filename{\@@gp@addext{\@@img@defext}{#2}}% add default extension + %\message{fn(\@@gp@filename)}% + \def\space{ }% change it back + \setkeys{incgP}{#1}% + \@@gp@checkbbox% + \ifx\@@gp@havebbox\@empty% bbox not specified as arg + \@@GetBBox\@@gp@setfbbox{\@@gp@filename}% load bbox from file + %\errmessage{z}% + \else% + \ifx\@@gp@format\@@gp@question% + \@@GetBBox\@@gp@setfbbox{\@@gp@filename}% determine FileFormat from file, possibly override with real bbox + \fi% + \fi% + \@@gp@checkbbox% + %\message{fn=(#2) havebbox=(\@@gp@havebbox) bbox=(\@@gp@llx)}% + \ifx\@@gp@havebbox\@empty% failed to determine bbox + \ifx\@@gp@format\@@gp@PDF \let\@@gp@err\@@gp@runpdfboxes + \else \let\@@gp@err\@empty\fi + \PackageError{graphicP}{Cannot get BoundingBox of image file `#2'\@@gp@err}\@ehc% + \@@gp@setbbox{0}{0}{72bp}{72bp}% fallback if the user continues + \fi% + %\expandafter\@@PutImage\@@gp@bbox% + \chardef\space0 % \space will expand to `\space ' + \edef\@tempa{\noexpand\@@PutImage% + {\@@gp@raise}{\@@gp@forceunknown}.% + {{\@@gp@llx}{\@@gp@lly}{\@@gp@urx}{\@@gp@ury}}% + {\@@gp@width}{\@@gp@height}{\@@gp@clip}{\@@gp@filename}{\@@gp@format}}% + \def\space{ }% change it back + \expandafter\endgroup\@tempa % so \@@PutImage can change global variables +}% + +%\zzzzzzzz diff --git a/macros/latex/exptl/graphicp/graphicpdoc.pdf b/macros/latex/exptl/graphicp/graphicpdoc.pdf new file mode 100644 index 0000000000..944635ed93 Binary files /dev/null and b/macros/latex/exptl/graphicp/graphicpdoc.pdf differ diff --git a/macros/latex/exptl/graphicp/graphicpdoc.tex b/macros/latex/exptl/graphicp/graphicpdoc.tex new file mode 100644 index 0000000000..86cc3b9135 --- /dev/null +++ b/macros/latex/exptl/graphicp/graphicpdoc.tex @@ -0,0 +1,146 @@ +% +% graphicpdoc.tex: documentation of GraphicP, a LaTeX source file +% by pts@fazekas.hu at Mon Feb 10 00:07:07 CET 2003 +% + +\documentclass[a4paper]{article} + \usepackage[latin2]{inputenc} + %\usepackage[magyar]{babel}% for testing the active ` + \usepackage[english]{babel} + %\usepackage{ascii} + %\usepackage{pts_cs} + %\usepackage{t1enc} + + \paperheight=297mm \paperwidth=210mm + \expandafter\ifx\csname pdfoutput\endcsname\relax% + \special{papersize=595bp,842bp}% + \else% + \pdfoutput=1% + \pdfcompresslevel=9% + \pdfpagewidth=595bp \pdfpageheight=842bp% + \pdfpageattr={/CropBox [0 0 595 842]}% + \fi% + + \hoffset=2cm \voffset=2cm + \textheight=\paperheight \advance\textheight by -2\voffset + \textwidth =\paperwidth \advance\textwidth by -2\hoffset + \advance\hoffset by -1in + \advance\voffset by -1in + \topmargin=0cm% + \headheight=0cm% + \headsep=0cm% + \marginparsep=0cm% + \marginparwidth=0cm% + \oddsidemargin=0cm% + \evensidemargin=0cm% csak páratlan oldalak E twoside nélkül + \footskip=15pt% a sorszám basline-ja a szöveg alsó bl-jától + \relax% + +\def\product/{\textsf{GraphicP}} +\def\tokenfbox#1{{\fboxrule=0.2pt \fboxsep=1pt \fbox{\textex{#1}}}} +\def\aproduct#1{\textsf{#1}} +\makeatletter +%** Example: \bchar\\ +\def\bchar#1{\expandafter\@gobble\string#1}% + +\title{Documentation of \product/} +\author{Szab\'o P\'eter\\\texttt{}} + +\begin{document} + +\makeatletter + \def\@listi{% \begin{document} után kell! + \leftmargin=\leftmargini% + \topsep=5pt plus3pt minus1pt% + %\partopsep=0pt% + \parsep=0.5pt plus0.5pt minus0.5pt% + \itemsep=3pt plus3pt minus1pt% + %\parsep=0pt \itemsep=0pt % works fine + }% + +\maketitle +\begin{abstract} + This is the documentation of \product/, a system that provides an easy, fast and reliable method for + including external images into {\LaTeX} and plain {\TeX} documents. The + \texttt{\bchar\\includegraphics} macro of \product/ is a drop-in + replacement of the same + command of {\LaTeX} \texttt{graphics.sty} and \texttt{graphicx.sty}, but with + many enhancements. + Input images are ususally in EPS or PDF format. Drivers for \aproduct{xdvi}, + \aproduct{dvips}, \aproduct{pdftex} and \aproduct{dvipdfm} are included. + Perl scripts are provided for + faster bounding box manipulations. +\end{abstract} + +\section{Availability and usage} + +You can download \product/ from +\texttt{http://www.inf.bme.hu/\textasciitilde pts/graphicp-latest.tar.gz}. + +Load \product/ with \texttt{\bchar\\usepackage\bchar\{graphicp\bchar\}} +instead of +\texttt{\bchar\\usepackage\bchar\{graphicx\bchar\}}. Use the +\texttt{\bchar\\includegra\allowbreak phics} macro as usual, but beware of the +differences. + +\section{Quick feature list} + +Features over {\LaTeX} \texttt{\bchar\\usepackage\bchar\{graphicx\bchar\}}: + +\begin{itemize} + +\item both plain TeX and LaTeX support +\item specified width=... and height=... are strictly enforced, without rounding +\item image scaling calculations are much more accurate +\item works with \textit{dvips -E} bounding-box calculations, even with buggy dvips + 5.86e +\item doesn't have to open the .eps file for reading the bbox +\item xdvi doesn't forcibly crop (clip) the image to the bbox +\item Below feature: allows the image descend below the baseline + (supports depth, not only width and height) +\item drop dependency on Perl, parse Adobe DSC comments in EPS files +\item non-standard, quick, DSC-like parsing for special PDF files +\item an enhanced \aproduct{epstopdf} utility +\item the \aproduct{img\textunderscore bbox.pl} utility +\item the \aproduct{pdfboxes.pl} utility +\item voluntary clipping (cropping) +\item all 8 mirror and rotate transformation (must be a multipe of 90 degrees) +\item does not rely on the filename to determine the FileFormat +\item embeds each image file only once with pdfTeX and dvipdfm +\item {}[long term plan] imtrix: unified PSTricks/PSFrag support for EPS and PDF + +\end{itemize} + +\section{Further reading} + +The full documentation hasn't been written yet. See the file +\texttt{graphicp.sty} for more information. + +To see samples, try the following compilation procedures: + +\begin{verbatim} + tex laltest # or: latex laltest + xdvi laltest + dvips -o laltest.ps laltest + dvipdfm -v laltest + xpdf laltest.pdf +\end{verbatim} + +\begin{verbatim} + pdftex laltest # or: pdflatex laltest + xpdf laltest.pdf +\end{verbatim} + +\begin{verbatim} + latex '\def\graphicPdriver{dvips}\input laltest' + xdvi laltest + dvips -o laltest.ps laltest +\end{verbatim} + +\begin{verbatim} + tex '\def\graphicPdriver{dvipdfm}\input laltest' + dvipdfm -v laltest + xpdf laltest.pdf +\end{verbatim} + +\end{document} diff --git a/macros/latex/exptl/graphicp/img_bbox.pl b/macros/latex/exptl/graphicp/img_bbox.pl new file mode 100755 index 0000000000..12c1b951c7 --- /dev/null +++ b/macros/latex/exptl/graphicp/img_bbox.pl @@ -0,0 +1,2079 @@ +#! /bin/sh +eval '(exit $?0)' && eval 'PERL_BADLANG=x;export PERL_BADLANG;: \ +;exec perl -x -S -- "$0" ${1+"$@"};#'if 0; +eval 'setenv PERL_BADLANG x;exec perl -x -S -- "$0" $argv:q;#'.q+ +#!perl -w +package Htex::img_bbox; $0=~/(.*)/s;unshift@INC,'.';do($1);die$@if$@;__END__+if !1; +# This Perl script was generated by JustLib2 at Sun Feb 9 23:57:24 2003. +# Don't touch/remove any lines above; http://www.inf.bme.hu/~pts/justlib +package just; BEGIN{$INC{'just.pm'}='just.pm'} +BEGIN{ $just::VERSION=2 } +sub end(){1} +sub main(){} + +BEGIN{$ INC{'integer.pm'}='integer.pm'} { +package integer; +use just; +# by pts@fazekas.hu at Wed Jan 10 12:42:08 CET 2001 +sub import { $^H |= 1 } +sub unimport { $^H &= ~1 } +just::end} + +BEGIN{$ INC{'strict.pm'}='strict.pm'} { +package strict; +use just; +# by pts@fazekas.hu at Wed Jan 10 12:42:08 CET 2001 +require 5.002; +sub bits { + (grep{'refs'eq$_}@_ && 2)| + (grep{'subs'eq$_}@_ && 0x200)| + (grep{'vars'eq$_}@_ && 0x400)| + ($@ || 0x602) +} +sub import { shift; $^H |= bits @_ } +sub unimport { shift; $^H &= ~ bits @_ } +just::end} + +BEGIN{$ INC{'Pts/string.pm'}='Pts/string.pm'} { +package Pts::string; +# by pts@fazekas.hu at Sat Dec 21 21:32:18 CET 2002 +use just; +use integer; +use strict; + +#** @param $_[0] a string +#** @param $_[1] index of first bit to return. Bit 128 of byte 0 is index 0. +#** @param $_[2] number of bits to return (<=32) +#** @return an integer (negative on overflow), bit at $_[1] is its MSB +sub get_bits_msb($$$) { + # assume: use integer; + my $loop=$_[1]; + my $count=$_[2]; + my $ret=0; + ($ret+=$ret+(1&(vec($_[0],$loop>>3,8)>>(7-($loop&7)))), $loop++) while $count--!=0; + $ret +} + +#** @param $_[0] a string +#** @return value if $_[0] represents a floating point numeric constant +#** in the C language (without the LU etc. modifiers) -- or undef. Returns +#** undef for integer constants +sub c_floatval($) { + my $S=$_[0]; + no integer; # very important; has local scope + return 0.0+$S if $S=~/\A[+-]?(?:[0-9]*\.[0-9]+|[0-9]+\.])(?:[eE][+-]?[0-9]+)?\Z(?!\n)/; + undef +} + +#** @param $_[0] a string +#** @return value if $_[0] represents a floating point or integer numeric +#** constant in the C language (without the LU etc. modifiers) -- or undef +sub c_numval($) { + my $S=$_[0]; + no integer; # very important; has local scope + return 0+$S if $S=~/\A[+-]?(?:[0-9]*\.[0-9]+(?:[eE][+-]?[0-9]+)?|[0-9]+\.?)\Z(?!\n)/; + undef +} + +#** @param $_[0] a string +#** @return the integer value of $_[0] in C -- or undef +sub c_intval($) { + my $S=$_[0]; + my $neg=1; + $neg=-1 if $S=~s@\A([+-])@@ and '-'eq$1; + return $neg*hex $1 if $S=~/\A0[xX]([0-9a-fA-F]+)\Z(?!\n)/; + return $neg*oct $1 if $S=~/\A0([0-7]+)\Z(?!\n)/; + return $neg*$1 if $S=~/\A([0-9]+)\Z(?!\n)/; + undef +} + +sub import { + no strict 'refs'; + my $package = (caller())[0]; + shift; # my package + for my $p (@_ ? @_ : qw{get_bits_msb c_floatval c_numval c_intval}) { *{$package."::$p"}=\&{$p} } +} + +just::end} + +BEGIN{$ INC{'Htex/dimen.pm'}='Htex/dimen.pm'} { +package Htex::dimen; +# by pts@fazekas.hu at Sat Dec 21 21:26:15 CET 2002 +use just; +use integer; +use strict; +use Pts::string qw(c_numval); + +my %bp_mul; +{ no integer; %bp_mul=( + 'bp'=>1, # 1 bp = 1 bp (big point) + 'in'=>72, # 1 in = 72 bp (inch) + 'pt'=>72/72.27, # 1 pt = 72/72.27 bp (point) + 'pc'=>12*72/72.27, # 1 pc = 12*72/72.27 bp (pica) + 'dd'=>1238/1157*72/72.27, # 1 dd = 1238/1157*72/72.27 bp (didot point) [about 1.06601110141206 bp] + 'cc'=>12*1238/1157*72/72.27, # 1 cc = 12*1238/1157*72/72.27 bp (cicero) + 'sp'=>72/72.27/65536, # 1 sp = 72/72.27/65536 bp (scaled point) + 'cm'=>72/2.54, # 1 cm = 72/2.54 bp (centimeter) + 'mm'=>7.2/2.54, # 1 mm = 7.2/2.54 bp (millimeter) +) } + +#** @param $_[0] a (real or integer) number, optionally postfixed by a +#** TeX dimension specifier (default=bp) +#** @return the number in bp, or undef +sub dimen2bp($) { + no integer; + my $S=$_[0]; + my $mul; + $mul=$bp_mul{$1} if $S=~s/\s*([a-z][a-z0-9]+)\Z(?!\n)// and exists $bp_mul{$1}; + my $val=c_numval($S); + $val*=$mul if defined $val and defined $mul; + $val +} + +just::end} + +BEGIN{$ INC{'Htex/ImgBBox.pm'}='Htex/ImgBBox.pm'} { +package Htex::ImgBBox; +# +# ImgBBox -- extract file format and size from image files +# by pts@fazekas.hu at Sat Dec 7 21:31:01 CET 2002 +# JustLib2 at Sat Dec 21 21:29:21 CET 2002 +# +# Dat: we know most of xloadimage-1.16, most of of file(1)-debian-potato, +# all of sam2p-0.40, all of xv-3.10 +# Dat: only in xloadimage: g3Ident, g3Load, "G3 FAX Image", (hard to identify file format) +# Dat: only in xloadimage: macIdent, macLoad, "MacPaint Image", (stupid, black-white) +# Imp: multiple paper sizes +# +use just; +use integer; +use strict; +use Htex::dimen; +use Pts::string; +# use Data::Dumper; + +# Dat: BBoxInfo is a hashref: +# Dat: Info.* keys has FileFormat-dependent meaning (thus Info.depth may have +# different meanings for different FileFormats) +# { 'FileFormat' => 'TIFF' # ... +# 'SubFormat' => 'PPM' +# 'Error' => 0 +# 'LLX' => ... # lower left x (usually 0) +# 'LLY' => ... # lower left y (usually 0) +# 'URX' => ... # upper right x (usually width) +# 'URY' => ... # upper right y (usually height) +# } + +# Dat: \usepackage[hiresbb]{graphicx} +# Dat: pdfTeX graphicx.sty doesn't respect PDF CropBox. For +# /MediaBox[a b c d], \ht=d, \wd=c, and no overwrite below (a,b) + +# --- + +#** import will set them +my $have_pdf; +my $have_paper; + +#** May moves the file offset, but only relatively (SEEK_CUR). +#** @param $_[0] \*FILE +#** @return BBoxInfo +sub calc($) { + my $F=$_[0]; + my $dummy; + my @L; + my $head; + #** BBoxInfo to return + my $bbi={ + # 'FileFormat' => '.IO.error', + 'FileFormat' => 'unknown', + 'LLX' => 0, 'LLY' => 0, # may be float; in `bp' + # 'URX' => 0, 'URY' => 0 # default: missing; may be float; in `bp' + }; + binmode $F; + if (0>read $F, $head, 256) { IOerr: $bbi->{Error}="IO: $!"; goto done } + if (length($head)==0) { $bbi->{FileFormat}='Empty'; return $bbi } + if ($head=~m@\A\s*/[*]\s+XPM\s+[*]/@) { # XPM + $bbi->{FileFormat}='XPM'; + goto IOerr if !seek $F, -length($head), 1; + select($F); $/='"'; select(STDOUT); <$F>; + $head=<$F>; + if ($head!~/\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+).*"\Z(?!\n)/s) { SYerr: $bbi->{Error}='syntax'; goto done } + # width, height, length(palette), length(pixelchar) + $bbi->{URX}=0+$1; + $bbi->{URY}=0+$2; + } elsif ($head=~m@\A\s*\/\*\s*Format_version=\S*\s+@i) { + $bbi->{FileFormat}='XBM1'; # ?? + goto IOerr if 0>read $F, $head, 256-length($head), length($head); + $head=~s@\*\/.*@@s; # keep only header + goto SYerr if $head!~m@\s+Width=(\d+)@i; + $bbi->{URX}=0+$1; + goto SYerr if $head!~m@\s+Height=(\d+)@i; + $bbi->{URY}=0+$1; + } elsif ($head=~m@\A(?:/[*].*?[*]/)?\s*#define\s+.*?_width\s+(\d+)\s*#define\s+.*?_height\s+(\d+)\s*@) { # XBM (1) + # Dat: this `if' must be after checking XPM + # Imp: recognise a longer comment (that does not fit into $head) + $bbi->{FileFormat}='XBM'; + $bbi->{URX}=0+$1; + $bbi->{URY}=0+$2; + } elsif ($head=~m@\A(?:/[*].*?[*]/)?\s*#define\s+.*?_height\s+(\d+)\s*#define\s+.*?_width\s+(\d+)\s*@) { # XBM (2) + $bbi->{FileFormat}='XBM'; + $bbi->{URX}=0+$2; + $bbi->{URY}=0+$1; + } elsif ($head=~m@\AP([1-6])[\s#]@) { # PNM + $bbi->{FileFormat}='PNM'; + my @subformats=qw{- PBM.text PGM.text PPM.text PBM.raw PGM.raw PPM.raw}; + $bbi->{SubFormat}=$subformats[0+$1]; + goto IOerr if 0>read $F, $head, 1024-length($head), length($head); + $head=~s@#.*@@g; # remove comments + goto SYerr if ($head!~/\AP[1-6]\s+(\d+)\s+(\d+)\s/); + $bbi->{URX}=0+$1; $bbi->{URY}=0+$2; + } elsif (substr($head, 0, 4) eq "MM\000\052" or substr($head, 0, 4) eq "II\052\000") { + $bbi->{FileFormat}='TIFF'; + my $LONG="N"; + my $SHORT="n"; + if (substr($head, 0, 1) eq "I") { + $bbi->{SubFormat}='LSBfirst'; + $LONG="V"; $SHORT="v"; + } else { + $bbi->{SubFormat}='MSBfirst'; + } + my($dummy,$ifd_ofs)=unpack $LONG.$LONG, $head; + goto IOerr if !seek $F, $ifd_ofs-length($head), 1; + my $ifd_len; + goto IOerr if 2!=read $F, $ifd_len, 2; + $ifd_len=unpack($SHORT,$ifd_len); + while ($ifd_len--!=0) { + my($entry,$tag,$type,$count,$value); + goto IOerr if 12!=read $F, $entry, 12; + ($tag,$type,$count)=unpack($SHORT.$SHORT.$LONG, $entry); + # vvv Dat: we discard tags with $value longer than 4 bytes + # Unfortunately BitsPerSample may be such a tag for RGB + if ($type==3) { $value=unpack($SHORT,substr($entry,8,2)) } + elsif ($type==4) { $value=unpack($LONG, substr($entry,8,4)) } + else { $value=vec($entry,8,8); } + if ($tag==256 and $count==1) { $bbi->{URX}=$value } # ImageWidth + elsif ($tag==257 and $count==1) { $bbi->{URY}=$value } # ImageLength + elsif ($tag==258 and $count<=2) { $bbi->{BitsPerSample}=$value } + elsif ($tag==259) { $bbi->{"Info.Compression"}=$value } + elsif ($tag==254) { $bbi->{"Info.NewSubfileType"}=$value } + elsif ($tag==255) { $bbi->{"Info.SubfileType"}=$value } + elsif ($tag==262) { $bbi->{"Info.PhotometricInterpretation"}=$value } + elsif ($tag==263) { $bbi->{"Info.Thresholding"}=$value } + elsif ($tag==264) { $bbi->{"Info.CellWidth"}=$value } + elsif ($tag==265) { $bbi->{"Info.CellLength"}=$value } + elsif ($tag==266) { $bbi->{"Info.FillOrder"}=$value } + elsif ($tag==274) { $bbi->{"Info.Orientation"}=$value } + elsif ($tag==277) { $bbi->{SamplesPerPixel}=$value } + elsif ($tag==278) { $bbi->{"Info.RowsPerStrip"}=$value } + elsif ($tag==280) { $bbi->{"Info.MinSampleValue"}=$value } + elsif ($tag==281) { $bbi->{"Info.MaxSampleValue"}=$value } + elsif ($tag==284) { $bbi->{"Info.PlanarConfiguration"}=$value } + elsif ($tag==290) { $bbi->{"Info.GrayResponseUnit"}=$value } + elsif ($tag==296) { $bbi->{"Info.ResolutionUnit"}=$value } + elsif ($tag==338 and $count<=2) { $bbi->{"Info.ExtraSamples"}=$value } + } + } elsif ($head=~/\A\12[\0-\005]\001[\001-\10]/) { + $bbi->{FileFormat}='PCX'; # PC Paintbrush image + ($dummy,$bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=unpack("A4vvvv",$head); + $bbi->{URX}++; $bbi->{URY}++; + # pinfo->w = 1+ (hdr[PCX_XMAXL] + ((int) hdr[PCX_XMAXH]<<8)) - (hdr[PCX_XMINL] + ((int) hdr[PCX_XMINH]<<8)); + # pinfo->h = 1+ (hdr[PCX_YMAXL] + ((int) hdr[PCX_YMAXH]<<8)) - (hdr[PCX_YMINL] + ((int) hdr[PCX_YMINH]<<8)); + } elsif ($head=~/\AGIF(8[79]a)/) { + $bbi->{FileFormat}='GIF'; + $bbi->{SubFormat}=$1; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A6vv",$head); + } elsif ($head=~/\A(\377+\330)\377/g) { + $bbi->{FileFormat}='JPEG'; + die if !seek $F, length($1)-length($head), 1; + my $id_rgb=0; + my $had_jfif=0; + my $cpp; + my $colortransform=-1; # as defined by the Adobe APP14 marker + my $tag; + my $w; + while (1) { + goto IOerr if !defined($tag=getc($F)) or ord($tag)!=255; + 1 while defined($tag=getc($F)) and 255==($tag=ord($tag)); + goto IOerr if !defined($tag); + if ($tag==0xC0) { # SOF0 marker: Baseline JPEG file + $bbi->{SubFormat}='Baseline'; + goto IOerr if 2!=read $F, $w, 2; + $dummy=unpack('n',$w)-2; # length includes itself + goto IOerr if $dummy<9 or $dummy!=read($F, $w, $dummy); + $bbi->{BitsPerSample}=vec($w,0,8); + $bbi->{URY}=(vec($w,1,8)<<8)|vec($w,2,8); + $bbi->{URX}=(vec($w,3,8)<<8)|vec($w,4,8); + $cpp=vec($w,5,8); + goto SYerr if ($dummy-=6)!=3*$cpp or $cpp>6 or $cpp<1; + $bbi->{'Info.hvs'}=vec($w,7,8); # HVSamples ? + $id_rgb=1 if $cpp==3 and $w=~/\A......R..G..B/s; + } elsif (0xC1<=$tag and $tag<=0xCF and $tag!=0xC4 and $tag!=0xC8) { # SOFn + $bbi->{Subformat}="SOF".($tag-0xC0); + last + } elsif ($tag==0xD9 or $tag==0xDA) { # EOI or SOS marker; we're almost done + if (!defined $cpp) { + } elsif ($cpp==1) { + $bbi->{'ColorSpace'}='Gray'; + } elsif ($cpp==3) { + $bbi->{'ColorSpace'}='YCbCr'; + if ($had_jfif!=0 or $colortransform==1) {} + elsif ($colortransform==0 or $id_rgb) { $bbi->{'ColorSpace'}='RGB' } + } elsif ($cpp==4) { + $bbi->{'ColorSpace'}='CMYK'; + if ($colortransform==2) { $bbi->{'ColorSpace'}='YCCK' } + } + last + } else { + # skip over a variable-length block; assumes proper length marker + # ($tag==0xE0) # APP0: JFIF application-specific marker + # ($tag==0xEE) # APP14: Adobe application-specific marker + goto IOerr if 2!=read $F, $w, 2; + $dummy=unpack('n',$w)-2; # length includes itself + goto IOerr if $dummy!=read $F, $w, $dummy; + $colortransform=ord($1) if + $tag==0xEE and $dummy==12 and $w=~/\AAdobe[\001-\377].....(.)/s; + $had_jfif=1 if + $tag==0xE0 and $dummy==14 and $w=~/\AJFIF\0/; + } ## IF + } ## WHILE + $bbi->{'Info.id_rgb'}=$id_rgb; + $bbi->{'Info.had_jfif'}=$had_jfif; + $bbi->{'Info.ColorTransform'}=$colortransform; + $bbi->{SamplesPerPixel}=$cpp; + } elsif (substr($head,0,8) eq "\211PNG\r\n\032\n") { + $bbi->{FileFormat}='PNG'; + goto SYerr if $head!~/\A........\0\0\0[\15-\77]IHDR/s; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A16NN",$head); + } elsif (substr($head,0,5) eq "%PDF-") { + $bbi->{FileFormat}='PDF'; # Adobe Portable Document Format + # Dat: this routine cannot read encrypted PDF files + # Dat: example $bbi return: { + # 'URY' => 792, 'LLX' => '0', 'LLY' => '0', 'URX' => 612 + # 'FileFormat' => 'PDF', 'SubFormat' => '1.2', 'Info.linearized' => 1, 'Info.binary' => 'Binary', + # 'Info.MediaBox' => [ 0, 0, 612, 792 ], + # 'Info.CropBox' => [ 41, 63, 572, 729 ], + # }; + # Dat: $bbi->{'Info.num_pages'} is not reported for Linearized PDF. + # Imp: report much more specific error messages + # Imp: better distinguish between IOerr and SYerr + $bbi->{SubFormat}=$1 if $head=~/\A%PDF-([\d.]+)/; + $bbi->{'Info.binary'}=($head=~/\A[^\r\n]+[\r\n]+[ -~]*[^\n\r -~]/) ? 'Binary' : 'Clean7Bit'; + # die $have_pdf; + goto done if !$have_pdf; + # if ($head=~m@\A(?:%[^\r\n]*[\r\n])*.{0,40}/Linearized@s and $head=~m@\A(?:%[^\r\n]*[\r\n])*.{0,200}/O\s+(\d+)@s) { + my $had_pdfboxes=($head=~m@/Type\s*/pdfboxes%@); # `%' is important + $head=pdf_rewrite($head,1); + my $page1obj; + $bbi->{'Info.linearized'}=0; + $bbi->{'Info.pdfboxes'}=0; + if (defined $head) { + $head=~s@\bendobj.*@@s; + if ($had_pdfboxes) { + # a hint of very strict format, by + $head=""; + goto IOerr if !seek($F, 0, 0) or 20>read($F, $head, 2048); + goto SYerr unless $head=~/\d\s+\d+\s+obj\s*(.*?)\bendobj/s; + $head=$1; goto SYerr unless $head=~m@/Type\s*/pdfboxes%@; + while ($head=~m@^\s*/(\w+Box)\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]@gm) { + ## print "($1) ($2) ($3) ($4) ($5)\n"; + ($bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=($2,$3,$4,$5) if $1 eq 'MediaBox'; + $bbi->{"Info.$1"}=[$2,$3,$4,$5]; + } + $bbi->{'Info.pdfboxes'}=1; + goto done; + } elsif ($head=~m@/Linearized\s+@ and $head=~m@/O\s+(\d+)@) { + $bbi->{'Info.linearized'}=1; + $page1obj=$bbi->{'Info.page1obj'}=$1+0; + } + } + goto IOerr if !seek $F, -1024, 2 and !seek $F, 0, 0; + goto IOerr if 1>read $F, $head, 1024; + goto SYerr if $head!~/startxref\s+(\d+)\s*%%EOF\s*\Z(?!\n)/ + and $head!~/startxref\s+(\d+)\s*%%EOF/; + # ^^^ Dat: some PDF files contain binary junk at the end + my $xref_ofs=$1+0; + goto IOerr if !seek $F, $xref_ofs, 0; + # die pdf_read_obj($F); + my $xref=[]; + my $trailer=pdf_read_xref($F,$xref); + goto SYerr if !defined $trailer; + + my $pages; + my $type; + if (!defined $page1obj) { do_pdf_slow: + ## die $trailer; + ## die pdf_ref($F,$xref,37550,0); + ## die pdf_get($F,$xref,$trailer,'/ID'); + ## die pdf_get($F,$xref,$trailer,'/Root'); + ## die pdf_get($F,$xref,$trailer,'/Size'); + ## die pdf_get($F,$xref,$trailer,'/Sizez'); + + my $root=pdf_get($F,$xref,$trailer,'/Root'); + goto IOerr if !defined $root; goto SYerr if !length $root; + $type=pdf_get($F,$xref,$root,'/Type'); + goto IOerr if !defined $type; goto SYerr if $type ne ' /Catalog'; + # die $root; + # vvv Dat: reading xref for /Pages in a linearized PDF is quite slow + $pages=pdf_get($F,$xref,$root,'/Pages'); + goto IOerr if !defined $pages; goto SYerr if !length $pages; + ## die $pages; + my $kids; + + while (1) { + $type=pdf_get($F,$xref,$pages,'/Type'); + goto IOerr if !defined $type; + last if $type ne ' /Pages'; + pdf_get_boxes($F, $xref, $pages, $bbi); + $kids=pdf_get($F,$xref,$pages,'/Kids'); + goto IOerr if !defined $kids; goto SYerr if !length $kids; + ## die $kids; + $pages=pdf_get($F,$xref,$kids,0); + ## die $pages; + goto IOerr if !defined $pages; goto SYerr if !length $pages; + } + goto SYerr if $type ne ' /Page'; + # Dat: cannot set $page1obj properly here, because it might be a direct object + $bbi->{'Info.page1obj'}=$Htex::PDFread::pdf_last_ref0; + } else { + # die $page1obj; + $pages=pdf_ref($F, $xref, $page1obj, 0); + goto IOerr if !defined $pages; + $type=pdf_get($F,$xref,$pages,'/Type'); + goto IOerr if !defined $type; + goto SYerr if $type ne ' /Page'; + my $mediabox=pdf_get($F,$xref,$pages,'/MediaBox'); + goto IOerr if !defined $mediabox; + goto do_pdf_slow if !length $mediabox; + } + pdf_get_boxes($F, $xref, $pages, $bbi); + } elsif (substr($head,0,4) eq "%!PS") { + # Dat: the user should not trust Val.languagelevel blindly. There are far + # too many PS files hanging around that do not conform to any standard. + $bbi->{FileFormat}=$bbi->{SubFormat}= + ($head=~/\A[^\n\r]*?\bEPSF-/) ? "EPS" : "PS"; + goto SYerr if $head!~s@[^\n\r]*[\n\r]+@@; + # vvv Dat `+' is `or' with full boolean eval + until ($head=~s@[\n\r]%%EndComments.*@@s + $head=~s@[\n\r](?:[^%]|%[^%]).*@@s) { + goto IOerr if 0>read $F, $head, 1024, length($head); + } + my $headlen=length($head); + $head=~s@(?:\r\n|\n\r|[\n\r])@\n@g; # uniformize newlines + $head=~s@\s*\n%%[+]\s*@ @g; # unify line continuations + my %H; + my $had_hires=0; # HiresBoundingBox overrides normal + my $val; + while ($head=~/^%%([A-Za-z]+):?\s*((?:.*\S)?)/gm) { + next if $2 ne '(atend)'; + # read additional ADSC comments from the last 1024 bytes of the file + goto IOerr if !seek $F, -1024, 2 and !seek $F, 0, 0; # Dat: seek to EOF + $dummy=tell $F; + goto IOerr if $dummy<$headlen and $headlen-$dummy!=read $F, $val, $headlen-$dummy; + goto IOerr if 0>read $F, $val, 1024; + $val=~s@(?:\r\n|\n\r|[\n\r])@\n@g; # uniformize newlines + $val=~s@\s*\n%%[+]\s*@ @g; # unify line continuations + $val=~s@^(?:[^%]|%[^%]).*\n?@@mg; # remove non-DSC lines + # vvv Dat: appending is schemantically correct here + $head.="\n$val"; last + } + while ($head=~/^%%([A-Za-z]+):?[ \t]*((?:.*\S)?)/gm) { # iterate over Adobe DSC comments + $dummy=lc($1); $val=$2; + next if $dummy eq 'enddata' or $dummy eq 'trailer' or $dummy eq 'eof'; + $bbi->{"Val.$dummy"}=$2; + if ($dummy eq 'documentdata') { + $dummy=lc($2); + $bbi->{'Info.binary'}='Clean7Bit' if $dummy eq 'clean7bit'; + $bbi->{'Info.binary'}='Clean8Bit' if $dummy eq 'clean8bit'; + $bbi->{'Info.binary'}='Binary' if $dummy eq 'binary'; + } elsif ($dummy eq 'creator' and $val=~/\bMetaPost\b/) { + $bbi->{FileFormat}='EPS'; + $bbi->{SubFormat}='MPS'; # useful for graphicP.sty + } elsif ($dummy eq 'boundingbox' and $val=~/\A([+-]?\d+)\s+([+-]?\d+)\s+([+-]?\d+)\s+([+-]?\d+)\Z(?!\n)/) { + ($bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=($1+0,$2+0,$3+0,$4+0) if !$had_hires; + } elsif (($dummy eq 'hiresboundingbox' or $dummy eq 'exactboundingbox') + and $val=~/\A([+-]?[0-9eE.-]+)\s+([+-]?[0-9eE.-]+)\s+([+-]?[0-9eE.-]+)\s+([+-]?[0-9eE.-]+)\Z(?!\n)/ + and defined c_numval($1) and defined c_numval($2) and defined c_numval($3) and defined c_numval($4) + ) { + # Dat: capitalized names are: HiResBoundingBox, ExactBoundingBox + no integer; + ($bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=($1+0,$2+0,$3+0,$4+0); + $had_hires=1; + } + } + } elsif ($head=~/\AFORM....ILBMBMHD/s) { + $bbi->{FileFormat}='LBM'; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A20nn",$head); + } elsif ($head=~/\AFORM....(RGB[8N])/s) { # /etc/magic + $bbi->{FileFormat}="IFF.$1"; + # dimension info not available + } elsif ($head=~/\ABM....\0\0\0\0....[\014-\177]\0\0\0/s) { # PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu) + $bbi->{FileFormat}='BMP'; + if (vec($head,14,8)==12) { + $bbi->{SubFormat}='OS/2 1.x'; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A18vv",$head); + } elsif (vec($head,14,8)==64) { + $bbi->{SubFormat}='OS/2 2.x'; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A18vv",$head); + } elsif (vec($head,14,8)==40) { + $bbi->{SubFormat}='Windows'; + ($dummy,$bbi->{URX},$bbi->{URY},$dummy,$bbi->{"Info.depth"})=unpack("A18VVvv",$head); + } else { goto SYerrr } + #0 string BM PC bitmap data + #>14 leshort 12 \b, OS/2 1.x format + #>>18 leshort x \b, %d x + #>>20 leshort x %d + #>14 leshort 64 \b, OS/2 2.x format + #>>18 leshort x \b, %d x + #>>20 leshort x %d + #>14 leshort 40 \b, Windows 3.x format + #>>18 lelong x \b, %d x + #>>22 lelong x %d x + #>>28 leshort x %d + } elsif (substr($head,0,10) eq "\367\002\001\203\222\300\34;\0\0") { FF__DVI: + $bbi->{FileFormat}='DVI'; + # read 1st page of the DVI file, look for TeX \special{papersize=21cm,29.7cm}, + # as understood by dvips and xdvi + ($dummy,$bbi->{'Info.version_id'},$bbi->{'Info.numerator'}, + $bbi->{'Info.denominator'},$bbi->{'Info.magnification'})=unpack('CCNNN',$head); + goto IOerr if !seek $F, 15-length($head), 1; + $dummy=vec($head,14,8); + goto IOerr if $dummy!=read $F, $bbi->{'Info.jobname'}, $dummy; + my($tag,$action); + my @actions=(0)x256; # skip that char + $actions[139]=15; # Bop + @actions[248,249,140,223]=(16,16,16,16); # stop parsing file + @actions[128,133,143,148,153,157,162,167,235]=(1,1,1,1,1,1,1,1,1); # read 1 extra bytes + @actions[129,134,144,149,154,158,163,168,236]=(2,2,2,2,2,2,2,2,2); # read 2 extra bytes + @actions[130,135,145,150,155,159,164,169,237]=(3,3,3,3,3,3,3,3,3); # read 2 extra bytes + @actions[131,136,146,151,156,160,165,170,238]=(4,4,4,4,4,4,4,4,4); # read 2 extra bytes + @actions[132,137]=(8,8); # read 8 extra bytes + @actions[243,244,245,246]=(17,18,19,20); # Fnt_def + @actions[239,240,241,242]=(33,34,35,26); # Special (XXX) + while (1) { + goto IOerr if !defined($tag=getc($F)); # Dat: EOF is error + $tag=$actions[ord($tag)]; + if ($tag==0) { + } elsif ($tag==16) { + last + } elsif ($tag==15) { # Bop + last if exists $bbi->{'Info.page1_nr'}; + goto IOerr if 44!=read $F, $dummy, 44; + $bbi->{'Info.page1_nr'}=unpack "N", $dummy; + } else { + # read number of ($tag&15) bytes in MSBfirst byte order + $dummy="\0\0\0\0"; + goto IOerr if ($tag&15)!=read $F, $dummy, ($tag&15), 4; + $dummy=unpack("N",substr($dummy,-4)); + if ($tag>=33) { # Special + goto IOerr if $dummy!=read $F, $tag, $dummy; + @L=split /\s*=\s*/, $tag, 2; + if ($#L) { + $bbi->{"Val.$L[0]"}=$L[1]; + if ($L[0] eq 'papersize') { + @L=split /,/, $L[1], 2; + $bbi->{URX}=Htex::dimen::dimen2bp($L[0]); + $bbi->{URY}=Htex::dimen::dimen2bp($L[1]); + if (!defined $bbi->{URX} or !defined $bbi->{URY}) { + delete $bbi->{URX}; delete $bbi->{URY}; + } + } + } else { $bbi->{'Info.special'}=$tag; } + } elsif ($tag>=17) { # Fnt_def + goto IOerr if 14!=read $F, $tag, 14; + $dummy=vec($tag,12,8)+vec($tag,13,8); + goto IOerr if $dummy!=read $F, $tag, $dummy; + } + } # IF + } # WHILE + } elsif ($head=~/\Aid=ImageMagick\r?\n/) { + $bbi->{FileFormat}='MIFF'; + # goto IOerr if 0>read $F, $head, 128-length($head), length($head); + goto SYerr if $head!~/\bcolumns=(\d+)\s+rows=(\d+)/; + $bbi->{URX}=0+$1; $bbi->{URY}=0+$2; + } elsif (substr($head,0,3) eq 'FWS') { + $bbi->{FileFormat}='SWF'; # Macromedia ShockWave Flash + my $nbits=get_bits_msb($head, 64, 5); + no integer; + $bbi->{URX}=get_bits_msb($head, 69+ $nbits, $nbits)/20.0; + $bbi->{LLX}=get_bits_msb($head, 69, $nbits)/20.0; + $bbi->{URY}=get_bits_msb($head, 69+3*$nbits, $nbits)/20.0; + $bbi->{LLY}=get_bits_msb($head, 69+2*$nbits, $nbits)/20.0; + } elsif (substr($head,0,14) eq "gimp xcf file\0") { # GIMP XCF image data + $bbi->{SubFormat}='version.000'; + do_XCF: + $bbi->{FileFormat}='XCF'; + ($dummy,$bbi->{URX},$bbi->{URY},$dummy)=unpack("A14NNN", $head); + if ($dummy==0) { $bbi->{ColorSpace}='RGB' } + elsif ($dummy==1) { $bbi->{ColorSpace}='Gray' } + elsif ($dummy==2) { $bbi->{ColorSpace}='Indexed' } + } elsif ($head=~/\Agimp xcf v(\d\d\d)\0/) { + $bbi->{SubFormat}="version.$1"; + goto do_XCF; + } elsif ($head=~/\A\0\0\001\0[\001-\50]\0/) { # Windows ICO icon + $bbi->{FileFormat}='ICO'; + # An .ico file may contain multiple icons (hence [\001-50]); we report the + # properties of the very first one. Code based on ImageMagick. + # Imp: WinXP True color icons + ($dummy,$bbi->{URX},$bbi->{URY},$bbi->{'Info.colors'},$bbi->{'Info.reserved'}, + $bbi->{'Info.planes'},$bbi->{BitsPerSample})=unpack("A6CCCCvv", $head); + # more precisely: BitsPerSample is bits per pixel; + # Dat: Info.reserved, BitsPerSample and Info.planes are often 0 + } elsif (substr($head,0,4)eq"8BPS") { # PSD image data (Adobe Photoshop bitmap) + # based on PHP 4.2 image.c; untested + $bbi->{FileFormat}='PSD'; + ($dummy,$bbi->{URY},$bbi->{URX})=unpack("A14NN",$head); + } elsif (substr($head,0,8) eq "\%bitmap\0") { # Fuzzy Bitmap (FBM) image; untested + $bbi->{FileFormat}='FBM'; + @L=unpack("A8A8A8A8A8A8A12A12A12A12A80A80",$head); # <=256 chars OK + for (@L) { s@\0.*@@s } # make strings null-terminated + $bbi->{"Info.credits"}=pop(@L); # string + $bbi->{"Info.title"}=pop(@L); # string + goto SYerr if !defined ($bbi->{aspect}=c_numval(pop(@L))); + shift(@L); # magic + for my $item (@L) { goto SYerr if !defined($item=c_intval($item)) } + ( $bbi->{URX},$bbi->{URY},$bbi->{"Info.planes"},$bbi->{"Info.bits"}, + $bbi->{"Info.physbits"},$bbi->{"Info.rowlen"},$bbi->{"Info.plnlen"}, + $bbi->{"Info.clrlen"})=@L; + # char cols[8]; /* Width in pixels */ + # char rows[8]; /* Height in pixels */ + # char planes[8]; /* Depth (1 for B+W, 3 for RGB) */ + # char bits[8]; /* Bits per pixel */ + # char physbits[8]; /* Bits to store each pixel */ + # char rowlen[12]; /* Length of a row in bytes */ + # char plnlen[12]; /* Length of a plane in bytes */ + # char clrlen[12]; /* Length of colormap in bytes */ + # char aspect[12]; /* ratio of Y to X of one pixel */ + } elsif (substr($head,0,4)eq"\x59\xa6\x6a\x95") { # Sun raster images; untested + $bbi->{FileFormat}='SunRaster'; + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("NNN",$head); + #0 belong 0x59a66a95 Sun raster image data + #>4 belong >0 \b, %d x + #>8 belong >0 %d, + #>12 belong >0 %d-bit, + ##>16 belong >0 %d bytes long, + #>20 belong 0 old format, + ##>20 belong 1 standard, + #>20 belong 2 compressed, + #>20 belong 3 RGB, + #>20 belong 4 TIFF, + #>20 belong 5 IFF, + #>20 belong 0xffff reserved for testing, + #>24 belong 0 no colormap + #>24 belong 1 RGB colormap + #>24 belong 2 raw colormap + #>28 belong >0 colormap is %d bytes long + } elsif (substr($head,0,4)eq"\xf1\x00\40\xbb") { + $bbi->{FileFormat}='CMUWM'; # from xloadimage; untested + ($dummy,$bbi->{URX},$bbi->{URY},$bbi->{"Info.depth"})=unpack("NNNn",$head); + } elsif (substr($head,0,4) eq "\361\0\100\273") { # CMU window manager raster image data + # from xvl untested + $bbi->{FileFormat}='CMUWM'; + ($dummy,$bbi->{URX},$bbi->{URY},$bbi->{'Info.num_bits'})=unpack("VVVV",$head); + } elsif (substr($head,0,2)eq"\x52\xCC") { # Utah Raster Toolkit RLE images; untested + $bbi->{FileFormat}='RLE'; # from xloadimage + ($dummy,$bbi->{URX},$bbi->{URY},$bbi->{LLX},$bbi->{LLY})=unpack("A6vvvv",$head); + $bbi->{BitsPerSample}=vec($head,12,8)/vec($head,11,8); + $bbi->{SamplesPerPixel}=vec($head,11,8); + #0 leshort 0xcc52 RLE image data, + #>6 leshort x %d x + #>8 leshort x %d + #>2 leshort >0 \b, lower left corner: %d + #>4 leshort >0 \b, lower right corner: %d + #>10 byte&0x1 =0x1 \b, clear first + #>10 byte&0x2 =0x2 \b, no background + #>10 byte&0x4 =0x4 \b, alpha channel + #>10 byte&0x8 =0x8 \b, comment + #>11 byte >0 \b, %d color channels + #>12 byte >0 \b, %d bits per pixel + #>13 byte >0 \b, %d color map channels + } elsif (substr($head,0,32)eq"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377") { # Kodak Photograph on CD Image + # derived from xloadimage; untested + $dummy=3587-length($head); + goto IOerr if $dummy=read $F, $head, $dummy, length($head); + goto SYerr if substr($head,2048,7) ne "PCD_IPI"; + $bbi->{FileFormat}='PCD'; + # vvv funny: an image format with fixed (hard-wired) image size + if ((vec($head,3586,8)&1)!=0) { ($bbi->{URY},$bbi->{URX})=(768,512) } + else { ($bbi->{UXY},$bbi->{URY})=(768,512) } + } elsif ($head=~/\A\0\0..\0\0\0[\001-\50]\0\0\0[\0-\002]\0\0\0([\001-\77])/s) { + $bbi->{FileFormat}='XWD'; + $bbi->{SubFormat}='MSBfirst'; + $bbi->{'Info.depth'}=ord($1); + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A16NN",$head); + } elsif ($head=~/\A..\0\0[\001-\50]\0\0\0[\0-\002]\0\0\0([\001-\77])\0\0\0/s) { + $bbi->{FileFormat}='XWD'; + $bbi->{SubFormat}='LSBfirst'; + $bbi->{'Info.depth'}=ord($1); + ($dummy,$bbi->{URX},$bbi->{URY})=unpack("A16VV",$head); + } elsif ($head=~/\A\0\001\0[\010-\377](?:\0.|\001\0)\0.....(?:[\001-\37].|\0[^\0]|\40\0){2}/s) { # GEM Bit image + # from xloadimage; untested + $bbi->{FileFormat}='GEM'; + ($dummy,$bbi->{'Info.hlen'},$bbi->{'Info.colors'},$bbi->{'Info.patlen'}, + $bbi->{URX},$bbi->{URY},$bbi->{'Info.llen'},$bbi->{'Info.lines'})=unpack("nnnnnnnn",$head); + } elsif ($head=~/\A....\0\0\0\004....\0\0[\0-\001].\0\0[\0-\003]./s) { # McIDAS areafile + # from xloadimage; untested + $bbi->{FileFormat}='McIDAS'; + $bbi->{SubFormat}='MSBfirst'; + ($dummy,$bbi->{URY},$bbi->{URX})=unpack("A32NN",$head); + } elsif ($head=~/\A....\004\0\0\0.....[\0-\001]\0\0.[\0-\003]\0\0/s) { # McIDAS areafile + # from xloadimage; untested + $bbi->{FileFormat}='McIDAS'; + $bbi->{SubFormat}='LSBfirst'; + ($dummy,$bbi->{URY},$bbi->{URX})=unpack("A32VV",$head); + } elsif ($head=~/\AVIEW/) { + # from xv; untested + $dummy="NNNNNN"; $bbi->{SubFormat}='MSBfirst'; + do_PM: + $bbi->{FileFormat}='PM'; + ($dummy,$bbi->{'Info.num_planes'},$bbi->{URX},$bbi->{URY}, + $bbi->{'Info.num_bands'}, $bbi->{'Info.pixel_format'})=unpack($dummy,$head); + } elsif ($head=~/\AWEIV/) { + $dummy="VVVVVV"; $bbi->{SubFormat}='LSBfirst'; + goto do_PM; + } elsif ($head=~/\A\001\332/) { # SGI 'rgb' image data + $bbi->{SubFormat}='MSBfirst'; $dummy="nCCnnnn"; + do_SGI: + $bbi->{FileFormat}='SGI'; # from xv IRIS; untested + ($dummy,$bbi->{'Info.compression'},$bbi->{'Info.precision'},$bbi->{'Info.dimension'}, + $bbi->{URX},$bbi->{URY},$bbi->{SamplesPerPixel})=unpack($dummy,$head); + if ($bbi->{'Info.compression'}==0) { $bbi->{'Info.compression'}='None' } + elsif ($bbi->{'Info.compression'}==1) { $bbi->{'Info.compression'}='RLE' } + $dummy=substr($head,80); + $bbi->{'Info.comment'}=$1 if $dummy=~m@\A([^\0])\0@s; + # Dat: Info.dimension is 2 or 3 + ## See http://reality.sgi.com/grafica/sgiimage.html + } elsif ($head=~/\A\332\001/) { # SGI 'rgb' image data + $bbi->{SubFormat}='MSBfirst'; $dummy="vCCvvvvv"; + goto do_SGI; + } elsif (substr($head,0,9) eq "SIMPLE =") { + $bbi->{FileFormat}='FITS'; + while ($head!~/\bEND/) { + goto IOerr if 1>read $F, $head, 1024, length($head); + } + $bbi->{'Info.bits_per_pixel'}=$1 if $head=~/\bBITPIX\s*=\s*(\d+)/; + $bbi->{'Info.num_axis'}=$1 if $head=~/\bNAXIS\s*=\s*(\d+)/; + $bbi->{URX}=$1 if $head=~/\bNAXIS1\s*=\s*(\d+)/; + $bbi->{URY}=$1 if $head=~/\bNAXIS2\s*=\s*(\d+)/; + $bbi->{'Info.depth'}=$1 if $head=~/\bNAXIS3\s*=\s*(\d+)/; + $bbi->{'Info.data_max'}=$1 if $head=~/\bDATAMAX\s*=\s*(\d+)/; + $bbi->{'Info.data_min'}=$1 if $head=~/\bDATAMIN\s*=\s*(\d+)/; + # Dat: it would be quite hard to extract the dimensions... + ## FITS is the Flexible Image Transport System, the de facto standard for + ## data and image transfer, storage, etc., for the astronomical community. + ## (FITS floating point formats are big-endian.) + #0 string SIMPLE\ \ = FITS image data + #>109 string 8 \b, 8-bit, character or unsigned binary integer + #>108 string 16 \b, 16-bit, two's complement binary integer + #>107 string \ 32 \b, 32-bit, two's complement binary integer + #>107 string -32 \b, 32-bit, floating point, single precision + #>107 string -64 \b, 64-bit, floating point, double precision + } elsif ($head=~/\A(?:NJPL1I|CCSD3Z|LBLSIZE=)/) { + # from xv, imagemagick; untested + $bbi->{FileFormat}='VICAR'; + while ($head!~/\bEND/) { + goto IOerr if 1>read $F, $head, 1024, length($head); + } + $bbi->{URX}=$1 if $head=~/\b(?:IMAGE_LINES|LINES|NL)\s*=\s*(\d+)/; + $bbi->{URY}=$1 if $head=~/\b(?:LINE_SAMPLES|NS)\s*=\s*(\d+)/; + ##------------------------------------------------------------------------------ + ## vicar: file(1) magic for VICAR files. + ## + ## From: Ossama Othman 32 string BYTE \b, 8 bits = VAX byte + #>32 string HALF \b, 16 bits = VAX word = Fortran INTEGER*2 + #>32 string FULL \b, 32 bits = VAX longword = Fortran INTEGER*4 + #>32 string REAL \b, 32 bits = VAX longword = Fortran REAL*4 + #>32 string DOUB \b, 64 bits = VAX quadword = Fortran REAL*8 + #>32 string COMPLEX \b, 64 bits = VAX quadword = Fortran COMPLEX*8 + ## VICAR label file + #43 string SFDU_LABEL VICAR label file + } elsif (substr($head,0,4) eq "IT01" or substr($head,0,4) eq "IT02") { # untested + $bbi->{FileFormat}='FIT'; # do not cunfuse FIT and FITS + ($dummy,$bbi->{URX},$bbi->{URY},$bbi->{'Info.num_bits'})=unpack("NNNN",$head); + } elsif (substr($head,0,4) eq "#FIG") { + $bbi->{FileFormat}='FIG'; + $bbi->{SubFormat}=$1 if $head=~/\A....[ \t]+(\S+)/s; + ## FIG (Facility for Interactive Generation of figures), an object-based format + ## (as handled by xfig). There is no size information, fig2dev saves bounding + ## box as EPS + #0 string #FIG FIG image text + #>5 string x \b, version %.3s + +## These file formats below are known to the Debian potato file(1) command, +## but the magic(5) file doesn't tell us how to extract size information +## +## NITF is defined by United States MIL-STD-2500A +#0 string NITF National Imagery Transmission Format +#>25 string >\0 dated %.14s +# +## NIFF (Navy Interchange File Format, a modification of TIFF) images +#0 string IIN1 NIFF image data +## ITC (CMU WM) raster files. It is essentially a byte-reversed Sun raster, +## 1 plane, no encoding. +## Artisan +#0 long 1123028772 Artisan image data +#>4 long 1 \b, rectangular 24-bit +#>4 long 2 \b, rectangular 8-bit with colormap +#>4 long 3 \b, rectangular 32-bit (24-bit with matte) +# +# +## PHIGS +#0 string ARF_BEGARF PHIGS clear text archive +#0 string @(#)SunPHIGS SunPHIGS +## version number follows, in the form m.n +##>40 string SunBin binary +##>32 string archive archive +## +## GKS (Graphics Kernel System) +#0 string GKSM GKS Metafile +#>24 string SunGKS \b, SunGKS +# +## CGM image files +#0 string BEGMF clear text Computer Graphics Metafile +## XXX - questionable magic +#0 beshort&0xffe0 0x0020 binary Computer Graphics Metafile +#0 beshort 0x3020 character Computer Graphics Metafile +# +## MGR bitmaps (Michael Haardt, u31b3hs@pool.informatik.rwth-aachen.de) +#0 string yz MGR bitmap, modern format, 8-bit aligned +#0 string zz MGR bitmap, old format, 1-bit deep, 16-bit aligned +#0 string xz MGR bitmap, old format, 1-bit deep, 32-bit aligned +#0 string yx MGR bitmap, modern format, squeezed +# +## image file format (Robert Potter, potter@cs.rochester.edu) +#0 string Imagefile\ version- iff image data +## this adds the whole header (inc. version number), informative but longish +#>10 string >\0 %s +# +## other images +#0 string This\ is\ a\ BitMap\ file Lisp Machine bit-array-file +#0 string \!\! Bennet Yee's "face" format +# +## From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image +## stuff. +## +#0 beshort 0x1010 PEX Binary Archive +# +## Visio drawings +#03000 string Visio\ (TM)\ Drawing %s +# +#0 string IC PC icon data +#0 string PI PC pointer image data +#0 string CI PC color icon data +#0 string CP PC color pointer image data + + } elsif (substr($head,0,2) eq "\37\x9d") { + # .Z compress(1)ed file; may be an image (i.e pbm.Z) + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='compress'; + } elsif (substr($head,0,2) eq "\37\x8b") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='gzip'; + } elsif (substr($head,0,2) eq "\37\x36") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='pack'; + } elsif ($head=~/\A(?:\377\037|\037\377)/) { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='compact'; + } elsif (substr($head,0,3) eq "BZh") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='bzip2'; + } elsif (substr($head,0,2) eq "BZ") { # check must be after bzip + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='bzip1'; + } elsif (substr($head,0,2) eq "\x76\xff") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='squeeze'; + } elsif (substr($head,0,2) eq "\x76\xfe") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='crunch'; + } elsif (substr($head,0,2) eq "\x76\xfd") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='LZH'; + } elsif (substr($head,0,2) eq "\037\237") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='freeze2'; + } elsif (substr($head,0,2) eq "\037\236") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='freeze1'; + } elsif (substr($head,0,2) eq "\037\240") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='SCO.LZH'; + } elsif (substr($head,0,9) eq "\x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a") { + $bbi->{FileFormat}='compress'; $bbi->{SubFormat}='lzop'; + + } elsif (substr($head,0,2) eq "\x60\xEA") { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='ARJ'; + } elsif ($head=~/\A..-l[hz]/s) { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='LHA'; + } elsif (substr($head,0,4) eq "Rar!") { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='RAR'; + } elsif (substr($head,0,4) eq "UC2\x1A") { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='UC2'; + } elsif (substr($head,0,4) eq "PK\003\004") { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='ZIP'; + } elsif (substr($head,0,4) eq "\xDC\xA7\xC4\xFD") { + $bbi->{FileFormat}='archive'; $bbi->{SubFormat}='ZOO'; + + } elsif ($head=~/\A.PC Research, Inc/s) { + $bbi->{FileFormat}='G3'; + $bbi->{SubFormat}='Digifax'; + # Dat: determining $bbi->{URX} and $bbi->{URY} would require a complex + # and full parsing of the G3 facsimile data + } elsif ($head=~/\A\367[\002-\005]/) { + # Dat: \005 is rather arbitrary here + goto FF__DVI; + } elsif ($head=~/\A[\36-\77](?:\001[\001\11]|\0[\002\12\003\13])\0\0/ and + vec($head, 1, 8)<=11 and (vec($head, 16, 8)<=8 or vec($head, 16, 8)==24)) { # potato magic + my @types=(0,'Map','RGB','Gray',0,0,0,0,0,'Map.RLE','RGB.RLE','Gray.RLE'); + $bbi->{FileFormat}='TGA'; + $bbi->{SubFormat}=$types[vec($head,2,8)]; + ($dummy,$bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=unpack("A8vvvv",$head); + # Imp: verify LLX!=0 URX-LLX + } elsif (30<=vec($head, 0, 8) and vec($head, 0, 8)<=63 and + vec($head, 1, 8)<=11 and (vec($head, 16, 8)<=8 or vec($head, 16, 8)==24)) { + # ^^^ Dat: TGA doesn't have a fixed-format header, so this detection is quite + # weak. That's why it is the last one we perform. + $bbi->{FileFormat}='TGA'; + $bbi->{SubFormat}='fallback'; + ($dummy,$bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=unpack("A8vvvv",$head); + # Imp: verify LLX!=0 URX-LLX + } elsif ($head=~/^PicData:\s*(\d+)\s*(\d+)\s*(\d+)/m) { # grayscale Faces Project imagegrayscale Faces Project image; untested + # ^^^ Dat: regexp match is quite weak; perform check last + $bbi->{FileFormat}='Faces'; # from xloadimage + $bbi->{URX}=$1+0; $bbi->{URY}=$2+0; $bbi->{"Info.bitdepth"}=$3+0; + } elsif ($head=~/\A\001\0/s) { # really weak + $bbi->{FileFormat}='G3'; + $bbi->{SubFormat}='MSBfirst.bytepad'; + } elsif ($head=~/\A\0\001/s) { # really weak + $bbi->{FileFormat}='G3'; + $bbi->{SubFormat}='LSBfirst.bytepad'; + } elsif ($head=~/\A\24\0/s) { # really weak + $bbi->{FileFormat}='G3'; + $bbi->{SubFormat}='MSBfirst.raw'; + } elsif ($head=~/\A\0\24/s) { # really weak + $bbi->{FileFormat}='G3'; + $bbi->{SubFormat}='LSBfirst.raw'; + # Dat: determining $bbi->{URX} and $bbi->{URY} would require a complex + # and full parsing of the G3 facsimile data + } else { + $bbi->{Error}='unrecognised FileFormat' + } + done: + if ($have_paper and exists $bbi->{URX} and exists $bbi->{URY}) { + ($bbi->{Paper},$bbi->{PaperWidth},$bbi->{PaperHeight})=@L[0,1,2] if + @L=Htex::papers::valid_bp($bbi->{URX},$bbi->{URY},$bbi->{LLX},$bbi->{LLY}); + } else { + delete $bbi->{LLX} if !exists $bbi->{URX}; + delete $bbi->{LLY} if !exists $bbi->{URY}; + } + $bbi +} + +sub import { + no strict 'refs'; + my $package=(caller())[0]; + shift; + ($have_paper,$have_pdf)=(1,1); + for my $p (@_) { + if ($p eq '-PDF') { $have_pdf=0 } + elsif ($p eq '-paper') { $have_paper=0 } + else { *{$package."::$p"}=\&{$p} } + } + if ($have_pdf) { require Htex::PDFread; import Htex::PDFread } + if ($have_paper) { require Htex::papers; import Htex::papers } +} + +just::end} + +BEGIN{$ INC{'vars.pm'}='vars.pm'} { +package vars; +use just; +# by pts@fazekas.hu at Wed Jan 10 12:42:08 CET 2001 +require 5.002; +sub import { + my $callpack = caller; + my ($sym, $ch, $sym9); + shift; + for $sym0 (@_) { + die("Can't declare another package's variables") if $sym0 =~ /::/; + ($ch, $sym) = unpack('a1a*', $sym0); + *{"${callpack}::$sym"} = + ( $ch eq "\$" ? \$ {"${callpack}::$sym"} + : $ch eq "\@" ? \@ {"${callpack}::$sym"} + : $ch eq "\%" ? \% {"${callpack}::$sym"} + : $ch eq "\*" ? \* {"${callpack}::$sym"} + : $ch eq "\&" ? \& {"${callpack}::$sym"} + : die("'$ch$sym' is not a valid variable name\n") + ); + } +} +just::end} + +BEGIN{$ INC{'Htex/PDFread.pm'}='Htex/PDFread.pm'} { +package Htex::PDFread; +# by pts@fazekas.hu at Sat Dec 21 21:28:09 CET 2002 +use just; +use integer; +use strict; +use Pts::string; +use vars qw($pdf_last_ref0); + +my @pdf_classify; +#** @param $_[0] a string in PDF source format +#** @return a rewritten string, or "" if $_[0] is truncated, or undef if +#** there is a parse error +sub pdf_rewrite($;$) { + my $explicit_term_p=$_[1]; + my $L=length($_[0]); + return "" if $L==0; + my $S="$_[0]\n>> "; # add sentinel + my $I=0; + my $O; + my $RET=""; + if (!@pdf_classify) { + # Dat: PDF whitespace(0) is [\000\011\012\014\015\040] + # Dat: PDF separators(10) are < > { } [ ] ( ) / % + # Dat: PDF regular(40) character is any of [\000-\377] which is not whitespace or separator + @pdf_classify=(40)x256; + @pdf_classify[ord('<'),ord('>'),ord('{'),ord('}'),ord('['),ord(']'), + ord('('),ord(')'),ord('/'),ord('%')]=(10,11,12,13,14,15,16,17,18,19); + @pdf_classify[000,011,012,014,015,040]=(0,0,0,0,0,0); + } + while ($I<$L) { + $O=$pdf_classify[vec($S,$I,8)]; + if ($O==0) { # whitespace + } elsif (12<=$O and $O<=15) { # one-char token + $RET.=" ".substr($S,$I,1); + } elsif ($O==18 or $O==40) { # name or /name + my $P=0; + if ($O==18) { $I++; $RET.=" /" } else { $RET.=" "; $P=1 } + my $T=""; + $T.=chr($O) while $pdf_classify[$O=vec($S,$I++,8)]==40; + $I--; + ## die $I; + $T=~s@([^A-Za-z0-9_.-])@sprintf"#%02x",ord$1@ge; # make name safe + $RET.=$T; + return $RET if $P and ($T eq "stream" or $T eq "endobj" or $T eq "startxref"); + next + } elsif ($O==11) { # `>' + return "" if ++$I==$L; # only `>' has arrived + return undef if vec($S,$I,8)!=62; # err(">> expected"); + $RET.=" >>"; + } elsif ($O==16) { # string + my $T=""; + my $depth=1; $I++; + while ($I<$L) { + $O=vec($S,$I++,8); bcont: + ## print chr($O),":$depth\n"; + if ($O==40) { $depth++ } + elsif ($O==41) { last unless --$depth } + elsif ($O==92) { # a backslash + $O=vec($S,$I++,8); + if (48<=$O && $O<=55) { + my $P=$O-48; $O=vec($S,$I++,8); + if (48<=$O && $O<=55) { + my $Q=$O-48; $O=vec($S,$I++,8); + if (48<=$O && $O<=55) { $T.=chr(255&($P<<6|$Q<<3|($O-48))) } + else { $T.=chr($P<<3|$Q); goto bcont } + } else { $T.=chr($P); goto bcont } + } elsif ($O==110) { $O=10 } + elsif ($O==114) { $O=13 } + elsif ($O==116) { $O=9 } + elsif ($O== 98) { $O=8 } + elsif ($O==102) { $O=12 } + } + $T.=chr($O) + } # WHILE + return "" if $depth; # err("unterminated string") + $T=~s@([^A-Za-z0-9_.-])@sprintf"\\%03o",ord$1@ge; # make string safe + $RET.=" ($T)"; next + } elsif ($O==10) { # hex string + $O=vec($S,++$I,8); + if ($O==60) { $RET.=" <<"; $I++; next } + # parse hexadecimal string + my $half=0x100; + my $T=""; + while (1) { + 1 until $pdf_classify[$O=vec($S,$I++,8)]; # skip whitespace + if ($O==62) { $T.=chr($half&0xFF) if $half&0x1000; last } # '>' + return undef if $pdf_classify[$O]!=40; # err("unexpected token in hex") + if (65<=$O and $O<=70) { $half+=$O-55 } + elsif (97<=$O and $O<=102) { $half+=$O-87 } + elsif (48<=$O and $O<=57) { $half+=$O-48 } + else { return undef } # err("illegal hex digit") + if ($half&0x1000) { $T.=chr($half&0xFF); $half=0x100 } + else { $half<<=4 } + } + $T=~s@([^A-Za-z0-9_.-])@sprintf"\\%03o",ord$1@ge; # make string safe + $RET.=" ($T)"; next + } elsif ($O==19) { # single-line comment + $I++ while ($O=vec($S,$I,8))!=13 && $O!=10; + ## print STDERR "I=$I L=$L\n"; + next + } else { return undef } # err("token expected") # $O==11, $O==17 + $I++ + } ## WHILE + ## print STDERR "XI=$I L=$L\n"; + # die $explicit_term_p; + return "" if $explicit_term_p; + ($I>$L) ? "" : $RET +} + +# Unit test: +#die unless pdf_rewrite("hello \n\t world\n\t") eq " hello world"; +#die unless pdf_rewrite('(hel\)lo\n\bw(or)ld)') eq ' (hel\051lo\012\010w\050or\051ld)'; +#die unless pdf_rewrite('(hel\)lo\n\bw(orld)') eq ''; +#die unless pdf_rewrite('[ (hel\)lo\n\bw(or)ld)>>') eq ' [ (hel\051lo\012\010w\050or\051ld) >>'; +#die unless pdf_rewrite('>') eq ""; +#die unless pdf_rewrite('<') eq ""; +#die unless pdf_rewrite('< ') eq ""; +#die unless !defined pdf_rewrite('< <'); +#die unless !defined pdf_rewrite('> >'); +#die unless pdf_rewrite('[ (hel\)lo\n\bw(or)ld) <') eq ""; +#die unless pdf_rewrite("<\n3\t1\r4f5C5 >]") eq ' (1O\134P) ]'; +#die unless pdf_rewrite("<\n3\t1\r4f5C5") eq ""; +#die unless !defined pdf_rewrite("<\n3\t1\r4f5C5]>"); +#die unless pdf_rewrite("% he te\n<\n3\t1\r4f5C5 >]endobj<<") eq ' (1O\134P) ] endobj'; +#die unless pdf_rewrite("") eq ""; +#die unless pdf_rewrite("<<") eq " <<"; +#die unless pdf_rewrite('%hello') eq ''; +#die unless pdf_rewrite("alma\n%korte\n42") eq ' alma 42'; +#die unless pdf_rewrite('/Size 42') eq ' /Size 42'; +#die "OK"; + +#** Reads a single PDF indirect object (without its stream) from a PDF file. +#** Does some trivial transformations on it to make later regexp matching +#** easier. Stops at `stream', `endobj' and `startxref'. +#** @param $_[0] a filehandle (e.g \*STDIN), correctly positioned in the PDF +#** file to the beginning of the object data (i.e just before `5 0 obj') +#** @return string containing PDF source code, or undef on error +sub pdf_read_obj($) { + my $F=$_[0]; my $L=1024; my $M; my $S=""; my $RET; + while (1) { # read as much data as necessary + return undef if 0>($M=read $F, $S, $L, length($S)); + $RET=pdf_rewrite($S,1); + ## print "($S)\n"; + return undef if !defined $RET; # parse error + return $RET if length $RET; # OK, found object + return undef if $M==0; # cannot read more, reached EOF + $L<<=1; + } + #$S=~m@[\000\011\012\014\015\040]*( + # %[^\r\n]*[\r\n]| + # /?[^\000\011\012\014\015\040<>{}\[\]()/%]*(?=[\000\011\012\014\015\040<>{}\[\]()/%])| # unterminated + # <<|>>|\{|}|\[|]| + # <[a-fA-F0-9\000\011\012\014\015\040]*>| # hex string + # \((?:[^\\()]+|\\[\000-\377])*\)| # literal string, the easy way + # \( # an unfinished string, needs special care + #)@gx +} + +#** @param $_[0] a filehandle (e.g \*STDIN), containing a PDF file, positioned +#** just before an `xref' table +#** @param $_[1] an xref table: $_[1][4][56] is the file offset of object 56 +#** from generation 4; will be extended +#** @return the `trailer' section after the `xref'; or undef +sub pdf_read_xref($$) { + # made much faster at Wed Dec 18 09:50:23 CET 2002 + my $T; + my $E; + my $F=$_[0]; + my $XREF=$_[1]; + return undef if 8>read $F, $T, 1024; + return undef unless $T=~s@\A\s*xref\s+(\d+)\s+(\d+)\s+(?=\S)@@; + my ($first,$len,$flen); + while (1) { + ($first,$len)=($1+0,$2+0); + ## print " $first + $len\n"; + $flen=($len*=20)-length($T)+20; + return undef unless $flen<1 or $flen==read $F, $T, $flen, length($T); + for (my $I=0;$I<$len;$I+=20, $first++) { + $E=substr($T, $I, 20); + return undef unless $E=~/\A(\d{10})\s(\d{5})\s([nf])\s\s/; + ## print "($1 $2 $3)\n"; + $XREF->[$2+0][$first]=$1+0 if $3 eq 'n'; + } + $E=substr($T, $len); + last if $E!~s@\A\s*(\d+)\s*(\d+)\s+(?=\S)@@; # next section + $T=$E; + } + + # die(-length($T)+$len); + ## die tell($F); + return undef if length($T)!=$len and !seek $F, -length($T)+$len, 1; + ## die tell($F); + return undef unless defined($T=pdf_read_obj($F)); + $XREF->[0][0]=undef if defined $XREF->[0]; + $XREF->[0][0]=$1+0 if $T=~m@ /Prev (\d+)@; # remember /Prev xref table + return undef unless $T=~m@\A trailer( .*) startxref\Z(?!\n)@s; + $1 +} + +$pdf_last_ref0=0; +#** @param $_[0] a filehandle (e.g \*STDIN), containing a PDF file +#** @param $_[1] an xref table: $_[1][4][56] is the file offset of object 56 +#** from generation 4 +#** @param $_[2] an object number +#** @param $_[3] a generation number +#** @return PDF source code of the reference, or undef +sub pdf_ref($$$$) { + my $F=$_[0]; my $XREF=$_[1]; my $ON=$_[2]+0; my $GN=$_[3]+0; + my $T; + $pdf_last_ref0=$ON if $GN==0; + ## print "REF $ON $GN;\n"; + until (ref $XREF->[$GN] and defined ($T=$XREF->[$GN][$ON])) { + return undef if !ref $XREF->[0] or !defined $XREF->[0][0]; # no /Prev entry, `$ON $GN R' not found + return undef unless seek $F, $XREF->[0][0], 0; + return undef if !defined pdf_read_xref($F,$XREF); + } + ## print "REF at $T;\n"; + return undef unless seek $F, $T, 0; + return undef unless defined($T=pdf_read_obj($F)); + ## print "REF=($T);\n"; + return undef unless $T=~s@\A (\d+) (\d+) obj\b(.*) (endobj|stream)\Z(?!\n)@$3@s; + $T +} + +#** Gets a key from a direct dict, and resolves it if it is an indirect object +#** @param $_[0] a filehandle (e.g \*STDIN), containing a PDF file +#** @param $_[1] an xref table: $_[1][4][56] is the file offset of object 56 +#** from generation 4 +#** @param $_[2] a PDF source dict (`<< ... >>') or array +#** @param $_[3] a key (`/...') +sub pdf_get($$$$) { + my $F=$_[0]; my $XREF=$_[1]; my $S=$_[2]; my $KEY=$_[3]; my $POS=0; + my $DEPTH=0; my $IS_DICT; my $C=0; my $N=0; + ## print "\n"; + while ($S=~/\G (\S+)/g) { + $C=vec($1,0,8); $POS=pos($S); + ## print "($1) $DEPTH $N\n"; + if ($1 eq '>>' or $1 eq ']') { + return undef if 0==$DEPTH--; + last if !$DEPTH; + $N++ if 1==$DEPTH; + } + elsif ($DEPTH==1 and !$IS_DICT and $KEY==$N) { $POS=pos($S)-=length($1)+1; goto do_ret } + elsif ($1 eq '<<') { $IS_DICT=1 if 0==$DEPTH++ } + elsif ($1 eq '[') { + if (0==$DEPTH++) { + $IS_DICT=0; + return undef if $KEY!~/\A(\d+)\Z(?!\n)/; # err("non-numeric key in array") + } + } + elsif (0==$DEPTH) { return undef } # not in a composite object + elsif (1!=$DEPTH) { next } + elsif (!$IS_DICT) { $N++ } + elsif ($C==40) { $N++ } # `(': string or bare name + elsif ($C>=47 and $C<=57) { # '/': /name 0..9: number + ## print "TRY ($1) KEY=$KEY.\n"; + next if ($N++&1)==1 or $1 ne $KEY; + do_ret: + ## print substr($S,pos($S)),";;\n"; + return pdf_ref $F, $XREF, $1, $2 if $S=~/\G (\d+) (\d+) R\b/gc; + ## print substr($S,pos($S)),"::\n"; + $DEPTH=0; + while ($S=~/\G( \S+)/g) { + if ($1 eq ' <<' or $1 eq ' [') { $DEPTH++ } + elsif ($1 eq ' >>' or $1 eq ' ]') { + ## die "($1)\n"; + return undef if 0==$DEPTH--; # err("nesting") + return substr($S,$POS,pos($S)-$POS) if 0==$DEPTH; + } elsif ($DEPTH==0) { return $1 } + } + } else { $N++ } # bare name + } + return undef if $POS!=length($S); # err("invalid source dict"); + "" # not found +} + +# Unit test: +#die unless pdf_get(\*STDIN, 0, ' [ al makorte 42 ]', 0) eq ' al'; +#die unless pdf_get(\*STDIN, 0, ' [ al makorte 42 ]', 1) eq ' makorte'; +#die unless pdf_get(\*STDIN, 0, ' [ al makorte 42 ]', 2) eq ' 42'; +#die unless pdf_get(\*STDIN, 0, ' [ al makorte 42 ]', 3) eq ''; +#die unless pdf_get(\*STDIN, 0, ' [ << >> ]', 0) eq ' << >>'; +#die unless pdf_get(\*STDIN, 0, ' [ << >> ]', 1) eq ''; +#die unless pdf_get(\*STDIN, 0, ' [ << >> [ al makorte 42 ] ]', 1) eq ' [ al makorte 42 ]'; +#die unless pdf_get(\*STDIN, 0, ' << /Alma [ 1 2 ] /Korte [ 3 4 ] >>', '/Korte') eq ' [ 3 4 ]'; +#die unless !defined pdf_get(\*STDIN, 0, ' [ al makorte 42 ]', '/Name'); +#die unless !defined pdf_get(\*STDIN, 0, ' << al makorte 42 >>', 42); +#die unless pdf_get(\*STDIN, 0, ' << al makorte 42 137 >>', 42) eq ' 137'; +#die unless pdf_get(\*STDIN, 0, ' << al makorte >>', 'al') eq ""; +#die "OK"; + +#** Reported boxes: /MediaBox /CropBox /BleedBox /TrimBox /ArtBox +#** @param $_[0] a filehandle (e.g \*STDIN), containing a PDF file +#** @param $_[1] an xref table: $_[1][4][56] is the file offset of object 56 +#** from generation 4 +#** @param $_[2] a PDF source dict (`<< ... >>') of /Type/Catalog +#** /Type/Pages or /Type/Page +#** @param $_[3] hashref to update. $_[3]{BleedBox}[2] will be the URX corner +#** of the BleedBox +sub pdf_get_boxes($$$$) { + my $F=$_[0]; my $XREF=$_[1]; my $S=$_[2]; my $bbi=$_[3]; + return if !defined $S; + for my $name (qw{MediaBox CropBox BleedBox TrimBox ArtBox}) { + my $box=pdf_get($F, $XREF, $S, "/$name"); + next if !defined $box or !length $box + or $box!~m@ \[ ([0-9eE.-]+) ([0-9eE.-]+) ([0-9eE.-]+) ([0-9eE.-]+) \]\Z(?!\n)@ + or !defined c_numval($1) or !defined c_numval($2) or !defined c_numval($3) or !defined c_numval($4); + ($bbi->{LLX},$bbi->{LLY},$bbi->{URX},$bbi->{URY})=($1+0,$2+0,$3+0,$4+0) if $name eq 'MediaBox'; + my $name2="Info.$name"; + ($bbi->{$name2}[0],$bbi->{$name2}[1],$bbi->{$name2}[2],$bbi->{$name2}[3])=($1+0,$2+0,$3+0,$4+0); + } +} + +sub import { + no strict 'refs'; + my $package=(caller())[0]; + shift; + for my $p (@_ ? @_ : qw{pdf_get_boxes pdf_get pdf_read_xref pdf_read_obj + pdf_rewrite pdf_ref}) { *{$package."::$p"}=\&{$p} } +} + +just::end} + +BEGIN{$ INC{'Htex/papers.pm'}='Htex/papers.pm'} { +package Htex::papers; +# contains paper size information +# by pts@fazekas.hu at Sun Dec 22 00:30:58 CET 2002 +use just; +use integer; +use strict; +use Htex::dimen; + +my @papers=( +# +# paper.txt +# by pts@fazekas.hu at Tue Jan 16 18:21:59 CET 2001 +# by pts@fazekas.hu at Tue Jan 16 19:13:16 CET 2001 +# +# Examined: dvips, gs, libpaperg +# +# all units are measured in Big Points (bp) +# 72 bp == 1 in +# 2.54 cm == 1 in +# +# papername width height +qw{Comm10 297 684}, +qw{Monarch 279 540}, +qw{halfexecutive 378 522}, + +qw{Legal 612 1008}, +qw{Statement 396 612}, +qw{Tabloid 792 1224}, +qw{Ledger 1224 792}, +qw{Folio 612 936}, +qw{Quarto 610 780}, +qw{7x9 504 648}, +qw{9x11 648 792}, +qw{9x12 648 864}, +qw{10x13 720 936}, +qw{10x14 720 1008}, +qw{Executive 540 720}, +qw{ISOB0 2835 4008}, +qw{ISOB1 2004 2835}, +qw{ISOB2 1417 2004}, +qw{ISOB3 1001 1417}, +qw{ISOB4 709 1001}, +qw{ISOB5 499 709}, +qw{ISOB6 354 499}, +qw{ISOB7 249 354}, +qw{ISOB8 176 249}, +qw{ISOB9 125 176}, +qw{ISOB10 88 125}, +qw{C7 230 323}, +qw{DL 312 624}, + +qw{a3 842 1190}, # defined by Adobe +qw{a4 595 842}, # defined by Adobe; must precede a4small + +# a4small should be a4 with an ImagingBBox of [25 25 570 817].}, +qw{a4small 595 842}, +qw{letter 612 792}, # must precede lettersmall +# lettersmall should be letter with an ImagingBBox of [25 25 587 767]. +qw{lettersmall 612 792}, +# note should be letter (or some other size) with the ImagingBBox +# shrunk by 25 units on all 4 sides. +qw{note 612 792}, +qw{letterLand 792 612}, +# End of Adobe-defined page sizes + +qw{a0 2380 3368}, +qw{a1 1684 2380}, +qw{a2 1190 1684}, +qw{a5 421 595}, +qw{a6 297 421}, +qw{a7 210 297}, +qw{a8 148 210}, +qw{a9 105 148}, +qw{a10 74 105}, +qw{b0 2836 4008}, +qw{b1 2004 2836}, +qw{b2 1418 2004}, +qw{b3 1002 1418}, +qw{b4 709 1002}, +qw{b5 501 709}, # defined by Adobe + +qw{a0Land 3368 2380}, +qw{a1Land 2380 1684}, +qw{a2Land 1684 1190}, +qw{a3Land 1190 842}, +qw{a4Land 842 595}, +qw{a5Land 595 421}, +qw{a6Land 421 297}, +qw{a7Land 297 210}, +qw{a8Land 210 148}, +qw{a9Land 148 105}, +qw{a10Land 105 74}, +qw{b0Land 4008 2836}, +qw{b1Land 2836 2004}, +qw{b2Land 2004 1418}, +qw{b3Land 1418 1002}, +qw{b4Land 1002 709}, +qw{b5Land 709 501}, + +qw{c0 2600 3677}, +qw{c1 1837 2600}, +qw{c2 1298 1837}, +qw{c3 918 1298}, +qw{c4 649 918}, +qw{c5 459 649}, +qw{c6 323 459}, + +# vvv U.S. CAD standard paper sizes +qw{archE 2592 3456}, +qw{archD 1728 2592}, +qw{archC 1296 1728}, +qw{archB 864 1296}, +qw{archA 648 864}, + +qw{flsa 612 936}, # U.S. foolscap +qw{flse 612 936}, # European foolscap +qw{halfletter 396 612}, +qw{csheet 1224 1584}, # ANSI C 17x22 +qw{dsheet 1584 2448}, # ANSI D 22x34 +qw{esheet 2448 3168}, # ANSI E 34x44 +qw{17x22 1224 1584}, # ANSI C 17x22 +qw{22x34 1584 2448}, # ANSI D 22x34 +qw{34x44 2448 3168}, # ANSI E 34x44 +); + +#** @param $_[0] width, in bp +#** @param $_[1] height, in bp +#** @return () or ("papername", width.bp, height.bp) +sub valid_bp($$;$$) { + no integer; + my ($W1,$H1)=(defined$_[2]?$_[2]:0,defined$_[3]?$_[3]:0); + my ($WW,$HH)=(Htex::dimen::dimen2bp($_[0]-$W1), Htex::dimen::dimen2bp($_[1]-$H1)); + # Dat: 1mm == 720/254bp; 3mm =~ 8.5bp + no integer; + for (my $I=0; $I<@papers; $I+=3) { + return @papers[$I,$I+1,$I+2] if abs($papers[$I+1]-$WW)<=8.5 and abs($papers[$I+2]-$HH)<=8.5; + } + () +} + +#** @param $_[0] "width width_unit, height, height_unit" +#** @return () or ("papername", width.bp, height.bp) +sub valid($) { # valid_papersize + my $S=lc shift; + $S=~/^\s*(\d+(\.\d+)?)\s*([a-z][a-z0-9]+)\s*,\s*(\d+(\.\d+)?)\s*([a-z][a-z0-9]+)\s*\Z(?!\n)/ ? + valid_bp("$1$3","$4$6") : (); +} + +just::end} + +BEGIN{$ INC{'Htex/img_bbox.pm'}='Htex/img_bbox.pm'} + +package Htex::img_bbox; +# img_bbox.pa -- extract file format and size from image files +# This file contains embedded perldoc(1) POD documentation. +# by pts@fazekas.hu at Sat Dec 7 21:31:01 CET 2002 +# JustLib2 at Sat Dec 21 21:29:21 CET 2002 +# +# img_bbox.pl is a standalone Perl script that can extract file format, +# width, height, bounding box and +# other meta-information from image files. Supported vector formats are: +# PDF, Flash SWF, EPS, PS, DVI and FIG. Supported raster image formats are: +# GIF, JPEG, PNG, TIFF, XPM, XBM1, XBM, PNM, PBM, PGM, PPM, PCX, LBM, other +# IFF, Windows and OS/2 BMP, MIFF, Gimp XCF, Windows ICO, Adobe PSD, FBM, +# SunRaster, CMUWM, Utah RLE, Photo CD PCD, XWD, GEM, McIDAS, PM, SGI IRIS, +# FITS, VICAR, PDS, FIT, Fax G3, Targa TGA and Faces. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Extracting the image size is not supported for: other IFF, FIG. +# +# +use just 1; +use integer; # important +use strict; # not so important +# use Htex::ImgBBox qw(calc -PDF -paper); +use Htex::ImgBBox qw(calc); + +sub delete0($$) { + delete $_[0]{$_[1]}; + "" +} + +#** @param $_[0] $bbi hashref +#** @return a multiline dump of all key--value pairs, sorted by key +sub all($) { + my $bbi=$_[0]; + my $RET=""; + for my $key (sort keys %$bbi) { if (1{$key}; + $RET.=" $key = ".(ref($val)eq'ARRAY' ? "[ @$val ]\n" : "$val\n"); + } } + $RET +} + +my %texq; +#** @param $_[0] arbitrary binary string +#** @return the string quoted, so it can be safely placed inside TeX +#** \message{...} or \special{...} +sub texq($) { + if (!keys %texq) { + $texq{' '}='\iftrue\space\fi '; # won't collapse two spaces into one + $texq{'\\'}='\expandafter\@secondoftwo\string\\\\'; + $texq{'{'}='\expandafter\@secondoftwo\string\{'; + $texq{'}'}='\expandafter\@secondoftwo\string\}'; + $texq{'%'}='\expandafter\@secondoftwo\string\%'; + $texq{'#'}='\expandafter\@secondoftwo\string\#'; + $texq{'^'}='\expandafter\@secondoftwo\string\^'; # no danger of ^^ + $texq{'~'}='\expandafter\@secondoftwo\string\~'; + $texq{'`'}='\expandafter\@secondoftwo\string\`'; + $texq{'"'}='\expandafter\@secondoftwo\string\"'; + # vvv will work only if the token is expanded only once + #$texq{'~'}='\noexpand~'; + #$texq{'`'}='\noexpand`'; + #$texq{'"'}='\noexpand"'; + } + my $S=$_[0]; + $S=~s@(\W)@exists$texq{$1}?$texq{$1}:$1@ge; + $S=~s~([\000-\037\177-\377])~sprintf"\\expandafter\\\@secondoftwo\\string\\^^%02x",ord$1~ge; + $S +} + +sub aq($$) { + $_[0] eq ":t" ? texq($_[1]) : $_[1] +} + +my $t_short="%{FileName} %{FileFormat:-??} %{LLX:-??} %{LLY:-??} %{URX:-??} %{URY:-??}%{Paper?+ %{Paper}}%{Error?+ error:%{Error}}\n"; +my $t_long="%{FileName}%{FileName?0}\n%{all}"; +# my $t_tex='\graphicPmeta{%{FileName:t}%{c}{%{FileFormat:-?}%{c}{%{LLX:-?}%{c}{%{LLY:-?}%{c}{%{URX:-?}%{c}{%{URY:-?}%{c}%{n}'; +my $t_tex='\graphicPmeta{%{FileName:t}%{c}{%{FileFormat:-?}%{SubFormat?+.%{SubFormat}}%{c}{%{LLX:-?}%{c}{%{LLY:-?}%{c}{%{URX:-?}%{c}{%{URY:-?}%{c}%{n}'; + +sub compile_template($) { + my $template=$_[0]; + # convert $template to Perl code + $template=~s@([\\'])@\\$1@g; + $template=~s@([}])|[%][{]([\w.-]+)(:t)?(:-|[?][+0-]|)@ + defined($1) ? "').'" : + $4 eq "" && $2 eq "all" ? "'.(all(\$bbi).'" : + $4 eq "" ? "'.(!defined\$bbi->{'$2'}?'':aq('".($3||"")."',\$bbi->{'$2'}).'" : + $4 eq "?+" ? "'.(!defined\$bbi->{'$2'}?'':'" : + $4 eq "?-" ? "'.(defined\$bbi->{'$2'}?'':'" : + $4 eq ":-" ? "'.(defined\$bbi->{'$2'}?aq('".($3||"")."',\$bbi->{'$2'}):'" : + $4 eq "?0" ? "'.(delete0(\$bbi,'$2').'" : + "[$1]($2)($4)" # should never happen + @ge; + my $sub=eval "sub { my \$bbi=\$_[0]; '$template' }"; + die "$0: template syntax error: $@" if $@ or ref($sub) ne 'CODE'; + $sub +} + +sub work($$) { + my($sub,$filename)=@_; + my $bbi; + # die "$0: $filename: $!\n" unless open F, "< $filename"; + if (open F, "< $filename") { + ## print STDERR "$filename\n"; + $bbi=calc(\*F); + } else { + $bbi->{Error}="open: $!" + } + $bbi->{FileName}=$filename; + $bbi->{n}="\n"; + $bbi->{p}="%"; + $bbi->{c}="}"; + print $sub->($bbi); +} + +sub usage() { + die "This is img_bbox.pl by pts\@fazekas.hu, version 0.08 +This program is free software, licensed under the GNU GPL. +This software comes with absolutely NO WARRANTY. Use at your own risk! + +Usage: $0 [