summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/csplain/opmac
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-09-06 23:13:44 +0000
committerKarl Berry <karl@freefriends.org>2013-09-06 23:13:44 +0000
commita5409c09805bf26ec9aa61b1c32fddbd4a5d2a67 (patch)
tree30056c5ca7998f3dd66ed8be5f8c3383620679d7 /Master/texmf-dist/tex/csplain/opmac
parentd211c476a793546259e3fe8b6417f3f36d477a99 (diff)
csplain (6sep13)
git-svn-id: svn://tug.org/texlive/trunk@31589 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/csplain/opmac')
-rw-r--r--Master/texmf-dist/tex/csplain/opmac/opmac-xetex.tex106
-rw-r--r--Master/texmf-dist/tex/csplain/opmac/opmac.tex108
-rw-r--r--Master/texmf-dist/tex/csplain/opmac/pdfuni.tex1
3 files changed, 169 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/csplain/opmac/opmac-xetex.tex b/Master/texmf-dist/tex/csplain/opmac/opmac-xetex.tex
new file mode 100644
index 00000000000..d62a97f26cc
--- /dev/null
+++ b/Master/texmf-dist/tex/csplain/opmac/opmac-xetex.tex
@@ -0,0 +1,106 @@
+% opmac-xetex.tex
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Petr Olsak, 2013
+
+% OPmac features (such as hyperlinks, outlines, colors, transformations,
+% pictures) are based on pdfTeX primitives. Unfortunately, these pdfTeX
+% primitives are unavailable in XeTeX. XeTeX uses dvipdfm(x) extension
+% instead this, which is based on \special{pdf:SOMETHING} commands (see the
+% documentation of dvipdfmx). This is a reason why we need to redefine some
+% OPmac macros in order to keep the mentioned features in XeTeX.
+
+% This file is read by opmac.tex automatically when XeTeX is detected.
+% Don't use \input opmac-xetex in your document.
+
+% Implementation
+
+% \special{pdf:bann <</Type/Annot/Subtype/Link/A<</S/GoTo/D(LABEL)>>>>}%
+% TEXT\special{pdf:eann} has to be used instead of
+% \pdfstartlink goto name{LABEL}\relax TEXT\pdfendlink:
+
+\def\link[#1:#2]#3#4{\leavevmode
+ \special{pdf:bann <</Type/Annot/Subtype/Link\pdfborder{#1}/A<</S/GoTo/D(#1:#2)>>>>}%
+ {#3#4}\special{pdf:eann}%
+}
+\def\pdfborder#1{\if^#1^\else \isdefined{#1border}\iftrue
+ \if^\csname#1border\endcsname^\else /C[\csname#1border\endcsname]/Border[0 0 1]%
+ \fi\fi\fi
+}
+
+% Unfortunately, \pdflinkmargin is unsupported in XeTeX. We create
+% only a void compensation:
+
+\newdimen\pdflinkmargin
+
+% \special{pdf:bann <</Type/Annot/Subtype/Link/A<</S/URI/URI(URL)>>>>}%
+% TEXT\special{pdf:eann} has to be used instead of
+% \pdfstartlink user{/Subtype/Link/A <</Type/Action/S/URI/URI(URL)>>}TEXT\pdfendlink:
+
+\def\urllink[#1:#2]#3{{\let~=\relax \let\\=\relax \let\{=\relax \let\}=\relax
+ \leavevmode
+ \special{pdf: bann <</Type/Annot/Subtype/Link\pdfborder{#1}/A<</S/URI/URI(#2)>>>>}%
+ {\def~{\nobreak\space}\urlcolor#3}\special{pdf:eann}}%
+}
+
+% \special{pdf:dest (LABEL) [@thispage /XYZ @xpos @ypos null]}
+% has to be used instead of \pdfdest name{LABEL} xyz :
+
+\def\destbox[#1]{\vbox to0pt{\kern-\destheight
+ \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}\vss}}
+
+% \special{pdf:literal CODE} has to be used instead of \pdfliteral{CODE}:
+
+\def\pdfliteral#1{\special{pdf:literal #1}}
+
+% The \pdfsetmatrix, \pdfsave, \pdfrestore can be implemented by \pdfliteral:
+
+\def\pdfsetmatrix#1{\pdfliteral{#1 0 0 cm}}
+\def\pdfsave{\pdfliteral{q}}
+\def\pdfrestore{\pdfliteral{Q}}
+
+% \special{pdf:outline LEVEL <</Title(TEXT)/A<</S/GoTo/D(LABEL)>>>>}
+% has to be used instead of
+% \pdfoutline goto name{LABEL} count CHILDS {TEXT}.
+% Note, we needn't calculate CHILDS, simply LEVEL of outline is used.
+
+\def\insertoutline#1{\global\advance\oulnum by1
+ \special{pdf:dest (oul:\the\oulnum) [@thispage /XYZ @xpos @ypos null]}%
+ \special{pdf:outline 0<</Title(#1)/A<</S/GoTo/D(oul:\the\oulnum)>>>>}%
+}
+\def\pdfoutline goto name#1 count #2#3<#4\relax{%
+ \special{pdf:out [\ifnum#3<\outlinelevel\space\else-\fi] #3
+ <</Title(\tmp)/A<</S/GoTo/D(#1)>>>>}%
+}
+
+% \special{pdf:docview<<CODE>>} has to be used instead of \pdfcatalog{CODE}:
+
+\def\pdfcatalog#1{\special{pdf:docview <<#1>>}}
+
+% \special{pdf:docinfo<<CODE>>} has to be used instead of \pdfinfo{CODE}:
+
+\def\pdfinfo#1{\special{pdf:docinfo <<#1>>}}
+
+% \XeTeXpicfile FILE width DIMEN height DIMEN
+% has to be used to load bitmap picture and
+% \XeTeXpdffile FILE width DIMEN height DIMEN
+% has to be used to load the picture in PDF format. We need to detect the
+% format by the extension of the file.
+
+\def\inspic #1 {\hbox{\def\tmp##1.pdf##2\relax{%
+ \ifnum\strcmp{##2}{.pdf}=0 \XeTeXpdffile \else \XeTeXpicfile \fi}%
+ \lowercase{\tmp #1}.pdf\relax \picdir#1
+ \ifdim\picwidth=0pt \else width\picwidth\fi
+ \ifdim\picheight=0pt \else height\picheight\fi}}
+
+\endinput
+
+=== Unsolved problems ===
+
+1) The size of clickable area cannot be controlled by height/depth parameter
+ and by \pdflinkmargin. The result depends on an accident.
+2) The PDF/bitmap loading depends on suffix, not on interal magic code in
+ the loaded file. The \inspic parameter have to be expanded.
+3) The memory sparing method of \pdfximage ... \pdfrefximage
+ is not simply available.
+
+% End of opmac-xetex.tex file
diff --git a/Master/texmf-dist/tex/csplain/opmac/opmac.tex b/Master/texmf-dist/tex/csplain/opmac/opmac.tex
index a365fea689b..bea5cdb51e7 100644
--- a/Master/texmf-dist/tex/csplain/opmac/opmac.tex
+++ b/Master/texmf-dist/tex/csplain/opmac/opmac.tex
@@ -5,7 +5,7 @@
%% The history of versions is at the end of this file, after \endpinput
\ifx\OPmacversion\undefined \else \endinput \fi
-\def\OPmacversion{Aug. 2013}
+\def\OPmacversion{Sep. 2013}
\immediate\write16{This is OPmac (Olsak's Plain macros), version <\OPmacversion>}
@@ -23,8 +23,8 @@
\addprotect~
\newif\ifpdftex \pdftextrue
-\ifx\pdfoutput\undefined \pdftexfalse
-\else \ifnum\pdfoutput=0 \pdftexfalse \fi \fi
+\ifx\pdfoutput\undefined \pdftexfalse \else \ifnum\pdfoutput=0 \pdftexfalse \fi \fi
+\ifx\XeTeXversion\undefined \else \pdftextrue \fi
\def\sdef#1{\expandafter\def\csname#1\endcsname}
\def\sxdef#1{\expandafter\xdef\csname#1\endcsname}
@@ -55,9 +55,8 @@
\let\\=\undefined
{\lccode`\?=`\% \lowercase{\gdef\percent{?}}}
{\lccode`\?=`\\ \lowercase{\gdef\bslash{?}}}
-\addprotect\percent \addprotect\bslash
-\def\,{\ifmmode \mskip\thinmuskip \else \kern.166em \fi}
-
+\def\,{\ifmmode \mskip\thinmuskip \else \thinspace \fi}
+\addprotect\percent \addprotect\bslash \addprotect\, \addprotect\exfont
%%%%%%%%%%%%%% Global parameters, sec. 3.2 in opmac-d.pdf
@@ -246,7 +245,7 @@
\ifeof\testin \else
\closein\testin
\input \jobname.ref
- \fnotenum=0 \mnotenum=0
+ \fnotenum=0 \mnotenum=0
\immediate\openout\reffile=\jobname.ref
\def\wref##1##2{\write\reffile{\string##1##2}}
\immediate\write\reffile {\percent\percent\space OPmac - REF file}
@@ -264,15 +263,15 @@
%%%%%%%%%%%%%% \label, \ref, \pgref, sec. 3.7 in opmac-d.pdf
-\def\label[#1]{\xdef\lastlabel{#1}\ignorespaces}
+\def\label[#1]{\isdefined{l0:#1}%
+ \iftrue \opwarning{duplicated label [#1], ignored}\else \xdef\lastlabel{#1}\fi
+ \ignorespaces}
\def\wlabel#1{%
\ifx\lastlabel\undefined \else
\dest[ref:\lastlabel]%
\edef\tmp{\wref\Xlabel{{\lastlabel}{#1}}}\tmp
- \isdefined{lab:\lastlabel}\iftrue \else
- \sxdef{lab:\lastlabel}{#1}%
- \fi
+ \sxdef{lab:\lastlabel}{#1}\sxdef{l0:\lastlabel}{}%
\global\let\lastlabel=\undefined
\fi
}
@@ -365,7 +364,7 @@
\def\othe#1.{\ifnum#1>0 \the#1.\fi}
\def\thechapnum{} \def\thesecnum{} \def\theseccnum{}
-\def\afternoindent{\global\everypar={\wipeepar\setbox0=\lastbox}}
+\def\afternoindent{\global\everypar={\wipeepar\setbox7=\lastbox}}
\def\wipeepar{\global\everypar={}}
\let\firstnoindent=\afternoindent
\def\nbpar{{\interlinepenalty=10000\par}}
@@ -395,6 +394,8 @@
}
\def\printcaption#1#2{{\bf#1 #2}\enspace}
+\expandafter\def\expandafter\endinsert\expandafter{\expandafter\par\endinsert}
+
\def\eqmark{\global\advance\dnum by1
\ifinner\else\eqno \fi
{\destheight=2.1em \wlabel\thednum}\thednum
@@ -821,7 +822,7 @@
\def\setcmykcolor#1{{%
\def\tmp{#1}\expandafter \ifx\csname currcolor\pdfK\endcsname \tmp \else
- \special{PDF:#1 \pdfK}%
+ \pdfliteral{#1 \pdfK}%
\expandafter\xdef\csname currcolor\pdfK\endcsname{#1}%
\writecolor\pdfK
\fi}%
@@ -850,9 +851,9 @@
\def\restorecolor{{\def\tmp##1##2##3##4\end{\xdef\savedcolors{##4}%
\def\tmpa{##2}\def\tmpb{##3}\writecolortrue
- \ifx\tmpa\currcolork \else \special{PDF:##2 k}\xdef\currcolork{##2}%
+ \ifx\tmpa\currcolork \else \pdfliteral{##2 k}\xdef\currcolork{##2}%
\ifnum##1=1 \writecolor k\fi\fi
- \ifx\tmpb\currcolorK \else \special{PDF:##3 K}\xdef\currcolorK{##3}%
+ \ifx\tmpb\currcolorK \else \pdfliteral{##3 K}\xdef\currcolorK{##3}%
\ifnum##1=1 \writecolor K\fi\fi}%
\expandafter\tmp\savedcolors\end}}
@@ -880,25 +881,23 @@
{\let\setpgcolor=\relax \sxdef{pgc:#1}%
{\csname pgc:#1\endcsname\setpgcolor K{\pdflastcolorK}}}\fi
}
-\def\setpgcolor#1#2{\special{PDF:#2 #1}}
+\def\setpgcolor#1#2{\pdfliteral{#2 #1}}
\def\preboxcclv{\csname pgc:\the\pageno\endcsname}
-\def\postboxcclv{%
+\def\postboxcclv{{%
\def\setpgcolor##1##2{\expandafter\xdef\csname currcolor##1\endcsname{##2}}%
- \ifnum\pageno<\lastpage {\advance\pageno by1 \csname pgc:\the\pageno\endcsname}%
+ \ifnum\pageno<\lastpage
+ \globaldefs=-1 \advancepageno \globaldefs=0 \csname pgc:\the\pageno\endcsname
\else \xdef\currcolork{\pdflastcolork}\xdef\currcolorK{\pdflastcolorK}\fi
- \Black \linecolor\Black
-}
+ \let\longlocalcolor=\relax \let\localcolor=\relax \Black \linecolor\Black
+}}
\ifpdftex\else
- \def\setcmykcolor#1{}
- \let\localcolor=\relax
+ \def\setcmykcolor#1{} \def\pdfliteral#1{}
+ \let\localcolor=\relax \let\longlocalcolor=\relax
\fi
-\def\draft{\edef\tmp{\headline={\noexpand\draftbox{\tenbf DRAFT}\the\headline}}
- \ifpdftex \tmp \else
- \opwarning{\string\draft: Grey color is possible in pdfTeX only}%
- \fi}
+\def\draft{\edef\tmp{\headline={\noexpand\draftbox{\tenbf DRAFT}\the\headline}}\tmp}
\def\draftbox#1{\vbox to0pt{\setbox0=\hbox{\typosize[10/]#1}%
\kern.5\vsize \kern4\wd0 \hbox to0pt{\kern.5\hsize \kern-2.5\wd0
@@ -907,6 +906,10 @@
\pdfrestore
\hss}\vss}\hss}
+\ifpdftex\else
+ \def\draft{\opwarning{\string\draft: Grey color is possible in pdfTeX only}}
+\fi
+
%%%%%%%%%%%%%% Hyperrefs -- sec. 3.16 in opmac-d.pdf
@@ -941,13 +944,12 @@
\def\pglink##1{\link[pg:##1]{\localcolor#1}{##1}}%
\def\citelink##1{\link[cite:##1]{\localcolor#1}{##1}}%
\def\reflink[##1]##2{\link[ref:##1]{\localcolor#1}{##2}}%
- \def\ulink[##1]##2{\urllink[##1]{##2}}%
+ \def\ulink[##1]##2{\urllink[url:##1]{##2}}%
\def\urlcolor{\longlocalcolor#2}%
}
\def\pdfborder#1{\if^#1^\else \isdefined{#1border}\iftrue
- \if^\csname#1border\endcsname^\else
- attr{/C[\csname#1border\endcsname] /Border[0 0 1]}%
+ \if^\csname#1border\endcsname^\else attr{/C[\csname#1border\endcsname] /Border[0 0 1]}%
\fi\fi\fi
}
@@ -970,7 +972,7 @@
\replacestrings{\{}{\char`\{ }%
\replacestrings{\}}{\char`\} }%
\replacestrings{&}{\urlbskip\char`\& \urlskip}%
- \ulink[url:#1]{\urlfont\tmpb}%
+ \ulink[#1]{\urlfont\tmpb}%
}}
\def\urlfont{\tt}
\def\urlskip{\null\nobreak\hskip0pt plus0.05em\relax}
@@ -1038,8 +1040,10 @@
}
\def\setlccodes#1#2{\if\relax#2\relax \else \lccode`#1=`#2 \expandafter \setlccodes \fi}
-\def\insertoutline#1{\pdfdest name{oul:#1} xyz\relax
- \pdfoutline goto name{oul:#1} count0 {#1}\relax
+\newcount\oulnum
+\def\insertoutline#1{\global\advance\oulnum by1
+ \pdfdest name{oul:\the\oulnum} xyz\relax
+ \pdfoutline goto name{oul:\the\oulnum} count0 {#1}\relax
}
\ifpdftex \else
@@ -1170,8 +1174,8 @@
\halign\expandafter{\the\tabdata\tabstrutA\cr#2\crcr}\egroup}
\def\scantabdata#1{\let\next=\scantabdata
- \ifx#1\relax\let\next=\relax
- \else\if#1|\addtabvrule
+ \ifx\relax#1\let\next=\relax
+ \else\ifx|#1\addtabvrule
\else\expandafter\ifx\csname tabdeclare#1\endcsname \relax
\opwarning{tab-declare letter #1 unknown, ignored}%
\else\expandafter \addtabitem\expandafter{\csname tabdeclare#1\endcsname}%
@@ -1311,10 +1315,12 @@
\fi
}
\def\mnoteA#1{\global\advance \mnotenum by1
- \isdefined{mn:\the\mnotenum}\iftrue
- \else\opwarning{unknown \noexpand\mnote side. TeX me again}\fi
- \edef\tmp{\csname mn:\the\mnotenum\endcsname}%
- \openref\wref\Xmnote{}%
+ \ifx\mnotesfixed\undefined
+ \isdefined{mn:\the\mnotenum}\iftrue
+ \else\opwarning{unknown \noexpand\mnote side. TeX me again}\fi
+ \edef\tmp{\csname mn:\the\mnotenum\endcsname}%
+ \openref\wref\Xmnote{}%
+ \else \let\tmp=\mnotesfixed \fi
\expandafter\ifx\tmp \left
\hbox to0pt{\kern-\mnotesize \kern-\mnoteindent
\vbox to0pt{\vss \setbox0=\vtop{\hsize=\mnotesize
@@ -1330,9 +1336,7 @@
\def\Xmnote{\advance\mnotenum by1
\sxdef{mn:\the\mnotenum}{\ifodd\lastpage \right \else \left \fi}}
-\def\fixmnotes#1{\tmpnum=0
- \loop \advance\tmpnum by1
- \isdefined{mn:\the\tmpnum}\iftrue \sxdef{mn:\the\tmpnum}{#1}\repeat}
+\def\fixmnotes#1{\def\mnotesfixed{#1}}
%%%%%%%%%%%%%% \cite, \bib, \usebibtex, \usebbl -- sec. 3.23 in opmac-d.pdf
@@ -1424,8 +1428,7 @@
\def\readbblfile #1{%
\openin\testin=#1.bbl
\ifeof\testin
- \opwarning{.bbl file doesn't exist.
- Use the ``bibtex #1'' command}%
+ \opwarning{.bbl file doesn't exist. Use the ``bibtex #1'' command}%
\else
\closein\testin
\bibnum=0
@@ -1587,8 +1590,9 @@
\fi}
\def\truedimen#1{#1=\expandafter\ignorept\the#1truept }
-%%%%%%%%%%%%%% REF file is read now -- sec 3.26 in opmac-d.pdf
+%%%%%%%%%%%%%% XeTeX specific + REF file is read now -- sec 3.26 in opmac-d.pdf
+\ifx\XeTeXversion\undefined \else \pdftexfalse \input opmac-xetex \fi
\inputref
\endinput
@@ -1617,7 +1621,7 @@ May 2013 \margins (2pages laylout) can be redefined by new \margins
\outlines use \pdfcatalog{/PageMode/UseOutlines}
Jul. 2013 \fnotetext unwanted space - corrected
\picw=0pt prints picture in natural size, \picheight introduced
- \isinlist corrected,
+ \isinlist corrected,
\othe\secnum in \secc removed
\dotocnum, \remskip, \reminsert introduced
\nonum, \notoc implemented
@@ -1632,7 +1636,19 @@ Aug. 2013 \dgsize corrected
\destheight rewritten as a dimen register
\rightskip, \leftskip corrected in \mnote
space corrected in \prepii
- \input ams-math only if \normalmath is \undefined
+ \input ams-math only if \normalmath is \undefined (released)
+Sep. 2013 \label: the ``duplicated label'' test added
+ \afternoindent: \box0 -> \box7
+ \scantabdata: \if#1| -> \ifx|#1
+ \fixmnotes recoded
+ \, uses \thinspace and it is \addprotected
+ \pdfliteral instead \special{PDF:...} used
+ XeTeX specific added
+ \draft, \insertoulines recoded
+ \endinsert redefined (\par added)
+ \addprotect\exfont (for exchars.tex cooperating)
+ \ulink improved and added to opmac-u
+ \postboxcclv: {\advancepageno} corrected
%%%%%%%%%%%%%% End of opmac.tex
diff --git a/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex b/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex
index 302d5ac940e..a2c35b4c5a0 100644
--- a/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex
+++ b/Master/texmf-dist/tex/csplain/opmac/pdfuni.tex
@@ -16,6 +16,7 @@
% setting more converted characters (not only Czech/Slovak) see the end of
% this file (after \endinput command)
+\ifx\XeTeXversion\undefined\else \def\cnvhook#1{}\endinput \fi
\def\tmp#1#2\end{\if$#2$\else
\errmessage {This file is UTF-8 encoded. Use TeX+encTeX or 16bit TeX engine.}\fi}%